-rw-r--r-- | kaddressbook/views/cardview.cpp | 31 | ||||
-rw-r--r-- | kaddressbook/views/cardview.h | 5 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 4 |
6 files changed, 75 insertions, 2 deletions
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp index 03df444..84d3116 100644 --- a/kaddressbook/views/cardview.cpp +++ b/kaddressbook/views/cardview.cpp @@ -1,131 +1,132 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ //BEGIN Includes #include "cardview.h" #include <limits.h> #include <qpainter.h> #include <qtimer.h> #include <qdatetime.h> #include <qlabel.h> #include <qstyle.h> #include <qcursor.h> #include <qtooltip.h> +#include <qapplication.h> #include "kabprefs.h" #include <kdebug.h> #include <kglobalsettings.h> //END includes #define MIN_ITEM_WIDTH 80 //BEGIN Helpers ////////////////////////////////////// // CardViewTip class CardViewTip : public QLabel { public: CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) { setPalette( QToolTip::palette() ); setFrameStyle( Panel|Plain ); setMidLineWidth(0); setIndent(1); } ~CardViewTip() {}; protected: void leaveEvent( QEvent * ) { hide(); } }; ////////////////////////////////////// // CardViewItemList // // Warning: make sure you use findRef() instead of find() to find an // item! Only the pointer value is unique in the list. // class CardViewItemList : public QPtrList<CardViewItem> { protected: virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2) { CardViewItem *cItem1 = (CardViewItem*)item1; CardViewItem *cItem2 = (CardViewItem*)item2; if ( cItem1 == cItem2 ) return 0; if ((cItem1 == 0) || (cItem2 == 0)) return cItem1 ? -1 : 1; if (cItem1->caption() < cItem2->caption()) return -1; else if (cItem1->caption() > cItem2->caption()) return 1; return 0; } private: /*int find( const CardViewItem * ) { qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); }*/ }; ////////////////////////////////////// // CardViewSeparator class CardViewSeparator { friend class CardView; public: CardViewSeparator(CardView *view) : mView(view) { mRect = QRect(0, 0, view->separatorWidth(), 0); } ~CardViewSeparator() {} void paintSeparator(QPainter *p, QColorGroup &cg) { p->fillRect(0, 0, mRect.width(), mRect.height(), cg.brush(QColorGroup::Button)); } void repaintSeparator() { mView->repaintContents(mRect); } private: CardView *mView; @@ -546,192 +547,194 @@ void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) { if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 ) return; // this is the caption s = caption(); trimmed = mView->d->mBFm->width( s ) > w - 4; y = 2 + mrg; lw = 0; isLabel=true; } else { // find the field Field *f = fieldAt( itempos ); if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) ) return; // y position: // header font height + 4px hader margin + 2px leading + item margin // + actual field index * (fontheight + 2px leading) int maxLines = mView->maxFieldLines(); bool se = mView->showEmptyFields(); int fh = mView->d->mFm->height(); // { Field *_f; for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next()) if ( se || ! _f->second.isEmpty() ) y += ( QMIN(_f->second.contains('\n')+1, maxLines) * fh ) + 2; // } if ( isLabel && itempos.y() > y + fh ) return; // label or data? s = isLabel ? f->first : f->second; // trimmed? int colonWidth = mView->d->mFm->width(":"); lw = drawLabels ? // label width QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) : 0; int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string if ( isLabel ) { trimmed = mView->d->mFm->width( s ) > mw - colonWidth; } else { QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) ); trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines); } } if ( trimmed ) { tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header tip->setText( s ); tip->adjustSize(); // find a proper position int lx; lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/; QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) )); pnt += QPoint(lx, y); if ( pnt.x() < 0 ) pnt.setX( 0 ); if ( pnt.x() + tip->width() > mView->visibleWidth() ) pnt.setX( mView->visibleWidth() - tip->width() ); if ( pnt.y() + tip->height() > mView->visibleHeight() ) pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) ); // show tip->move( pnt ); tip->show(); } } CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const { int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; int iy = itempos.y(); // skip below caption if ( iy <= ypos ) return 0; // try find a field bool showEmpty = mView->showEmptyFields(); int fh = mView->d->mFm->height(); int maxLines = mView->maxFieldLines(); Field *f; for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) { if ( showEmpty || !f->second.isEmpty() ) ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; if ( iy <= ypos ) break; } return f ? f : 0; } //END CardViewItem //BEGIN CardView CardView::CardView(QWidget *parent, const char *name) : QScrollView(parent, name), d(new CardViewPrivate()) { + mFlagKeyPressed = false; + mFlagBlockKeyPressed = false; d->mItemList.setAutoDelete(true); d->mSeparatorList.setAutoDelete(true); QFont f = font(); d->mFm = new QFontMetrics(f); f.setBold(true); d->mHeaderFont = f; d->mBFm = new QFontMetrics(f); d->mTip = ( new CardViewTip( viewport() ) ), d->mTip->hide(); d->mTimer = ( new QTimer(this, "mouseTimer") ), viewport()->setMouseTracking( true ); viewport()->setFocusProxy(this); viewport()->setFocusPolicy(WheelFocus); viewport()->setBackgroundMode(PaletteBase); connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); //US setBackgroundMode(PaletteBackground, PaletteBase); setBackgroundMode(PaletteBackground); // no reason for a vertical scrollbar setVScrollBarMode(AlwaysOff); } CardView::~CardView() { delete d->mFm; delete d->mBFm; delete d; d = 0; } void CardView::insertItem(CardViewItem *item) { d->mItemList.inSort(item); setLayoutDirty(true); } void CardView::takeItem(CardViewItem *item) { if ( d->mCurrentItem == item ) d->mCurrentItem = item->nextItem(); d->mItemList.take(d->mItemList.findRef(item)); setLayoutDirty(true); } void CardView::clear() { d->mItemList.clear(); setLayoutDirty(true); } CardViewItem *CardView::currentItem() { if ( ! d->mCurrentItem && d->mItemList.count() ) d->mCurrentItem = d->mItemList.first(); return d->mCurrentItem; } void CardView::setCurrentItem( CardViewItem *item ) { if ( !item ) return; else if ( item->cardView() != this ) { kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl; return; } else if ( item == currentItem() ) { return; } if ( d->mSelectionMode == Single ) { setSelected( item, true ); } else { CardViewItem *it = d->mCurrentItem; d->mCurrentItem = item; if ( it ) it->repaintCard(); item->repaintCard(); } if ( ! d->mOnSeparator ) ensureItemVisible( item ); emit currentChanged( item ); } CardViewItem *CardView::itemAt(const QPoint &viewPos) { @@ -1258,193 +1261,201 @@ void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) QScrollView::contentsMouseDoubleClickEvent(e); CardViewItem *item = itemAt(e->pos()); if (item) { d->mCurrentItem = item; } if (item && !KABPrefs::instance()->mHonorSingleClick) { emit executed(item); } else emit doubleClicked(item); } void CardView::contentsMouseMoveEvent( QMouseEvent *e ) { // resizing if ( d->mResizeAnchor ) { int x = e->x(); if ( x != d->mRubberBandAnchor ) drawRubberBands( x ); return; } if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { startDrag(); return; } d->mTimer->start( 500 ); // see if we are over a separator // only if we actually have them painted? if ( d->mDrawSeparators ) { int colcontentw = d->mItemWidth + (2*d->mItemSpacing); int colw = colcontentw + d->mSepWidth; int m = e->x()%colw; if ( m >= colcontentw && m > 0 ) { setCursor( SplitVCursor ); // Why does this fail sometimes? d->mOnSeparator = true; } else { setCursor( ArrowCursor ); d->mOnSeparator = false; } } } void CardView::enterEvent( QEvent * ) { d->mTimer->start( 500 ); } void CardView::leaveEvent( QEvent * ) { d->mTimer->stop(); if (d->mOnSeparator) { d->mOnSeparator = false; setCursor( ArrowCursor ); } } void CardView::focusInEvent( QFocusEvent * ) { if (!d->mCurrentItem && d->mItemList.count() ) { setCurrentItem( d->mItemList.first() ); } else if ( d->mCurrentItem ) { d->mCurrentItem->repaintCard(); } } void CardView::focusOutEvent( QFocusEvent * ) { if (d->mCurrentItem) d->mCurrentItem->repaintCard(); } void CardView::keyPressEvent( QKeyEvent *e ) { if ( ! ( childCount() && d->mCurrentItem ) ) { e->ignore(); return; } - + if ( mFlagBlockKeyPressed ) + return; + qApp->processEvents(); + if ( e->isAutoRepeat() && !mFlagKeyPressed ) { + e->accept(); + return; + } + if (! e->isAutoRepeat() ) + mFlagKeyPressed = true; uint pos = d->mItemList.findRef( d->mCurrentItem ); CardViewItem *aItem = 0L; // item that gets the focus CardViewItem *old = d->mCurrentItem; switch ( e->key() ) { case Key_Up: if ( pos > 0 ) { aItem = d->mItemList.at( pos - 1 ); setCurrentItem( aItem ); } break; case Key_Down: if ( pos < d->mItemList.count() - 1 ) { aItem = d->mItemList.at( pos + 1 ); setCurrentItem( aItem ); } break; case Key_Left: { // look for an item in the previous/next column, starting from // the vertical middle of the current item. // FIXME use nice calculatd measures!!! QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); aItem = itemAt( aPoint ); // maybe we hit some space below an item while ( !aItem && aPoint.y() > 27 ) { aPoint -= QPoint( 0, 16 ); aItem = itemAt( aPoint ); } if ( aItem ) setCurrentItem( aItem ); } break; case Key_Right: { // FIXME use nice calculated measures!!! QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y ); aPoint += QPoint( 30,(d->mCurrentItem->height()/2) ); aItem = itemAt( aPoint ); while ( !aItem && aPoint.y() > 27 ) { aPoint -= QPoint( 0, 16 ); aItem = itemAt( aPoint ); } if ( aItem ) setCurrentItem( aItem ); } break; case Key_Home: aItem = d->mItemList.first(); setCurrentItem( aItem ); break; case Key_End: aItem = d->mItemList.last(); setCurrentItem( aItem ); break; case Key_Prior: // PageUp { // QListView: "Make the item above the top visible and current" // TODO if contentsY(), pick the top item of the leftmost visible column if ( contentsX() <= 0 ) return; int cw = columnWidth(); int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing; aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) ); if ( aItem ) setCurrentItem( aItem ); } break; case Key_Next: // PageDown { // QListView: "Make the item below the bottom visible and current" // find the first not fully visible column. // TODO: consider if a partly visible (or even hidden) item at the // bottom of the rightmost column exists int cw = columnWidth(); int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1; // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) ) theCol += cw; // make sure this is not too far right while ( theCol > contentsWidth() ) theCol -= columnWidth(); aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) ); if ( aItem ) setCurrentItem( aItem ); } break; @@ -1622,101 +1633,119 @@ void CardView::tryShowFullText() void CardView::drawRubberBands( int pos ) { if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return; int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span; int x = d->firstX + tmpcw - d->mSepWidth - contentsX(); int h = visibleHeight(); QPainter p( viewport() ); p.setRasterOp( XorROP ); p.setPen( gray ); p.setBrush( gray ); uint n = d->first; // erase if ( d->mRubberBandAnchor ) do { p.drawRect( x, 0, 2, h ); x += tmpcw; n++; } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); // paint new if ( ! pos ) return; tmpcw = (pos - d->firstX)/d->span; n = d->first; x = d->firstX + tmpcw - d->mSepWidth - contentsX(); do { p.drawRect( x, 0, 2, h ); x += tmpcw; n++; } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); d->mRubberBandAnchor = pos; } int CardView::itemWidth() const { return d->mItemWidth; } void CardView::setItemWidth( int w ) { if ( w == d->mItemWidth ) return; if ( w < MIN_ITEM_WIDTH ) w = MIN_ITEM_WIDTH; d->mItemWidth = w; setLayoutDirty( true ); #ifndef KAB_EMBEDDED updateContents(); #else //KAB_EMBEDDED //US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() ); qDebug("CardView::setItemWidth has to be verified"); updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); #endif //KAB_EMBEDDED } void CardView::setHeaderFont( const QFont &fnt ) { d->mHeaderFont = fnt; delete d->mBFm; d->mBFm = new QFontMetrics( fnt ); } QFont CardView::headerFont() const { return d->mHeaderFont; } void CardView::setFont( const QFont &fnt ) { QScrollView::setFont( fnt ); delete d->mFm; d->mFm = new QFontMetrics( fnt ); } int CardView::separatorWidth() { return d->mSepWidth; } void CardView::setSeparatorWidth( int width ) { d->mSepWidth = width; setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... } int CardView::maxFieldLines() const { return d->mMaxFieldLines; } void CardView::setMaxFieldLines( int howmany ) { d->mMaxFieldLines = howmany ? howmany : INT_MAX; // FIXME update, forcing the items to recalc height!! } + +void CardView::keyReleaseEvent ( QKeyEvent * e ) +{ + if ( mFlagBlockKeyPressed ) + return; + if ( !e->isAutoRepeat() ) { + mFlagBlockKeyPressed = true; + qApp->processEvents(); + mFlagBlockKeyPressed = false; + mFlagKeyPressed = false; + } + QScrollView::keyReleaseEvent ( e ); +} + + + + + //END Cardview #ifndef KAB_EMBEDDED #include "cardview.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h index 37dddb6..2ea3771 100644 --- a/kaddressbook/views/cardview.h +++ b/kaddressbook/views/cardview.h @@ -313,161 +313,164 @@ class CardView : public QScrollView /** @return the advisory internal margin in items. Setting a value above 1 means * a space between the item contents and the focus recttangle drawn around * the current item. The default value is 0. * The value should be used by CardViewItem and derived classes. * Note that this should not be greater than half of the minimal item width, * which is 80. It is currently not checked, so setting a value greater than 40 * will probably mean a crash in the items painting routine. * @private Note: I looked for a value in QStyle::PixelMetric to use, but I could * not see a usefull one. One may turn up in a future version of Qt. */ uint itemMargin(); /** Sets the internal item margin. @see itemMargin(). */ void setItemMargin( uint margin ); /** @return the item spacing. * The item spacing is the space (in pixels) between each item in a * column, between the items and column separators if drawn, and between * the items and the borders of the widget. The default value is set to * 10. * @private Note: There is no usefull QStyle::PixelMetric to use for this atm. * An option would be using KDialog::spacingHint(). */ uint itemSpacing(); /** Sets the item spacing. * @see itemSpacing() */ void setItemSpacing( uint spacing ); /** @return the width made available to the card items. */ int itemWidth() const; /** Sets the width made available to card items. */ void setItemWidth( int width ); /** Sets the header font */ void setHeaderFont( const QFont &fnt ); /** @return the header font */ QFont headerFont() const; /** @reimp */ void setFont( const QFont &fnt ); /** Sets the column separator width */ void setSeparatorWidth( int width ); /** @return the column separator width */ int separatorWidth(); /** Sets the maximum number of lines to display pr field. If set to 0 (the default) all lines will be displayed. */ void setMaxFieldLines( int howmany ); /** @return the maximum number of lines pr field */ int maxFieldLines() const; signals: /** Emitted whenever the selection changes. This means a user highlighted * a new item or unhighlighted a currently selected item. */ void selectionChanged(); /** Same as above method, only it carries the item that was selected. This * method will only be emitted in single select mode, since it defineds * which item was selected. */ void selectionChanged(CardViewItem *); /** This method is emitted whenever an item is clicked. */ void clicked(CardViewItem *); /** Emitted whenever the user 'executes' an item. This is dependant on * the KDE global config. This could be a single click or a doubleclick. * Also emitted when the return key is pressed on an item. */ void executed(CardViewItem *); /** Emitted whenever the user double clicks on an item. */ void doubleClicked(CardViewItem *); /** Emitted when the current item changes */ void currentChanged( CardViewItem * ); /** Emitted when the return key is pressed in an item. */ void returnPressed( CardViewItem * ); protected: + bool mFlagKeyPressed; + bool mFlagBlockKeyPressed; + virtual void keyPressEvent ( QKeyEvent * ); + virtual void keyReleaseEvent ( QKeyEvent * ); /** Determines which cards intersect that region and tells them to paint * themselves. */ void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); /** Sets the layout to dirty and repaints. */ void resizeEvent(QResizeEvent *e); /** Changes the direction the canvas scolls. */ void contentsWheelEvent(QWheelEvent *e); /** Sets the layout to dirty and calls for a repaint. */ void setLayoutDirty(bool dirty); /** Does the math based on the bounding rect of the cards to properly * lay the cards out on the screen. This is only done if the layout is * marked as dirty. */ void calcLayout(); // virtual void mousePressEvent(QMouseEvent *e); // virtual void mouseReleaseEvent(QMouseEvent *e); // virtual void mouseMoveEvent(QMouseEvent *e); virtual void contentsMousePressEvent(QMouseEvent *e); virtual void contentsMouseMoveEvent(QMouseEvent *e); virtual void contentsMouseReleaseEvent(QMouseEvent *e); virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); virtual void enterEvent( QEvent * ); virtual void leaveEvent( QEvent * ); virtual void focusInEvent( QFocusEvent * ); virtual void focusOutEvent( QFocusEvent * ); - virtual void keyPressEvent( QKeyEvent * ); /** Overload this method to be told when a drag should be started. * In most cases you will want to start a drag event with the currently * selected item. */ virtual void startDrag(); private slots: /** Called by a timer to display a label with truncated text. * Pop up a label, if there is a field with obscured text or * label at the cursor position. */ void tryShowFullText(); private: /** draws and erases the rubber bands while columns are resized. * @p pos is the horizontal position inside the viewport to use as * the anchor. * If pos is 0, only erase is done. */ void drawRubberBands( int pos ); CardViewPrivate *d; }; #endif diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index e75810e..09d9c03 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp @@ -1,127 +1,128 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qheader.h> #include <qiconset.h> #include <qimage.h> #include <qdragobject.h> #include <qcombobox.h> #include <qpainter.h> #include <qbrush.h> #include <qevent.h> +#include <qapplication.h> #include <klocale.h> #include <kglobalsettings.h> #include <kiconloader.h> #include <kdebug.h> #include <kconfig.h> #include <kapplication.h> #include <kurl.h> #include "kaddressbooktableview.h" #include "contactlistview.h" ///////////////////////////////// // DynamicTip Methods DynamicTip::DynamicTip( ContactListView *parent) : QToolTip( parent ) { } void DynamicTip::maybeTip( const QPoint &pos ) { static bool ishidden = true; if (!parentWidget()->inherits( "ContactListView" )) return; ContactListView *plv = (ContactListView*)parentWidget(); if (!plv->tooltips()) return; QPoint posVp = plv->viewport()->pos(); QListViewItem *lvi = plv->itemAt( pos - posVp ); if (!lvi) return; #ifndef KAB_EMBEDDED ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); #else //KAB_EMBEDDED ContactListViewItem *plvi = (ContactListViewItem*)(lvi); #endif //KAB_EMBEDDED if (!plvi) return; if (ishidden) { QString s; QRect r = plv->itemRect( lvi ); r.moveBy( posVp.x(), posVp.y() ); //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() // << "," << r.height() << endl; KABC::Addressee a = plvi->addressee(); if (a.isEmpty()) return; s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) .arg(a.formattedName()); s += '\n'; s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) .arg(a.organization()); QString notes = a.note().stripWhiteSpace(); if ( !notes.isEmpty() ) { notes += '\n'; s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); QFontMetrics fm( font() ); // Begin word wrap code based on QMultiLineEdit code int i = 0; bool doBreak = false; int linew = 0; int lastSpace = -1; int a = 0; int lastw = 0; while ( i < int(notes.length()) ) { doBreak = FALSE; if ( notes[i] != '\n' ) linew += fm.width( notes[i] ); if ( lastSpace >= a && notes[i] != '\n' ) if (linew >= parentWidget()->width()) { doBreak = TRUE; if ( lastSpace > a ) { i = lastSpace; linew = lastw; } else i = QMAX( a, i-1 ); } if ( notes[i] == '\n' || doBreak ) { @@ -155,246 +156,274 @@ void DynamicTip::maybeTip( const QPoint &pos ) /////////////////////////// // ContactListViewItem Methods ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, ContactListView *parent, KABC::AddressBook *doc, const KABC::Field::List &fields ) : KListViewItem(parent), mAddressee(a), mFields( fields ), parentListView( parent ), mDocument(doc) { refresh(); } QString ContactListViewItem::key(int column, bool ascending) const { #ifndef DESKTOP_VERSION int lan = KGlobal::locale()->language(); //qDebug("language %d ", lan); if ( lan == 1 ) { //GERMAN QString ret = QListViewItem::key(column, ascending).lower().utf8(); int start = -1; while ( (start = ret.find( 'ä', start+1)) > 0 ) { ret.at(start-1) = 'a'; } start = -1; while ( (start = ret.find( 'ö', start+1)) > 0 ) { ret.at(start-1) = 'o'; } start = -1; while ( (start = ret.find( 'ü', start+1)) > 0 ) { ret.at(start-1) = 'o'; } start = -1; while ( (start = ret.find( 'ß', start+1)) > 0 ) { ret.at(start-1) = 's'; } //qDebug("conv string %s ", ret.latin1()); return ret; } else #endif return QListViewItem::key(column, ascending).lower(); } void ContactListViewItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align) { KListViewItem::paintCell(p, cg, column, width, align); if ( !p ) return; if (parentListView->singleLine()) { p->setPen( parentListView->alternateColor() ); p->drawLine( 0, height() - 1, width, height() - 1 ); } } ContactListView *ContactListViewItem::parent() { return parentListView; } void ContactListViewItem::refresh() { // Update our addressee, since it may have changed else were mAddressee = mDocument->findByUid(mAddressee.uid()); if (mAddressee.isEmpty()) return; int i = 0; KABC::Field::List::ConstIterator it; for( it = mFields.begin(); it != mFields.end(); ++it ) { setText( i++, (*it)->value( mAddressee ) ); } } /////////////////////////////// // ContactListView ContactListView::ContactListView(KAddressBookTableView *view, KABC::AddressBook* /* doc */, QWidget *parent, const char *name ) : KListView( parent, name ), pabWidget( view ), oldColumn( 0 ) { + mFlagBlockKeyPressed = false; + mFlagKeyPressed = false; mABackground = true; mSingleLine = false; mToolTips = true; #ifndef KAB_EMBEDDED mAlternateColor = KGlobalSettings::alternateBackgroundColor(); #else //KAB_EMBEDDED mAlternateColor = QColor(240, 240, 240); #endif //KAB_EMBEDDED setAlternateBackgroundEnabled(mABackground); setAcceptDrops( true ); viewport()->setAcceptDrops( true ); setAllColumnsShowFocus( true ); setShowSortIndicator(true); setSelectionModeExt( KListView::Extended ); setDropVisualizer(false); // setFrameStyle(QFrame::NoFrame); //setLineWidth ( 0 ); //setMidLineWidth ( 0 ); //setMargin ( 0 ); #ifndef KAB_EMBEDDED connect(this, SIGNAL(dropped(QDropEvent*)), this, SLOT(itemDropped(QDropEvent*))); #endif //KAB_EMBEDDED new DynamicTip( this ); } void ContactListView::printMe() { #ifdef DESKTOP_VERSION QPrinter printer; if (!printer.setup() ) return; QPainter p; p.begin ( &printer ); QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); float dx, dy; int wid = (m.width() * 9)/10; dx = (float) wid/(float)contentsWidth (); dy = (float)(m.height()) / (float)contentsHeight (); float scale; // scale to fit the width or height of the paper if ( dx < dy ) scale = dx; else scale = dy; p.translate( m.width()/10,0 ); p.scale( scale, scale ); qDebug("scale %f ", scale); drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); p.end(); qDebug("Why does it not print??? "); #endif } void ContactListView::setAlternateColor(const QColor &m_AlternateColor) { mAlternateColor = m_AlternateColor; } void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) { QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); // Get the brush, which will have the background pixmap if there is one. if (b.pixmap()) { p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), *(b.pixmap()), rect.left() + contentsX(), rect.top() + contentsY() ); } else { // Do a normal paint KListView::paintEmptyArea(p, rect); } } void ContactListView::contentsMousePressEvent(QMouseEvent* e) { presspos = e->pos(); KListView::contentsMousePressEvent(e); } // To initiate a drag operation void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) { if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { emit startAddresseeDrag(); } else KListView::contentsMouseMoveEvent( e ); } bool ContactListView::acceptDrag(QDropEvent *e) const { #ifndef KAB_EMBEDDED return QTextDrag::canDecode(e); #else //KAB_EMBEDDED qDebug("ContactListView::acceptDrag has to be fixed"); return false; #endif //KAB_EMBEDDED } void ContactListView::itemDropped(QDropEvent *e) { contentsDropEvent(e); } void ContactListView::contentsDropEvent( QDropEvent *e ) { emit addresseeDropped(e); } void ContactListView::setAlternateBackgroundEnabled(bool enabled) { mABackground = enabled; if (mABackground) { setAlternateBackground(mAlternateColor); } else { setAlternateBackground(QColor()); } } void ContactListView::setBackgroundPixmap(const QString &filename) { if (filename.isEmpty()) { unsetPalette(); } else { qDebug("ContactListView::setBackgroundPixmap has to be verified"); //US setPaletteBackgroundPixmap(QPixmap(filename)); KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); } } + +void ContactListView::keyPressEvent ( QKeyEvent * e ) +{ + if ( mFlagBlockKeyPressed ) + return; + qApp->processEvents(); + if ( e->isAutoRepeat() && !mFlagKeyPressed ) { + e->accept(); + return; + } + if (! e->isAutoRepeat() ) + mFlagKeyPressed = true; + KListView::keyPressEvent ( e ); +} +void ContactListView::keyReleaseEvent ( QKeyEvent * e ) +{ + if ( mFlagBlockKeyPressed ) + return; + if ( !e->isAutoRepeat() ) { + mFlagBlockKeyPressed = true; + qApp->processEvents(); + mFlagBlockKeyPressed = false; + mFlagKeyPressed = false; + } + KListView::keyReleaseEvent ( e ); +} #ifndef KAB_EMBEDDED #include "contactlistview.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h index 9d1a672..46477e1 100644 --- a/kaddressbook/views/contactlistview.h +++ b/kaddressbook/views/contactlistview.h @@ -1,130 +1,134 @@ #ifndef CONTACTLISTVIEW_H #define CONTACTLISTVIEW_H #include <qcolor.h> #include <qpixmap.h> #include <qtooltip.h> #include <qstring.h> #include <klistview.h> #include <kabc/field.h> #include <kabc/addressee.h> #include <kabc/addressbook.h> class QDropEvent; class KAddressBookTableView; class ContactListView; /** The whole tooltip design needs a lot of work. Currently it is * hacked together to function. */ class DynamicTip : public QToolTip { public: DynamicTip( ContactListView * parent ); protected: void maybeTip( const QPoint & ); private: }; class ContactListViewItem : public KListViewItem { public: ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, KABC::AddressBook *doc, const KABC::Field::List &fields ); const KABC::Addressee &addressee() const { return mAddressee; } virtual void refresh(); virtual ContactListView* parent(); virtual QString key ( int, bool ) const; /** Adds the border around the cell if the user wants it. * This is how the single line config option is implemented. */ virtual void paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align ); private: KABC::Addressee mAddressee; KABC::Field::List mFields; ContactListView *parentListView; KABC::AddressBook *mDocument; }; ///////////////////////////////////////////// // ContactListView class ContactListView : public KListView { Q_OBJECT public: ContactListView(KAddressBookTableView *view, KABC::AddressBook *doc, QWidget *parent, const char *name = 0L ); virtual ~ContactListView() {} //void resort(); /** Returns true if tooltips should be displayed, false otherwise */ bool tooltips() const { return mToolTips; } void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } bool alternateBackground() const { return mABackground; } void setAlternateBackgroundEnabled(bool enabled); bool singleLine() const { return mSingleLine; } void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } const QColor &alternateColor() const { return mAlternateColor; } void setAlternateColor(const QColor &mAlternateColor); /** Sets the background pixmap to <i>filename</i>. If the * QString is empty (QString::isEmpty()), then the background * pixmap will be disabled. */ void setBackgroundPixmap(const QString &filename); protected: + bool mFlagKeyPressed; + bool mFlagBlockKeyPressed; + virtual void keyPressEvent ( QKeyEvent * ); + virtual void keyReleaseEvent ( QKeyEvent * ); /** Paints the background pixmap in the empty area. This method is needed * since Qt::FixedPixmap will not scroll with the list view. */ virtual void paintEmptyArea( QPainter * p, const QRect & rect ); virtual void contentsMousePressEvent(QMouseEvent*); void contentsMouseMoveEvent( QMouseEvent *e ); void contentsDropEvent( QDropEvent *e ); virtual bool acceptDrag(QDropEvent *e) const; protected slots: void itemDropped(QDropEvent *e); public slots: void printMe(); signals: void startAddresseeDrag(); void addresseeDropped(QDropEvent *); private: KAddressBookTableView *pabWidget; int oldColumn; int column; bool ascending; bool mABackground; bool mSingleLine; bool mToolTips; QColor mAlternateColor; QPoint presspos; }; #endif diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index cce68b9..9c35fd6 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -115,198 +115,202 @@ AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) } AddresseeCardView::~AddresseeCardView() { } void AddresseeCardView::printMe() { #ifdef DESKTOP_VERSION QPrinter printer; if (!printer.setup() ) return; QPainter p; p.begin ( &printer ); QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); float dx, dy; int wid = (m.width() * 9)/10; dx = (float) wid/(float)contentsWidth (); dy = (float)(m.height()) / (float)contentsHeight (); float scale; // scale to fit the width or height of the paper if ( dx < dy ) scale = dx; else scale = dy; p.translate( m.width()/10,0 ); p.scale( scale, scale ); drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); p.end(); repaint(); #endif } void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) { #ifndef KAB_EMBEDDED if (QTextDrag::canDecode(e)) e->accept(); #else //KAB_EMBEDDED qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); #endif //KAB_EMBEDDED } void AddresseeCardView::dropEvent(QDropEvent *e) { emit addresseeDropped(e); } void AddresseeCardView::startDrag() { emit startAddresseeDrag(); } /////////////////////////////// // KAddressBookCardView KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : KAddressBookView( ab, parent, name ) { mShowEmptyFields = false; // Init the GUI QVBoxLayout *layout = new QVBoxLayout(viewWidget()); mCardView = new AddresseeCardView(viewWidget(), "mCardView"); mCardView->setSelectionMode(CardView::Extended); layout->addWidget(mCardView); // Connect up the signals connect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); connect(mCardView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); connect(mCardView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); connect(this, SIGNAL(printView()), mCardView , SLOT(printMe())); } KAddressBookCardView::~KAddressBookCardView() { } void KAddressBookCardView::setFocusAV() { if ( mCardView ) mCardView->setFocus(); } void KAddressBookCardView::scrollUP() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); QApplication::postEvent( mCardView, ev ); + ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); + QApplication::postEvent( mCardView, ev ); } void KAddressBookCardView::scrollDOWN() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); QApplication::postEvent( mCardView, ev ); + ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); + QApplication::postEvent( mCardView, ev ); } void KAddressBookCardView::readConfig(KConfig *config) { KAddressBookView::readConfig(config); // costum colors? if ( config->readBoolEntry( "EnableCustomColors", false ) ) { QPalette p( mCardView->palette() ); QColor c = p.color(QPalette::Normal, QColorGroup::Base ); p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Text ); p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Button ); p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::ButtonText ); p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Highlight ); p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); mCardView->viewport()->setPalette( p ); } else { // needed if turned off during a session. mCardView->viewport()->setPalette( mCardView->palette() ); } //custom fonts? QFont f( font() ); if ( config->readBoolEntry( "EnableCustomFonts", false ) ) { mCardView->setFont( config->readFontEntry( "TextFont", &f) ); f.setBold( true ); mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); } else { mCardView->setFont( f ); f.setBold( true ); mCardView->setHeaderFont( f ); } mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", true)); mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); mCardView->setShowEmptyFields( mShowEmptyFields ); mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); #if 0 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven disconnect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); if (KABPrefs::instance()->mHonorSingleClick) connect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); else connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); #endif connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); } void KAddressBookCardView::writeConfig( KConfig *config ) { config->writeEntry( "ItemWidth", mCardView->itemWidth() ); KAddressBookView::writeConfig( config ); } void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) { mCardView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } QRegExp re = getRegExp( s ); if (!re.isValid()) return; mCardView->viewport()->setUpdatesEnabled( false ); KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index f4b008c..e322473 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -1,164 +1,168 @@ // $Id$ #include <qvbox.h> #include <qlistbox.h> #include <qwidget.h> #include <qfile.h> #include <qimage.h> #include <qcombobox.h> #include <qapplication.h> #include <qdragobject.h> #include <qevent.h> #include <qurl.h> #include <qpixmap.h> #include <kabc/addressbook.h> #include <kapplication.h> #include <kconfig.h> #include <kcolorbutton.h> #include <kdebug.h> #include <kglobal.h> #include <kiconloader.h> #include <klineedit.h> #include <klocale.h> #include <kmessagebox.h> #include <kurl.h> #include <kurlrequester.h> //US#include "configuretableviewdialog.h" #include "contactlistview.h" #include "kabprefs.h" #include "undocmds.h" #include "viewmanager.h" #include <qlayout.h> #include <qheader.h> #include <qregexp.h> #include "kaddressbooktableview.h" KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : KAddressBookView( ab, parent, name ) { mainLayout = new QVBoxLayout( viewWidget(), 2 ); // The list view will be created when the config is read. mListView = 0; } KAddressBookTableView::~KAddressBookTableView() { } void KAddressBookTableView::setFocusAV() { if ( mListView ) mListView->setFocus(); } void KAddressBookTableView::scrollUP() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); QApplication::postEvent( mListView, ev ); + ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); + QApplication::postEvent( mListView, ev ); } void KAddressBookTableView::scrollDOWN() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); QApplication::postEvent( mListView, ev ); + ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); + QApplication::postEvent( mListView, ev ); } void KAddressBookTableView::reconstructListView() { if (mListView) { disconnect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); disconnect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); delete mListView; } mListView = new ContactListView( this, addressBook(), viewWidget() ); connect(this, SIGNAL(printView()), mListView , SLOT(printMe())); //US set singleClick manually, because it is no global configparameter in embedded space mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); // Add the columns KABC::Field::List fieldList = fields(); KABC::Field::List::ConstIterator it; int c = 0; for( it = fieldList.begin(); it != fieldList.end(); ++it ) { mListView->addColumn( (*it)->label() ); mListView->setColumnWidthMode(c++, QListView::Manual); //US // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); } connect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); if (KABPrefs::instance()->mHonorSingleClick) { // qDebug("KAddressBookTableView::reconstructListView single"); connect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); } else { // qDebug("KAddressBookTableView::reconstructListView double"); connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); } connect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); connect(mListView, SIGNAL(signalDelete()), this, SLOT(addresseeDeleted())); //US performceimprovement. Refresh is done from the outside //US refresh(); mListView->setSorting( 0, true ); mainLayout->addWidget( mListView ); mainLayout->activate(); mListView->show(); } void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) { mListView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } QRegExp re = getRegExp( s ); if (!re.isValid()) return; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; #if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) == 0) #else if (re.match(field->value( *it ).lower()) != -1) #endif ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); } } else { KABC::Field::List fieldList = allFields(); |