author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/addresseeview.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | kabc/addresseeview.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index cde19a1..425e67c 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -26,25 +26,30 @@ | |||
26 | //US#include <kglobalsettings.h> | 26 | //US#include <kglobalsettings.h> |
27 | #include <kiconloader.h> | 27 | #include <kiconloader.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | //US #include <kstringhandler.h> | 29 | //US #include <kstringhandler.h> |
30 | #include <qscrollview.h> | 30 | #include <q3scrollview.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qvbox.h> | 33 | #include <q3vbox.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #ifdef DESKTOP_VERSION | 39 | #ifdef DESKTOP_VERSION |
40 | #include <qpaintdevicemetrics.h> | 40 | #include <q3paintdevicemetrics.h> |
41 | #include <qprinter.h> | 41 | #include <qprinter.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #endif | 43 | #endif |
44 | #include <QDesktopWidget> | ||
44 | 45 | ||
45 | 46 | ||
46 | #include <qstylesheet.h> | 47 | #include <q3stylesheet.h> |
48 | //Added by qt3to4: | ||
49 | #include <Q3HBoxLayout> | ||
50 | #include <QPixmap> | ||
51 | #include <Q3VBoxLayout> | ||
47 | #include "externalapphandler.h" | 52 | #include "externalapphandler.h" |
48 | #include <kabc/addresseeview.h> | 53 | #include <kabc/addresseeview.h> |
49 | 54 | ||
50 | 55 | ||
@@ -58,9 +63,9 @@ | |||
58 | using namespace KABC; | 63 | using namespace KABC; |
59 | bool AddresseeView::sFullDetailsMode = false; | 64 | bool AddresseeView::sFullDetailsMode = false; |
60 | 65 | ||
61 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 66 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
62 | : QTextBrowser( parent, name ) | 67 | : Q3TextBrowser( parent, name ) |
63 | 68 | ||
64 | 69 | ||
65 | { | 70 | { |
66 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 71 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
@@ -81,9 +86,9 @@ void AddresseeView::printMe() | |||
81 | if (!printer.setup() ) | 86 | if (!printer.setup() ) |
82 | return; | 87 | return; |
83 | QPainter p; | 88 | QPainter p; |
84 | p.begin ( &printer ); | 89 | p.begin ( &printer ); |
85 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 90 | Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer ); |
86 | float dx, dy; | 91 | float dx, dy; |
87 | int wid = (m.width() * 9)/10; | 92 | int wid = (m.width() * 9)/10; |
88 | dx = (float) wid/(float)contentsWidth (); | 93 | dx = (float) wid/(float)contentsWidth (); |
89 | dy = (float)(m.height()) / (float)contentsHeight (); | 94 | dy = (float)(m.height()) / (float)contentsHeight (); |
@@ -401,9 +406,9 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
401 | } | 406 | } |
402 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 407 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
403 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 408 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
404 | if ( picAvailintern ) { | 409 | if ( picAvailintern ) { |
405 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 410 | Q3MimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
406 | int wid = picture.data().width(); | 411 | int wid = picture.data().width(); |
407 | int hei = picture.data().height(); | 412 | int hei = picture.data().height(); |
408 | if ( wid > 128 || hei > 128 ) { | 413 | if ( wid > 128 || hei > 128 ) { |
409 | if ( wid > hei ) { | 414 | if ( wid > hei ) { |
@@ -417,9 +422,9 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
417 | picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); | 422 | picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); |
418 | } else { | 423 | } else { |
419 | if ( picAvailUrl ) { | 424 | if ( picAvailUrl ) { |
420 | QPixmap picPix( picture.url() ); | 425 | QPixmap picPix( picture.url() ); |
421 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); | 426 | Q3MimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); |
422 | int wid = picPix.width(); | 427 | int wid = picPix.width(); |
423 | int hei = picPix.height(); | 428 | int hei = picPix.height(); |
424 | if ( wid > 128 || hei > 128 ) { | 429 | if ( wid > 128 || hei > 128 ) { |
425 | if ( wid > hei ) { | 430 | if ( wid > hei ) { |
@@ -434,43 +439,43 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
434 | } else { | 439 | } else { |
435 | if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { | 440 | if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { |
436 | static bool setDefaultImageChildren = false; | 441 | static bool setDefaultImageChildren = false; |
437 | if ( !setDefaultImageChildren ) { | 442 | if ( !setDefaultImageChildren ) { |
438 | QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); | 443 | Q3MimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); |
439 | setDefaultImageChildren = true; | 444 | setDefaultImageChildren = true; |
440 | } | 445 | } |
441 | picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; | 446 | picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; |
442 | 447 | ||
443 | } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { | 448 | } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { |
444 | static bool setDefaultImagepouses = false; | 449 | static bool setDefaultImagepouses = false; |
445 | if ( !setDefaultImagepouses ) { | 450 | if ( !setDefaultImagepouses ) { |
446 | QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); | 451 | Q3MimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); |
447 | setDefaultImagepouses = true; | 452 | setDefaultImagepouses = true; |
448 | } | 453 | } |
449 | picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; | 454 | picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; |
450 | } else { | 455 | } else { |
451 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); | 456 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); |
452 | if ( gen == "male" ) { | 457 | if ( gen == "male" ) { |
453 | static bool setDefaultImageMale = false; | 458 | static bool setDefaultImageMale = false; |
454 | if ( !setDefaultImageMale ) { | 459 | if ( !setDefaultImageMale ) { |
455 | QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); | 460 | Q3MimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); |
456 | setDefaultImageMale = true; | 461 | setDefaultImageMale = true; |
457 | } | 462 | } |
458 | picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; | 463 | picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; |
459 | 464 | ||
460 | } else if ( gen == "female" ) { | 465 | } else if ( gen == "female" ) { |
461 | static bool setDefaultImageFemale = false; | 466 | static bool setDefaultImageFemale = false; |
462 | if ( !setDefaultImageFemale ) { | 467 | if ( !setDefaultImageFemale ) { |
463 | QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); | 468 | Q3MimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); |
464 | setDefaultImageFemale = true; | 469 | setDefaultImageFemale = true; |
465 | } | 470 | } |
466 | picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; | 471 | picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; |
467 | 472 | ||
468 | } else { | 473 | } else { |
469 | static bool setDefaultImage = false; | 474 | static bool setDefaultImage = false; |
470 | if ( !setDefaultImage ) { | 475 | if ( !setDefaultImage ) { |
471 | //qDebug("Setting default pixmap "); | 476 | //qDebug("Setting default pixmap "); |
472 | QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); | 477 | Q3MimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); |
473 | setDefaultImage = true; | 478 | setDefaultImage = true; |
474 | } | 479 | } |
475 | picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; | 480 | picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; |
476 | } | 481 | } |
@@ -652,9 +657,9 @@ KABC::Addressee AddresseeView::addressee() const | |||
652 | void AddresseeView::addTag(const QString & tag,const QString & text) | 657 | void AddresseeView::addTag(const QString & tag,const QString & text) |
653 | { | 658 | { |
654 | if ( text.isEmpty() ) | 659 | if ( text.isEmpty() ) |
655 | return; | 660 | return; |
656 | int number=text.contains("\n"); | 661 | int number=text.count("\n"); |
657 | QString str = "<" + tag + ">"; | 662 | QString str = "<" + tag + ">"; |
658 | QString tmpText=text; | 663 | QString tmpText=text; |
659 | QString tmpStr=str; | 664 | QString tmpStr=str; |
660 | if(number !=-1) | 665 | if(number !=-1) |
@@ -687,26 +692,26 @@ AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bo | |||
687 | findButton( Ok )->setText( i18n("Remote")); | 692 | findButton( Ok )->setText( i18n("Remote")); |
688 | findButton( User1 )->setText( i18n("Local")); | 693 | findButton( User1 )->setText( i18n("Local")); |
689 | QWidget* topframe = new QWidget( this ); | 694 | QWidget* topframe = new QWidget( this ); |
690 | setMainWidget( topframe ); | 695 | setMainWidget( topframe ); |
691 | QBoxLayout* bl; | 696 | Q3BoxLayout* bl; |
692 | if ( QApplication::desktop()->width() < 640 ) { | 697 | if ( QApplication::desktop()->width() < 640 ) { |
693 | bl = new QVBoxLayout( topframe ); | 698 | bl = new Q3VBoxLayout( topframe ); |
694 | } else { | 699 | } else { |
695 | bl = new QHBoxLayout( topframe ); | 700 | bl = new Q3HBoxLayout( topframe ); |
696 | } | 701 | } |
697 | QVBox* subframe = new QVBox( topframe ); | 702 | Q3VBox* subframe = new Q3VBox( topframe ); |
698 | bl->addWidget(subframe ); | 703 | bl->addWidget(subframe ); |
699 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); | 704 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); |
700 | if ( takeloc ) | 705 | if ( takeloc ) |
701 | lab->setBackgroundColor(Qt::green.light() ); | 706 | lab->setBackgroundColor(QColor(Qt::green).light() ); |
702 | AddresseeView * av = new AddresseeView( subframe ); | 707 | AddresseeView * av = new AddresseeView( subframe ); |
703 | av->setAddressee( loc ); | 708 | av->setAddressee( loc ); |
704 | subframe = new QVBox( topframe ); | 709 | subframe = new Q3VBox( topframe ); |
705 | bl->addWidget(subframe ); | 710 | bl->addWidget(subframe ); |
706 | lab = new QLabel( i18n("Remote Addressee"), subframe ); | 711 | lab = new QLabel( i18n("Remote Addressee"), subframe ); |
707 | if ( !takeloc ) | 712 | if ( !takeloc ) |
708 | lab->setBackgroundColor(Qt::green.light() ); | 713 | lab->setBackgroundColor(QColor(Qt::green).light() ); |
709 | av = new AddresseeView( subframe ); | 714 | av = new AddresseeView( subframe ); |
710 | av->setAddressee( rem ); | 715 | av->setAddressee( rem ); |
711 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); | 716 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); |
712 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); | 717 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); |