-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 27 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 |
5 files changed, 61 insertions, 0 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 23b091c..e75810e 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -264,32 +264,59 @@ ContactListView::ContactListView(KAddressBookTableView *view, | |||
264 | setShowSortIndicator(true); | 264 | setShowSortIndicator(true); |
265 | 265 | ||
266 | setSelectionModeExt( KListView::Extended ); | 266 | setSelectionModeExt( KListView::Extended ); |
267 | setDropVisualizer(false); | 267 | setDropVisualizer(false); |
268 | // setFrameStyle(QFrame::NoFrame); | 268 | // setFrameStyle(QFrame::NoFrame); |
269 | //setLineWidth ( 0 ); | 269 | //setLineWidth ( 0 ); |
270 | //setMidLineWidth ( 0 ); | 270 | //setMidLineWidth ( 0 ); |
271 | //setMargin ( 0 ); | 271 | //setMargin ( 0 ); |
272 | #ifndef KAB_EMBEDDED | 272 | #ifndef KAB_EMBEDDED |
273 | connect(this, SIGNAL(dropped(QDropEvent*)), | 273 | connect(this, SIGNAL(dropped(QDropEvent*)), |
274 | this, SLOT(itemDropped(QDropEvent*))); | 274 | this, SLOT(itemDropped(QDropEvent*))); |
275 | #endif //KAB_EMBEDDED | 275 | #endif //KAB_EMBEDDED |
276 | 276 | ||
277 | 277 | ||
278 | new DynamicTip( this ); | 278 | new DynamicTip( this ); |
279 | } | 279 | } |
280 | void ContactListView::printMe() | ||
281 | { | ||
282 | #ifdef DESKTOP_VERSION | ||
283 | QPrinter printer; | ||
284 | if (!printer.setup() ) | ||
285 | return; | ||
286 | QPainter p; | ||
287 | p.begin ( &printer ); | ||
288 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
289 | float dx, dy; | ||
290 | int wid = (m.width() * 9)/10; | ||
291 | dx = (float) wid/(float)contentsWidth (); | ||
292 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
293 | float scale; | ||
294 | // scale to fit the width or height of the paper | ||
295 | if ( dx < dy ) | ||
296 | scale = dx; | ||
297 | else | ||
298 | scale = dy; | ||
299 | p.translate( m.width()/10,0 ); | ||
300 | p.scale( scale, scale ); | ||
301 | qDebug("scale %f ", scale); | ||
302 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
303 | p.end(); | ||
304 | qDebug("Why does it not print??? "); | ||
305 | #endif | ||
306 | } | ||
280 | 307 | ||
281 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 308 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
282 | { | 309 | { |
283 | mAlternateColor = m_AlternateColor; | 310 | mAlternateColor = m_AlternateColor; |
284 | } | 311 | } |
285 | 312 | ||
286 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 313 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) |
287 | { | 314 | { |
288 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); | 315 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); |
289 | 316 | ||
290 | // Get the brush, which will have the background pixmap if there is one. | 317 | // Get the brush, which will have the background pixmap if there is one. |
291 | if (b.pixmap()) | 318 | if (b.pixmap()) |
292 | { | 319 | { |
293 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), | 320 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), |
294 | *(b.pixmap()), | 321 | *(b.pixmap()), |
295 | rect.left() + contentsX(), | 322 | rect.left() + contentsX(), |
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h index fad7f38..9d1a672 100644 --- a/kaddressbook/views/contactlistview.h +++ b/kaddressbook/views/contactlistview.h | |||
@@ -92,32 +92,33 @@ public: | |||
92 | void setBackgroundPixmap(const QString &filename); | 92 | void setBackgroundPixmap(const QString &filename); |
93 | 93 | ||
94 | protected: | 94 | protected: |
95 | /** Paints the background pixmap in the empty area. This method is needed | 95 | /** Paints the background pixmap in the empty area. This method is needed |
96 | * since Qt::FixedPixmap will not scroll with the list view. | 96 | * since Qt::FixedPixmap will not scroll with the list view. |
97 | */ | 97 | */ |
98 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); | 98 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); |
99 | virtual void contentsMousePressEvent(QMouseEvent*); | 99 | virtual void contentsMousePressEvent(QMouseEvent*); |
100 | void contentsMouseMoveEvent( QMouseEvent *e ); | 100 | void contentsMouseMoveEvent( QMouseEvent *e ); |
101 | void contentsDropEvent( QDropEvent *e ); | 101 | void contentsDropEvent( QDropEvent *e ); |
102 | virtual bool acceptDrag(QDropEvent *e) const; | 102 | virtual bool acceptDrag(QDropEvent *e) const; |
103 | 103 | ||
104 | protected slots: | 104 | protected slots: |
105 | void itemDropped(QDropEvent *e); | 105 | void itemDropped(QDropEvent *e); |
106 | 106 | ||
107 | public slots: | 107 | public slots: |
108 | void printMe(); | ||
108 | 109 | ||
109 | signals: | 110 | signals: |
110 | void startAddresseeDrag(); | 111 | void startAddresseeDrag(); |
111 | void addresseeDropped(QDropEvent *); | 112 | void addresseeDropped(QDropEvent *); |
112 | 113 | ||
113 | private: | 114 | private: |
114 | KAddressBookTableView *pabWidget; | 115 | KAddressBookTableView *pabWidget; |
115 | int oldColumn; | 116 | int oldColumn; |
116 | int column; | 117 | int column; |
117 | bool ascending; | 118 | bool ascending; |
118 | 119 | ||
119 | bool mABackground; | 120 | bool mABackground; |
120 | bool mSingleLine; | 121 | bool mSingleLine; |
121 | bool mToolTips; | 122 | bool mToolTips; |
122 | 123 | ||
123 | QColor mAlternateColor; | 124 | QColor mAlternateColor; |
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 2d7ed08..107be59 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -25,32 +25,33 @@ | |||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kabc/addressbook.h> | 32 | #include <kabc/addressbook.h> |
33 | #include <kabc/addressee.h> | 33 | #include <kabc/addressee.h> |
34 | #include <kconfig.h> | 34 | #include <kconfig.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | 37 | ||
38 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
39 | #include "viewmanager.h" | 39 | #include "viewmanager.h" |
40 | 40 | ||
41 | |||
41 | #include "kaddressbookcardview.h" | 42 | #include "kaddressbookcardview.h" |
42 | 43 | ||
43 | #ifndef KAB_EMBEDDED | 44 | #ifndef KAB_EMBEDDED |
44 | extern "C" { | 45 | extern "C" { |
45 | void *init_libkaddrbk_cardview() | 46 | void *init_libkaddrbk_cardview() |
46 | { | 47 | { |
47 | return ( new CardViewFactory ); | 48 | return ( new CardViewFactory ); |
48 | } | 49 | } |
49 | } | 50 | } |
50 | #endif //KAB_EMBEDDED | 51 | #endif //KAB_EMBEDDED |
51 | 52 | ||
52 | //////////////////////////////// | 53 | //////////////////////////////// |
53 | // AddresseeCardViewItem (internal class) | 54 | // AddresseeCardViewItem (internal class) |
54 | class AddresseeCardViewItem : public CardViewItem | 55 | class AddresseeCardViewItem : public CardViewItem |
55 | { | 56 | { |
56 | public: | 57 | public: |
@@ -103,32 +104,58 @@ class AddresseeCardViewItem : public CardViewItem | |||
103 | KABC::AddressBook *mDocument; | 104 | KABC::AddressBook *mDocument; |
104 | KABC::Addressee mAddressee; | 105 | KABC::Addressee mAddressee; |
105 | }; | 106 | }; |
106 | 107 | ||
107 | /////////////////////////////// | 108 | /////////////////////////////// |
108 | // AddresseeCardView | 109 | // AddresseeCardView |
109 | 110 | ||
110 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 111 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
111 | : CardView(parent, name) | 112 | : CardView(parent, name) |
112 | { | 113 | { |
113 | setAcceptDrops(true); | 114 | setAcceptDrops(true); |
114 | } | 115 | } |
115 | 116 | ||
116 | AddresseeCardView::~AddresseeCardView() | 117 | AddresseeCardView::~AddresseeCardView() |
117 | { | 118 | { |
118 | } | 119 | } |
120 | void AddresseeCardView::printMe() | ||
121 | { | ||
122 | #ifdef DESKTOP_VERSION | ||
123 | QPrinter printer; | ||
124 | if (!printer.setup() ) | ||
125 | return; | ||
126 | QPainter p; | ||
127 | p.begin ( &printer ); | ||
128 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
129 | float dx, dy; | ||
130 | int wid = (m.width() * 9)/10; | ||
131 | dx = (float) wid/(float)contentsWidth (); | ||
132 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
133 | float scale; | ||
134 | // scale to fit the width or height of the paper | ||
135 | if ( dx < dy ) | ||
136 | scale = dx; | ||
137 | else | ||
138 | scale = dy; | ||
139 | p.translate( m.width()/10,0 ); | ||
140 | p.scale( scale, scale ); | ||
141 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
142 | p.end(); | ||
143 | repaint(); | ||
144 | #endif | ||
145 | } | ||
119 | 146 | ||
120 | 147 | ||
121 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 148 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
122 | { | 149 | { |
123 | #ifndef KAB_EMBEDDED | 150 | #ifndef KAB_EMBEDDED |
124 | if (QTextDrag::canDecode(e)) | 151 | if (QTextDrag::canDecode(e)) |
125 | e->accept(); | 152 | e->accept(); |
126 | #else //KAB_EMBEDDED | 153 | #else //KAB_EMBEDDED |
127 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 154 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
128 | #endif //KAB_EMBEDDED | 155 | #endif //KAB_EMBEDDED |
129 | } | 156 | } |
130 | 157 | ||
131 | void AddresseeCardView::dropEvent(QDropEvent *e) | 158 | void AddresseeCardView::dropEvent(QDropEvent *e) |
132 | { | 159 | { |
133 | emit addresseeDropped(e); | 160 | emit addresseeDropped(e); |
134 | } | 161 | } |
@@ -151,32 +178,34 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | |||
151 | // Init the GUI | 178 | // Init the GUI |
152 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 179 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
153 | 180 | ||
154 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 181 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
155 | mCardView->setSelectionMode(CardView::Extended); | 182 | mCardView->setSelectionMode(CardView::Extended); |
156 | layout->addWidget(mCardView); | 183 | layout->addWidget(mCardView); |
157 | 184 | ||
158 | // Connect up the signals | 185 | // Connect up the signals |
159 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 186 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
160 | this, SLOT(addresseeExecuted(CardViewItem *))); | 187 | this, SLOT(addresseeExecuted(CardViewItem *))); |
161 | connect(mCardView, SIGNAL(selectionChanged()), | 188 | connect(mCardView, SIGNAL(selectionChanged()), |
162 | this, SLOT(addresseeSelected())); | 189 | this, SLOT(addresseeSelected())); |
163 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 190 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
164 | this, SIGNAL(dropped(QDropEvent*))); | 191 | this, SIGNAL(dropped(QDropEvent*))); |
165 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 192 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
166 | this, SIGNAL(startDrag())); | 193 | this, SIGNAL(startDrag())); |
194 | connect(this, SIGNAL(printView()), | ||
195 | mCardView , SLOT(printMe())); | ||
167 | } | 196 | } |
168 | 197 | ||
169 | KAddressBookCardView::~KAddressBookCardView() | 198 | KAddressBookCardView::~KAddressBookCardView() |
170 | { | 199 | { |
171 | } | 200 | } |
172 | void KAddressBookCardView::setFocusAV() | 201 | void KAddressBookCardView::setFocusAV() |
173 | { | 202 | { |
174 | if ( mCardView ) | 203 | if ( mCardView ) |
175 | mCardView->setFocus(); | 204 | mCardView->setFocus(); |
176 | 205 | ||
177 | } | 206 | } |
178 | void KAddressBookCardView::scrollUP() | 207 | void KAddressBookCardView::scrollUP() |
179 | { | 208 | { |
180 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 209 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
181 | QApplication::postEvent( mCardView, ev ); | 210 | QApplication::postEvent( mCardView, ev ); |
182 | 211 | ||
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index 8f22d54..2a71f7e 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h | |||
@@ -72,32 +72,34 @@ class KAddressBookCardView : public KAddressBookView | |||
72 | 72 | ||
73 | protected slots: | 73 | protected slots: |
74 | void addresseeExecuted(CardViewItem *item); | 74 | void addresseeExecuted(CardViewItem *item); |
75 | void addresseeSelected(); | 75 | void addresseeSelected(); |
76 | 76 | ||
77 | private: | 77 | private: |
78 | AddresseeCardView *mCardView; | 78 | AddresseeCardView *mCardView; |
79 | bool mShowEmptyFields; | 79 | bool mShowEmptyFields; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | class AddresseeCardView : public CardView | 82 | class AddresseeCardView : public CardView |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | AddresseeCardView(QWidget *parent, const char *name = 0); | 86 | AddresseeCardView(QWidget *parent, const char *name = 0); |
87 | ~AddresseeCardView(); | 87 | ~AddresseeCardView(); |
88 | public slots: | ||
89 | void printMe(); | ||
88 | 90 | ||
89 | signals: | 91 | signals: |
90 | void startAddresseeDrag(); | 92 | void startAddresseeDrag(); |
91 | void addresseeDropped(QDropEvent *); | 93 | void addresseeDropped(QDropEvent *); |
92 | 94 | ||
93 | protected: | 95 | protected: |
94 | virtual void dragEnterEvent(QDragEnterEvent *); | 96 | virtual void dragEnterEvent(QDragEnterEvent *); |
95 | virtual void dropEvent(QDropEvent *); | 97 | virtual void dropEvent(QDropEvent *); |
96 | virtual void startDrag(); | 98 | virtual void startDrag(); |
97 | }; | 99 | }; |
98 | 100 | ||
99 | 101 | ||
100 | class CardViewFactory : public ViewFactory | 102 | class CardViewFactory : public ViewFactory |
101 | { | 103 | { |
102 | public: | 104 | public: |
103 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 105 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 61703ee..ecd6f05 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -76,32 +76,34 @@ void KAddressBookTableView::reconstructListView() | |||
76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
77 | this, SLOT(addresseeExecuted(QListViewItem*))); | 77 | this, SLOT(addresseeExecuted(QListViewItem*))); |
78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
79 | this, SLOT(addresseeExecuted(QListViewItem*))); | 79 | this, SLOT(addresseeExecuted(QListViewItem*))); |
80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
81 | SIGNAL(startDrag())); | 81 | SIGNAL(startDrag())); |
82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
83 | this, SLOT(addresseeExecuted(QListViewItem*))); | 83 | this, SLOT(addresseeExecuted(QListViewItem*))); |
84 | 84 | ||
85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
86 | SIGNAL(dropped(QDropEvent*))); | 86 | SIGNAL(dropped(QDropEvent*))); |
87 | delete mListView; | 87 | delete mListView; |
88 | } | 88 | } |
89 | 89 | ||
90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
91 | 91 | ||
92 | connect(this, SIGNAL(printView()), | ||
93 | mListView , SLOT(printMe())); | ||
92 | //US set singleClick manually, because it is no global configparameter in embedded space | 94 | //US set singleClick manually, because it is no global configparameter in embedded space |
93 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | 95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); |
94 | 96 | ||
95 | // Add the columns | 97 | // Add the columns |
96 | KABC::Field::List fieldList = fields(); | 98 | KABC::Field::List fieldList = fields(); |
97 | KABC::Field::List::ConstIterator it; | 99 | KABC::Field::List::ConstIterator it; |
98 | 100 | ||
99 | int c = 0; | 101 | int c = 0; |
100 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 102 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
101 | mListView->addColumn( (*it)->label() ); | 103 | mListView->addColumn( (*it)->label() ); |
102 | mListView->setColumnWidthMode(c++, QListView::Manual); | 104 | mListView->setColumnWidthMode(c++, QListView::Manual); |
103 | //US | 105 | //US |
104 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 106 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
105 | } | 107 | } |
106 | 108 | ||
107 | connect(mListView, SIGNAL(selectionChanged()), | 109 | connect(mListView, SIGNAL(selectionChanged()), |