File: krmaskchoice.cpp

package info (click to toggle)
krusader 2%3A2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,448 kB
  • sloc: cpp: 56,112; ansic: 1,187; xml: 811; sh: 23; makefile: 3
file content (141 lines) | stat: -rw-r--r-- 5,048 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
    SPDX-FileCopyrightText: 2000 Shie Erlich <krusader@users.sourceforge.net>
    SPDX-FileCopyrightText: 2000 Rafi Yanai <krusader@users.sourceforge.net>
    SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "krmaskchoice.h"

// QtCore
#include <QVariant>
// QtWidgets
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>

#include <KComboBox>
#include <KLocalizedString>

#include "../GUI/krlistwidget.h"
#include "../compat.h"

/**
 * Constructs a KrMaskChoice which is a child of 'parent', with the
 * name 'name' and widget flags set to 'f'
 *
 * The dialog will by default be modeless, unless you set 'modal' to
 * TRUE to construct a modal dialog.
 */
KrMaskChoice::KrMaskChoice(QWidget *parent)
    : QDialog(parent)
{
    setModal(true);
    resize(401, 314);
    setWindowTitle(i18n("Choose Files"));

    auto *MainLayout = new QVBoxLayout(this);

    auto *HeaderLayout = new QHBoxLayout();
    MainLayout->addLayout(HeaderLayout);

    PixmapLabel1 = new QLabel(this);
    PixmapLabel1->setScaledContents(true);
    PixmapLabel1->setMaximumSize(QSize(31, 31));
    HeaderLayout->addWidget(PixmapLabel1);

    label = new QLabel(this);
    label->setText(i18n("Select the following files:"));
    HeaderLayout->addWidget(label);

    selection = new KComboBox(this);
    selection->setEditable(true);
    selection->setInsertPolicy(QComboBox::InsertAtTop);
    selection->setAutoCompletion(true);
    MainLayout->addWidget(selection);

    auto *GroupBox1 = new QGroupBox(this);
    GroupBox1->setTitle(i18n("Predefined Selections"));
    MainLayout->addWidget(GroupBox1);

    auto *gbLayout = new QHBoxLayout(GroupBox1);

    preSelections = new KrListWidget(GroupBox1);
    preSelections->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    preSelections->setWhatsThis(
        i18n("A predefined selection is a file-mask which you often use.\nSome examples are: \"*.c, *.h\", \"*.c, *.o\", etc.\nYou can add these masks to the "
             "list by typing them and pressing the Add button.\nDelete removes a predefined selection and Clear removes all of them.\nNotice that the line in "
             "which you edit the mask has its own history, you can scroll it, if needed."));
    gbLayout->addWidget(preSelections);

    auto *vbox = new QVBoxLayout();
    gbLayout->addLayout(vbox);

    PushButton7 = new QPushButton(GroupBox1);
    PushButton7->setText(i18n("Add"));
    PushButton7->setToolTip(i18n("Adds the selection in the line-edit to the list"));
    vbox->addWidget(PushButton7);

    PushButton7_2 = new QPushButton(GroupBox1);
    PushButton7_2->setText(i18n("Delete"));
    PushButton7_2->setToolTip(i18n("Delete the marked selection from the list"));
    vbox->addWidget(PushButton7_2);

    PushButton7_3 = new QPushButton(GroupBox1);
    PushButton7_3->setText(i18n("Clear"));
    PushButton7_3->setToolTip(i18n("Clears the entire list of selections"));
    vbox->addWidget(PushButton7_3);
    vbox->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Expanding));

    QDialogButtonBox *ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
    MainLayout->addWidget(ButtonBox);

    // signals and slots connections
    connect(ButtonBox, &QDialogButtonBox::rejected, this, &KrMaskChoice::reject);
    connect(ButtonBox, &QDialogButtonBox::accepted, this, &KrMaskChoice::accept);
    connect(PushButton7, &QPushButton::clicked, this, &KrMaskChoice::addSelection);
    connect(PushButton7_2, &QPushButton::clicked, this, &KrMaskChoice::deleteSelection);
    connect(PushButton7_3, &QPushButton::clicked, this, &KrMaskChoice::clearSelections);
    connect(selection, QOverload<const QString &>::of(&KComboBox::QCOMBOBOX_ACTIVATED), selection, &KComboBox::setEditText);
    connect(selection->lineEdit(), &QLineEdit::returnPressed, this, &KrMaskChoice::accept);
    connect(preSelections, &KrListWidget::currentItemChanged, this, &KrMaskChoice::currentItemChanged);
    connect(preSelections, &KrListWidget::itemActivated, this, &KrMaskChoice::acceptFromList);
}

/*
 *  Destroys the object and frees any allocated resources
 */
KrMaskChoice::~KrMaskChoice()
{
    // no need to delete child widgets, Qt does it all for us
}

void KrMaskChoice::addSelection()
{
    qWarning("KrMaskChoice::addSelection(): Not implemented yet!");
}

void KrMaskChoice::clearSelections()
{
    qWarning("KrMaskChoice::clearSelections(): Not implemented yet!");
}

void KrMaskChoice::deleteSelection()
{
    qWarning("KrMaskChoice::deleteSelection(): Not implemented yet!");
}

void KrMaskChoice::acceptFromList(QListWidgetItem *)
{
    qWarning("KrMaskChoice::acceptFromList(QListWidgetItem *): Not implemented yet!");
}

void KrMaskChoice::currentItemChanged(QListWidgetItem *)
{
    qWarning("KrMaskChoice::currentItemChanged(QListWidgetItem *): Not implemented yet!");
}