jobtrackersearchwidget.cpp 2.11 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
  SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

4
  SPDX-License-Identifier: GPL-2.0-or-later
Laurent Montel's avatar
Laurent Montel committed
5
6
7
8
*/

#include "jobtrackersearchwidget.h"

Laurent Montel's avatar
Laurent Montel committed
9
10
#include <QCheckBox>
#include <QComboBox>
Laurent Montel's avatar
Laurent Montel committed
11
12
13
14
15
16
#include <QHBoxLayout>
#include <QLineEdit>

JobTrackerSearchWidget::JobTrackerSearchWidget(QWidget *parent)
    : QWidget(parent)
{
17
    auto mainLayout = new QHBoxLayout(this);
Laurent Montel's avatar
Laurent Montel committed
18
    mainLayout->setObjectName(QStringLiteral("mainlayout"));
Laurent Montel's avatar
Laurent Montel committed
19
    mainLayout->setContentsMargins(0, 0, 0, 0);
Laurent Montel's avatar
Laurent Montel committed
20
21
22
23
24
25
26

    mSearchLineEdit = new QLineEdit(this);
    mSearchLineEdit->setObjectName(QStringLiteral("searchline"));
    mSearchLineEdit->setClearButtonEnabled(true);
    mSearchLineEdit->setPlaceholderText(QStringLiteral("Search..."));
    mainLayout->addWidget(mSearchLineEdit);
    connect(mSearchLineEdit, &QLineEdit::textChanged, this, &JobTrackerSearchWidget::searchTextChanged);
Laurent Montel's avatar
Laurent Montel committed
27

28
29
30
31
32
    mSelectOnlyError = new QCheckBox(QStringLiteral("Show Only Errors"), this);
    mSelectOnlyError->setObjectName(QStringLiteral("selectonlyerror"));
    mainLayout->addWidget(mSelectOnlyError);
    connect(mSelectOnlyError, &QCheckBox::toggled, this, &JobTrackerSearchWidget::selectOnlyErrorChanged);

Laurent Montel's avatar
Laurent Montel committed
33
34
35
    mSelectColumn = new QComboBox(this);
    mSelectColumn->setObjectName(QStringLiteral("selectcolumn"));
    mainLayout->addWidget(mSelectColumn);
David Faure's avatar
David Faure committed
36
    mSelectColumn->addItem(QStringLiteral("All Columns"), -1);
Laurent Montel's avatar
Laurent Montel committed
37
38
39
40
41
42
43
    mSelectColumn->addItem(QStringLiteral("Job ID"), 0);
    mSelectColumn->addItem(QStringLiteral("Created"), 1);
    mSelectColumn->addItem(QStringLiteral("Wait time"), 2);
    mSelectColumn->addItem(QStringLiteral("Job duration"), 3);
    mSelectColumn->addItem(QStringLiteral("Job Type"), 4);
    mSelectColumn->addItem(QStringLiteral("State"), 5);
    mSelectColumn->addItem(QStringLiteral("Info"), 6);
44
    connect(mSelectColumn, qOverload<int>(&QComboBox::currentIndexChanged), this, &JobTrackerSearchWidget::slotColumnChanged);
Laurent Montel's avatar
Laurent Montel committed
45
46
47
48
49
}

JobTrackerSearchWidget::~JobTrackerSearchWidget()
{
}
Laurent Montel's avatar
Laurent Montel committed
50
51
52
53
54
55
56
57

void JobTrackerSearchWidget::slotColumnChanged(int index)
{
    QVariant var = mSelectColumn->itemData(index);
    if (var.isValid()) {
        Q_EMIT columnChanged(var.toInt());
    }
}