author | zautrix <zautrix> | 2004-11-07 17:35:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-07 17:35:51 (UTC) |
commit | d90d17044d7daf6677074b0964d59f94407157d5 (patch) (unidiff) | |
tree | 82bf4f2001465637572534650769a864c15a6f7c /kaddressbook | |
parent | b6ef669713ee1d52adcfc9754dd039a4ff6675da (diff) | |
download | kdepimpi-d90d17044d7daf6677074b0964d59f94407157d5.zip kdepimpi-d90d17044d7daf6677074b0964d59f94407157d5.tar.gz kdepimpi-d90d17044d7daf6677074b0964d59f94407157d5.tar.bz2 |
some mail fixes and warnings removed
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/views/cardview.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d651224..c339244 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2682,129 +2682,129 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2682 | Addressee newAdd; | 2682 | Addressee newAdd; |
2683 | addresseeRSync = newAdd; | 2683 | addresseeRSync = newAdd; |
2684 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2684 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2685 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2685 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2686 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2686 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2687 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2687 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2688 | } | 2688 | } |
2689 | } | 2689 | } |
2690 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2690 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2691 | // qDebug("FULLDATE 2"); | 2691 | // qDebug("FULLDATE 2"); |
2692 | fullDateRange = true; | 2692 | fullDateRange = true; |
2693 | } | 2693 | } |
2694 | if ( ! fullDateRange ) { | 2694 | if ( ! fullDateRange ) { |
2695 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2695 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2696 | 2696 | ||
2697 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2697 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2698 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2698 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2699 | fullDateRange = true; | 2699 | fullDateRange = true; |
2700 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2700 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2701 | } | 2701 | } |
2702 | } | 2702 | } |
2703 | // fullDateRange = true; // debug only! | 2703 | // fullDateRange = true; // debug only! |
2704 | if ( fullDateRange ) | 2704 | if ( fullDateRange ) |
2705 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2705 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2706 | else | 2706 | else |
2707 | mLastAddressbookSync = addresseeLSync.revision(); | 2707 | mLastAddressbookSync = addresseeLSync.revision(); |
2708 | // for resyncing if own file has changed | 2708 | // for resyncing if own file has changed |
2709 | // PENDING fixme later when implemented | 2709 | // PENDING fixme later when implemented |
2710 | #if 0 | 2710 | #if 0 |
2711 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2711 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2712 | mLastAddressbookSync = loadedFileVersion; | 2712 | mLastAddressbookSync = loadedFileVersion; |
2713 | qDebug("setting mLastAddressbookSync "); | 2713 | qDebug("setting mLastAddressbookSync "); |
2714 | } | 2714 | } |
2715 | #endif | 2715 | #endif |
2716 | 2716 | ||
2717 | //qDebug("*************************** "); | 2717 | //qDebug("*************************** "); |
2718 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2718 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2719 | QStringList er = remote->uidList(); | 2719 | QStringList er = remote->uidList(); |
2720 | Addressee inR ;//= er.first(); | 2720 | Addressee inR ;//= er.first(); |
2721 | Addressee inL; | 2721 | Addressee inL; |
2722 | 2722 | ||
2723 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2723 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2724 | 2724 | ||
2725 | int modulo = (er.count()/10)+1; | 2725 | int modulo = (er.count()/10)+1; |
2726 | int incCounter = 0; | 2726 | int incCounter = 0; |
2727 | while ( incCounter < er.count()) { | 2727 | while ( incCounter < er.count()) { |
2728 | if (syncManager->isProgressBarCanceled()) | 2728 | if (syncManager->isProgressBarCanceled()) |
2729 | return false; | 2729 | return false; |
2730 | if ( incCounter % modulo == 0 ) | 2730 | if ( incCounter % modulo == 0 ) |
2731 | syncManager->showProgressBar(incCounter); | 2731 | syncManager->showProgressBar(incCounter); |
2732 | 2732 | ||
2733 | uid = er[ incCounter ]; | 2733 | uid = er[ incCounter ]; |
2734 | bool skipIncidence = false; | 2734 | bool skipIncidence = false; |
2735 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2735 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2736 | skipIncidence = true; | 2736 | skipIncidence = true; |
2737 | QString idS,OidS; | 2737 | QString idS,OidS; |
2738 | qApp->processEvents(); | 2738 | qApp->processEvents(); |
2739 | if ( !skipIncidence ) { | 2739 | if ( !skipIncidence ) { |
2740 | inL = local->findByUid( uid ); | 2740 | inL = local->findByUid( uid ); |
2741 | inR = remote->findByUid( uid ); | 2741 | inR = remote->findByUid( uid ); |
2742 | //inL.setResource( 0 ); | 2742 | //inL.setResource( 0 ); |
2743 | //inR.setResource( 0 ); | 2743 | //inR.setResource( 0 ); |
2744 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2744 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2745 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2745 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2746 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2746 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2747 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2747 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2748 | if ( take == 3 ) | 2748 | if ( take == 3 ) |
2749 | return false; | 2749 | return false; |
2750 | if ( take == 1 ) {// take local ********************** | 2750 | if ( take == 1 ) {// take local ********************** |
2751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2752 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2752 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2753 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2753 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2754 | local->insertAddressee( inL, false ); | 2754 | local->insertAddressee( inL, false ); |
2755 | idS = inR.externalUID(); | 2755 | idS = inR.externalUID(); |
2756 | OidS = inR.originalExternalUID(); | 2756 | OidS = inR.originalExternalUID(); |
2757 | } | 2757 | } |
2758 | else | 2758 | else |
2759 | idS = inR.IDStr(); | 2759 | idS = inR.IDStr(); |
2760 | remote->removeAddressee( inR ); | 2760 | remote->removeAddressee( inR ); |
2761 | inR = inL; | 2761 | inR = inL; |
2762 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2762 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2763 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2763 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2764 | inR.setOriginalExternalUID( OidS ); | 2764 | inR.setOriginalExternalUID( OidS ); |
2765 | inR.setExternalUID( idS ); | 2765 | inR.setExternalUID( idS ); |
2766 | if ( syncManager->syncWithDesktop() ) { | 2766 | if ( syncManager->syncWithDesktop() ) { |
2767 | inR.setIDStr("changed" ); | 2767 | inR.setIDStr("changed" ); |
2768 | } | 2768 | } |
2769 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2769 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2770 | } else { | 2770 | } else { |
2771 | inR.setIDStr( idS ); | 2771 | inR.setIDStr( idS ); |
2772 | } | 2772 | } |
2773 | inR.setResource( 0 ); | 2773 | inR.setResource( 0 ); |
2774 | remote->insertAddressee( inR , false); | 2774 | remote->insertAddressee( inR , false); |
2775 | ++changedRemote; | 2775 | ++changedRemote; |
2776 | } else { // take == 2 take remote ********************** | 2776 | } else { // take == 2 take remote ********************** |
2777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2778 | if ( inR.revision().date().year() < 2004 ) | 2778 | if ( inR.revision().date().year() < 2004 ) |
2779 | inR.setRevision( modifiedCalendar ); | 2779 | inR.setRevision( modifiedCalendar ); |
2780 | } | 2780 | } |
2781 | idS = inL.IDStr(); | 2781 | idS = inL.IDStr(); |
2782 | local->removeAddressee( inL ); | 2782 | local->removeAddressee( inL ); |
2783 | inL = inR; | 2783 | inL = inR; |
2784 | inL.setIDStr( idS ); | 2784 | inL.setIDStr( idS ); |
2785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2786 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2786 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2787 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2787 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2788 | } | 2788 | } |
2789 | inL.setResource( 0 ); | 2789 | inL.setResource( 0 ); |
2790 | local->insertAddressee( inL , false ); | 2790 | local->insertAddressee( inL , false ); |
2791 | ++changedLocal; | 2791 | ++changedLocal; |
2792 | } | 2792 | } |
2793 | } | 2793 | } |
2794 | } | 2794 | } |
2795 | } else { // no conflict ********** add or delete remote | 2795 | } else { // no conflict ********** add or delete remote |
2796 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2796 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2797 | QString des = addresseeLSync.note(); | 2797 | QString des = addresseeLSync.note(); |
2798 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2798 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2799 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2799 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2800 | remote->insertAddressee( inR, false ); | 2800 | remote->insertAddressee( inR, false ); |
2801 | ++deletedAddresseeR; | 2801 | ++deletedAddresseeR; |
2802 | } else { | 2802 | } else { |
2803 | inR.setRevision( modifiedCalendar ); | 2803 | inR.setRevision( modifiedCalendar ); |
2804 | remote->insertAddressee( inR, false ); | 2804 | remote->insertAddressee( inR, false ); |
2805 | inL = inR; | 2805 | inL = inR; |
2806 | inL.setIDStr( ":" ); | 2806 | inL.setIDStr( ":" ); |
2807 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2807 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2808 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2808 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2809 | inL.setResource( 0 ); | 2809 | inL.setResource( 0 ); |
2810 | local->insertAddressee( inL , false); | 2810 | local->insertAddressee( inL , false); |
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> | |||
93 | 93 | ||
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
96 | 96 | ||
97 | private: | 97 | private: |
98 | /*int find( const CardViewItem * ) | 98 | /*int find( const CardViewItem * ) |
99 | { | 99 | { |
100 | qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); | 100 | qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); |
101 | }*/ | 101 | }*/ |
102 | }; | 102 | }; |
103 | 103 | ||
104 | ////////////////////////////////////// | 104 | ////////////////////////////////////// |
105 | // CardViewSeparator | 105 | // CardViewSeparator |
106 | class CardViewSeparator | 106 | class CardViewSeparator |
107 | { | 107 | { |
108 | friend class CardView; | 108 | friend class CardView; |
109 | 109 | ||
110 | public: | 110 | public: |
111 | CardViewSeparator(CardView *view) | 111 | CardViewSeparator(CardView *view) |
112 | : mView(view) | 112 | : mView(view) |
113 | { | 113 | { |
114 | mRect = QRect(0, 0, view->separatorWidth(), 0); | 114 | mRect = QRect(0, 0, view->separatorWidth(), 0); |
115 | } | 115 | } |
116 | 116 | ||
117 | ~CardViewSeparator() {} | 117 | ~CardViewSeparator() {} |
118 | 118 | ||
119 | void paintSeparator(QPainter *p, QColorGroup &cg) | 119 | void paintSeparator(QPainter *p, QColorGroup &cg) |
120 | { | 120 | { |
121 | p->fillRect(0, 0, mRect.width(), mRect.height(), | 121 | p->fillRect(0, 0, mRect.width(), mRect.height(), |
122 | cg.brush(QColorGroup::Button)); | 122 | cg.brush(QColorGroup::Button)); |
123 | } | 123 | } |
124 | 124 | ||
125 | void repaintSeparator() | 125 | void repaintSeparator() |
126 | { | 126 | { |
127 | mView->repaintContents(mRect); | 127 | mView->repaintContents(mRect); |
128 | } | 128 | } |
129 | 129 | ||
130 | private: | 130 | private: |
131 | CardView *mView; | 131 | CardView *mView; |
132 | QRect mRect; | 132 | QRect mRect; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | //END Helpers | 135 | //END Helpers |
136 | 136 | ||
137 | //BEGIN Private Data | 137 | //BEGIN Private Data |
138 | 138 | ||
139 | class CardViewPrivate | 139 | class CardViewPrivate |
140 | { | 140 | { |
141 | public: | 141 | public: |
142 | CardViewPrivate() | 142 | CardViewPrivate() |
143 | : mSelectionMode( CardView::Multi ), | 143 | : mSelectionMode( CardView::Multi ), |
144 | mDrawCardBorder( true ), | 144 | mDrawCardBorder( true ), |
145 | mDrawFieldLabels( true ), | 145 | mDrawFieldLabels( true ), |
146 | mDrawSeparators( true), | 146 | mDrawSeparators( true), |
147 | mSepWidth( 2 ), | 147 | mSepWidth( 2 ), |
148 | mShowEmptyFields( false ), | 148 | mShowEmptyFields( false ), |
149 | mLayoutDirty( true ), | 149 | mLayoutDirty( true ), |
150 | mLastClickOnItem( false ), | 150 | mLastClickOnItem( false ), |
151 | mItemMargin( 0 ), | 151 | mItemMargin( 0 ), |
152 | mItemSpacing( 10 ), | 152 | mItemSpacing( 10 ), |
153 | mItemWidth( 200 ), | 153 | mItemWidth( 200 ), |
154 | mMaxFieldLines( INT_MAX ), | 154 | mMaxFieldLines( INT_MAX ), |
155 | mCurrentItem( 0L ), | 155 | mCurrentItem( 0L ), |
156 | mLastClickPos( QPoint(0, 0) ), | 156 | mLastClickPos( QPoint(0, 0) ), |
157 | mResizeAnchor(0), | ||
157 | mRubberBandAnchor( 0 ), | 158 | mRubberBandAnchor( 0 ), |
158 | mCompText( QString::null ), | 159 | mCompText( QString::null ) |
159 | mResizeAnchor(0) | ||
160 | {}; | 160 | {}; |
161 | 161 | ||
162 | CardViewItemList mItemList; | 162 | CardViewItemList mItemList; |
163 | QPtrList<CardViewSeparator> mSeparatorList; | 163 | QPtrList<CardViewSeparator> mSeparatorList; |
164 | QFontMetrics *mFm; | 164 | QFontMetrics *mFm; |
165 | QFontMetrics *mBFm; // bold font | 165 | QFontMetrics *mBFm; // bold font |
166 | QFont mHeaderFont; // custom header font | 166 | QFont mHeaderFont; // custom header font |
167 | CardView::SelectionMode mSelectionMode; | 167 | CardView::SelectionMode mSelectionMode; |
168 | bool mDrawCardBorder; | 168 | bool mDrawCardBorder; |
169 | bool mDrawFieldLabels; | 169 | bool mDrawFieldLabels; |
170 | bool mDrawSeparators; | 170 | bool mDrawSeparators; |
171 | int mSepWidth; | 171 | int mSepWidth; |
172 | bool mShowEmptyFields; | 172 | bool mShowEmptyFields; |
173 | bool mLayoutDirty; | 173 | bool mLayoutDirty; |
174 | bool mLastClickOnItem; | 174 | bool mLastClickOnItem; |
175 | uint mItemMargin; // internal margin in items | 175 | uint mItemMargin; // internal margin in items |
176 | uint mItemSpacing; // spacing between items, column seperators and border | 176 | uint mItemSpacing; // spacing between items, column seperators and border |
177 | int mItemWidth; // width of all items | 177 | int mItemWidth; // width of all items |
178 | uint mMaxFieldLines; // Max lines to dispaly pr field | 178 | uint mMaxFieldLines; // Max lines to dispaly pr field |
179 | CardViewItem *mCurrentItem; | 179 | CardViewItem *mCurrentItem; |
180 | QPoint mLastClickPos; | 180 | QPoint mLastClickPos; |
181 | QTimer *mTimer; // times out if mouse rests for more than 500 msecs | 181 | QTimer *mTimer; // times out if mouse rests for more than 500 msecs |
182 | CardViewTip *mTip; // passed to the item under a resting cursor to display full text | 182 | CardViewTip *mTip; // passed to the item under a resting cursor to display full text |
183 | bool mOnSeparator; // set/reset on mouse movement | 183 | bool mOnSeparator; // set/reset on mouse movement |
184 | // for resizing by dragging the separators | 184 | // for resizing by dragging the separators |
185 | int mResizeAnchor; // uint, ulong? the mouse down separator left | 185 | int mResizeAnchor; // uint, ulong? the mouse down separator left |
186 | int mRubberBandAnchor; // for erasing rubber bands | 186 | int mRubberBandAnchor; // for erasing rubber bands |
187 | // data used for resizing. | 187 | // data used for resizing. |
188 | // as they are beeded by each mouse move while resizing, we store them here, | 188 | // as they are beeded by each mouse move while resizing, we store them here, |
189 | // saving 8 calculations in each mouse move. | 189 | // saving 8 calculations in each mouse move. |
190 | int colspace; // amount of space between items pr column | 190 | int colspace; // amount of space between items pr column |
191 | uint first; // the first col to anchor at for painting rubber bands | 191 | uint first; // the first col to anchor at for painting rubber bands |
192 | int firstX; // X position of first in pixel | 192 | int firstX; // X position of first in pixel |
193 | int pressed; // the colummn that was pressed on at resizing start | 193 | int pressed; // the colummn that was pressed on at resizing start |
194 | int span; // pressed - first | 194 | int span; // pressed - first |
195 | // key completion | 195 | // key completion |
196 | QString mCompText; // current completion string | 196 | QString mCompText; // current completion string |
197 | QDateTime mCompUpdated; // ...was updated at this time | 197 | QDateTime mCompUpdated; // ...was updated at this time |
198 | }; | 198 | }; |
199 | 199 | ||
200 | class CardViewItemPrivate | 200 | class CardViewItemPrivate |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | CardViewItemPrivate() : | 203 | CardViewItemPrivate() : |
204 | x( 0 ), | 204 | mSelected( false ), |
205 | y( 0 ), | 205 | x( 0 ), |
206 | mSelected( false ){}; | 206 | y( 0 ){}; |
207 | 207 | ||
208 | 208 | ||
209 | QString mCaption; | 209 | QString mCaption; |
210 | QPtrList< CardViewItem::Field > mFieldList; | 210 | QPtrList< CardViewItem::Field > mFieldList; |
211 | bool mSelected; | 211 | bool mSelected; |
212 | int x; // horizontal position, set by the view | 212 | int x; // horizontal position, set by the view |
213 | int y; // vertical position, set by the view | 213 | int y; // vertical position, set by the view |
214 | int maxLabelWidth; // the width of the widest label, according to the view font. | 214 | int maxLabelWidth; // the width of the widest label, according to the view font. |
215 | int hcache; // height cache | 215 | int hcache; // height cache |
216 | }; | 216 | }; |
217 | //END Private Data | 217 | //END Private Data |
218 | 218 | ||
219 | //BEGIN CardViewItem | 219 | //BEGIN CardViewItem |
220 | 220 | ||
221 | CardViewItem::CardViewItem(CardView *parent, QString caption) | 221 | CardViewItem::CardViewItem(CardView *parent, QString caption) |
222 | : d(new CardViewItemPrivate()), mView(parent) | 222 | : d(new CardViewItemPrivate()), mView(parent) |
223 | { | 223 | { |
224 | d->mCaption = caption; | 224 | d->mCaption = caption; |
225 | 225 | ||
226 | initialize(); | 226 | initialize(); |
227 | } | 227 | } |
228 | 228 | ||
229 | CardViewItem::~CardViewItem() | 229 | CardViewItem::~CardViewItem() |
230 | { | 230 | { |
231 | // Remove ourself from the view | 231 | // Remove ourself from the view |
232 | if (mView != 0) | 232 | if (mView != 0) |
233 | mView->takeItem(this); | 233 | mView->takeItem(this); |
234 | 234 | ||
235 | delete d; | 235 | delete d; |
236 | d = 0; | 236 | d = 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | void CardViewItem::initialize() | 239 | void CardViewItem::initialize() |
240 | { | 240 | { |
241 | d->mSelected = false; | 241 | d->mSelected = false; |
242 | d->mFieldList.setAutoDelete(true); | 242 | d->mFieldList.setAutoDelete(true); |
243 | d->maxLabelWidth = 0; | 243 | d->maxLabelWidth = 0; |
244 | d->hcache=0; | 244 | d->hcache=0; |
245 | 245 | ||
246 | //calcRect(); | 246 | //calcRect(); |
247 | 247 | ||
248 | // Add ourself to the view | 248 | // Add ourself to the view |
249 | if (mView != 0) | 249 | if (mView != 0) |
250 | mView->insertItem(this); | 250 | mView->insertItem(this); |
251 | } | 251 | } |
252 | 252 | ||
253 | void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) | 253 | void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) |
254 | { | 254 | { |
255 | 255 | ||
256 | if (!mView) | 256 | if (!mView) |
257 | return; | 257 | return; |
258 | 258 | ||
259 | QPen pen; | 259 | QPen pen; |
260 | QBrush brush; | 260 | QBrush brush; |
261 | QFontMetrics fm = *(mView->d->mFm); | 261 | QFontMetrics fm = *(mView->d->mFm); |
262 | QFontMetrics bFm = *(mView->d->mBFm); | 262 | QFontMetrics bFm = *(mView->d->mBFm); |
263 | bool drawLabels = mView->d->mDrawFieldLabels; | 263 | bool drawLabels = mView->d->mDrawFieldLabels; |
264 | bool drawBorder = mView->d->mDrawCardBorder; | 264 | bool drawBorder = mView->d->mDrawCardBorder; |
265 | int mg = mView->itemMargin(); | 265 | int mg = mView->itemMargin(); |
266 | int w = mView->itemWidth() - (mg*2); | 266 | int w = mView->itemWidth() - (mg*2); |
267 | int h = height() - (mg*2); | 267 | int h = height() - (mg*2); |
268 | const int colonWidth( fm.width(":") ); | 268 | const int colonWidth( fm.width(":") ); |
269 | int labelXPos = 2 + mg; | 269 | int labelXPos = 2 + mg; |
270 | int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); | 270 | int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); |