-rw-r--r-- | kaddressbook/mainembedded.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index cf1fd3e..7f368eb 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,190 +1,191 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #else | 4 | #else |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <qwindowsstyle.h> | 6 | #include <qwindowsstyle.h> |
7 | #include <qplatinumstyle.h> | 7 | #include <qplatinumstyle.h> |
8 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
12 | #include <kglobal.h> | 12 | #include <kglobal.h> |
13 | #include <stdio.h> | 13 | #include <stdio.h> |
14 | #include <qdir.h> | 14 | #include <qdir.h> |
15 | #include "kaddressbookmain.h" | 15 | #include "kaddressbookmain.h" |
16 | 16 | ||
17 | int main( int argc, char **argv ) | 17 | int main( int argc, char **argv ) |
18 | { | 18 | { |
19 | #ifndef DESKTOP_VERSION | 19 | #ifndef DESKTOP_VERSION |
20 | QPEApplication a( argc, argv ); | 20 | QPEApplication a( argc, argv ); |
21 | a.setKeepRunning (); | 21 | a.setKeepRunning (); |
22 | #else | 22 | #else |
23 | QApplication a( argc, argv ); | 23 | QApplication a( argc, argv ); |
24 | QApplication::setStyle( new QPlatinumStyle ()); | 24 | QApplication::setStyle( new QPlatinumStyle ()); |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | bool exitHelp = false; | 27 | bool exitHelp = false; |
28 | if ( argc > 1 ) { | 28 | if ( argc > 1 ) { |
29 | QString command = argv[1]; | 29 | QString command = argv[1]; |
30 | if ( command == "-help" ){ | 30 | if ( command == "-help" ){ |
31 | printf("KA/E command line commands:\n"); | 31 | printf("KA/E command line commands:\n"); |
32 | printf(" no command: Start KA/E in usual way\n"); | 32 | printf(" no command: Start KA/E in usual way\n"); |
33 | printf(" -help: This output\n"); | 33 | printf(" -help: This output\n"); |
34 | printf(" KA/E is exiting now. Bye!\n"); | 34 | printf(" KA/E is exiting now. Bye!\n"); |
35 | exitHelp = true; | 35 | exitHelp = true; |
36 | } | 36 | } |
37 | } | 37 | } |
38 | if ( ! exitHelp ) { | 38 | if ( ! exitHelp ) { |
39 | 39 | ||
40 | KGlobal::setAppName( "kaddressbook" ); | 40 | KGlobal::setAppName( "kaddressbook" ); |
41 | #ifndef DESKTOP_VERSION | 41 | #ifndef DESKTOP_VERSION |
42 | if ( QApplication::desktop()->width() > 320 ) | 42 | if ( QApplication::desktop()->width() > 320 ) |
43 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 43 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
44 | else | 44 | else |
45 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 45 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
46 | #else | 46 | #else |
47 | QString fileName ; | 47 | QString fileName ; |
48 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 48 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
49 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 49 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
50 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 50 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
51 | 51 | ||
52 | #endif | 52 | #endif |
53 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 53 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
54 | KAddressBookMain m ; | 54 | KAddressBookMain m ; |
55 | //US MainWindow m; | 55 | //US MainWindow m; |
56 | //US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); | 56 | //US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); |
57 | 57 | ||
58 | #ifndef DESKTOP_VERSION | 58 | #ifndef DESKTOP_VERSION |
59 | a.showMainWidget( &m ); | 59 | a.showMainWidget( &m ); |
60 | #else | 60 | #else |
61 | a.setMainWidget( &m ); | 61 | a.setMainWidget( &m ); |
62 | m.resize (640, 480 ); | ||
62 | m.show(); | 63 | m.show(); |
63 | #endif | 64 | #endif |
64 | a.exec(); | 65 | a.exec(); |
65 | 66 | ||
66 | } | 67 | } |
67 | qDebug("KA: Bye! "); | 68 | qDebug("KA: Bye! "); |
68 | } | 69 | } |
69 | 70 | ||
70 | /* | 71 | /* |
71 | #include <stdlib.h> | 72 | #include <stdlib.h> |
72 | 73 | ||
73 | #include <qstring.h> | 74 | #include <qstring.h> |
74 | 75 | ||
75 | #include <kabc/stdaddressbook.h> | 76 | #include <kabc/stdaddressbook.h> |
76 | #include <kaboutdata.h> | 77 | #include <kaboutdata.h> |
77 | #include <kcmdlineargs.h> | 78 | #include <kcmdlineargs.h> |
78 | #include <kcrash.h> | 79 | #include <kcrash.h> |
79 | #include <kdebug.h> | 80 | #include <kdebug.h> |
80 | #include <klocale.h> | 81 | #include <klocale.h> |
81 | #include <kstartupinfo.h> | 82 | #include <kstartupinfo.h> |
82 | #include <kuniqueapplication.h> | 83 | #include <kuniqueapplication.h> |
83 | #include <kwin.h> | 84 | #include <kwin.h> |
84 | 85 | ||
85 | #include "kaddressbookmain.h" | 86 | #include "kaddressbookmain.h" |
86 | #include "kabcore.h" | 87 | #include "kabcore.h" |
87 | 88 | ||
88 | extern "C" { | 89 | extern "C" { |
89 | 90 | ||
90 | void crashHandler( int ) | 91 | void crashHandler( int ) |
91 | { | 92 | { |
92 | KABC::StdAddressBook::handleCrash(); | 93 | KABC::StdAddressBook::handleCrash(); |
93 | ::exit( 0 ); | 94 | ::exit( 0 ); |
94 | } | 95 | } |
95 | 96 | ||
96 | } | 97 | } |
97 | 98 | ||
98 | class KAddressBookApp : public KUniqueApplication { | 99 | class KAddressBookApp : public KUniqueApplication { |
99 | public: | 100 | public: |
100 | KAddressBookApp() : mMainWin( 0 ) {} | 101 | KAddressBookApp() : mMainWin( 0 ) {} |
101 | ~KAddressBookApp() {} | 102 | ~KAddressBookApp() {} |
102 | 103 | ||
103 | int newInstance(); | 104 | int newInstance(); |
104 | 105 | ||
105 | private: | 106 | private: |
106 | KAddressBookMain *mMainWin; | 107 | KAddressBookMain *mMainWin; |
107 | }; | 108 | }; |
108 | 109 | ||
109 | int KAddressBookApp::newInstance() | 110 | int KAddressBookApp::newInstance() |
110 | { | 111 | { |
111 | if ( isRestored() ) { | 112 | if ( isRestored() ) { |
112 | // There can only be one main window | 113 | // There can only be one main window |
113 | if ( KMainWindow::canBeRestored( 1 ) ) { | 114 | if ( KMainWindow::canBeRestored( 1 ) ) { |
114 | mMainWin = new KAddressBookMain; | 115 | mMainWin = new KAddressBookMain; |
115 | mMainWin->show(); | 116 | mMainWin->show(); |
116 | mMainWin->restore( 1 ); | 117 | mMainWin->restore( 1 ); |
117 | } | 118 | } |
118 | } else { | 119 | } else { |
119 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 120 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
120 | 121 | ||
121 | QCString addrStr = args->getOption( "addr" ); | 122 | QCString addrStr = args->getOption( "addr" ); |
122 | QCString uidStr = args->getOption( "uid" ); | 123 | QCString uidStr = args->getOption( "uid" ); |
123 | QString addr; | 124 | QString addr; |
124 | QString uid; | 125 | QString uid; |
125 | if ( !addrStr.isEmpty() ) | 126 | if ( !addrStr.isEmpty() ) |
126 | addr = QString::fromLocal8Bit( addrStr ); | 127 | addr = QString::fromLocal8Bit( addrStr ); |
127 | if ( !uidStr.isEmpty() ) | 128 | if ( !uidStr.isEmpty() ) |
128 | uid = QString::fromLocal8Bit( uidStr ); | 129 | uid = QString::fromLocal8Bit( uidStr ); |
129 | 130 | ||
130 | 131 | ||
131 | if ( args->isSet( "editor-only" ) ) { | 132 | if ( args->isSet( "editor-only" ) ) { |
132 | if ( !mMainWin ) | 133 | if ( !mMainWin ) |
133 | mMainWin = new KAddressBookMain; | 134 | mMainWin = new KAddressBookMain; |
134 | KStartupInfo::appStarted(); | 135 | KStartupInfo::appStarted(); |
135 | mMainWin->hide(); | 136 | mMainWin->hide(); |
136 | } else { | 137 | } else { |
137 | if ( mMainWin ) { | 138 | if ( mMainWin ) { |
138 | mMainWin->show(); | 139 | mMainWin->show(); |
139 | KWin::setActiveWindow( mMainWin->winId() ); | 140 | KWin::setActiveWindow( mMainWin->winId() ); |
140 | } else { | 141 | } else { |
141 | mMainWin = new KAddressBookMain; | 142 | mMainWin = new KAddressBookMain; |
142 | mMainWin->show(); | 143 | mMainWin->show(); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do | 146 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do |
146 | if ( !addr.isEmpty() ) | 147 | if ( !addr.isEmpty() ) |
147 | mMainWin->addEmail( addr ); | 148 | mMainWin->addEmail( addr ); |
148 | 149 | ||
149 | if ( !uid.isEmpty() ) | 150 | if ( !uid.isEmpty() ) |
150 | mMainWin->showContactEditor( uid ); | 151 | mMainWin->showContactEditor( uid ); |
151 | if ( args->isSet( "new-contact" ) ) { | 152 | if ( args->isSet( "new-contact" ) ) { |
152 | mMainWin->newContact(); | 153 | mMainWin->newContact(); |
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
156 | KCrash::setEmergencySaveFunction( crashHandler ); | 157 | KCrash::setEmergencySaveFunction( crashHandler ); |
157 | 158 | ||
158 | return 0; | 159 | return 0; |
159 | } | 160 | } |
160 | 161 | ||
161 | // the dummy argument is required, because KMail apparently sends an empty | 162 | // the dummy argument is required, because KMail apparently sends an empty |
162 | // argument. | 163 | // argument. |
163 | static KCmdLineOptions kmoptions[] = | 164 | static KCmdLineOptions kmoptions[] = |
164 | { | 165 | { |
165 | { "a", 0 , 0 }, | 166 | { "a", 0 , 0 }, |
166 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, | 167 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, |
167 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, | 168 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, |
168 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, | 169 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, |
169 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, | 170 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, |
170 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, | 171 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, |
171 | { 0, 0, 0} | 172 | { 0, 0, 0} |
172 | }; | 173 | }; |
173 | 174 | ||
174 | int main( int argc, char *argv[] ) | 175 | int main( int argc, char *argv[] ) |
175 | { | 176 | { |
176 | KLocale::setMainCatalogue( "kaddressbook" ); | 177 | KLocale::setMainCatalogue( "kaddressbook" ); |
177 | 178 | ||
178 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); | 179 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); |
179 | KCmdLineArgs::addCmdLineOptions( kmoptions ); | 180 | KCmdLineArgs::addCmdLineOptions( kmoptions ); |
180 | KUniqueApplication::addCmdLineOptions(); | 181 | KUniqueApplication::addCmdLineOptions(); |
181 | 182 | ||
182 | if ( !KAddressBookApp::start() ) | 183 | if ( !KAddressBookApp::start() ) |
183 | exit( 0 ); | 184 | exit( 0 ); |
184 | 185 | ||
185 | KAddressBookApp app; | 186 | KAddressBookApp app; |
186 | KGlobal::locale()->insertCatalogue( "libkdepim" ); | 187 | KGlobal::locale()->insertCatalogue( "libkdepim" ); |
187 | 188 | ||
188 | return app.exec(); | 189 | return app.exec(); |
189 | } | 190 | } |
190 | */ | 191 | */ |
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 98b2fb2..9804e28 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -1,340 +1,340 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
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 <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qiconset.h> | 25 | #include <qiconset.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <qdragobject.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qbrush.h> | 30 | #include <qbrush.h> |
31 | #include <qevent.h> | 31 | #include <qevent.h> |
32 | 32 | ||
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobalsettings.h> | 34 | #include <kglobalsettings.h> |
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <kconfig.h> | 37 | #include <kconfig.h> |
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kurl.h> | 39 | #include <kurl.h> |
40 | 40 | ||
41 | #include "kaddressbooktableview.h" | 41 | #include "kaddressbooktableview.h" |
42 | 42 | ||
43 | #include "contactlistview.h" | 43 | #include "contactlistview.h" |
44 | 44 | ||
45 | ///////////////////////////////// | 45 | ///////////////////////////////// |
46 | // DynamicTip Methods | 46 | // DynamicTip Methods |
47 | 47 | ||
48 | DynamicTip::DynamicTip( ContactListView *parent) | 48 | DynamicTip::DynamicTip( ContactListView *parent) |
49 | : QToolTip( parent ) | 49 | : QToolTip( parent ) |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void DynamicTip::maybeTip( const QPoint &pos ) | 53 | void DynamicTip::maybeTip( const QPoint &pos ) |
54 | { | 54 | { |
55 | static bool ishidden = true; | 55 | static bool ishidden = true; |
56 | if (!parentWidget()->inherits( "ContactListView" )) | 56 | if (!parentWidget()->inherits( "ContactListView" )) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | ContactListView *plv = (ContactListView*)parentWidget(); | 59 | ContactListView *plv = (ContactListView*)parentWidget(); |
60 | if (!plv->tooltips()) | 60 | if (!plv->tooltips()) |
61 | return; | 61 | return; |
62 | 62 | ||
63 | QPoint posVp = plv->viewport()->pos(); | 63 | QPoint posVp = plv->viewport()->pos(); |
64 | 64 | ||
65 | QListViewItem *lvi = plv->itemAt( pos - posVp ); | 65 | QListViewItem *lvi = plv->itemAt( pos - posVp ); |
66 | if (!lvi) | 66 | if (!lvi) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); | 70 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); | 72 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | 74 | ||
75 | if (!plvi) | 75 | if (!plvi) |
76 | return; | 76 | return; |
77 | 77 | ||
78 | if (ishidden) { | 78 | if (ishidden) { |
79 | QString s; | 79 | QString s; |
80 | QRect r = plv->itemRect( lvi ); | 80 | QRect r = plv->itemRect( lvi ); |
81 | r.moveBy( posVp.x(), posVp.y() ); | 81 | r.moveBy( posVp.x(), posVp.y() ); |
82 | 82 | ||
83 | //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() | 83 | //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() |
84 | // << "," << r.height() << endl; | 84 | // << "," << r.height() << endl; |
85 | 85 | ||
86 | KABC::Addressee a = plvi->addressee(); | 86 | KABC::Addressee a = plvi->addressee(); |
87 | if (a.isEmpty()) | 87 | if (a.isEmpty()) |
88 | return; | 88 | return; |
89 | 89 | ||
90 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) | 90 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) |
91 | .arg(a.formattedName()); | 91 | .arg(a.formattedName()); |
92 | 92 | ||
93 | s += '\n'; | 93 | s += '\n'; |
94 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) | 94 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) |
95 | .arg(a.organization()); | 95 | .arg(a.organization()); |
96 | 96 | ||
97 | QString notes = a.note().stripWhiteSpace(); | 97 | QString notes = a.note().stripWhiteSpace(); |
98 | if ( !notes.isEmpty() ) { | 98 | if ( !notes.isEmpty() ) { |
99 | notes += '\n'; | 99 | notes += '\n'; |
100 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); | 100 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); |
101 | QFontMetrics fm( font() ); | 101 | QFontMetrics fm( font() ); |
102 | 102 | ||
103 | // Begin word wrap code based on QMultiLineEdit code | 103 | // Begin word wrap code based on QMultiLineEdit code |
104 | int i = 0; | 104 | int i = 0; |
105 | bool doBreak = false; | 105 | bool doBreak = false; |
106 | int linew = 0; | 106 | int linew = 0; |
107 | int lastSpace = -1; | 107 | int lastSpace = -1; |
108 | int a = 0; | 108 | int a = 0; |
109 | int lastw = 0; | 109 | int lastw = 0; |
110 | 110 | ||
111 | while ( i < int(notes.length()) ) { | 111 | while ( i < int(notes.length()) ) { |
112 | doBreak = FALSE; | 112 | doBreak = FALSE; |
113 | if ( notes[i] != '\n' ) | 113 | if ( notes[i] != '\n' ) |
114 | linew += fm.width( notes[i] ); | 114 | linew += fm.width( notes[i] ); |
115 | 115 | ||
116 | if ( lastSpace >= a && notes[i] != '\n' ) | 116 | if ( lastSpace >= a && notes[i] != '\n' ) |
117 | if (linew >= parentWidget()->width()) { | 117 | if (linew >= parentWidget()->width()) { |
118 | doBreak = TRUE; | 118 | doBreak = TRUE; |
119 | if ( lastSpace > a ) { | 119 | if ( lastSpace > a ) { |
120 | i = lastSpace; | 120 | i = lastSpace; |
121 | linew = lastw; | 121 | linew = lastw; |
122 | } | 122 | } |
123 | else | 123 | else |
124 | i = QMAX( a, i-1 ); | 124 | i = QMAX( a, i-1 ); |
125 | } | 125 | } |
126 | 126 | ||
127 | if ( notes[i] == '\n' || doBreak ) { | 127 | if ( notes[i] == '\n' || doBreak ) { |
128 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; | 128 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; |
129 | 129 | ||
130 | a = i + 1; | 130 | a = i + 1; |
131 | lastSpace = a; | 131 | lastSpace = a; |
132 | linew = 0; | 132 | linew = 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | if ( notes[i].isSpace() ) { | 135 | if ( notes[i].isSpace() ) { |
136 | lastSpace = i; | 136 | lastSpace = i; |
137 | lastw = linew; | 137 | lastw = linew; |
138 | } | 138 | } |
139 | 139 | ||
140 | if ( lastSpace <= a ) { | 140 | if ( lastSpace <= a ) { |
141 | lastw = linew; | 141 | lastw = linew; |
142 | } | 142 | } |
143 | 143 | ||
144 | ++i; | 144 | ++i; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | tip( r, s ); | 148 | tip( r, s ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | hide(); | 151 | hide(); |
152 | ishidden = !ishidden; | 152 | ishidden = !ishidden; |
153 | 153 | ||
154 | } | 154 | } |
155 | 155 | ||
156 | /////////////////////////// | 156 | /////////////////////////// |
157 | // ContactListViewItem Methods | 157 | // ContactListViewItem Methods |
158 | 158 | ||
159 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | 159 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, |
160 | ContactListView *parent, | 160 | ContactListView *parent, |
161 | KABC::AddressBook *doc, | 161 | KABC::AddressBook *doc, |
162 | const KABC::Field::List &fields ) | 162 | const KABC::Field::List &fields ) |
163 | : KListViewItem(parent), mAddressee(a), mFields( fields ), | 163 | : KListViewItem(parent), mAddressee(a), mFields( fields ), |
164 | parentListView( parent ), mDocument(doc) | 164 | parentListView( parent ), mDocument(doc) |
165 | { | 165 | { |
166 | refresh(); | 166 | refresh(); |
167 | } | 167 | } |
168 | 168 | ||
169 | QString ContactListViewItem::key(int column, bool ascending) const | 169 | QString ContactListViewItem::key(int column, bool ascending) const |
170 | { | 170 | { |
171 | return QListViewItem::key(column, ascending).lower(); | 171 | return QListViewItem::key(column, ascending).lower(); |
172 | } | 172 | } |
173 | 173 | ||
174 | void ContactListViewItem::paintCell(QPainter * p, | 174 | void ContactListViewItem::paintCell(QPainter * p, |
175 | const QColorGroup & cg, | 175 | const QColorGroup & cg, |
176 | int column, | 176 | int column, |
177 | int width, | 177 | int width, |
178 | int align) | 178 | int align) |
179 | { | 179 | { |
180 | KListViewItem::paintCell(p, cg, column, width, align); | 180 | KListViewItem::paintCell(p, cg, column, width, align); |
181 | 181 | ||
182 | if ( !p ) | 182 | if ( !p ) |
183 | return; | 183 | return; |
184 | 184 | ||
185 | if (parentListView->singleLine()) { | 185 | if (parentListView->singleLine()) { |
186 | p->setPen( parentListView->alternateColor() ); | 186 | p->setPen( parentListView->alternateColor() ); |
187 | p->drawLine( 0, height() - 1, width, height() - 1 ); | 187 | p->drawLine( 0, height() - 1, width, height() - 1 ); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | ContactListView *ContactListViewItem::parent() | 192 | ContactListView *ContactListViewItem::parent() |
193 | { | 193 | { |
194 | return parentListView; | 194 | return parentListView; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | void ContactListViewItem::refresh() | 198 | void ContactListViewItem::refresh() |
199 | { | 199 | { |
200 | // Update our addressee, since it may have changed else were | 200 | // Update our addressee, since it may have changed else were |
201 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 201 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
202 | if (mAddressee.isEmpty()) | 202 | if (mAddressee.isEmpty()) |
203 | return; | 203 | return; |
204 | 204 | ||
205 | int i = 0; | 205 | int i = 0; |
206 | KABC::Field::List::ConstIterator it; | 206 | KABC::Field::List::ConstIterator it; |
207 | for( it = mFields.begin(); it != mFields.end(); ++it ) { | 207 | for( it = mFields.begin(); it != mFields.end(); ++it ) { |
208 | setText( i++, (*it)->value( mAddressee ) ); | 208 | setText( i++, (*it)->value( mAddressee ) ); |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | /////////////////////////////// | 212 | /////////////////////////////// |
213 | // ContactListView | 213 | // ContactListView |
214 | 214 | ||
215 | ContactListView::ContactListView(KAddressBookTableView *view, | 215 | ContactListView::ContactListView(KAddressBookTableView *view, |
216 | KABC::AddressBook* /* doc */, | 216 | KABC::AddressBook* /* doc */, |
217 | QWidget *parent, | 217 | QWidget *parent, |
218 | const char *name ) | 218 | const char *name ) |
219 | : KListView( parent, name ), | 219 | : KListView( parent, name ), |
220 | pabWidget( view ), | 220 | pabWidget( view ), |
221 | oldColumn( 0 ) | 221 | oldColumn( 0 ) |
222 | { | 222 | { |
223 | mABackground = true; | 223 | mABackground = true; |
224 | mSingleLine = false; | 224 | mSingleLine = false; |
225 | mToolTips = true; | 225 | mToolTips = true; |
226 | #ifndef KAB_EMBEDDED | 226 | #ifndef KAB_EMBEDDED |
227 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 227 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
228 | #else //KAB_EMBEDDED | 228 | #else //KAB_EMBEDDED |
229 | mAlternateColor = QColor(240, 240, 240); | 229 | mAlternateColor = QColor(240, 240, 240); |
230 | #endif //KAB_EMBEDDED | 230 | #endif //KAB_EMBEDDED |
231 | 231 | ||
232 | setAlternateBackgroundEnabled(mABackground); | 232 | setAlternateBackgroundEnabled(mABackground); |
233 | setAcceptDrops( true ); | 233 | setAcceptDrops( true ); |
234 | viewport()->setAcceptDrops( true ); | 234 | viewport()->setAcceptDrops( true ); |
235 | setAllColumnsShowFocus( true ); | 235 | setAllColumnsShowFocus( true ); |
236 | setShowSortIndicator(true); | 236 | setShowSortIndicator(true); |
237 | 237 | ||
238 | setSelectionModeExt( KListView::Extended ); | 238 | setSelectionModeExt( KListView::Extended ); |
239 | setDropVisualizer(false); | 239 | setDropVisualizer(false); |
240 | // setFrameStyle(QFrame::NoFrame); | 240 | // setFrameStyle(QFrame::NoFrame); |
241 | setLineWidth ( 0 ); | 241 | //setLineWidth ( 0 ); |
242 | setMidLineWidth ( 0 ); | 242 | //setMidLineWidth ( 0 ); |
243 | setMargin ( 0 ); | 243 | //setMargin ( 0 ); |
244 | #ifndef KAB_EMBEDDED | 244 | #ifndef KAB_EMBEDDED |
245 | connect(this, SIGNAL(dropped(QDropEvent*)), | 245 | connect(this, SIGNAL(dropped(QDropEvent*)), |
246 | this, SLOT(itemDropped(QDropEvent*))); | 246 | this, SLOT(itemDropped(QDropEvent*))); |
247 | #endif //KAB_EMBEDDED | 247 | #endif //KAB_EMBEDDED |
248 | 248 | ||
249 | 249 | ||
250 | new DynamicTip( this ); | 250 | new DynamicTip( this ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 253 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) |
254 | { | 254 | { |
255 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); | 255 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); |
256 | 256 | ||
257 | // Get the brush, which will have the background pixmap if there is one. | 257 | // Get the brush, which will have the background pixmap if there is one. |
258 | if (b.pixmap()) | 258 | if (b.pixmap()) |
259 | { | 259 | { |
260 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), | 260 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), |
261 | *(b.pixmap()), | 261 | *(b.pixmap()), |
262 | rect.left() + contentsX(), | 262 | rect.left() + contentsX(), |
263 | rect.top() + contentsY() ); | 263 | rect.top() + contentsY() ); |
264 | } | 264 | } |
265 | 265 | ||
266 | else | 266 | else |
267 | { | 267 | { |
268 | // Do a normal paint | 268 | // Do a normal paint |
269 | KListView::paintEmptyArea(p, rect); | 269 | KListView::paintEmptyArea(p, rect); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) | 273 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) |
274 | { | 274 | { |
275 | presspos = e->pos(); | 275 | presspos = e->pos(); |
276 | KListView::contentsMousePressEvent(e); | 276 | KListView::contentsMousePressEvent(e); |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | // To initiate a drag operation | 280 | // To initiate a drag operation |
281 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 281 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) |
282 | { | 282 | { |
283 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { | 283 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { |
284 | emit startAddresseeDrag(); | 284 | emit startAddresseeDrag(); |
285 | } | 285 | } |
286 | else | 286 | else |
287 | KListView::contentsMouseMoveEvent( e ); | 287 | KListView::contentsMouseMoveEvent( e ); |
288 | } | 288 | } |
289 | 289 | ||
290 | bool ContactListView::acceptDrag(QDropEvent *e) const | 290 | bool ContactListView::acceptDrag(QDropEvent *e) const |
291 | { | 291 | { |
292 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
293 | return QTextDrag::canDecode(e); | 293 | return QTextDrag::canDecode(e); |
294 | #else //KAB_EMBEDDED | 294 | #else //KAB_EMBEDDED |
295 | qDebug("ContactListView::acceptDrag has to be fixed"); | 295 | qDebug("ContactListView::acceptDrag has to be fixed"); |
296 | return false; | 296 | return false; |
297 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
298 | } | 298 | } |
299 | 299 | ||
300 | void ContactListView::itemDropped(QDropEvent *e) | 300 | void ContactListView::itemDropped(QDropEvent *e) |
301 | { | 301 | { |
302 | contentsDropEvent(e); | 302 | contentsDropEvent(e); |
303 | } | 303 | } |
304 | 304 | ||
305 | void ContactListView::contentsDropEvent( QDropEvent *e ) | 305 | void ContactListView::contentsDropEvent( QDropEvent *e ) |
306 | { | 306 | { |
307 | emit addresseeDropped(e); | 307 | emit addresseeDropped(e); |
308 | } | 308 | } |
309 | 309 | ||
310 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) | 310 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) |
311 | { | 311 | { |
312 | mABackground = enabled; | 312 | mABackground = enabled; |
313 | 313 | ||
314 | if (mABackground) | 314 | if (mABackground) |
315 | { | 315 | { |
316 | setAlternateBackground(mAlternateColor); | 316 | setAlternateBackground(mAlternateColor); |
317 | } | 317 | } |
318 | else | 318 | else |
319 | { | 319 | { |
320 | setAlternateBackground(QColor()); | 320 | setAlternateBackground(QColor()); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void ContactListView::setBackgroundPixmap(const QString &filename) | 324 | void ContactListView::setBackgroundPixmap(const QString &filename) |
325 | { | 325 | { |
326 | if (filename.isEmpty()) | 326 | if (filename.isEmpty()) |
327 | { | 327 | { |
328 | unsetPalette(); | 328 | unsetPalette(); |
329 | } | 329 | } |
330 | else | 330 | else |
331 | { | 331 | { |
332 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); | 332 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); |
333 | //US setPaletteBackgroundPixmap(QPixmap(filename)); | 333 | //US setPaletteBackgroundPixmap(QPixmap(filename)); |
334 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); | 334 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); |
335 | } | 335 | } |
336 | 336 | ||
337 | } | 337 | } |
338 | #ifndef KAB_EMBEDDED | 338 | #ifndef KAB_EMBEDDED |
339 | #include "contactlistview.moc" | 339 | #include "contactlistview.moc" |
340 | #endif //KAB_EMBEDDED | 340 | #endif //KAB_EMBEDDED |