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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/***************************************************************************
* Copyright (C) 2005 by Danny Kukawka *
* [email protected], [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of version 2 of the GNU General Public License *
* as published by the Free Software Foundation. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
/*!
* \file blacklisteditdialog.cpp
* \brief In this file can be found the "blacklist edit dialog" related code.
* \author Danny Kukawka, <[email protected]>, <[email protected]>
* \date 2005
*/
// own header
#include "blacklisteditdialog.h"
// KDE headers:
#include <klocale.h>
#include <kiconloader.h>
// QT headers:
#include <tqbuttongroup.h>
#include <tqdialog.h>
#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqlistbox.h>
#include <tqpushbutton.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqtooltip.h>
/*! This is the default constructor of class blacklistEditDialog . */
blacklistEditDialog::blacklistEditDialog( TQStringList blacklisted, TQString captionName,
bool initImport, TQWidget *parent, const char *name)
:blacklistedit_Dialog(parent, name, false, WDestructiveClose )
{
blacklist = blacklisted;
changed = initImport;
pB_add->setEnabled(false);
pB_remove->setEnabled(false);
lB_blacklist->insertStringList(blacklist);
lB_blacklist->sort();
if (captionName.startsWith(i18n("General Blacklist")))
this->bG_scheme->setTitle(captionName);
else
this->bG_scheme->setTitle( i18n("Scheme: ") + captionName);
this->setIcon(SmallIcon("configure", TQIconSet::Automatic));
buttonCancel->setIconSet(SmallIconSet("cancel", TQIconSet::Automatic));
buttonOk->setIconSet(SmallIconSet("ok", TQIconSet::Automatic));
pB_add->setIconSet(SmallIconSet("forward", TQIconSet::Automatic));
pB_remove->setIconSet(SmallIconSet("back", TQIconSet::Automatic));
}
/*! This is the default destructor of class blacklistEditDialog . */
blacklistEditDialog::~blacklistEditDialog()
{
// no need to delete child widgets, TQt does it all for us
}
/*!
* SLOT: called if the 'ok' button clicked. This TQT_SLOT emit
* \ref config_finished() and close the dialog.
*/
void blacklistEditDialog::buttonOk_released() {
if(changed == true) {
changed = false;
emit config_finished( blacklist );
}
close();
}
/*!
* SLOT: called if the 'cancel' button clicked. This TQT_SLOT close
* the dialog.
*/
void blacklistEditDialog::buttonCancel_released(){
changed = false;
close();
}
/*!
* SLOT: called if the 'remove' button clicked. The TQT_SLOT try to remove
* the selected item from the TQListBox and the TQStringList \ref blacklist .
*/
void blacklistEditDialog::pB_remove_released(){
if(blacklist.remove(lB_blacklist->selectedItem()->text()) > 0) {
lB_blacklist->removeItem(lB_blacklist->currentItem());
lB_blacklist->sort();
changed = true;
pB_remove->setEnabled(false);
tLabel_info->setText(i18n("Selected entry removed."));
}
else {
tLabel_info->setText(i18n("Could not remove the selected entry."));
}
}
/*!
* SLOT: called if the 'add' button clicked. The TQT_SLOT try to add the string from
* the TQLineEdit lE_blacklist to the TQListBox and the TQStringList \ref blacklist .
*/
void blacklistEditDialog::pB_add_released(){
TQString text = lE_blacklist->text();
// remove the whitespaces and check if text is empty
if(text.stripWhiteSpace() != "") {
// check if the entry is already present
if(!lB_blacklist->findItem(text, TQt::ExactMatch)) {
lB_blacklist->insertItem(text);
lB_blacklist->sort();
blacklist.append(text);
blacklist.sort();
tLabel_info->setText(i18n("Inserted new entry."));
changed = true;
}
else {
tLabel_info->setText(i18n("Entry exists already. Did not insert new entry."));
}
}
else tLabel_info->setText(i18n("Empty entry was not inserted."));
// set the widgets back to default
lE_blacklist->setText("");
pB_remove->setEnabled(false);
pB_add->setEnabled(false);
}
/*!
* SLOT: called if a item in the TQListBox lB_blacklist is selected.
* Here we enable the remove button pB_remove .
*/
void blacklistEditDialog::lB_blacklist_currentChanged(){
// enable the remove button
pB_remove->setEnabled(true);
}
/*!
* SLOT: called if the input-line in the dialog is modified. Here we enable
* the add button pB_add .
*/
void blacklistEditDialog::lE_blacklist_textChanged(){
// enable the add button
pB_add->setEnabled(true);
}
#include "blacklisteditdialog.moc"
|