Messagelib

aggregationeditor.cpp
1/******************************************************************************
2 *
3 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 *
7 *******************************************************************************/
8
9#include "utils/aggregationeditor.h"
10#include "core/aggregation.h"
11#include "utils/comboboxutils.h"
12
13#include <KTextEdit>
14#include <QCheckBox>
15#include <QGridLayout>
16#include <QLabel>
17#include <QLineEdit>
18#include <QPushButton>
19
20#include <KLocalizedString>
21#include <QComboBox>
22
23using namespace MessageList::Utils;
24using namespace MessageList::Core;
25
26AggregationEditor::AggregationEditor(QWidget *parent)
27 : OptionSetEditor(parent)
28{
29 // Grouping and Threading tab
30 auto tab = new QWidget(this);
31 addTab(tab, i18n("Groups && Threading"));
32
33 auto tabg = new QGridLayout(tab);
34
35 tabg->addWidget(new QLabel(i18nc("@label:textbox", "Grouping:"), tab), 0, 0);
36 mGroupingCombo = new QComboBox(tab);
37 tabg->addWidget(mGroupingCombo, 0, 1);
38
39 connect(mGroupingCombo, &QComboBox::activated, this, &AggregationEditor::groupingComboActivated);
40
41 tabg->addWidget(new QLabel(i18nc("@label:textbox", "Group expand policy:"), tab), 3, 0);
42 mGroupExpandPolicyCombo = new QComboBox(tab);
43 tabg->addWidget(mGroupExpandPolicyCombo, 3, 1);
44
45 tabg->addWidget(new QLabel(i18nc("@label:textbox", "Threading:"), tab), 4, 0);
46 mThreadingCombo = new QComboBox(tab);
47 tabg->addWidget(mThreadingCombo, 4, 1);
48
49 connect(mThreadingCombo, &QComboBox::activated, this, &AggregationEditor::threadingComboActivated);
50
51 tabg->addWidget(new QLabel(i18nc("@label:textbox", "Thread leader:"), tab), 5, 0);
52 mThreadLeaderCombo = new QComboBox(tab);
53 tabg->addWidget(mThreadLeaderCombo, 5, 1);
54
55 tabg->addWidget(new QLabel(i18nc("@label:textbox", "Thread expand policy:"), tab), 6, 0);
56 mThreadExpandPolicyCombo = new QComboBox(tab);
57 tabg->addWidget(mThreadExpandPolicyCombo, 6, 1);
58
59 tabg->setColumnStretch(1, 1);
60 tabg->setRowStretch(9, 1);
61
62 // Advanced tab
63 tab = new QWidget(this);
64 addTab(tab, i18nc("@title:tab Advanced settings tab for aggregation mode", "Advanced"));
65
66 tabg = new QGridLayout(tab);
67
68 tabg->addWidget(new QLabel(i18nc("@label:textbox", "Fill view strategy:"), tab), 0, 0);
69 mFillViewStrategyCombo = new QComboBox(tab);
70 tabg->addWidget(mFillViewStrategyCombo, 0, 1);
71
72 tabg->setColumnStretch(1, 1);
73 tabg->setRowStretch(1, 1);
74 fillGroupingCombo();
75 fillThreadingCombo();
76 fillFillViewStrategyCombo();
77
78 fillThreadLeaderCombo();
79 fillThreadExpandPolicyCombo();
80 fillGroupExpandPolicyCombo();
81}
82
83AggregationEditor::~AggregationEditor() = default;
84
86{
87 mCurrentAggregation = set;
88
89 if (!mCurrentAggregation) {
90 setEnabled(false);
91 return;
92 }
93 setEnabled(true);
94 nameEdit()->setText(set->name());
96
97 ComboBoxUtils::setIntegerOptionComboValue(mGroupingCombo, (int)mCurrentAggregation->grouping());
98 ComboBoxUtils::setIntegerOptionComboValue(mThreadingCombo, (int)mCurrentAggregation->threading());
99 ComboBoxUtils::setIntegerOptionComboValue(mFillViewStrategyCombo, (int)mCurrentAggregation->fillViewStrategy());
100
101 // Necessary to fill after apply mGroupingCombo/mThreadingCombo/mFillViewStrategyCombo otherwise other combo are not filled.
102 fillThreadLeaderCombo();
103 fillThreadExpandPolicyCombo();
104 fillGroupExpandPolicyCombo();
105
106 ComboBoxUtils::setIntegerOptionComboValue(mThreadLeaderCombo, (int)mCurrentAggregation->threadLeader());
107
108 ComboBoxUtils::setIntegerOptionComboValue(mThreadExpandPolicyCombo, (int)mCurrentAggregation->threadExpandPolicy());
109
110 ComboBoxUtils::setIntegerOptionComboValue(mGroupExpandPolicyCombo, (int)mCurrentAggregation->groupExpandPolicy());
111 fillThreadLeaderCombo();
112 fillThreadExpandPolicyCombo();
113 fillGroupExpandPolicyCombo();
114
115 setReadOnly(mCurrentAggregation->readOnly());
116}
117
118void AggregationEditor::setReadOnly(bool readOnly)
119{
120 mGroupingCombo->setEnabled(!readOnly);
121 mGroupExpandPolicyCombo->setEnabled(!readOnly);
122 mThreadingCombo->setEnabled(!readOnly);
123 mThreadLeaderCombo->setEnabled(!readOnly);
124 mThreadExpandPolicyCombo->setEnabled(!readOnly);
125 mFillViewStrategyCombo->setEnabled(!readOnly);
126
127 OptionSetEditor::setReadOnly(readOnly);
128}
129
131{
132 mCurrentAggregation->setName(nameEdit()->text());
133 mCurrentAggregation->setDescription(descriptionEdit()->toPlainText());
134
135 mCurrentAggregation->setGrouping(static_cast<Aggregation::Grouping>(ComboBoxUtils::getIntegerOptionComboValue(mGroupingCombo, 0)));
136
137 mCurrentAggregation->setGroupExpandPolicy(
138 static_cast<Aggregation::GroupExpandPolicy>(ComboBoxUtils::getIntegerOptionComboValue(mGroupExpandPolicyCombo, 0)));
139
140 mCurrentAggregation->setThreading(static_cast<Aggregation::Threading>(ComboBoxUtils::getIntegerOptionComboValue(mThreadingCombo, 0)));
141
142 mCurrentAggregation->setThreadLeader(static_cast<Aggregation::ThreadLeader>(ComboBoxUtils::getIntegerOptionComboValue(mThreadLeaderCombo, 0)));
143
144 mCurrentAggregation->setThreadExpandPolicy(
145 static_cast<Aggregation::ThreadExpandPolicy>(ComboBoxUtils::getIntegerOptionComboValue(mThreadExpandPolicyCombo, 0)));
146
147 mCurrentAggregation->setFillViewStrategy(static_cast<Aggregation::FillViewStrategy>(ComboBoxUtils::getIntegerOptionComboValue(mFillViewStrategyCombo, 0)));
148}
149
150void AggregationEditor::slotNameEditTextEdited(const QString &newName)
151{
152 if (!mCurrentAggregation) {
153 return;
154 }
155 mCurrentAggregation->setName(newName);
157}
158
159void AggregationEditor::fillGroupingCombo()
160{
162}
163
164void AggregationEditor::groupingComboActivated(int)
165{
166 fillGroupExpandPolicyCombo();
167 fillThreadLeaderCombo();
168}
169
170void AggregationEditor::fillGroupExpandPolicyCombo()
171{
172 ComboBoxUtils::fillIntegerOptionCombo(mGroupExpandPolicyCombo,
175}
176
177void AggregationEditor::fillThreadingCombo()
178{
180}
181
182void AggregationEditor::threadingComboActivated(int)
183{
184 fillThreadLeaderCombo();
185 fillThreadExpandPolicyCombo();
186}
187
188void AggregationEditor::fillThreadLeaderCombo()
189{
190 ComboBoxUtils::fillIntegerOptionCombo(mThreadLeaderCombo,
194}
195
196void AggregationEditor::fillThreadExpandPolicyCombo()
197{
198 ComboBoxUtils::fillIntegerOptionCombo(mThreadExpandPolicyCombo,
201}
202
203void AggregationEditor::fillFillViewStrategyCombo()
204{
206}
207
208#include "moc_aggregationeditor.cpp"
A set of aggregation options that can be applied to the MessageList::Model in a single shot.
Definition aggregation.h:29
FillViewStrategy fillViewStrategy() const
Returns the current fill view strategy.
@ NoGrouping
Don't group messages at all.
Definition aggregation.h:37
GroupExpandPolicy
The available group expand policies.
Definition aggregation.h:53
void setThreadLeader(ThreadLeader tl)
Sets the current thread leader determination method.
static QList< QPair< QString, int > > enumerateGroupExpandPolicyOptions(Grouping g)
Enumerates the group sort direction options compatible with the specified Grouping.
void setGrouping(Grouping g)
Sets the Grouping option.
Threading
The available threading methods.
Definition aggregation.h:65
@ NoThreading
Perform no threading at all.
Definition aggregation.h:66
void setThreadExpandPolicy(ThreadExpandPolicy threadExpandPolicy)
Sets the current thread expand policy.
void setFillViewStrategy(FillViewStrategy fillViewStrategy)
Sets the current fill view strategy.
static QList< QPair< QString, int > > enumerateGroupingOptions()
Enumerates the available grouping options as a QList of pairs in that the first item is the localized...
static QList< QPair< QString, int > > enumerateFillViewStrategyOptions()
Enumerates the fill view strategies.
void setThreading(Threading t)
Sets the threading method option.
Grouping grouping() const
Returns the currently set Grouping option.
ThreadExpandPolicy threadExpandPolicy() const
Returns the current thread expand policy.
Threading threading() const
Returns the current threading method.
static QList< QPair< QString, int > > enumerateThreadExpandPolicyOptions(Threading t)
Enumerates the thread expand policies compatible with the specified Threading option.
static QList< QPair< QString, int > > enumerateThreadLeaderOptions(Grouping g, Threading t)
Enumerates the thread leader determination methods compatible with the specified Threading and the sp...
GroupExpandPolicy groupExpandPolicy() const
Returns the current GroupExpandPolicy.
ThreadExpandPolicy
The available thread expand policies.
Definition aggregation.h:90
ThreadLeader
The available thread leading options.
Definition aggregation.h:78
static QList< QPair< QString, int > > enumerateThreadingOptions()
Enumerates the available threading method options.
FillViewStrategy
The available fill view strategies.
ThreadLeader threadLeader() const
Returns the current thread leader determination method.
void setGroupExpandPolicy(GroupExpandPolicy groupExpandPolicy)
Sets the GroupExpandPolicy for the groups.
const QString & description() const
Returns a description of this option set.
Definition optionset.h:79
void setName(const QString &name)
Sets the name of this OptionSet.
Definition optionset.h:69
const QString & name() const
Returns the name of this OptionSet.
Definition optionset.h:59
void setDescription(const QString &description)
Sets the description for this option set.
Definition optionset.h:87
void editAggregation(Core::Aggregation *set)
Sets the Aggregation to be edited.
void aggregationNameChanged()
This is triggered when the aggregation name changes in the editor text field.
void commit()
Explicitly commits the changes in the editor to the edited Aggregation, if any.
The base class for the OptionSet editors.
QLineEdit * nameEdit() const
Returns the editor for the name of the OptionSet.
KTextEdit * descriptionEdit() const
Returns the editor for the description of the OptionSet.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
The implementation independent part of the MessageList library.
Definition aggregation.h:22
void fillIntegerOptionCombo(QComboBox *combo, const QList< QPair< QString, int > > &optionDescriptors)
Fills the specified QComboBox with the options available in optionDescriptors.
void setIntegerOptionComboValue(QComboBox *combo, int value)
Sets the currently selected option in the specified combo.
int getIntegerOptionComboValue(QComboBox *combo, int defaultValue)
Returns the identifier of the currently selected option in the specified combo.
void activated(int index)
void setText(const QString &)
Q_EMITQ_EMIT
void setText(const QString &text)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setEnabled(bool)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.