Diffstat (limited to 'kaddressbook/views/contactlistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 9accf78..227645d 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -16,25 +16,30 @@ | |||
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 <q3header.h> |
25 | #include <qiconset.h> | 25 | #include <qicon.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <q3dragobject.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 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //Added by qt3to4: | ||
34 | #include <QDropEvent> | ||
35 | #include <QPixmap> | ||
36 | #include <QMouseEvent> | ||
37 | #include <QKeyEvent> | ||
33 | 38 | ||
34 | #include <klocale.h> | 39 | #include <klocale.h> |
35 | #include <kglobalsettings.h> | 40 | #include <kglobalsettings.h> |
36 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
37 | #include <kdebug.h> | 42 | #include <kdebug.h> |
38 | #include <kconfig.h> | 43 | #include <kconfig.h> |
39 | #include <kapplication.h> | 44 | #include <kapplication.h> |
40 | #include <kurl.h> | 45 | #include <kurl.h> |
@@ -42,33 +47,34 @@ | |||
42 | #include "kaddressbooktableview.h" | 47 | #include "kaddressbooktableview.h" |
43 | 48 | ||
44 | #include "contactlistview.h" | 49 | #include "contactlistview.h" |
45 | 50 | ||
46 | ///////////////////////////////// | 51 | ///////////////////////////////// |
47 | // DynamicTip Methods | 52 | // DynamicTip Methods |
48 | 53 | ||
49 | DynamicTip::DynamicTip( ContactListView *parent) | 54 | DynamicTip::DynamicTip( ContactListView *parent) |
50 | : QToolTip( parent ) | 55 | /* TODO:hacker:: QToolTip( parent ) */ |
51 | { | 56 | { |
52 | } | 57 | } |
53 | 58 | ||
54 | void DynamicTip::maybeTip( const QPoint &pos ) | 59 | void DynamicTip::maybeTip( const QPoint &pos ) |
55 | { | 60 | { |
61 | /* TODO:hacker: | ||
56 | static bool ishidden = true; | 62 | static bool ishidden = true; |
57 | if (!parentWidget()->inherits( "ContactListView" )) | 63 | if (!parentWidget()->inherits( "ContactListView" )) |
58 | return; | 64 | return; |
59 | 65 | ||
60 | ContactListView *plv = (ContactListView*)parentWidget(); | 66 | ContactListView *plv = (ContactListView*)parentWidget(); |
61 | if (!plv->tooltips()) | 67 | if (!plv->tooltips()) |
62 | return; | 68 | return; |
63 | 69 | ||
64 | QPoint posVp = plv->viewport()->pos(); | 70 | QPoint posVp = plv->viewport()->pos(); |
65 | 71 | ||
66 | QListViewItem *lvi = plv->itemAt( pos - posVp ); | 72 | Q3ListViewItem *lvi = plv->itemAt( pos - posVp ); |
67 | if (!lvi) | 73 | if (!lvi) |
68 | return; | 74 | return; |
69 | 75 | ||
70 | #ifndef KAB_EMBEDDED | 76 | #ifndef KAB_EMBEDDED |
71 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); | 77 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); |
72 | #else //KAB_EMBEDDED | 78 | #else //KAB_EMBEDDED |
73 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); | 79 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); |
74 | #endif //KAB_EMBEDDED | 80 | #endif //KAB_EMBEDDED |
@@ -146,17 +152,17 @@ void DynamicTip::maybeTip( const QPoint &pos ) | |||
146 | } | 152 | } |
147 | } | 153 | } |
148 | 154 | ||
149 | tip( r, s ); | 155 | tip( r, s ); |
150 | } | 156 | } |
151 | else | 157 | else |
152 | hide(); | 158 | hide(); |
153 | ishidden = !ishidden; | 159 | ishidden = !ishidden; |
154 | 160 | */ | |
155 | } | 161 | } |
156 | 162 | ||
157 | /////////////////////////// | 163 | /////////////////////////// |
158 | // ContactListViewItem Methods | 164 | // ContactListViewItem Methods |
159 | 165 | ||
160 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | 166 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, |
161 | ContactListView *parent, | 167 | ContactListView *parent, |
162 | KABC::AddressBook *doc, | 168 | KABC::AddressBook *doc, |
@@ -168,17 +174,17 @@ ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | |||
168 | } | 174 | } |
169 | 175 | ||
170 | QString ContactListViewItem::key(int column, bool ascending) const | 176 | QString ContactListViewItem::key(int column, bool ascending) const |
171 | { | 177 | { |
172 | #ifndef DESKTOP_VERSION | 178 | #ifndef DESKTOP_VERSION |
173 | int lan = KGlobal::locale()->language(); | 179 | int lan = KGlobal::locale()->language(); |
174 | //qDebug("language %d ", lan); | 180 | //qDebug("language %d ", lan); |
175 | if ( lan == 1 ) { //GERMAN | 181 | if ( lan == 1 ) { //GERMAN |
176 | QString ret = QListViewItem::key(column, ascending).lower().utf8(); | 182 | QString ret = Q3ListViewItem::key(column, ascending).lower().utf8(); |
177 | int start = -1; | 183 | int start = -1; |
178 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { | 184 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { |
179 | ret.at(start-1) = 'a'; | 185 | ret.at(start-1) = 'a'; |
180 | } | 186 | } |
181 | start = -1; | 187 | start = -1; |
182 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { | 188 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { |
183 | ret.at(start-1) = 'o'; | 189 | ret.at(start-1) = 'o'; |
184 | } | 190 | } |
@@ -192,17 +198,17 @@ QString ContactListViewItem::key(int column, bool ascending) const | |||
192 | } | 198 | } |
193 | //qDebug("conv string %s ", ret.latin1()); | 199 | //qDebug("conv string %s ", ret.latin1()); |
194 | 200 | ||
195 | return ret; | 201 | return ret; |
196 | 202 | ||
197 | } | 203 | } |
198 | else | 204 | else |
199 | #endif | 205 | #endif |
200 | return QListViewItem::key(column, ascending).lower(); | 206 | return Q3ListViewItem::key(column, ascending).lower(); |
201 | } | 207 | } |
202 | 208 | ||
203 | void ContactListViewItem::paintCell(QPainter * p, | 209 | void ContactListViewItem::paintCell(QPainter * p, |
204 | const QColorGroup & cg, | 210 | const QColorGroup & cg, |
205 | int column, | 211 | int column, |
206 | int width, | 212 | int width, |
207 | int align) | 213 | int align) |
208 | { | 214 | { |
@@ -283,17 +289,17 @@ ContactListView::ContactListView(KAddressBookTableView *view, | |||
283 | void ContactListView::printMe() | 289 | void ContactListView::printMe() |
284 | { | 290 | { |
285 | #ifdef DESKTOP_VERSION | 291 | #ifdef DESKTOP_VERSION |
286 | QPrinter printer; | 292 | QPrinter printer; |
287 | if (!printer.setup() ) | 293 | if (!printer.setup() ) |
288 | return; | 294 | return; |
289 | QPainter p; | 295 | QPainter p; |
290 | p.begin ( &printer ); | 296 | p.begin ( &printer ); |
291 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 297 | Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer ); |
292 | float dx, dy; | 298 | float dx, dy; |
293 | int wid = (m.width() * 9)/10; | 299 | int wid = (m.width() * 9)/10; |
294 | dx = (float) wid/(float)contentsWidth (); | 300 | dx = (float) wid/(float)contentsWidth (); |
295 | dy = (float)(m.height()) / (float)contentsHeight (); | 301 | dy = (float)(m.height()) / (float)contentsHeight (); |
296 | float scale; | 302 | float scale; |
297 | // scale to fit the width or height of the paper | 303 | // scale to fit the width or height of the paper |
298 | if ( dx < dy ) | 304 | if ( dx < dy ) |
299 | scale = dx; | 305 | scale = dx; |
@@ -338,27 +344,27 @@ void ContactListView::contentsMousePressEvent(QMouseEvent* e) | |||
338 | presspos = e->pos(); | 344 | presspos = e->pos(); |
339 | KListView::contentsMousePressEvent(e); | 345 | KListView::contentsMousePressEvent(e); |
340 | } | 346 | } |
341 | 347 | ||
342 | 348 | ||
343 | // To initiate a drag operation | 349 | // To initiate a drag operation |
344 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 350 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) |
345 | { | 351 | { |
346 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { | 352 | if ((e->state() & Qt::LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { |
347 | emit startAddresseeDrag(); | 353 | emit startAddresseeDrag(); |
348 | } | 354 | } |
349 | else | 355 | else |
350 | KListView::contentsMouseMoveEvent( e ); | 356 | KListView::contentsMouseMoveEvent( e ); |
351 | } | 357 | } |
352 | 358 | ||
353 | bool ContactListView::acceptDrag(QDropEvent *e) const | 359 | bool ContactListView::acceptDrag(QDropEvent *e) const |
354 | { | 360 | { |
355 | #ifndef KAB_EMBEDDED | 361 | #ifndef KAB_EMBEDDED |
356 | return QTextDrag::canDecode(e); | 362 | return Q3TextDrag::canDecode(e); |
357 | #else //KAB_EMBEDDED | 363 | #else //KAB_EMBEDDED |
358 | qDebug("ContactListView::acceptDrag has to be fixed"); | 364 | qDebug("ContactListView::acceptDrag has to be fixed"); |
359 | return false; | 365 | return false; |
360 | #endif //KAB_EMBEDDED | 366 | #endif //KAB_EMBEDDED |
361 | } | 367 | } |
362 | 368 | ||
363 | void ContactListView::itemDropped(QDropEvent *e) | 369 | void ContactListView::itemDropped(QDropEvent *e) |
364 | { | 370 | { |
@@ -419,11 +425,11 @@ void ContactListView::keyReleaseEvent ( QKeyEvent * e ) | |||
419 | if ( !e->isAutoRepeat() ) { | 425 | if ( !e->isAutoRepeat() ) { |
420 | mFlagBlockKeyPressed = true; | 426 | mFlagBlockKeyPressed = true; |
421 | qApp->processEvents(); | 427 | qApp->processEvents(); |
422 | mFlagBlockKeyPressed = false; | 428 | mFlagBlockKeyPressed = false; |
423 | mFlagKeyPressed = false; | 429 | mFlagKeyPressed = false; |
424 | } | 430 | } |
425 | KListView::keyReleaseEvent ( e ); | 431 | KListView::keyReleaseEvent ( e ); |
426 | } | 432 | } |
427 | #ifndef KAB_EMBEDDED | 433 | #ifndef KAB_EMBEDDED_ |
428 | #include "contactlistview.moc" | 434 | #include "moc_contactlistview.cpp" |
429 | #endif //KAB_EMBEDDED | 435 | #endif //KAB_EMBEDDED |