Astyle kdelibs
[kdepim.git] / akonadiconsole / agentconfigdialog.cpp
blobd4f10e893c5cd86e31add729c72acc2150df5f45
1 /*
2 Copyright (c) 2010 Volker Krause <vkrause@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 USA.
20 #include "agentconfigdialog.h"
21 #include "agentconfigmodel.h"
22 #include <KLocalizedString>
23 #include <QIcon>
24 #include <KConfigGroup>
25 #include <QDialogButtonBox>
26 #include <QPushButton>
27 #include <KGuiItem>
28 #include <QVBoxLayout>
30 AgentConfigDialog::AgentConfigDialog(QWidget *parent) :
31 QDialog(parent),
32 m_model(new AgentConfigModel(this))
34 QWidget *mainWidget = new QWidget(this);
35 QVBoxLayout *mainLayout = new QVBoxLayout;
36 setLayout(mainLayout);
37 mainLayout->addWidget(mainWidget);
38 ui.setupUi(mainWidget);
39 ui.propertyView->setModel(m_model);
41 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close | QDialogButtonBox::Apply);
42 QPushButton *user1Button = new QPushButton;
43 buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
44 QPushButton *user2Button = new QPushButton;
45 buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
46 connect(buttonBox, &QDialogButtonBox::accepted, this, &AgentConfigDialog::accept);
47 connect(buttonBox, &QDialogButtonBox::rejected, this, &AgentConfigDialog::reject);
48 mainLayout->addWidget(buttonBox);
49 KGuiItem::assign(user1Button, KGuiItem(QStringLiteral("Save Configuration")));
50 KGuiItem::assign(user2Button, KGuiItem(QStringLiteral("Refresh")));
51 buttonBox->button(QDialogButtonBox::Apply)->setText(QStringLiteral("Apply Configuration"));
53 setWindowTitle(QStringLiteral("Agent Configuration"));
55 connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &AgentConfigDialog::reconfigure);
56 connect(user1Button, &QPushButton::clicked, m_model, &AgentConfigModel::writeConfig);
57 connect(user2Button, &QPushButton::clicked, m_model, &AgentConfigModel::reload);
60 void AgentConfigDialog::setAgentInstance(const Akonadi::AgentInstance &instance)
62 m_instance = instance;
63 m_model->setAgentInstance(instance);
66 void AgentConfigDialog::reconfigure()
68 m_instance.reconfigure();