Akonadi

tagmanagementdialog.cpp
1/*
2 This file is part of Akonadi
3
4 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "tagmanagementdialog.h"
10#include "ui_tagmanagementdialog.h"
11
12#include "controlgui.h"
13#include "monitor.h"
14#include "tagmodel.h"
15
16#include <KConfigGroup>
17#include <KLocalizedString>
18#include <KSharedConfig>
19
20using namespace Akonadi;
21namespace
22{
23static const char myTagManagementDialogGroupName[] = "TagManagementDialog";
24}
25class Akonadi::TagManagementDialogPrivate
26{
27public:
28 explicit TagManagementDialogPrivate(QDialog *parent)
29 : q(parent)
30 {
31 }
32
33 void writeConfig() const;
34 void readConfig() const;
35
36 Ui::TagManagementDialog ui;
37 QDialog *const q;
38 QDialogButtonBox *buttonBox = nullptr;
39};
40
41void TagManagementDialogPrivate::writeConfig() const
42{
43 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myTagManagementDialogGroupName));
44 group.writeEntry("Size", q->size());
45}
46
47void TagManagementDialogPrivate::readConfig() const
48{
49 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myTagManagementDialogGroupName));
50 const QSize sizeDialog = group.readEntry("Size", QSize(500, 400));
51 if (sizeDialog.isValid()) {
52 q->resize(sizeDialog);
53 }
54}
55
56TagManagementDialog::TagManagementDialog(QWidget *parent)
57 : QDialog(parent)
58 , d(new TagManagementDialogPrivate(this))
59{
60 auto monitor = new Monitor(this);
61 monitor->setObjectName(QLatin1StringView("TagManagementDialogMonitor"));
62 monitor->setTypeMonitored(Monitor::Tags);
63
64 d->ui.setupUi(this);
65 d->ui.tagEditWidget->setModel(new TagModel(monitor, this));
66 d->ui.tagEditWidget->setSelectionEnabled(false);
67
68 d->readConfig();
69
71}
72
73TagManagementDialog::~TagManagementDialog()
74{
75 d->writeConfig();
76}
77
78QDialogButtonBox *TagManagementDialog::buttons() const
79{
80 return d->buttonBox;
81}
82
83#include "moc_tagmanagementdialog.cpp"
static void widgetNeedsAkonadi(QWidget *widget)
Disable the given widget when Akonadi is not operational and show an error overlay (given enough spac...
Monitors an item or collection for changes.
Definition monitor.h:71
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
Helper integration between Akonadi and Qt.
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.