Fix correct signal/slot
[kdepim.git] / sieveeditor / sieveeditorscriptmanagerwidget.cpp
blob6d5db8551bf5395bfb8389c761fdffc2ddbc7109
1 /*
2 Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
21 #include "sieveeditorscriptmanagerwidget.h"
22 #include "sieveeditormanagesievewidget.h"
24 #include <QHBoxLayout>
25 #include <QTreeWidget>
27 SieveEditorScriptManagerWidget::SieveEditorScriptManagerWidget(QWidget *parent)
28 : QWidget(parent)
30 QHBoxLayout *hbox = new QHBoxLayout;
31 setLayout(hbox);
32 mTreeView = new SieveEditorManageSieveWidget;
33 connect(mTreeView, &SieveEditorManageSieveWidget::newScript, this, &SieveEditorScriptManagerWidget::slotNewScript);
34 connect(mTreeView, &SieveEditorManageSieveWidget::editScript, this, &SieveEditorScriptManagerWidget::slotEditScript);
35 connect(mTreeView, &SieveEditorManageSieveWidget::updateButtons, this, &SieveEditorScriptManagerWidget::slotUpdateButtons);
36 connect(mTreeView, &SieveEditorManageSieveWidget::scriptDeleted, this, &SieveEditorScriptManagerWidget::scriptDeleted);
37 connect(mTreeView, &SieveEditorManageSieveWidget::serverSieveFound, this, &SieveEditorScriptManagerWidget::serverSieveFound);
38 hbox->addWidget(mTreeView);
41 SieveEditorScriptManagerWidget::~SieveEditorScriptManagerWidget()
46 void SieveEditorScriptManagerWidget::slotUpdateButtons(QTreeWidgetItem *item)
48 Q_UNUSED(item);
49 bool newScriptAction;
50 bool editScriptAction;
51 bool deleteScriptAction;
52 bool desactivateScriptAction;
53 mTreeView->enableDisableActions(newScriptAction, editScriptAction, deleteScriptAction, desactivateScriptAction);
54 Q_EMIT updateButtons(newScriptAction, editScriptAction, deleteScriptAction, desactivateScriptAction);
57 void SieveEditorScriptManagerWidget::slotEditScript(const QUrl &url, const QStringList &capabilities)
59 Q_EMIT createScriptPage(url, capabilities, false);
62 void SieveEditorScriptManagerWidget::slotNewScript(const QUrl &url, const QStringList &capabilities)
64 Q_EMIT createScriptPage(url, capabilities, true);
67 void SieveEditorScriptManagerWidget::slotCreateNewScript()
69 mTreeView->slotNewScript();
72 void SieveEditorScriptManagerWidget::slotDeleteScript()
74 mTreeView->slotDeleteScript();
77 void SieveEditorScriptManagerWidget::slotRefreshList()
79 updateServerList();
82 void SieveEditorScriptManagerWidget::updateServerList()
84 mTreeView->slotRefresh();
87 void SieveEditorScriptManagerWidget::editScript()
89 mTreeView->slotEditScript();
92 void SieveEditorScriptManagerWidget::desactivateScript()
94 mTreeView->slotDeactivateScript();
97 void SieveEditorScriptManagerWidget::refreshList()
99 mTreeView->slotRefresh();