-rw-r--r-- | kaddressbook/geowidget.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/kaddressbook/geowidget.cpp b/kaddressbook/geowidget.cpp index 13cd084..caff3b2 100644 --- a/kaddressbook/geowidget.cpp +++ b/kaddressbook/geowidget.cpp | |||
@@ -18,67 +18,74 @@ | |||
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <kabc/geo.h> | 24 | #include <kabc/geo.h> |
25 | 25 | ||
26 | #ifndef KAB_EMBEDDED | 26 | #ifndef KAB_EMBEDDED |
27 | #include <kaccelmanager.h> | 27 | #include <kaccelmanager.h> |
28 | #else //KAB_EMBEDDED | 28 | #else //KAB_EMBEDDED |
29 | 29 | ||
30 | #include <qtextstream.h> | 30 | #include <q3textstream.h> |
31 | //Added by qt3to4: | ||
32 | #include <QPaintEvent> | ||
33 | #include <Q3GridLayout> | ||
34 | #include <Q3Frame> | ||
35 | #include <QMouseEvent> | ||
31 | #include <kglobal.h> | 36 | #include <kglobal.h> |
32 | #endif //KAB_EMBEDDED | 37 | #endif //KAB_EMBEDDED |
33 | 38 | ||
39 | #include <QDesktopWidget> | ||
40 | |||
34 | #include <knuminput.h> | 41 | #include <knuminput.h> |
35 | #include <kcombobox.h> | 42 | #include <kcombobox.h> |
36 | #include <kdebug.h> | 43 | #include <kdebug.h> |
37 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
38 | #include <klocale.h> | 45 | #include <klocale.h> |
39 | #include <kstandarddirs.h> | 46 | #include <kstandarddirs.h> |
40 | 47 | ||
41 | #include <qcheckbox.h> | 48 | #include <qcheckbox.h> |
42 | #include <qfile.h> | 49 | #include <qfile.h> |
43 | #include <qapplication.h> | 50 | #include <qapplication.h> |
44 | #include <qgroupbox.h> | 51 | #include <q3groupbox.h> |
45 | #include <qlabel.h> | 52 | #include <qlabel.h> |
46 | #include <qlayout.h> | 53 | #include <qlayout.h> |
47 | #include <qlistbox.h> | 54 | #include <q3listbox.h> |
48 | #include <qpainter.h> | 55 | #include <qpainter.h> |
49 | #include <qpixmap.h> | 56 | #include <qpixmap.h> |
50 | #include <qpushbutton.h> | 57 | #include <qpushbutton.h> |
51 | #include <qregexp.h> | 58 | #include <qregexp.h> |
52 | #include <qstring.h> | 59 | #include <qstring.h> |
53 | #include <stdlib.h> | 60 | #include <stdlib.h> |
54 | 61 | ||
55 | #include "geowidget.h" | 62 | #include "geowidget.h" |
56 | 63 | ||
57 | GeoWidget::GeoWidget( QWidget *parent, const char *name ) | 64 | GeoWidget::GeoWidget( QWidget *parent, const char *name ) |
58 | : QWidget( parent, name ) | 65 | : QWidget( parent, name ) |
59 | { | 66 | { |
60 | QLabel *label = 0; | 67 | QLabel *label = 0; |
61 | 68 | ||
62 | QGridLayout *topLayout = new QGridLayout( this, 4, 3 ); | 69 | Q3GridLayout *topLayout = new Q3GridLayout( this, 4, 3 ); |
63 | topLayout->setMargin( KDialog::marginHint() ); | 70 | topLayout->setMargin( KDialog::marginHint() ); |
64 | topLayout->setSpacing( KDialog::spacingHint() ); | 71 | topLayout->setSpacing( KDialog::spacingHint() ); |
65 | 72 | ||
66 | label = new QLabel( this ); | 73 | label = new QLabel( this ); |
67 | //US ambiguous call to loadIcon. Add an additional parameter | 74 | //US ambiguous call to loadIcon. Add an additional parameter |
68 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop ) ); | 75 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop ) ); |
69 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop, 0 ) ); | 76 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop, 0 ) ); |
70 | label->setAlignment( Qt::AlignTop ); | 77 | label->setAlignment( Qt::AlignTop ); |
71 | topLayout->addMultiCellWidget( label, 0, 3, 0, 0 ); | 78 | topLayout->addMultiCellWidget( label, 0, 3, 0, 0 ); |
72 | label->setAlignment( AlignCenter ); | 79 | label->setAlignment( Qt::AlignCenter ); |
73 | mGeoIsValid = new QCheckBox( i18n( "Use geo data" ), this ); | 80 | mGeoIsValid = new QCheckBox( i18n( "Use geo data" ), this ); |
74 | topLayout->addMultiCellWidget( mGeoIsValid, 0, 0, 1, 2 ); | 81 | topLayout->addMultiCellWidget( mGeoIsValid, 0, 0, 1, 2 ); |
75 | 82 | ||
76 | label = new QLabel( i18n( "Latitude:" ), this ); | 83 | label = new QLabel( i18n( "Latitude:" ), this ); |
77 | topLayout->addWidget( label, 1, 1 ); | 84 | topLayout->addWidget( label, 1, 1 ); |
78 | 85 | ||
79 | mLatitudeBox = new KDoubleSpinBox( -90, 90, 1, 0, 6, this ); | 86 | mLatitudeBox = new KDoubleSpinBox( -90, 90, 1, 0, 6, this ); |
80 | mLatitudeBox->setEnabled( false ); | 87 | mLatitudeBox->setEnabled( false ); |
81 | mLatitudeBox->setSuffix( "" ); | 88 | mLatitudeBox->setSuffix( "" ); |
82 | topLayout->addWidget( mLatitudeBox, 1, 2 ); | 89 | topLayout->addWidget( mLatitudeBox, 1, 2 ); |
83 | label->setBuddy( mLatitudeBox ); | 90 | label->setBuddy( mLatitudeBox ); |
84 | 91 | ||
@@ -158,34 +165,34 @@ void GeoWidget::editGeoData() | |||
158 | 165 | ||
159 | emit changed(); | 166 | emit changed(); |
160 | } | 167 | } |
161 | } | 168 | } |
162 | 169 | ||
163 | 170 | ||
164 | 171 | ||
165 | GeoDialog::GeoDialog( QWidget *parent, const char *name ) | 172 | GeoDialog::GeoDialog( QWidget *parent, const char *name ) |
166 | : KDialogBase( Plain, i18n( "Geo Data Input" ), Ok | Cancel, Ok, | 173 | : KDialogBase( Plain, i18n( "Geo Data Input" ), Ok | Cancel, Ok, |
167 | parent, name, true, true ), | 174 | parent, name, true, true ), |
168 | mUpdateSexagesimalInput( true ) | 175 | mUpdateSexagesimalInput( true ) |
169 | { | 176 | { |
170 | QFrame *page = plainPage(); | 177 | Q3Frame *page = plainPage(); |
171 | 178 | ||
172 | QGridLayout *topLayout = new QGridLayout( page, 1, 1, marginHintSmall(), | 179 | Q3GridLayout *topLayout = new Q3GridLayout( page, 1, 1, marginHintSmall(), |
173 | spacingHint() ); | 180 | spacingHint() ); |
174 | //topLayout->setRowStretch( 1, 1 ); | 181 | //topLayout->setRowStretch( 1, 1 ); |
175 | 182 | ||
176 | mMapWidget = new GeoMapWidget( page ); | 183 | mMapWidget = new GeoMapWidget( page ); |
177 | mCityCombo = new KComboBox( page ); | 184 | mCityCombo = new KComboBox( page ); |
178 | QGroupBox *sexagesimalGroup = new QGroupBox( 0, Vertical, i18n( "Sexagesimal" ), page ); | 185 | Q3GroupBox *sexagesimalGroup = new Q3GroupBox( 0, Qt::Vertical, i18n( "Sexagesimal" ), page ); |
179 | QGridLayout *sexagesimalLayout = new QGridLayout( sexagesimalGroup->layout(), | 186 | Q3GridLayout *sexagesimalLayout = new Q3GridLayout( sexagesimalGroup->layout(), |
180 | 2, 5, spacingHint() ); | 187 | 2, 5, spacingHint() ); |
181 | QLabel *label; | 188 | QLabel *label; |
182 | if ( QApplication::desktop()->width() < 320 ) { | 189 | if ( QApplication::desktop()->width() < 320 ) { |
183 | label = new QLabel( i18n( "La." ), sexagesimalGroup ); | 190 | label = new QLabel( i18n( "La." ), sexagesimalGroup ); |
184 | sexagesimalLayout->setSpacing ( spacingHintSmall() ); | 191 | sexagesimalLayout->setSpacing ( spacingHintSmall() ); |
185 | sexagesimalLayout->setMargin ( marginHintSmall() ); | 192 | sexagesimalLayout->setMargin ( marginHintSmall() ); |
186 | topLayout->setMargin ( 0 ); | 193 | topLayout->setMargin ( 0 ); |
187 | mCityCombo->setMaximumWidth( 220 ); | 194 | mCityCombo->setMaximumWidth( 220 ); |
188 | sexagesimalGroup->setMaximumWidth( 220 ); | 195 | sexagesimalGroup->setMaximumWidth( 220 ); |
189 | } | 196 | } |
190 | else | 197 | else |
191 | label = new QLabel( i18n( "Latitude:" ), sexagesimalGroup ); | 198 | label = new QLabel( i18n( "Latitude:" ), sexagesimalGroup ); |
@@ -420,26 +427,26 @@ void GeoDialog::loadCityList() | |||
420 | #ifndef _WIN32_ | 427 | #ifndef _WIN32_ |
421 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/zone.tab"; | 428 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/zone.tab"; |
422 | #else | 429 | #else |
423 | fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\zone.tab"; | 430 | fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\zone.tab"; |
424 | #endif | 431 | #endif |
425 | #else | 432 | #else |
426 | fileName = getenv("QPEDIR"); | 433 | fileName = getenv("QPEDIR"); |
427 | fileName += "/pics/kdepim/kaddressbook/zone.tab"; | 434 | fileName += "/pics/kdepim/kaddressbook/zone.tab"; |
428 | #endif | 435 | #endif |
429 | 436 | ||
430 | QFile file( fileName); | 437 | QFile file( fileName); |
431 | 438 | ||
432 | if ( file.open( IO_ReadOnly ) ) { | 439 | if ( file.open( QIODevice::ReadOnly ) ) { |
433 | QTextStream s( &file ); | 440 | Q3TextStream s( &file ); |
434 | 441 | ||
435 | QString line, country; | 442 | QString line, country; |
436 | QRegExp coord( "[+-]\\d+[+-]\\d+" ); | 443 | QRegExp coord( "[+-]\\d+[+-]\\d+" ); |
437 | QRegExp name( "[^\\s]+/[^\\s]+" ); | 444 | QRegExp name( "[^\\s]+/[^\\s]+" ); |
438 | int posc, posn, pos; | 445 | int posc, posn, pos; |
439 | 446 | ||
440 | while ( !s.eof() ) { | 447 | while ( !s.eof() ) { |
441 | line = s.readLine().stripWhiteSpace(); | 448 | line = s.readLine().stripWhiteSpace(); |
442 | if ( line.isEmpty() || line[ 0 ] == '#' ) | 449 | if ( line.isEmpty() || line[ 0 ] == '#' ) |
443 | continue; | 450 | continue; |
444 | 451 | ||
445 | country = line.left( 2 ); | 452 | country = line.left( 2 ); |
@@ -543,25 +550,25 @@ int GeoDialog::nearestCity( double x, double y ) | |||
543 | ( (*it).latitude - y ) * ( (*it).latitude - y ); | 550 | ( (*it).latitude - y ) * ( (*it).latitude - y ); |
544 | if ( dist < 1.5 ) | 551 | if ( dist < 1.5 ) |
545 | return pos; | 552 | return pos; |
546 | } | 553 | } |
547 | 554 | ||
548 | return -1; | 555 | return -1; |
549 | } | 556 | } |
550 | 557 | ||
551 | 558 | ||
552 | GeoMapWidget::GeoMapWidget( QWidget *parent, const char *name ) | 559 | GeoMapWidget::GeoMapWidget( QWidget *parent, const char *name ) |
553 | : QWidget( parent, name ), mLatitude( 0 ), mLongitude( 0 ) | 560 | : QWidget( parent, name ), mLatitude( 0 ), mLongitude( 0 ) |
554 | { | 561 | { |
555 | setBackgroundMode( NoBackground ); | 562 | setBackgroundMode( Qt::NoBackground ); |
556 | 563 | ||
557 | setFixedSize( 240, 120 ); | 564 | setFixedSize( 240, 120 ); |
558 | 565 | ||
559 | update(); | 566 | update(); |
560 | } | 567 | } |
561 | 568 | ||
562 | GeoMapWidget::~GeoMapWidget() | 569 | GeoMapWidget::~GeoMapWidget() |
563 | { | 570 | { |
564 | } | 571 | } |
565 | 572 | ||
566 | void GeoMapWidget::setLatitude( double latitude ) | 573 | void GeoMapWidget::setLatitude( double latitude ) |
567 | { | 574 | { |
@@ -615,15 +622,15 @@ void GeoMapWidget::paintEvent( QPaintEvent* ) | |||
615 | 622 | ||
616 | double latOffset = ( mLatitude * latMid ) / 90; | 623 | double latOffset = ( mLatitude * latMid ) / 90; |
617 | double longOffset = ( mLongitude * longMid ) / 180; | 624 | double longOffset = ( mLongitude * longMid ) / 180; |
618 | 625 | ||
619 | int x = (int)(longMid + longOffset); | 626 | int x = (int)(longMid + longOffset); |
620 | int y = (int)(latMid - latOffset); | 627 | int y = (int)(latMid - latOffset); |
621 | p.drawEllipse( x, y, 4, 4 ); | 628 | p.drawEllipse( x, y, 4, 4 ); |
622 | 629 | ||
623 | p.end(); | 630 | p.end(); |
624 | bitBlt( this, 0, 0, &world ); | 631 | bitBlt( this, 0, 0, &world ); |
625 | } | 632 | } |
626 | 633 | ||
627 | #ifndef KAB_EMBEDDED | 634 | #ifndef KAB_EMBEDDED_ |
628 | #include "geowidget.moc" | 635 | #include "moc_geowidget.cpp" |
629 | #endif //KAB_EMBEDDED | 636 | #endif //KAB_EMBEDDED |