I think I should add at this point that I'm not a c++ programmer, so please don't beat me if the solution is extremely ugly...
Opinions? Best, Albrecht.
Index: src/IDlgConfig.ui
===================================================================
--- src/IDlgConfig.ui (Revision 1853)
+++ src/IDlgConfig.ui (Arbeitskopie)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>563</width>
- <height>524</height>
+ <width>565</width>
+ <height>559</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -316,7 +316,7 @@
</item>
</layout>
</item>
- <item row="3" column="1">
+ <item row="5" column="1">
<widget class="QLabel" name="labelMessage">
<property name="text">
<string/>
@@ -329,6 +329,30 @@
</property>
</widget>
</item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="comboDevCharset">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="labelDevCharset">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Character Set</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QPushButton" name="buttonGarminIcons">
+ <property name="text">
+ <string>Customize Waypoint Icons...</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
Index: src/CDlgConfig.h
===================================================================
--- src/CDlgConfig.h (Revision 1853)
+++ src/CDlgConfig.h (Arbeitskopie)
@@ -38,9 +38,11 @@ class CDlgConfig : public QDialog, private Ui::IDl
void slotCurrentDeviceChanged(int index);
void slotSelectFont();
void slotBrowserChanged(int idx);
+ void slotSetupGarminIcons();
private:
void fillTypeCombo();
+ void fillCharsetCombo();
};
#endif //CDLGCONFIG_H
Index: src/CResources.cpp
===================================================================
--- src/CResources.cpp (Revision 1853)
+++ src/CResources.cpp (Arbeitskopie)
@@ -75,6 +75,7 @@ CResources::CResources(QObject * parent)
m_devIPPort = cfg.value("device/ipPort",m_devIPPort).toUInt();
m_devSerialPort = cfg.value("device/serialPort",m_devSerialPort).toString();
m_devType = cfg.value("device/type",m_devType).toString();
+ m_devCharset = cfg.value("device/charset",m_devCharset).toString();
emit sigDeviceChanged();
@@ -128,6 +129,7 @@ CResources::~CResources()
cfg.setValue("device/serialPort",m_devSerialPort);
cfg.setValue("device/serialPort",m_devSerialPort);
cfg.setValue("device/type",m_devType);
+ cfg.setValue("device/charset",m_devCharset);
cfg.setValue("device/dnlTrk",IDevice::m_DownloadAllTrk);
cfg.setValue("device/dnlWpt",IDevice::m_DownloadAllWpt);
@@ -188,6 +190,15 @@ IDevice * CResources::device()
}
+QString CResources::charset()
+{
+ if (m_devCharset.isNull() || m_devCharset.isEmpty())
+ return "latin1";
+ else
+ return m_devCharset;
+}
+
+
void CResources::openLink(const QString& link)
{
QString cmd;
Index: src/CMainWindow.cpp
===================================================================
--- src/CMainWindow.cpp (Revision 1853)
+++ src/CMainWindow.cpp (Arbeitskopie)
@@ -43,7 +43,6 @@
#include "CUndoStack.h"
#include "WptIcons.h"
#include "CAppOpts.h"
-#include "CDlgSetupGarminIcons.h"
#include <QtGui>
#ifdef WIN32
@@ -567,7 +566,6 @@ void CMainWindow::setupMenuBar()
#else
menu->addAction(QIcon(":/icons/iconConfig16x16.png"),tr("&General"),this,SLOT(slotConfig()));
#endif
- menu->addAction(QIcon(":/icons/iconConfig16x16.png"),tr("&Garmin Icons"),this,SLOT(slotSetupGarminIcons()));
menuBar()->addMenu(menu);
menu = new QMenu(this);
@@ -663,12 +661,6 @@ void CMainWindow::slotConfig()
dlg.exec();
}
-void CMainWindow::slotSetupGarminIcons()
-{
- CDlgSetupGarminIcons dlg;
- dlg.exec();
-}
-
void CMainWindow::slotLoadData()
{
Index: src/IDlgSetupGarminIcons.ui
===================================================================
--- src/IDlgSetupGarminIcons.ui (Revision 1853)
+++ src/IDlgSetupGarminIcons.ui (Arbeitskopie)
@@ -11,8 +11,11 @@
</rect>
</property>
<property name="windowTitle">
- <string>Dialog</string>
+ <string>Garmin Waypoint Icons</string>
</property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="listCustomIcons">
@@ -21,7 +24,7 @@
</property>
<column>
<property name="text">
- <string> </string>
+ <string/>
</property>
</column>
<column>
@@ -31,12 +34,12 @@
</column>
<column>
<property name="text">
- <string> </string>
+ <string/>
</property>
</column>
<column>
<property name="text">
- <string> </string>
+ <string/>
</property>
</column>
<column>
Index: src/CDeviceGarmin.cpp
===================================================================
--- src/CDeviceGarmin.cpp (Revision 1853)
+++ src/CDeviceGarmin.cpp (Arbeitskopie)
@@ -634,6 +634,7 @@ void CDeviceGarmin::uploadWpts(const QList<CWpt*>&
if(dev == 0) return;
std::list<Garmin::Wpt_t> garwpts;
+ QTextCodec *codec = QTextCodec::codecForName(CResources::self().charset().toAscii());
QMap<QString,CWpt*>::iterator wpt = CWptDB::self().begin();
while(wpt != CWptDB::self().end()) {
@@ -652,8 +653,8 @@ void CDeviceGarmin::uploadWpts(const QList<CWpt*>&
garwpt.lon = (*wpt)->lon;
garwpt.alt = (*wpt)->ele;
garwpt.dist = (*wpt)->prx;
- garwpt.ident = (*wpt)->name.toLatin1().data();
- garwpt.comment = (*wpt)->comment.toLatin1().data();
+ garwpt.ident = codec->fromUnicode((*wpt)->name).data();
+ garwpt.comment = codec->fromUnicode((*wpt)->comment).data();
garwpts.push_back(garwpt);
@@ -702,13 +703,14 @@ void CDeviceGarmin::downloadWpts(QList<CWpt*>& wpt
return;
}
+ QTextCodec *codec = QTextCodec::codecForName(CResources::self().charset().toAscii());
std::list<Garmin::Wpt_t>::const_iterator garwpt = garwpts.begin();
while(garwpt != garwpts.end()) {
CWpt * wpt = new CWpt(&CWptDB::self());
- wpt->name = garwpt->ident.c_str();
- wpt->comment = garwpt->comment.c_str();
+ wpt->name = codec->toUnicode(garwpt->ident.c_str());
+ wpt->comment = codec->toUnicode(garwpt->comment.c_str());
wpt->lon = garwpt->lon;
wpt->lat = garwpt->lat;
wpt->ele = garwpt->alt;
@@ -738,12 +740,13 @@ void CDeviceGarmin::uploadTracks(const QList<CTrac
if(dev == 0) return;
std::list<Garmin::Track_t> gartrks;
+ QTextCodec *codec = QTextCodec::codecForName(CResources::self().charset().toAscii());
QList<CTrack*>::const_iterator trk = trks.begin();
while(trk != trks.end()) {
Garmin::Track_t gartrk;
- gartrk.ident = (*trk)->getName().toLatin1().data();
+ gartrk.ident = codec->fromUnicode((*trk)->getName()).data();
gartrk.color = (*trk)->getColorIdx();
const QList<CTrack::pt_t>& trkpts = (*trk)->getTrackPoints();
@@ -809,12 +812,13 @@ void CDeviceGarmin::downloadTracks(QList<CTrack*>&
return;
}
+ QTextCodec *codec = QTextCodec::codecForName(CResources::self().charset().toAscii());
std::list<Garmin::Track_t>::const_iterator gartrk = gartrks.begin();
while(gartrk != gartrks.end()) {
CTrack * trk = new CTrack(&CTrackDB::self());
- trk->setName(gartrk->ident.c_str());
+ trk->setName(codec->toUnicode(gartrk->ident.c_str()));
trk->setColor(gartrk->color);
std::vector<Garmin::TrkPt_t>::const_iterator gartrkpt = gartrk->track.begin();
@@ -906,6 +910,8 @@ void CDeviceGarmin::uploadRoutes(const QList<CRout
std::list<Garmin::Route_t> garrtes;
int id = 0;
+ QTextCodec *codec = QTextCodec::codecForName(CResources::self().charset().toAscii());
+
QList<CRoute*>::const_iterator rte = rtes.begin();
while(rte != rtes.end()) {
Garmin::Route_t garrte;
@@ -921,7 +927,7 @@ void CDeviceGarmin::uploadRoutes(const QList<CRout
}
QString name = (*rte)->getName();
- garrte.ident = name.toLatin1().data();
+ garrte.ident = codec->fromUnicode(name).data();
unsigned cnt = 0;
const QList<XY>& rtepts = (*rte)->getRoutePoints();
@@ -932,7 +938,7 @@ void CDeviceGarmin::uploadRoutes(const QList<CRout
garrtept.lon = rtept->u;
garrtept.lat = rtept->v;
garrtept.Wpt_t::ident = QString("%1.%2").arg(id).arg(++cnt,3,10,QChar('0')).toAscii().data();
- garrtept.Wpt_t::comment = name.toAscii().data();
+ garrtept.Wpt_t::comment = codec->fromUnicode(name).data();
garrtept.Wpt_t::smbl = smbl;
garrte.route.push_back(garrtept);
@@ -985,12 +991,14 @@ void CDeviceGarmin::downloadRoutes(QList<CRoute*>&
return;
}
+ QTextCodec *codec = QTextCodec::codecForName(CResources::self().charset().toAscii());
+
std::list<Garmin::Route_t>::const_iterator garrte = garrtes.begin();
while(garrte != garrtes.end()) {
CRoute * rte = new CRoute(&CRouteDB::self());
- rte->setName(garrte->ident.c_str());
+ rte->setName(codec->toUnicode(garrte->ident.c_str()));
std::vector<Garmin::RtePt_t>::const_iterator garrtept = garrte->route.begin();
while(garrtept != garrte->route.end()) {
Index: src/CMainWindow.h
===================================================================
--- src/CMainWindow.h (Revision 1853)
+++ src/CMainWindow.h (Arbeitskopie)
@@ -91,7 +91,6 @@ class CMainWindow : public QMainWindow
void slotDeviceChanged();
void slotScreenshot();
void slotLoadRecent();
- void slotSetupGarminIcons();
private:
CMenus *actionGroupProvider;
Index: src/CDlgConfig.cpp
===================================================================
--- src/CDlgConfig.cpp (Revision 1853)
+++ src/CDlgConfig.cpp (Arbeitskopie)
@@ -24,6 +24,7 @@
#include "CUnitNautic.h"
#include "CUnitMetric.h"
#include "CMapTDB.h"
+#include "CDlgSetupGarminIcons.h"
#include <QtGui>
@@ -80,6 +81,8 @@ void CDlgConfig::exec()
connect(comboDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentDeviceChanged(int)));
comboDevice->setCurrentIndex(comboDevice->findData(resources.m_devKey));
+ connect(buttonGarminIcons, SIGNAL(clicked()), this, SLOT(slotSetupGarminIcons()));
+
lineDevIPAddr->setText(resources.m_devIPAddress);
lineDevIPPort->setText(QString::number(resources.m_devIPPort));
lineDevSerialPort->setText(resources.m_devSerialPort);
@@ -128,6 +131,7 @@ void CDlgConfig::accept()
resources.m_devIPPort = lineDevIPPort->text().toUShort();
resources.m_devSerialPort = lineDevSerialPort->text();
resources.m_devType = comboDevType->itemText(comboDevType->currentIndex());
+ resources.m_devCharset = comboDevCharset->itemText(comboDevCharset->currentIndex());
if(resources.m_device) {
delete resources.m_device;
@@ -157,6 +161,9 @@ void CDlgConfig::slotCurrentDeviceChanged(int inde
labelDevSerialPort->setEnabled(false);
comboDevType->setEnabled(false);
labelDevType->setEnabled(false);
+ comboDevCharset->setEnabled(false);
+ labelDevCharset->setEnabled(false);
+ buttonGarminIcons->setEnabled(false);
if(comboDevice->itemData(index) == "QLandkarteM") {
lineDevIPAddr->setEnabled(true);
@@ -169,7 +176,11 @@ void CDlgConfig::slotCurrentDeviceChanged(int inde
lineDevSerialPort->setEnabled(true);
labelDevSerialPort->setEnabled(true);
labelDevType->setEnabled(true);
+ comboDevCharset->setEnabled(true);
+ labelDevCharset->setEnabled(true);
+ buttonGarminIcons->setEnabled(true);
fillTypeCombo();
+ fillCharsetCombo();
}
else if(comboDevice->itemData(index) == "Mikrokopter") {
lineDevSerialPort->setEnabled(true);
@@ -220,6 +231,22 @@ void CDlgConfig::fillTypeCombo()
}
+void CDlgConfig::fillCharsetCombo()
+{
+ comboDevCharset->clear();
+
+ CResources& resources = CResources::self();
+ QList<QByteArray> allCodecs = QTextCodec::availableCodecs();
+ QByteArray codec;
+
+ qSort(allCodecs);
+ foreach(codec, allCodecs) {
+ comboDevCharset->addItem(codec);
+ }
+ comboDevCharset->setCurrentIndex(comboDevCharset->findText(resources.m_devCharset));
+}
+
+
void CDlgConfig::slotBrowserChanged(int idx)
{
if(idx == CResources::eOther) {
@@ -229,3 +256,9 @@ void CDlgConfig::slotBrowserChanged(int idx)
lineBrowserCmd->setEnabled(false);
}
}
+
+void CDlgConfig::slotSetupGarminIcons()
+{
+ CDlgSetupGarminIcons dlg;
+ dlg.exec();
+}
Index: src/CResources.h
===================================================================
--- src/CResources.h (Revision 1853)
+++ src/CResources.h (Arbeitskopie)
@@ -46,6 +46,7 @@ class CResources : public QObject
/// get pointer to current device handler
IDevice * device();
+ QString charset();
/// the font used for text on the map
const QFont& getMapFont(){return m_mapfont;}
@@ -113,6 +114,7 @@ class CResources : public QObject
QString m_devSerialPort;
QString m_devType;
+ QString m_devCharset;
/// mouse wheel zoom direction
bool m_flipMouseWheel;
pgpkSeplzDQw1.pgp
Description: PGP signature
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ QLandkarte-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qlandkarte-users
