Akonadi

tagmanagementdialog.cpp
1 /*
2  This file is part of Akonadi
3 
4  Copyright (c) 2014 Christian Mollekopf <[email protected]>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "tagmanagementdialog.h"
23 #include "ui_tagmanagementdialog.h"
24 
25 #include "tagmodel.h"
26 #include "monitor.h"
27 #include "controlgui.h"
28 
29 #include <KLocalizedString>
30 #include <KSharedConfig>
31 #include <KConfigGroup>
32 
33 using namespace Akonadi;
34 
35 struct Q_DECL_HIDDEN TagManagementDialog::Private {
36  Private(QDialog *parent)
37  : d(parent)
38  {}
39 
40  ~Private()
41  {
42  writeConfig();
43  }
44 
45  void writeConfig();
46  void readConfig();
47 
48  Ui::TagManagementDialog ui;
49  QDialog * const d = nullptr;
50  QDialogButtonBox *buttonBox = nullptr;
51 };
52 
53 void TagManagementDialog::Private::writeConfig()
54 {
55  KConfigGroup group(KSharedConfig::openConfig(), "TagManagementDialog");
56  group.writeEntry("Size", d->size());
57 }
58 
59 void TagManagementDialog::Private::readConfig()
60 {
61  KConfigGroup group(KSharedConfig::openConfig(), "TagManagementDialog");
62  const QSize sizeDialog = group.readEntry("Size", QSize(500, 400));
63  if (sizeDialog.isValid()) {
64  d->resize(sizeDialog);
65  }
66 }
67 
68 TagManagementDialog::TagManagementDialog(QWidget *parent)
69  : QDialog(parent)
70  , d(new Private(this))
71 {
72  Monitor *monitor = new Monitor(this);
73  monitor->setObjectName(QStringLiteral("TagManagementDialogMonitor"));
74  monitor->setTypeMonitored(Monitor::Tags);
75 
76  d->ui.setupUi(this);
77  d->ui.tagEditWidget->setModel(new TagModel(monitor, this));
78  d->ui.tagEditWidget->setSelectionEnabled(false);
79 
80  d->readConfig();
81 
83 }
84 
85 TagManagementDialog::~TagManagementDialog() = default;
86 
87 QDialogButtonBox *TagManagementDialog::buttons() const
88 {
89  return d->buttonBox;
90 }
91 
bool isValid() const const
A dialog to manage tags.
static void widgetNeedsAkonadi(QWidget *widget)
Disable the given widget when Akonadi is not operational and show an error overlay (given enough spac...
Definition: controlgui.cpp:266
void setObjectName(const QString &name)
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
void setTypeMonitored(Type type, bool monitored=true)
Sets whether given type (Collection, Item, Tag should be monitored).
Definition: monitor.cpp:149
Monitors an item or collection for changes.
Definition: monitor.h:84
void readConfig()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 22:46:12 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.