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

messagelist

  • sources
  • kde-4.14
  • kdepim
  • messagelist
  • utils
aggregationeditor.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4  *
5  * This program is free softhisare; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Softhisare Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Softhisare
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  *******************************************************************************/
20 
21 #include "utils/aggregationeditor.h"
22 #include "core/aggregation.h"
23 #include "utils/comboboxutils.h"
24 
25 #include <QLabel>
26 #include <QGridLayout>
27 #include <QTreeWidget>
28 #include <QGroupBox>
29 #include <QPushButton>
30 #include <QCheckBox>
31 
32 #include <KComboBox>
33 #include <KLineEdit>
34 #include <KLocalizedString>
35 #include <KTextEdit>
36 
37 using namespace MessageList::Utils;
38 using namespace MessageList::Core;
39 
40 AggregationEditor::AggregationEditor( QWidget *parent )
41  : OptionSetEditor( parent )
42 {
43  mCurrentAggregation = 0;
44 
45  // Grouping and Threading tab
46  QWidget * tab = new QWidget( this );
47  addTab( tab, i18n( "Groups && Threading" ) );
48 
49  QGridLayout * tabg = new QGridLayout( tab );
50 
51  tabg->addWidget( new QLabel( i18n( "Grouping:" ), tab ), 0, 0 );
52  mGroupingCombo = new KComboBox( tab );
53  tabg->addWidget( mGroupingCombo, 0, 1 );
54 
55  connect( mGroupingCombo, SIGNAL(activated(int)),
56  SLOT(groupingComboActivated(int)) );
57 
58  tabg->addWidget( new QLabel( i18n( "Group expand policy:" ), tab ), 3, 0 );
59  mGroupExpandPolicyCombo = new KComboBox( tab );
60  tabg->addWidget( mGroupExpandPolicyCombo, 3, 1 );
61 
62  tabg->addWidget( new QLabel( i18n( "Threading:" ), tab ), 4, 0 );
63  mThreadingCombo = new KComboBox( tab );
64  tabg->addWidget( mThreadingCombo, 4, 1 );
65 
66  connect( mThreadingCombo, SIGNAL(activated(int)),
67  SLOT(threadingComboActivated(int)) );
68 
69  tabg->addWidget( new QLabel( i18n( "Thread leader:" ), tab ), 5, 0 );
70  mThreadLeaderCombo = new KComboBox( tab );
71  tabg->addWidget( mThreadLeaderCombo, 5, 1 );
72 
73  tabg->addWidget( new QLabel( i18n( "Thread expand policy:" ), tab ), 6, 0 );
74  mThreadExpandPolicyCombo = new KComboBox( tab );
75  tabg->addWidget( mThreadExpandPolicyCombo, 6, 1 );
76 
77  tabg->setColumnStretch( 1, 1 );
78  tabg->setRowStretch( 9, 1 );
79 
80  // Advanced tab
81  tab = new QWidget( this );
82  addTab( tab, i18nc( "@title:tab Advanced settings tab for aggregation mode", "Advanced" ) );
83 
84  tabg = new QGridLayout( tab );
85 
86  tabg->addWidget( new QLabel( i18n( "Fill view strategy:" ), tab ), 0, 0 );
87  mFillViewStrategyCombo = new KComboBox( tab );
88  tabg->addWidget( mFillViewStrategyCombo, 0, 1 );
89 
90  tabg->setColumnStretch( 1, 1 );
91  tabg->setRowStretch( 1, 1 );
92  fillGroupingCombo();
93  fillThreadingCombo();
94  fillFillViewStrategyCombo();
95 
96  fillThreadLeaderCombo();
97  fillThreadExpandPolicyCombo();
98  fillGroupExpandPolicyCombo();
99 }
100 
101 AggregationEditor::~AggregationEditor()
102 {
103 }
104 
105 void AggregationEditor::editAggregation( Aggregation *set )
106 {
107  mCurrentAggregation = set;
108 
109  if ( !mCurrentAggregation )
110  {
111  setEnabled( false );
112  return;
113  }
114  setEnabled( true );
115  nameEdit()->setText( set->name() );
116  descriptionEdit()->setText( set->description() );
117 
118  ComboBoxUtils::setIntegerOptionComboValue( mGroupingCombo, (int)mCurrentAggregation->grouping() );
119  ComboBoxUtils::setIntegerOptionComboValue( mThreadingCombo,
120  (int)mCurrentAggregation->threading() );
121  ComboBoxUtils::setIntegerOptionComboValue( mFillViewStrategyCombo,
122  (int)mCurrentAggregation->fillViewStrategy() );
123 
124  //Necessary to fill after apply mGroupingCombo/mThreadingCombo/mFillViewStrategyCombo otherwise other combo are not filled.
125  fillThreadLeaderCombo();
126  fillThreadExpandPolicyCombo();
127  fillGroupExpandPolicyCombo();
128 
129  ComboBoxUtils::setIntegerOptionComboValue( mThreadLeaderCombo,
130  (int)mCurrentAggregation->threadLeader() );
131 
132  ComboBoxUtils::setIntegerOptionComboValue( mThreadExpandPolicyCombo,
133  (int)mCurrentAggregation->threadExpandPolicy() );
134 
135  ComboBoxUtils::setIntegerOptionComboValue( mGroupExpandPolicyCombo,
136  (int)mCurrentAggregation->groupExpandPolicy() );
137  fillThreadLeaderCombo();
138  fillThreadExpandPolicyCombo();
139  fillGroupExpandPolicyCombo();
140 
141  setReadOnly( mCurrentAggregation->readOnly() );
142 }
143 
144 void AggregationEditor::setReadOnly(bool readOnly)
145 {
146  mGroupingCombo->setEnabled(!readOnly);
147  mGroupExpandPolicyCombo->setEnabled(!readOnly);
148  mThreadingCombo->setEnabled(!readOnly);
149  mThreadLeaderCombo->setEnabled(!readOnly);
150  mThreadExpandPolicyCombo->setEnabled(!readOnly);
151  mFillViewStrategyCombo->setEnabled(!readOnly);
152 
153  OptionSetEditor::setReadOnly(readOnly);
154 }
155 
156 void AggregationEditor::commit()
157 {
158  mCurrentAggregation->setName( nameEdit()->text() );
159  mCurrentAggregation->setDescription( descriptionEdit()->toPlainText() );
160 
161 
162  mCurrentAggregation->setGrouping(
163  (Aggregation::Grouping)ComboBoxUtils::getIntegerOptionComboValue( mGroupingCombo, 0 )
164  );
165 
166  mCurrentAggregation->setGroupExpandPolicy(
167  (Aggregation::GroupExpandPolicy)ComboBoxUtils::getIntegerOptionComboValue( mGroupExpandPolicyCombo, 0 )
168  );
169 
170  mCurrentAggregation->setThreading(
171  (Aggregation::Threading)ComboBoxUtils::getIntegerOptionComboValue( mThreadingCombo, 0 )
172  );
173 
174  mCurrentAggregation->setThreadLeader(
175  (Aggregation::ThreadLeader)ComboBoxUtils::getIntegerOptionComboValue( mThreadLeaderCombo, 0 )
176  );
177 
178  mCurrentAggregation->setThreadExpandPolicy(
179  (Aggregation::ThreadExpandPolicy)ComboBoxUtils::getIntegerOptionComboValue( mThreadExpandPolicyCombo, 0 )
180  );
181 
182  mCurrentAggregation->setFillViewStrategy(
183  (Aggregation::FillViewStrategy)ComboBoxUtils::getIntegerOptionComboValue( mFillViewStrategyCombo, 0 )
184  );
185 }
186 
187 void AggregationEditor::slotNameEditTextEdited( const QString &newName )
188 {
189  if( !mCurrentAggregation )
190  return;
191  mCurrentAggregation->setName( newName );
192  emit aggregationNameChanged();
193 }
194 
195 void AggregationEditor::fillGroupingCombo()
196 {
197  ComboBoxUtils::fillIntegerOptionCombo(
198  mGroupingCombo,
199  Aggregation::enumerateGroupingOptions()
200  );
201 }
202 
203 void AggregationEditor::groupingComboActivated( int )
204 {
205  fillGroupExpandPolicyCombo();
206  fillThreadLeaderCombo();
207 }
208 
209 void AggregationEditor::fillGroupExpandPolicyCombo()
210 {
211  ComboBoxUtils::fillIntegerOptionCombo(
212  mGroupExpandPolicyCombo,
213  Aggregation::enumerateGroupExpandPolicyOptions(
214  (Aggregation::Grouping) ComboBoxUtils::getIntegerOptionComboValue( mGroupingCombo, Aggregation::NoGrouping )
215  )
216  );
217 }
218 
219 void AggregationEditor::fillThreadingCombo()
220 {
221  ComboBoxUtils::fillIntegerOptionCombo(
222  mThreadingCombo,
223  Aggregation::enumerateThreadingOptions()
224  );
225 }
226 
227 void AggregationEditor::threadingComboActivated( int )
228 {
229  fillThreadLeaderCombo();
230  fillThreadExpandPolicyCombo();
231 }
232 
233 void AggregationEditor::fillThreadLeaderCombo()
234 {
235  ComboBoxUtils::fillIntegerOptionCombo(
236  mThreadLeaderCombo,
237  Aggregation::enumerateThreadLeaderOptions(
238  (Aggregation::Grouping) ComboBoxUtils::getIntegerOptionComboValue( mGroupingCombo, Aggregation::NoGrouping ),
239  (Aggregation::Threading) ComboBoxUtils::getIntegerOptionComboValue( mThreadingCombo, Aggregation::NoThreading )
240  )
241  );
242 }
243 
244 void AggregationEditor::fillThreadExpandPolicyCombo()
245 {
246  ComboBoxUtils::fillIntegerOptionCombo(
247  mThreadExpandPolicyCombo,
248  Aggregation::enumerateThreadExpandPolicyOptions(
249  (Aggregation::Threading) ComboBoxUtils::getIntegerOptionComboValue( mThreadingCombo, Aggregation::NoThreading )
250  )
251  );
252 }
253 
254 void AggregationEditor::fillFillViewStrategyCombo()
255 {
256  ComboBoxUtils::fillIntegerOptionCombo(
257  mFillViewStrategyCombo,
258  Aggregation::enumerateFillViewStrategyOptions()
259  );
260 }
261 
262 
QWidget
MessageList::Core::Aggregation
A set of aggregation options that can be applied to the MessageList::Model in a single shot...
Definition: aggregation.h:43
MessageList::Core::Aggregation::setFillViewStrategy
void setFillViewStrategy(FillViewStrategy fillViewStrategy)
Sets the current fill view strategy.
Definition: aggregation.h:272
MessageList::Core::OptionSet::setDescription
void setDescription(const QString &description)
Sets the description for this option set.
Definition: optionset.h:94
MessageList::Core::Aggregation::setGroupExpandPolicy
void setGroupExpandPolicy(GroupExpandPolicy groupExpandPolicy)
Sets the GroupExpandPolicy for the groups.
Definition: aggregation.h:188
MessageList::Utils::OptionSetEditor::setReadOnly
void setReadOnly(bool readOnly)
Definition: optionseteditor.cpp:70
MessageList::Core::Aggregation::ThreadExpandPolicy
ThreadExpandPolicy
The available thread expand policies.
Definition: aggregation.h:109
MessageList::Core::Aggregation::threadLeader
ThreadLeader threadLeader() const
Returns the current thread leader determination method.
Definition: aggregation.h:221
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
MessageList::Utils::ComboBoxUtils::setIntegerOptionComboValue
void setIntegerOptionComboValue(KComboBox *combo, int value)
Sets the currently selected option in the specified combo.
Definition: comboboxutils.cpp:59
MessageList::Core::Aggregation::grouping
Grouping grouping() const
Returns the currently set Grouping option.
Definition: aggregation.h:162
MessageList::Core::Aggregation::Threading
Threading
The available threading methods.
Definition: aggregation.h:83
MessageList::Utils::OptionSetEditor::nameEdit
KLineEdit * nameEdit() const
Returns the editor for the name of the OptionSet.
Definition: optionseteditor.cpp:81
MessageList::Core::Aggregation::threading
Threading threading() const
Returns the current threading method.
Definition: aggregation.h:202
MessageList::Core::Aggregation::FillViewStrategy
FillViewStrategy
The available fill view strategies.
Definition: aggregation.h:124
MessageList::Core::OptionSet::description
const QString & description() const
Returns a description of this option set.
Definition: optionset.h:88
QGridLayout
MessageList::Core::Aggregation::GroupExpandPolicy
GroupExpandPolicy
The available group expand policies.
Definition: aggregation.h:70
MessageList::Core::Aggregation::setThreadExpandPolicy
void setThreadExpandPolicy(ThreadExpandPolicy threadExpandPolicy)
Sets the current thread expand policy.
Definition: aggregation.h:252
MessageList::Core::OptionSet::name
const QString & name() const
Returns the name of this OptionSet.
Definition: optionset.h:72
QGridLayout::setRowStretch
void setRowStretch(int row, int stretch)
MessageList::Core::Aggregation::ThreadLeader
ThreadLeader
The available thread leading options.
Definition: aggregation.h:97
MessageList::Utils::AggregationEditor::aggregationNameChanged
void aggregationNameChanged()
This is triggered when the aggregation name changes in the editor text field.
MessageList::Core::Aggregation::setThreadLeader
void setThreadLeader(ThreadLeader tl)
Sets the current thread leader determination method.
Definition: aggregation.h:229
MessageList::Utils::OptionSetEditor
The base class for the OptionSet editors.
Definition: optionseteditor.h:45
QString
aggregation.h
MessageList::Utils::ComboBoxUtils::fillIntegerOptionCombo
void fillIntegerOptionCombo(KComboBox *combo, const QList< QPair< QString, int > > &optionDescriptors)
Fills the specified KComboBox with the options available in optionDescriptors.
Definition: comboboxutils.cpp:29
aggregationeditor.h
MessageList::Utils::OptionSetEditor::descriptionEdit
KTextEdit * descriptionEdit() const
Returns the editor for the description of the OptionSet.
Definition: optionseteditor.cpp:76
MessageList::Utils::AggregationEditor::commit
void commit()
Explicitly commits the changes in the editor to the edited Aggregation, if any.
Definition: aggregationeditor.cpp:156
MessageList::Core::OptionSet::setName
void setName(const QString &name)
Sets the name of this OptionSet.
Definition: optionset.h:80
MessageList::Core::Aggregation::groupExpandPolicy
GroupExpandPolicy groupExpandPolicy() const
Returns the current GroupExpandPolicy.
Definition: aggregation.h:181
MessageList::Core::Aggregation::setGrouping
void setGrouping(Grouping g)
Sets the Grouping option.
Definition: aggregation.h:168
comboboxutils.h
MessageList::Core::Aggregation::Grouping
Grouping
Message grouping.
Definition: aggregation.h:52
QGridLayout::setColumnStretch
void setColumnStretch(int column, int stretch)
MessageList::Core::Aggregation::setThreading
void setThreading(Threading t)
Sets the threading method option.
Definition: aggregation.h:208
KComboBox
MessageList::Core::Aggregation::fillViewStrategy
FillViewStrategy fillViewStrategy() const
Returns the current fill view strategy.
Definition: aggregation.h:266
MessageList::Utils::AggregationEditor::AggregationEditor
AggregationEditor(QWidget *parent)
Definition: aggregationeditor.cpp:40
MessageList::Core::OptionSet::readOnly
bool readOnly() const
Definition: optionset.h:118
MessageList::Utils::ComboBoxUtils::getIntegerOptionComboValue
int getIntegerOptionComboValue(KComboBox *combo, int defaultValue)
Returns the identifier of the currently selected option in the specified combo.
Definition: comboboxutils.cpp:71
MessageList::Utils::AggregationEditor::~AggregationEditor
~AggregationEditor()
Definition: aggregationeditor.cpp:101
MessageList::Utils::AggregationEditor::editAggregation
void editAggregation(Core::Aggregation *set)
Sets the Aggregation to be edited.
Definition: aggregationeditor.cpp:105
QLabel
MessageList::Core::Aggregation::threadExpandPolicy
ThreadExpandPolicy threadExpandPolicy() const
Returns the current thread expand policy.
Definition: aggregation.h:244
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:01 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
  • 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