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.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index da552c3..03df444 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -93,178 +93,178 @@ class CardViewItemList : public QPtrList<CardViewItem>
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;
QRect mRect;
};
//END Helpers
//BEGIN Private Data
class CardViewPrivate
{
public:
CardViewPrivate()
: mSelectionMode( CardView::Multi ),
mDrawCardBorder( true ),
mDrawFieldLabels( true ),
mDrawSeparators( true),
mSepWidth( 2 ),
mShowEmptyFields( false ),
mLayoutDirty( true ),
mLastClickOnItem( false ),
mItemMargin( 0 ),
mItemSpacing( 10 ),
mItemWidth( 200 ),
mMaxFieldLines( INT_MAX ),
mCurrentItem( 0L ),
mLastClickPos( QPoint(0, 0) ),
+ mResizeAnchor(0),
mRubberBandAnchor( 0 ),
- mCompText( QString::null ),
- mResizeAnchor(0)
+ mCompText( QString::null )
{};
CardViewItemList mItemList;
QPtrList<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
uint mItemSpacing; // spacing between items, column seperators and border
int mItemWidth; // width of all items
uint mMaxFieldLines; // Max lines to dispaly pr field
CardViewItem *mCurrentItem;
QPoint mLastClickPos;
QTimer *mTimer; // times out if mouse rests for more than 500 msecs
CardViewTip *mTip; // passed to the item under a resting cursor to display full text
bool mOnSeparator; // set/reset on mouse movement
// for resizing by dragging the separators
int mResizeAnchor; // uint, ulong? the mouse down separator left
int mRubberBandAnchor; // for erasing rubber bands
// data used for resizing.
// as they are beeded by each mouse move while resizing, we store them here,
// saving 8 calculations in each mouse move.
int colspace; // amount of space between items pr column
uint first; // the first col to anchor at for painting rubber bands
int firstX; // X position of first in pixel
int pressed; // the colummn that was pressed on at resizing start
int span; // pressed - first
// key completion
QString mCompText; // current completion string
QDateTime mCompUpdated; // ...was updated at this time
};
class CardViewItemPrivate
{
public:
CardViewItemPrivate() :
- x( 0 ),
- y( 0 ),
- mSelected( false ){};
+ mSelected( false ),
+ x( 0 ),
+ y( 0 ){};
QString mCaption;
QPtrList< 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)
{
d->mCaption = caption;
initialize();
}
CardViewItem::~CardViewItem()
{
// Remove ourself from the view
if (mView != 0)
mView->takeItem(this);
delete d;
d = 0;
}
void CardViewItem::initialize()
{
d->mSelected = false;
d->mFieldList.setAutoDelete(true);
d->maxLabelWidth = 0;
d->hcache=0;
//calcRect();
// Add ourself to the view
if (mView != 0)
mView->insertItem(this);
}
void CardViewItem::paintCard(QPainter *p, QColorGroup &cg)
{
if (!mView)
return;
QPen pen;
QBrush brush;
QFontMetrics fm = *(mView->d->mFm);
QFontMetrics bFm = *(mView->d->mBFm);
bool drawLabels = mView->d->mDrawFieldLabels;
bool drawBorder = mView->d->mDrawCardBorder;
int mg = mView->itemMargin();
int w = mView->itemWidth() - (mg*2);
int h = height() - (mg*2);
const int colonWidth( fm.width(":") );
int labelXPos = 2 + mg;
int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 );