• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messagelist

  • sources
  • kde-4.12
  • kdepim
  • messagelist
  • utils
themecombobox.cpp
Go to the documentation of this file.
1 /* Copyright 2009 James Bendig <james@imptalk.com>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of
6  the License or (at your option) version 3 or any later version
7  accepted by the membership of KDE e.V. (or its successor approved
8  by the membership of KDE e.V.), which shall act as a proxy
9  defined in Section 14 of version 3 of the license.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "themecombobox.h"
20 
21 #include "messagelist/utils/themecombobox.h"
22 #include "messagelist/utils/themecombobox_p.h"
23 #include "messagelist/storagemodel.h"
24 #include "messagelist/core/manager.h"
25 #include "messagelist/core/theme.h"
26 #include "messagelist/core/settings.h"
27 
28 #include <KDE/KGlobal>
29 
30 using namespace MessageList::Core;
31 using namespace MessageList::Utils;
32 
33 ThemeComboBox::ThemeComboBox( QWidget * parent )
34 : KComboBox( parent ), d( new ThemeComboBoxPrivate( this ) )
35 {
36  if( Manager::instance() )
37  d->slotLoadThemes();
38  else
39  setEnabled(false);
40 }
41 
42 ThemeComboBox::~ThemeComboBox()
43 {
44  delete d;
45 }
46 
47 QString ThemeComboBox::currentTheme() const
48 {
49  return itemData( currentIndex() ).toString();
50 }
51 
52 void ThemeComboBox::writeDefaultConfig() const
53 {
54  KConfigGroup group( Settings::self()->config(), "MessageListView::StorageModelThemes" );
55 
56  const QString themeID = currentTheme();
57  group.writeEntry( QLatin1String( "DefaultSet" ), themeID );
58 
59  Manager::instance()->themesConfigurationCompleted();
60 }
61 
62 void ThemeComboBox::writeStorageModelConfig( const Akonadi::Collection &col, bool isPrivateSetting ) const
63 {
64  if ( col.isValid() )
65  writeStorageModelConfig( QString::number( col.id() ), isPrivateSetting );
66 }
67 
68 void ThemeComboBox::writeStorageModelConfig( MessageList::Core::StorageModel *storageModel, bool isPrivateSetting ) const
69 {
70  writeStorageModelConfig( storageModel->id(), isPrivateSetting );
71 }
72 
73 void ThemeComboBox::writeStorageModelConfig( const QString &id, bool isPrivateSetting )const
74 {
75  QString themeID;
76  if ( isPrivateSetting ) {
77  themeID = currentTheme();
78  } else { // explicitly use default theme id when using default theme.
79  themeID = Manager::instance()->defaultTheme()->id();
80  }
81  Manager::instance()->saveThemeForStorageModel( id, themeID, isPrivateSetting );
82  Manager::instance()->themesConfigurationCompleted();
83 }
84 
85 
86 void ThemeComboBox::readStorageModelConfig( const Akonadi::Collection& col, bool &isPrivateSetting )
87 {
88  const Theme *theme = Manager::instance()->themeForStorageModel( col, &isPrivateSetting );
89  d->setCurrentTheme( theme );
90 
91 }
92 
93 void ThemeComboBox::readStorageModelConfig( MessageList::Core::StorageModel *storageModel, bool &isPrivateSetting )
94 {
95  const Theme *theme = Manager::instance()->themeForStorageModel( storageModel, &isPrivateSetting );
96  d->setCurrentTheme( theme );
97 }
98 
99 void ThemeComboBox::selectDefault()
100 {
101  const Theme *defaultTheme = Manager::instance()->defaultTheme();
102  d->setCurrentTheme( defaultTheme );
103 }
104 
105 void ThemeComboBoxPrivate::slotLoadThemes()
106 {
107  q->clear();
108 
109  // Get all message list themes and sort them into alphabetical order.
110  QList< Theme * > themes = Manager::instance()->themes().values();
111  qSort( themes.begin(), themes.end(), MessageList::Core::Theme::compareName );
112 
113  foreach( const Theme * theme, themes )
114  {
115  q->addItem( theme->name(), QVariant( theme->id() ) );
116  }
117 }
118 
119 void ThemeComboBoxPrivate::setCurrentTheme( const Theme *theme )
120 {
121  Q_ASSERT( theme != 0 );
122 
123  const QString themeID = theme->id();
124  const int themeIndex = q->findData( QVariant( themeID ) );
125  q->setCurrentIndex( themeIndex );
126 }
127 
128 #include "themecombobox.moc"
themecombobox_p.h
MessageList::Core::OptionSet::id
const QString & id() const
Returns the unique id of this OptionSet.
Definition: optionset.h:66
MessageList::Utils::ThemeComboBox::currentTheme
QString currentTheme() const
Definition: themecombobox.cpp:47
MessageList::Core::StorageModel::id
virtual QString id() const =0
Returns an unique id for this Storage collection.
QWidget
MessageList::Utils::ThemeComboBoxPrivate::q
ThemeComboBox *const q
Definition: themecombobox_p.h:44
theme.h
themecombobox.h
MessageList::Core::OptionSet::name
const QString & name() const
Returns the name of this OptionSet.
Definition: optionset.h:72
storagemodel.h
MessageList::Utils::ThemeComboBoxPrivate::setCurrentTheme
void setCurrentTheme(const Core::Theme *theme)
Definition: themecombobox.cpp:119
MessageList::Utils::ThemeComboBoxPrivate
Definition: themecombobox_p.h:38
manager.h
MessageList::Utils::ThemeComboBox::writeDefaultConfig
void writeDefaultConfig() const
Definition: themecombobox.cpp:52
MessageList::Core::StorageModel
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
Definition: storagemodelbase.h:45
settings.h
MessageList::Utils::ThemeComboBox::writeStorageModelConfig
void writeStorageModelConfig(MessageList::Core::StorageModel *storageModel, bool isPrivateSetting) const
Definition: themecombobox.cpp:68
MessageList::Core::Theme::compareName
static bool compareName(Theme *theme1, Theme *theme2)
Definition: theme.h:872
KComboBox
MessageList::Core::Theme
The Theme class defines the visual appearance of the MessageList.
Definition: theme.h:65
MessageList::Utils::ThemeComboBox::readStorageModelConfig
void readStorageModelConfig(const Akonadi::Collection &col, bool &isPrivateSetting)
Definition: themecombobox.cpp:86
MessageList::Utils::ThemeComboBox::~ThemeComboBox
~ThemeComboBox()
Definition: themecombobox.cpp:42
MessageList::Utils::ThemeComboBoxPrivate::slotLoadThemes
void slotLoadThemes()
Refresh list of themes in the combobox.
Definition: themecombobox.cpp:105
MessageList::Utils::ThemeComboBox::selectDefault
void selectDefault()
Definition: themecombobox.cpp:99
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messagelist

Skip menu "messagelist"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal