summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/contactlistview.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/views/contactlistview.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/views/contactlistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/contactlistview.cpp32
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
@@ -12,67 +12,73 @@
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 <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>
41 46
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
49DynamicTip::DynamicTip( ContactListView *parent) 54DynamicTip::DynamicTip( ContactListView *parent)
50 : QToolTip( parent ) 55 /* TODO:hacker:: QToolTip( parent ) */
51{ 56{
52} 57}
53 58
54void DynamicTip::maybeTip( const QPoint &pos ) 59void 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
75 81
76 if (!plvi) 82 if (!plvi)
77 return; 83 return;
78 84
@@ -142,71 +148,71 @@ void DynamicTip::maybeTip( const QPoint &pos )
142 lastw = linew; 148 lastw = linew;
143 } 149 }
144 150
145 ++i; 151 ++i;
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
160ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, 166ContactListViewItem::ContactListViewItem(const KABC::Addressee &a,
161 ContactListView *parent, 167 ContactListView *parent,
162 KABC::AddressBook *doc, 168 KABC::AddressBook *doc,
163 const KABC::Field::List &fields ) 169 const KABC::Field::List &fields )
164 : KListViewItem(parent), mAddressee(a), mFields( fields ), 170 : KListViewItem(parent), mAddressee(a), mFields( fields ),
165 parentListView( parent ), mDocument(doc) 171 parentListView( parent ), mDocument(doc)
166{ 172{
167 refresh(); 173 refresh();
168} 174}
169 175
170QString ContactListViewItem::key(int column, bool ascending) const 176QString 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 }
185 start = -1; 191 start = -1;
186 while ( (start = ret.find( 'ü', start+1)) > 0 ) { 192 while ( (start = ret.find( 'ü', start+1)) > 0 ) {
187 ret.at(start-1) = 'o'; 193 ret.at(start-1) = 'o';
188 } 194 }
189 start = -1; 195 start = -1;
190 while ( (start = ret.find( 'ß', start+1)) > 0 ) { 196 while ( (start = ret.find( 'ß', start+1)) > 0 ) {
191 ret.at(start-1) = 's'; 197 ret.at(start-1) = 's';
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
203void ContactListViewItem::paintCell(QPainter * p, 209void 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{
209 KListViewItem::paintCell(p, cg, column, width, align); 215 KListViewItem::paintCell(p, cg, column, width, align);
210 216
211 if ( !p ) 217 if ( !p )
212 return; 218 return;
@@ -279,25 +285,25 @@ ContactListView::ContactListView(KAddressBookTableView *view,
279 285
280 286
281 new DynamicTip( this ); 287 new DynamicTip( this );
282} 288}
283void ContactListView::printMe() 289void 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;
300 else 306 else
301 scale = dy; 307 scale = dy;
302 p.translate( m.width()/10,0 ); 308 p.translate( m.width()/10,0 );
303 p.scale( scale, scale ); 309 p.scale( scale, scale );
@@ -334,35 +340,35 @@ void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
334} 340}
335 341
336void ContactListView::contentsMousePressEvent(QMouseEvent* e) 342void ContactListView::contentsMousePressEvent(QMouseEvent* e)
337{ 343{
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
344void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) 350void 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
353bool ContactListView::acceptDrag(QDropEvent *e) const 359bool 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
358qDebug("ContactListView::acceptDrag has to be fixed"); 364qDebug("ContactListView::acceptDrag has to be fixed");
359 return false; 365 return false;
360#endif //KAB_EMBEDDED 366#endif //KAB_EMBEDDED
361} 367}
362 368
363void ContactListView::itemDropped(QDropEvent *e) 369void ContactListView::itemDropped(QDropEvent *e)
364{ 370{
365 contentsDropEvent(e); 371 contentsDropEvent(e);
366} 372}
367 373
368void ContactListView::contentsDropEvent( QDropEvent *e ) 374void ContactListView::contentsDropEvent( QDropEvent *e )
@@ -415,15 +421,15 @@ void ContactListView::keyPressEvent ( QKeyEvent * e )
415void ContactListView::keyReleaseEvent ( QKeyEvent * e ) 421void ContactListView::keyReleaseEvent ( QKeyEvent * e )
416{ 422{
417 if ( mFlagBlockKeyPressed ) 423 if ( mFlagBlockKeyPressed )
418 return; 424 return;
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