author | ulf69 <ulf69> | 2004-09-09 18:55:32 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-09 18:55:32 (UTC) |
commit | 72860f2b84ba97de9223238d9fb97edc0804cc68 (patch) (side-by-side diff) | |
tree | 0f0ace3690f299260f08a63b4851c422d30cb7be | |
parent | 578bb7c0193afcb84bb08a65f17f6abc0375676e (diff) | |
download | kdepimpi-72860f2b84ba97de9223238d9fb97edc0804cc68.zip kdepimpi-72860f2b84ba97de9223238d9fb97edc0804cc68.tar.gz kdepimpi-72860f2b84ba97de9223238d9fb97edc0804cc68.tar.bz2 |
sourceforge 1014886: select fonts and colors for tableview
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 29 |
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 @@ -221,64 +221,69 @@ ContactListView::ContactListView(KAddressBookTableView *view, oldColumn( 0 ) { mABackground = true; mSingleLine = false; mToolTips = true; #ifndef KAB_EMBEDDED mAlternateColor = KGlobalSettings::alternateBackgroundColor(); #else //KAB_EMBEDDED mAlternateColor = QColor(240, 240, 240); #endif //KAB_EMBEDDED setAlternateBackgroundEnabled(mABackground); setAcceptDrops( true ); viewport()->setAcceptDrops( true ); setAllColumnsShowFocus( true ); setShowSortIndicator(true); setSelectionModeExt( KListView::Extended ); setDropVisualizer(false); // setFrameStyle(QFrame::NoFrame); //setLineWidth ( 0 ); //setMidLineWidth ( 0 ); //setMargin ( 0 ); #ifndef KAB_EMBEDDED connect(this, SIGNAL(dropped(QDropEvent*)), this, SLOT(itemDropped(QDropEvent*))); #endif //KAB_EMBEDDED new DynamicTip( this ); } +void ContactListView::setAlternateColor(const QColor &m_AlternateColor) +{ + mAlternateColor = m_AlternateColor; +} + void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) { QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); // Get the brush, which will have the background pixmap if there is one. if (b.pixmap()) { p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), *(b.pixmap()), rect.left() + contentsX(), rect.top() + contentsY() ); } else { // Do a normal paint KListView::paintEmptyArea(p, rect); } } void ContactListView::contentsMousePressEvent(QMouseEvent* e) { presspos = e->pos(); KListView::contentsMousePressEvent(e); } // To initiate a drag operation void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) { if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { emit startAddresseeDrag(); 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 @@ -54,64 +54,65 @@ private: ContactListView *parentListView; KABC::AddressBook *mDocument; }; ///////////////////////////////////////////// // ContactListView class ContactListView : public KListView { Q_OBJECT public: ContactListView(KAddressBookTableView *view, KABC::AddressBook *doc, QWidget *parent, const char *name = 0L ); virtual ~ContactListView() {} //void resort(); /** Returns true if tooltips should be displayed, false otherwise */ bool tooltips() const { return mToolTips; } void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } bool alternateBackground() const { return mABackground; } void setAlternateBackgroundEnabled(bool enabled); bool singleLine() const { return mSingleLine; } void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } const QColor &alternateColor() const { return mAlternateColor; } + void setAlternateColor(const QColor &mAlternateColor); /** Sets the background pixmap to <i>filename</i>. If the * QString is empty (QString::isEmpty()), then the background * pixmap will be disabled. */ void setBackgroundPixmap(const QString &filename); protected: /** Paints the background pixmap in the empty area. This method is needed * since Qt::FixedPixmap will not scroll with the list view. */ virtual void paintEmptyArea( QPainter * p, const QRect & rect ); virtual void contentsMousePressEvent(QMouseEvent*); void contentsMouseMoveEvent( QMouseEvent *e ); void contentsDropEvent( QDropEvent *e ); virtual bool acceptDrag(QDropEvent *e) const; protected slots: void itemDropped(QDropEvent *e); public slots: signals: void startAddresseeDrag(); void addresseeDropped(QDropEvent *); private: KAddressBookTableView *pabWidget; int oldColumn; int column; bool ascending; 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 @@ -3,65 +3,65 @@ #include <qvbox.h> #include <qlistbox.h> #include <qwidget.h> #include <qfile.h> #include <qimage.h> #include <qcombobox.h> #include <qapplication.h> #include <qdragobject.h> #include <qevent.h> #include <qurl.h> #include <qpixmap.h> #include <kabc/addressbook.h> #include <kapplication.h> #include <kconfig.h> #include <kcolorbutton.h> #include <kdebug.h> #include <kglobal.h> #include <kiconloader.h> #include <klineedit.h> #include <klocale.h> #include <kmessagebox.h> #include <kurl.h> #include <kurlrequester.h> //US#include "configuretableviewdialog.h" #include "contactlistview.h" #include "kabprefs.h" #include "undocmds.h" #include "viewmanager.h" #include <qlayout.h> - +#include <qheader.h> #include "kaddressbooktableview.h" KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : KAddressBookView( ab, parent, name ) { mainLayout = new QVBoxLayout( viewWidget(), 2 ); // The list view will be created when the config is read. mListView = 0; } KAddressBookTableView::~KAddressBookTableView() { } void KAddressBookTableView::reconstructListView() { if (mListView) { disconnect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); disconnect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); @@ -113,87 +113,98 @@ void KAddressBookTableView::reconstructListView() } void KAddressBookTableView::writeConfig(KConfig *config) { KAddressBookView::writeConfig(config); mListView->saveLayout(config, config->group()); } void KAddressBookTableView::readConfig(KConfig *config) { KAddressBookView::readConfig( config ); // The config could have changed the fields, so we need to reconstruct // the listview. reconstructListView(); // costum colors? if ( config->readBoolEntry( "EnableCustomColors", false ) ) { QPalette p( mListView->palette() ); QColor c = p.color(QPalette::Normal, QColorGroup::Base ); p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Text ); p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Button ); p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::ButtonText ); p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Highlight ); p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); - c = p.color(QPalette::Normal, QColorGroup::Base ); - p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) ); - mListView->viewport()->setPalette( p ); +#ifndef KAB_EMBEDDED + c = KGlobalSettings::alternateBackgroundColor(); +#else //KAB_EMBEDDED + c = QColor(240, 240, 240); +#endif //KAB_EMBEDDED + c = config->readColorEntry ("AlternatingBackgroundColor", &c); + mListView->setAlternateColor(c); + + + //US mListView->viewport()->setPalette( p ); + mListView->setPalette( p ); } else { // needed if turned off during a session. - mListView->viewport()->setPalette( mListView->palette() ); + //US mListView->viewport()->setPalette( mListView->palette() ); + mListView->setPalette( mListView->palette() ); } //custom fonts? QFont f( font() ); if ( config->readBoolEntry( "EnableCustomFonts", false ) ) { - // mListView->setFont( config->readFontEntry( "TextFont", &f) ); + mListView->setFont( config->readFontEntry( "TextFont", &f) ); f.setBold( true ); - // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); + //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); + mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); } else { - // mListView->setFont( f ); + mListView->setFont( f ); f.setBold( true ); - // mListView->setHeaderFont( f ); + //US mListView->setHeaderFont( f ); + mListView->header()->setFont( f ); } // Set the list view options mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", true)); mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); if (config->readBoolEntry("Background", false)) mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); // Restore the layout of the listview mListView->restoreLayout(config, config->group()); } void KAddressBookTableView::refresh(QString uid) { // For now just repopulate. In reality this method should // check the value of uid, and if valid iterate through // the listview to find the entry, then tell it to refresh. if (uid.isNull()) { // Clear the list view QString currentUID, nextUID; #ifndef KAB_EMBEDDED ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); #else //KAB_EMBEDDED ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |