filternamedialog.cpp 1.39 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
2
3
4
5
6
7
/*
  SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>

  SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "filternamedialog.h"
Laurent Montel's avatar
Laurent Montel committed
8
#include "filternamewidget.h"
Laurent Montel's avatar
Laurent Montel committed
9
10
#include <KLocalizedString>
#include <QDialogButtonBox>
Laurent Montel's avatar
Laurent Montel committed
11
#include <QPushButton>
Laurent Montel's avatar
Laurent Montel committed
12
13
14
15
16
#include <QVBoxLayout>

using namespace MessageList::Core;
FilterNameDialog::FilterNameDialog(QWidget *parent)
    : QDialog(parent)
Laurent Montel's avatar
Laurent Montel committed
17
    , mFilterNameWidget(new FilterNameWidget(this))
Laurent Montel's avatar
Laurent Montel committed
18
{
Laurent Montel's avatar
Laurent Montel committed
19
20
21
22
23
24
25
26
27
28
    auto mainLayout = new QVBoxLayout(this);
    mainLayout->setObjectName(QStringLiteral("mainLayout"));

    mFilterNameWidget->setObjectName(QStringLiteral("mFilterNameWidget"));
    mainLayout->addWidget(mFilterNameWidget);

    auto button = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
    mainLayout->addWidget(button);
    connect(button, &QDialogButtonBox::accepted, this, &FilterNameDialog::accept);
    connect(button, &QDialogButtonBox::rejected, this, &FilterNameDialog::reject);
Laurent Montel's avatar
Laurent Montel committed
29
30
31
    auto okButton = button->button(QDialogButtonBox::Ok);
    okButton->setEnabled(false);
    connect(mFilterNameWidget, &FilterNameWidget::updateOkButton, okButton, &QPushButton::setEnabled);
Laurent Montel's avatar
Laurent Montel committed
32
33
34
35
36
}

FilterNameDialog::~FilterNameDialog()
{
}
Laurent Montel's avatar
Laurent Montel committed
37
38
39
40
41

QString FilterNameDialog::filterName() const
{
    return mFilterNameWidget->filterName();
}
42
43
44
45
46

void FilterNameDialog::setExistingFilterNames(const QStringList &lst)
{
    mFilterNameWidget->setExistingFilterNames(lst);
}