summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/cardview.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/views/cardview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/cardview.cpp114
1 files changed, 61 insertions, 53 deletions
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index b6e053f..1a29f41 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -25,24 +25,32 @@
#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>
+//Added by qt3to4:
+#include <QKeyEvent>
+#include <Q3PtrList>
+#include <QResizeEvent>
+#include <QFocusEvent>
+#include <QMouseEvent>
+#include <QEvent>
+#include <QWheelEvent>
#include "kabprefs.h"
#include <kdebug.h>
#include <kglobalsettings.h>
//END includes
#define MIN_ITEM_WIDTH 80
//BEGIN Helpers
//////////////////////////////////////
// CardViewTip
class CardViewTip : public QLabel {
@@ -62,29 +70,29 @@ class CardViewTip : public QLabel {
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>
+class CardViewItemList : public Q3PtrList<CardViewItem>
{
protected:
- virtual int compareItems(QPtrCollection::Item item1,
- QPtrCollection::Item item2)
+ virtual int compareItems(Q3PtrCollection::Item item1,
+ Q3PtrCollection::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;
@@ -152,25 +160,25 @@ class CardViewPrivate
mItemMargin( 0 ),
mItemSpacing( 10 ),
mItemWidth( 200 ),
mMaxFieldLines( INT_MAX ),
mCurrentItem( 0L ),
mLastClickPos( QPoint(0, 0) ),
mResizeAnchor(0),
mRubberBandAnchor( 0 ),
mCompText( QString::null )
{};
CardViewItemList mItemList;
- QPtrList<CardViewSeparator> mSeparatorList;
+ Q3PtrList<CardViewSeparator> mSeparatorList;
QFontMetrics *mFm;
QFontMetrics *mBFm; // bold font
QFont mHeaderFont; // custom header font
CardView::SelectionMode mSelectionMode;
bool mDrawCardBorder;
bool mDrawFieldLabels;
bool mDrawSeparators;
int mSepWidth;
bool mShowEmptyFields;
bool mLayoutDirty;
bool mLastClickOnItem;
uint mItemMargin; // internal margin in items
@@ -199,25 +207,25 @@ class CardViewPrivate
};
class CardViewItemPrivate
{
public:
CardViewItemPrivate() :
mSelected( false ),
x( 0 ),
y( 0 ){};
QString mCaption;
- QPtrList< CardViewItem::Field > mFieldList;
+ Q3PtrList< CardViewItem::Field > mFieldList;
bool mSelected;
int x; // horizontal position, set by the view
int y; // vertical position, set by the view
int maxLabelWidth; // the width of the widest label, according to the view font.
int hcache; // height cache
};
//END Private Data
//BEGIN CardViewItem
CardViewItem::CardViewItem(CardView *parent, QString caption)
: d(new CardViewItemPrivate()), mView(parent)
@@ -304,25 +312,25 @@ void CardViewItem::paintCard(QPainter *p, QColorGroup &cg)
p->save();
QFont bFont = mView->headerFont();
//bFont.setBold(true);
p->setFont(bFont);
if (isSelected())
p->setPen(cg.highlightedText());
else
p->setPen(cg.buttonText());
p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm));
p->restore();
// Go through the fields and draw them
- QPtrListIterator< CardViewItem::Field > iter(d->mFieldList);
+ Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
QString label, value;
int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders)
p->setPen(cg.text());
int fh = fm.height();
int cln( 0 );
QString tmp;
int maxLines = mView->maxFieldLines();
for (iter.toFirst(); iter.current(); ++iter)
{
value = (*iter)->second;
if ( value.isEmpty() && ! mView->d->mShowEmptyFields )
@@ -399,30 +407,30 @@ int CardViewItem::height( bool allowCache ) const
int baseHeight = 8 + ( 2 * mView->itemMargin() );
// size of font for each field
// 2 pad for each field
// anders: if the view does not show empty fields, check for value
bool sef = mView->showEmptyFields();
int fh = mView->d->mFm->height();//lineSpacing(); // font height
//int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property
int fieldHeight = 0;
int lines;
int maxLines( mView->maxFieldLines() );
- QPtrListIterator< CardViewItem::Field > iter(d->mFieldList);
+ Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
for (iter.toFirst(); iter.current(); ++iter)
{
if ( !sef && (*iter)->second.isEmpty() )
continue;
- lines = QMIN( (*iter)->second.contains('\n') + 1, maxLines );
+ lines = QMIN( (*iter)->second.count('\n') + 1, maxLines );
fieldHeight += ( lines * fh ) + 2;//sp;
}
// height of caption font (bold)
fieldHeight += mView->d->mBFm->height();
d->hcache = baseHeight + fieldHeight;
return d->hcache;
}
bool CardViewItem::isSelected() const
{
return d->mSelected;
@@ -441,25 +449,25 @@ void CardViewItem::insertField(const QString &label, const QString &value)
if (mView)
{
mView->setLayoutDirty(true);
d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth );
}
}
void CardViewItem::removeField(const QString &label)
{
CardViewItem::Field *f;
- QPtrListIterator< CardViewItem::Field > iter(d->mFieldList);
+ Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
for (iter.toFirst(); iter.current(); ++iter)
{
f = *iter;
if (f->first == label)
break;
}
if (*iter)
d->mFieldList.remove(*iter);
d->hcache = 0;
if (mView)
@@ -514,25 +522,25 @@ void CardViewItem::repaintCard()
if (mView)
mView->repaintItem(this);
}
void CardViewItem::setCaption(const QString &caption)
{
d->mCaption = caption;
repaintCard();
}
QString CardViewItem::fieldValue(const QString &label)
{
- QPtrListIterator< CardViewItem::Field > iter(d->mFieldList);
+ Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
for (iter.toFirst(); iter.current(); ++iter)
if ((*iter)->first == label)
return (*iter)->second;
return QString();
}
void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip )
{
bool trimmed( false );
QString s;
@@ -560,42 +568,42 @@ void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip )
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;
+ y += ( QMIN(_f->second.count('\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);
+ trimmed = r.width() > mw || r.height()/fh > QMIN(s.count('\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);
@@ -617,61 +625,61 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
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;
+ ypos += ( QMIN( f->second.count('\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),
+ : Q3ScrollView(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);
+ viewport()->setFocusPolicy(Qt::WheelFocus);
+ viewport()->setBackgroundMode(Qt::PaletteBase);
connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) );
//US setBackgroundMode(PaletteBackground, PaletteBase);
- setBackgroundMode(PaletteBackground);
+ setBackgroundMode(Qt::PaletteBackground);
// no reason for a vertical scrollbar
setVScrollBarMode(AlwaysOff);
}
CardView::~CardView()
{
delete d->mFm;
delete d->mBFm;
delete d;
d = 0;
}
@@ -730,25 +738,25 @@ void CardView::setCurrentItem( CardViewItem *item )
if ( it )
it->repaintCard();
item->repaintCard();
}
if ( ! d->mOnSeparator )
ensureItemVisible( item );
emit currentChanged( item );
}
CardViewItem *CardView::itemAt(const QPoint &viewPos)
{
CardViewItem *item = 0;
- QPtrListIterator<CardViewItem> iter(d->mItemList);
+ Q3PtrListIterator<CardViewItem> iter(d->mItemList);
bool found = false;
for (iter.toFirst(); iter.current() && !found; ++iter)
{
item = *iter;
//if (item->d->mRect.contains(viewPos))
if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos))
found = true;
}
if (found)
return item;
@@ -778,25 +786,25 @@ void CardView::setSelectionMode(CardView::SelectionMode mode)
selectAll(false);
d->mSelectionMode = mode;
}
CardView::SelectionMode CardView::selectionMode() const
{
return d->mSelectionMode;
}
void CardView::selectAll(bool state)
{
- QPtrListIterator<CardViewItem> iter(d->mItemList);
+ Q3PtrListIterator<CardViewItem> iter(d->mItemList);
if (!state)
{
for (iter.toFirst(); iter.current(); ++iter)
{
if ((*iter)->isSelected())
{
(*iter)->setSelected(false);
(*iter)->repaintCard();
}
}
//emit selectionChanged(); // WARNING FIXME
emit selectionChanged(0);
@@ -869,25 +877,25 @@ void CardView::setSelected(CardViewItem *item, bool selected)
emit selectionChanged();
}
}
bool CardView::isSelected(CardViewItem *item) const
{
return (item && item->isSelected());
}
CardViewItem *CardView::selectedItem() const
{
// find the first selected item
- QPtrListIterator<CardViewItem> iter(d->mItemList);
+ Q3PtrListIterator<CardViewItem> iter(d->mItemList);
for (iter.toFirst(); iter.current(); ++iter)
{
if ((*iter)->isSelected())
return *iter;
}
return 0;
}
CardViewItem *CardView::firstItem() const
{
return d->mItemList.first();
@@ -946,83 +954,83 @@ void CardView::drawContents(QPainter *p, int clipx, int clipy,
QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale
int cX, cY;
contentsToViewport ( clipx, clipy, cX, cY );
QRect clipRect(clipx, clipy, clipw, cliph);
QRect cardRect;
QRect sepRect;
CardViewItem *item;
CardViewSeparator *sep;
// make sure the viewport is a pure background
viewport()->erase( QRect ( cX, cY , clipw, cliph ) );
// Now tell the cards to draw, if they are in the clip region
- QPtrListIterator<CardViewItem> iter(d->mItemList);
+ Q3PtrListIterator<CardViewItem> iter(d->mItemList);
for (iter.toFirst(); iter.current(); ++iter)
{
item = *iter;
cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() );
if (clipRect.intersects(cardRect) || clipRect.contains(cardRect))
{
//kdDebug() << "\trepainting card at: " << cardRect.x() << ", "
// << cardRect.y() << endl;
// Tell the card to paint
p->save();
p->translate(cardRect.x(), cardRect.y());
item->paintCard(p, cg);
p->restore();
}
}
// Followed by the separators if they are in the clip region
- QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
+ Q3PtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
for (sepIter.toFirst(); sepIter.current(); ++sepIter)
{
sep = *sepIter;
sepRect = sep->mRect;
if (clipRect.intersects(sepRect) || clipRect.contains(sepRect))
{
p->save();
p->translate(sepRect.x(), sepRect.y());
sep->paintSeparator(p, cg);
p->restore();
}
}
}
void CardView::resizeEvent(QResizeEvent *e)
{
- QScrollView::resizeEvent(e);
+ Q3ScrollView::resizeEvent(e);
setLayoutDirty(true);
}
void CardView::calcLayout()
{
//kdDebug() << "CardView::calcLayout:" << endl;
// Start in the upper left corner and layout all the
// cars using their height and width
int maxWidth = 0;
int maxHeight = 0;
int xPos = 0;
int yPos = 0;
int cardSpacing = d->mItemSpacing;
// delete the old separators
d->mSeparatorList.clear();
- QPtrListIterator<CardViewItem> iter(d->mItemList);
+ Q3PtrListIterator<CardViewItem> iter(d->mItemList);
CardViewItem *item = 0;
CardViewSeparator *sep = 0;
xPos += cardSpacing;
for (iter.toFirst(); iter.current(); ++iter)
{
item = *iter;
yPos += cardSpacing;
if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height())
{
@@ -1047,25 +1055,25 @@ void CardView::calcLayout()
item->d->x = xPos;
item->d->y = yPos;
yPos += item->height();
maxWidth = QMAX(maxWidth, d->mItemWidth);
}
xPos += maxWidth;
resizeContents( xPos + cardSpacing, maxHeight );
// Update the height of all the separators now that we know the
// max height of a column
- QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
+ Q3PtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
for (sepIter.toFirst(); sepIter.current(); ++sepIter)
{
(*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin);
}
d->mLayoutDirty = false;
}
CardViewItem *CardView::itemAfter(CardViewItem *item)
{
/*int pos = */d->mItemList.findRef(item);
return d->mItemList.next();//at(pos+1);
@@ -1092,25 +1100,25 @@ uint CardView::itemSpacing()
void CardView::setItemSpacing( uint spacing )
{
if ( spacing == d->mItemSpacing )
return;
d->mItemSpacing = spacing;
setLayoutDirty( true );
}
void CardView::contentsMousePressEvent(QMouseEvent *e)
{
- QScrollView::contentsMousePressEvent(e);
+ Q3ScrollView::contentsMousePressEvent(e);
QPoint pos = e->pos();
d->mLastClickPos = pos;
CardViewItem *item = itemAt(pos);
if (item == 0)
{
d->mLastClickOnItem = false;
if ( d->mOnSeparator)
{
d->mResizeAnchor = e->x()+contentsX();
@@ -1162,25 +1170,25 @@ void CardView::contentsMousePressEvent(QMouseEvent *e)
emit selectionChanged();
}
else if (d->mSelectionMode == CardView::Extended)
{
if ((e->button() & Qt::LeftButton) &&
(e->state() & Qt::ShiftButton))
{
if ( item == other ) return;
bool s = ! item->isSelected();
- if ( s && ! (e->state() & ControlButton) )
+ if ( s && ! (e->state() & Qt::ControlButton) )
{
bool b = signalsBlocked();
blockSignals(true);
selectAll(false);
blockSignals(b);
}
int from, to, a, b;
a = d->mItemList.findRef( item );
b = d->mItemList.findRef( other );
from = a < b ? a : b;
to = a > b ? a : b;
@@ -1210,25 +1218,25 @@ void CardView::contentsMousePressEvent(QMouseEvent *e)
blockSignals(b);
item->setSelected(true);
item->repaintCard();
emit selectionChanged();
}
}
}
void CardView::contentsMouseReleaseEvent(QMouseEvent *e)
{
- QScrollView::contentsMouseReleaseEvent(e);
+ Q3ScrollView::contentsMouseReleaseEvent(e);
if ( d->mResizeAnchor )
{
// finish the resizing:
unsetCursor();
// hide rubber bands
int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span);
drawRubberBands( 0 );
// we should move to reflect the new position if we are scrolled.
if ( contentsX() )
{
int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() );
@@ -1248,25 +1256,25 @@ void CardView::contentsMouseReleaseEvent(QMouseEvent *e)
// Get the item at this position
CardViewItem *item = itemAt(e->pos());
if (item && KABPrefs::instance()->mHonorSingleClick)
{
emit executed(item);
}
}
void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e)
{
- QScrollView::contentsMouseDoubleClickEvent(e);
+ Q3ScrollView::contentsMouseDoubleClickEvent(e);
CardViewItem *item = itemAt(e->pos());
if (item)
{
d->mCurrentItem = item;
}
if (item && !KABPrefs::instance()->mHonorSingleClick)
{
emit executed(item);
} else
@@ -1293,47 +1301,47 @@ void CardView::contentsMouseMoveEvent( QMouseEvent *e )
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?
+ setCursor( Qt::SplitVCursor ); // Why does this fail sometimes?
d->mOnSeparator = true;
}
else
{
- setCursor( ArrowCursor );
+ setCursor( Qt::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 );
+ setCursor( Qt::ArrowCursor );
}
}
void CardView::focusInEvent( QFocusEvent * )
{
if (!d->mCurrentItem && d->mItemList.count() )
{
setCurrentItem( d->mItemList.first() );
}
else if ( d->mCurrentItem )
{
d->mCurrentItem->repaintCard();
@@ -1359,145 +1367,145 @@ void CardView::keyPressEvent( QKeyEvent *e )
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:
+ case Qt::Key_Up:
if ( pos > 0 )
{
aItem = d->mItemList.at( pos - 1 );
setCurrentItem( aItem );
}
break;
- case Key_Down:
+ case Qt::Key_Down:
if ( pos < d->mItemList.count() - 1 )
{
aItem = d->mItemList.at( pos + 1 );
setCurrentItem( aItem );
}
break;
- case Key_Left:
+ case Qt::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:
+ case Qt::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:
+ case Qt::Key_Home:
aItem = d->mItemList.first();
setCurrentItem( aItem );
break;
- case Key_End:
+ case Qt::Key_End:
aItem = d->mItemList.last();
setCurrentItem( aItem );
break;
- case Key_Prior: // PageUp
+ case Qt::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
+ case Qt::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;
- case Key_Space:
+ case Qt::Key_Space:
setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() );
emit selectionChanged();
break;
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
{
emit returnPressed( d->mCurrentItem );
emit executed( d->mCurrentItem );
}
break;
default:
- if ( (e->state() & ControlButton) && e->key() == Key_A )
+ if ( (e->state() & Qt::ControlButton) && e->key() == Qt::Key_A )
{
// select all
selectAll( true );
break;
}
// if we have a string, do autosearch
else if ( ! e->text().isEmpty() && e->text()[0].isPrint() )
{
}
break;
}
// handle selection
if ( aItem )
{
if ( d->mSelectionMode == CardView::Extended )
{
- if ( (e->state() & ShiftButton) )
+ if ( (e->state() & Qt::ShiftButton) )
{
// shift button: toggle range
// if control button is pressed, leave all items
// and toggle selection current->old current
// otherwise, ??????
bool s = ! aItem->isSelected();
int from, to, a, b;
a = d->mItemList.findRef( aItem );
b = d->mItemList.findRef( old );
from = a < b ? a : b;
to = a > b ? a : b;
@@ -1510,25 +1518,25 @@ void CardView::keyPressEvent( QKeyEvent *e )
}
//kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl;
CardViewItem *item;
for ( ; from <= to; from++ )
{
item = d->mItemList.at( from );
item->setSelected( s );
repaintItem( item );
}
emit selectionChanged();
}
- else if ( (e->state() & ControlButton) )
+ else if ( (e->state() & Qt::ControlButton) )
{
// control button: do nothing
}
else
{
// no button: move selection to this item
bool b = signalsBlocked();
blockSignals(true);
selectAll(false);
blockSignals(b);
setSelected( aItem, true );
@@ -1629,27 +1637,27 @@ 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 );
+ p.setCompositionMode( QPainter::CompositionMode_Xor );
+ p.setPen( Qt::gray );
+ p.setBrush( Qt::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;
@@ -1690,25 +1698,25 @@ 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 );
+ Q3ScrollView::setFont( fnt );
delete d->mFm;
d->mFm = new QFontMetrics( fnt );
}
int CardView::separatorWidth()
{
return d->mSepWidth;
}
void CardView::setSeparatorWidth( int width )
{
d->mSepWidth = width;
@@ -1727,24 +1735,24 @@ void CardView::setMaxFieldLines( int howmany )
}
void CardView::keyReleaseEvent ( QKeyEvent * e )
{
if ( mFlagBlockKeyPressed )
return;
if ( !e->isAutoRepeat() ) {
mFlagBlockKeyPressed = true;
qApp->processEvents();
mFlagBlockKeyPressed = false;
mFlagKeyPressed = false;
}
- QScrollView::keyReleaseEvent ( e );
+ Q3ScrollView::keyReleaseEvent ( e );
}
//END Cardview
-#ifndef KAB_EMBEDDED
-#include "cardview.moc"
+#ifndef KAB_EMBEDDED_
+#include "moc_cardview.cpp"
#endif //KAB_EMBEDDED