summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
authorulf69 <ulf69>2004-09-09 18:55:32 (UTC)
committer ulf69 <ulf69>2004-09-09 18:55:32 (UTC)
commit72860f2b84ba97de9223238d9fb97edc0804cc68 (patch) (unidiff)
tree0f0ace3690f299260f08a63b4851c422d30cb7be /kaddressbook/views
parent578bb7c0193afcb84bb08a65f17f6abc0375676e (diff)
downloadkdepimpi-72860f2b84ba97de9223238d9fb97edc0804cc68.zip
kdepimpi-72860f2b84ba97de9223238d9fb97edc0804cc68.tar.gz
kdepimpi-72860f2b84ba97de9223238d9fb97edc0804cc68.tar.bz2
sourceforge 1014886: select fonts and colors for tableview
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/contactlistview.cpp5
-rw-r--r--kaddressbook/views/contactlistview.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp29
3 files changed, 26 insertions, 9 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index 9804e28..4cc22ea 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -229,48 +229,53 @@ ContactListView::ContactListView(KAddressBookTableView *view,
229 mAlternateColor = QColor(240, 240, 240); 229 mAlternateColor = QColor(240, 240, 240);
230#endif //KAB_EMBEDDED 230#endif //KAB_EMBEDDED
231 231
232 setAlternateBackgroundEnabled(mABackground); 232 setAlternateBackgroundEnabled(mABackground);
233 setAcceptDrops( true ); 233 setAcceptDrops( true );
234 viewport()->setAcceptDrops( true ); 234 viewport()->setAcceptDrops( true );
235 setAllColumnsShowFocus( true ); 235 setAllColumnsShowFocus( true );
236 setShowSortIndicator(true); 236 setShowSortIndicator(true);
237 237
238 setSelectionModeExt( KListView::Extended ); 238 setSelectionModeExt( KListView::Extended );
239 setDropVisualizer(false); 239 setDropVisualizer(false);
240 // setFrameStyle(QFrame::NoFrame); 240 // setFrameStyle(QFrame::NoFrame);
241 //setLineWidth ( 0 ); 241 //setLineWidth ( 0 );
242 //setMidLineWidth ( 0 ); 242 //setMidLineWidth ( 0 );
243 //setMargin ( 0 ); 243 //setMargin ( 0 );
244#ifndef KAB_EMBEDDED 244#ifndef KAB_EMBEDDED
245 connect(this, SIGNAL(dropped(QDropEvent*)), 245 connect(this, SIGNAL(dropped(QDropEvent*)),
246 this, SLOT(itemDropped(QDropEvent*))); 246 this, SLOT(itemDropped(QDropEvent*)));
247#endif //KAB_EMBEDDED 247#endif //KAB_EMBEDDED
248 248
249 249
250 new DynamicTip( this ); 250 new DynamicTip( this );
251} 251}
252 252
253void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
254{
255 mAlternateColor = m_AlternateColor;
256}
257
253void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) 258void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
254{ 259{
255 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); 260 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
256 261
257 // Get the brush, which will have the background pixmap if there is one. 262 // Get the brush, which will have the background pixmap if there is one.
258 if (b.pixmap()) 263 if (b.pixmap())
259 { 264 {
260 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), 265 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
261 *(b.pixmap()), 266 *(b.pixmap()),
262 rect.left() + contentsX(), 267 rect.left() + contentsX(),
263 rect.top() + contentsY() ); 268 rect.top() + contentsY() );
264 } 269 }
265 270
266 else 271 else
267 { 272 {
268 // Do a normal paint 273 // Do a normal paint
269 KListView::paintEmptyArea(p, rect); 274 KListView::paintEmptyArea(p, rect);
270 } 275 }
271} 276}
272 277
273void ContactListView::contentsMousePressEvent(QMouseEvent* e) 278void ContactListView::contentsMousePressEvent(QMouseEvent* e)
274{ 279{
275 presspos = e->pos(); 280 presspos = e->pos();
276 KListView::contentsMousePressEvent(e); 281 KListView::contentsMousePressEvent(e);
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index ae9c994..fad7f38 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -62,48 +62,49 @@ private:
62class ContactListView : public KListView 62class ContactListView : public KListView
63{ 63{
64 Q_OBJECT 64 Q_OBJECT
65 65
66public: 66public:
67 ContactListView(KAddressBookTableView *view, 67 ContactListView(KAddressBookTableView *view,
68 KABC::AddressBook *doc, 68 KABC::AddressBook *doc,
69 QWidget *parent, 69 QWidget *parent,
70 const char *name = 0L ); 70 const char *name = 0L );
71 virtual ~ContactListView() {} 71 virtual ~ContactListView() {}
72 //void resort(); 72 //void resort();
73 73
74 /** Returns true if tooltips should be displayed, false otherwise 74 /** Returns true if tooltips should be displayed, false otherwise
75 */ 75 */
76 bool tooltips() const { return mToolTips; } 76 bool tooltips() const { return mToolTips; }
77 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } 77 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; }
78 78
79 bool alternateBackground() const { return mABackground; } 79 bool alternateBackground() const { return mABackground; }
80 void setAlternateBackgroundEnabled(bool enabled); 80 void setAlternateBackgroundEnabled(bool enabled);
81 81
82 bool singleLine() const { return mSingleLine; } 82 bool singleLine() const { return mSingleLine; }
83 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } 83 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; }
84 84
85 const QColor &alternateColor() const { return mAlternateColor; } 85 const QColor &alternateColor() const { return mAlternateColor; }
86 void setAlternateColor(const QColor &mAlternateColor);
86 87
87 /** Sets the background pixmap to <i>filename</i>. If the 88 /** Sets the background pixmap to <i>filename</i>. If the
88 * QString is empty (QString::isEmpty()), then the background 89 * QString is empty (QString::isEmpty()), then the background
89 * pixmap will be disabled. 90 * pixmap will be disabled.
90 */ 91 */
91 void setBackgroundPixmap(const QString &filename); 92 void setBackgroundPixmap(const QString &filename);
92 93
93protected: 94protected:
94 /** 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
95 * since Qt::FixedPixmap will not scroll with the list view. 96 * since Qt::FixedPixmap will not scroll with the list view.
96 */ 97 */
97 virtual void paintEmptyArea( QPainter * p, const QRect & rect ); 98 virtual void paintEmptyArea( QPainter * p, const QRect & rect );
98 virtual void contentsMousePressEvent(QMouseEvent*); 99 virtual void contentsMousePressEvent(QMouseEvent*);
99 void contentsMouseMoveEvent( QMouseEvent *e ); 100 void contentsMouseMoveEvent( QMouseEvent *e );
100 void contentsDropEvent( QDropEvent *e ); 101 void contentsDropEvent( QDropEvent *e );
101 virtual bool acceptDrag(QDropEvent *e) const; 102 virtual bool acceptDrag(QDropEvent *e) const;
102 103
103protected slots: 104protected slots:
104 void itemDropped(QDropEvent *e); 105 void itemDropped(QDropEvent *e);
105 106
106public slots: 107public slots:
107 108
108signals: 109signals:
109 void startAddresseeDrag(); 110 void startAddresseeDrag();
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 0847b64..ab11e2a 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -11,49 +11,49 @@
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <qurl.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14 14
15#include <kabc/addressbook.h> 15#include <kabc/addressbook.h>
16#include <kapplication.h> 16#include <kapplication.h>
17#include <kconfig.h> 17#include <kconfig.h>
18#include <kcolorbutton.h> 18#include <kcolorbutton.h>
19#include <kdebug.h> 19#include <kdebug.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <kiconloader.h> 21#include <kiconloader.h>
22#include <klineedit.h> 22#include <klineedit.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <kurl.h> 25#include <kurl.h>
26#include <kurlrequester.h> 26#include <kurlrequester.h>
27 27
28//US#include "configuretableviewdialog.h" 28//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 29#include "contactlistview.h"
30#include "kabprefs.h" 30#include "kabprefs.h"
31#include "undocmds.h" 31#include "undocmds.h"
32#include "viewmanager.h" 32#include "viewmanager.h"
33 33
34#include <qlayout.h> 34#include <qlayout.h>
35 35#include <qheader.h>
36 36
37#include "kaddressbooktableview.h" 37#include "kaddressbooktableview.h"
38 38
39 39
40KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 40KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
41 QWidget *parent, const char *name ) 41 QWidget *parent, const char *name )
42 : KAddressBookView( ab, parent, name ) 42 : KAddressBookView( ab, parent, name )
43{ 43{
44 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 44 mainLayout = new QVBoxLayout( viewWidget(), 2 );
45 45
46 // The list view will be created when the config is read. 46 // The list view will be created when the config is read.
47 mListView = 0; 47 mListView = 0;
48} 48}
49 49
50KAddressBookTableView::~KAddressBookTableView() 50KAddressBookTableView::~KAddressBookTableView()
51{ 51{
52} 52}
53 53
54void KAddressBookTableView::reconstructListView() 54void KAddressBookTableView::reconstructListView()
55{ 55{
56 if (mListView) 56 if (mListView)
57 { 57 {
58 disconnect(mListView, SIGNAL(selectionChanged()), 58 disconnect(mListView, SIGNAL(selectionChanged()),
59 this, SLOT(addresseeSelected())); 59 this, SLOT(addresseeSelected()));
@@ -121,71 +121,82 @@ void KAddressBookTableView::writeConfig(KConfig *config)
121 121
122void KAddressBookTableView::readConfig(KConfig *config) 122void KAddressBookTableView::readConfig(KConfig *config)
123{ 123{
124 KAddressBookView::readConfig( config ); 124 KAddressBookView::readConfig( config );
125 // The config could have changed the fields, so we need to reconstruct 125 // The config could have changed the fields, so we need to reconstruct
126 // the listview. 126 // the listview.
127 reconstructListView(); 127 reconstructListView();
128 128
129 // costum colors? 129 // costum colors?
130 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 130 if ( config->readBoolEntry( "EnableCustomColors", false ) )
131 { 131 {
132 QPalette p( mListView->palette() ); 132 QPalette p( mListView->palette() );
133 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 133 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
134 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 134 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
135 c = p.color(QPalette::Normal, QColorGroup::Text ); 135 c = p.color(QPalette::Normal, QColorGroup::Text );
136 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 136 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
137 c = p.color(QPalette::Normal, QColorGroup::Button ); 137 c = p.color(QPalette::Normal, QColorGroup::Button );
138 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 138 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
139 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 139 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
140 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 140 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
141 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 141 c = p.color(QPalette::Normal, QColorGroup::Highlight );
142 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 142 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
143 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 143 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
144 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 144 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
145 c = p.color(QPalette::Normal, QColorGroup::Base ); 145#ifndef KAB_EMBEDDED
146 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) ); 146 c = KGlobalSettings::alternateBackgroundColor();
147 mListView->viewport()->setPalette( p ); 147#else //KAB_EMBEDDED
148 c = QColor(240, 240, 240);
149#endif //KAB_EMBEDDED
150 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
151 mListView->setAlternateColor(c);
152
153
154 //US mListView->viewport()->setPalette( p );
155 mListView->setPalette( p );
148 } 156 }
149 else 157 else
150 { 158 {
151 // needed if turned off during a session. 159 // needed if turned off during a session.
152 mListView->viewport()->setPalette( mListView->palette() ); 160 //US mListView->viewport()->setPalette( mListView->palette() );
161 mListView->setPalette( mListView->palette() );
153 } 162 }
154 163
155 //custom fonts? 164 //custom fonts?
156 QFont f( font() ); 165 QFont f( font() );
157 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 166 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
158 { 167 {
159 // mListView->setFont( config->readFontEntry( "TextFont", &f) ); 168 mListView->setFont( config->readFontEntry( "TextFont", &f) );
160 f.setBold( true ); 169 f.setBold( true );
161 // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 170 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
171 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
162 } 172 }
163 else 173 else
164 { 174 {
165 // mListView->setFont( f ); 175 mListView->setFont( f );
166 f.setBold( true ); 176 f.setBold( true );
167 // mListView->setHeaderFont( f ); 177 //US mListView->setHeaderFont( f );
178 mListView->header()->setFont( f );
168 } 179 }
169 180
170 181
171 182
172 183
173 184
174 // Set the list view options 185 // Set the list view options
175 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 186 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
176 true)); 187 true));
177 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 188 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
178 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 189 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
179 190
180 if (config->readBoolEntry("Background", false)) 191 if (config->readBoolEntry("Background", false))
181 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 192 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
182 193
183 // Restore the layout of the listview 194 // Restore the layout of the listview
184 mListView->restoreLayout(config, config->group()); 195 mListView->restoreLayout(config, config->group());
185} 196}
186 197
187void KAddressBookTableView::refresh(QString uid) 198void KAddressBookTableView::refresh(QString uid)
188{ 199{
189 // For now just repopulate. In reality this method should 200 // For now just repopulate. In reality this method should
190 // check the value of uid, and if valid iterate through 201 // check the value of uid, and if valid iterate through
191 // the listview to find the entry, then tell it to refresh. 202 // the listview to find the entry, then tell it to refresh.