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

kontact

  • sources
  • kde-4.14
  • kdepim
  • kontact
  • plugins
  • kmail
kcmkmailsummary.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5  Copyright (C) 2013-2015 Laurent Montel <montel@kde.org>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "kcmkmailsummary.h"
27 
28 #include "pimcommon/folderdialog/checkedcollectionwidget.h"
29 
30 #include <Akonadi/ETMViewStateSaver>
31 #include <KMime/KMimeMessage>
32 
33 #include <KAboutData>
34 #include <KAcceleratorManager>
35 #include <KCheckableProxyModel>
36 #include <KComponentData>
37 #include <KDebug>
38 #include <KDialog>
39 #include <KLocalizedString>
40 #include <KLineEdit>
41 
42 #include <QCheckBox>
43 #include <QTreeView>
44 #include <QVBoxLayout>
45 
46 extern "C"
47 {
48 KDE_EXPORT KCModule *create_kmailsummary( QWidget *parent, const char * )
49 {
50  KComponentData inst( "kcmkmailsummary" );
51  return new KCMKMailSummary( inst, parent );
52 }
53 }
54 
55 KCMKMailSummary::KCMKMailSummary( const KComponentData &inst, QWidget *parent )
56  : KCModule( inst, parent )
57 {
58  initGUI();
59 
60  connect( mCheckedCollectionWidget->folderTreeView(), SIGNAL(clicked(QModelIndex)),
61  SLOT(modified()) );
62  connect( mFullPath, SIGNAL(toggled(bool)), SLOT(modified()) );
63 
64  KAcceleratorManager::manage( this );
65 
66  load();
67 
68  KAboutData *about =
69  new KAboutData( I18N_NOOP( "kcmkmailsummary" ), 0,
70  ki18n( "Mail Summary Configuration Dialog" ),
71  0, KLocalizedString(), KAboutData::License_GPL,
72  ki18n( "Copyright © 2004–2010 Tobias Koenig" ) );
73 
74  about->addAuthor( ki18n( "Tobias Koenig" ),
75  KLocalizedString(), "tokoe@kde.org" );
76  setAboutData( about );
77 }
78 
79 void KCMKMailSummary::modified()
80 {
81  emit changed( true );
82 }
83 
84 void KCMKMailSummary::initGUI()
85 {
86  QVBoxLayout *layout = new QVBoxLayout( this );
87  layout->setSpacing( KDialog::spacingHint() );
88  layout->setMargin( 0 );
89 
90  mCheckedCollectionWidget = new PimCommon::CheckedCollectionWidget(KMime::Message::mimeType());
91 
92  mFullPath = new QCheckBox( i18n( "Show full path for folders" ), this );
93  mFullPath->setToolTip(
94  i18nc( "@info:tooltip", "Show full path for each folder" ) );
95  mFullPath->setWhatsThis(
96  i18nc( "@info:whatsthis",
97  "Enable this option if you want to see the full path "
98  "for each folder listed in the summary. If this option is "
99  "not enabled, then only the base folder path will be shown." ) );
100  layout->addWidget( mCheckedCollectionWidget );
101  layout->addWidget( mFullPath );
102 }
103 
104 void KCMKMailSummary::initFolders()
105 {
106  KSharedConfigPtr _config = KSharedConfig::openConfig( QLatin1String("kcmkmailsummaryrc") );
107 
108  mModelState =
109  new KViewStateMaintainer<Akonadi::ETMViewStateSaver>( _config->group( "CheckState" ), this );
110  mModelState->setSelectionModel( mCheckedCollectionWidget->selectionModel() );
111 }
112 
113 void KCMKMailSummary::loadFolders()
114 {
115  KConfig _config( QLatin1String("kcmkmailsummaryrc") );
116  KConfigGroup config(&_config, "General" );
117  mModelState->restoreState();
118  const bool showFolderPaths = config.readEntry( "showFolderPaths", false );
119  mFullPath->setChecked( showFolderPaths );
120 }
121 
122 void KCMKMailSummary::storeFolders()
123 {
124  KConfig _config( QLatin1String("kcmkmailsummaryrc") );
125  KConfigGroup config(&_config, "General" );
126  mModelState->saveState();
127  config.writeEntry( "showFolderPaths", mFullPath->isChecked() );
128  config.sync();
129 }
130 
131 void KCMKMailSummary::load()
132 {
133  initFolders();
134  loadFolders();
135 
136  emit changed( false );
137 }
138 
139 void KCMKMailSummary::save()
140 {
141  storeFolders();
142 
143  emit changed( false );
144 }
145 
146 void KCMKMailSummary::defaults()
147 {
148  mFullPath->setChecked( true );
149 
150  emit changed( true );
151 }
152 
QModelIndex
KCMKMailSummary
Definition: kcmkmailsummary.h:42
QWidget
create_kmailsummary
KCModule * create_kmailsummary(QWidget *parent, const char *)
Definition: kcmkmailsummary.cpp:48
KCMKMailSummary::load
virtual void load()
Definition: kcmkmailsummary.cpp:131
KCMKMailSummary::KCMKMailSummary
KCMKMailSummary(const KComponentData &inst, QWidget *parent=0)
Definition: kcmkmailsummary.cpp:55
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
KCMKMailSummary::save
virtual void save()
Definition: kcmkmailsummary.cpp:139
QCheckBox
QVBoxLayout
kcmkmailsummary.h
QLayout::setMargin
void setMargin(int margin)
QAbstractButton::setChecked
void setChecked(bool)
KCMKMailSummary::defaults
virtual void defaults()
Definition: kcmkmailsummary.cpp:146
QWidget::setWhatsThis
void setWhatsThis(const QString &)
QLatin1String
QWidget::setToolTip
void setToolTip(const QString &)
KCModule
QBoxLayout::setSpacing
void setSpacing(int spacing)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • 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
  • pimprint

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