Switch to unified view

a/src/qtgui/confgui/confgui.cpp b/src/qtgui/confgui/confgui.cpp
...
...
4
4
5
#include <stdio.h>
5
#include <stdio.h>
6
#include <stdlib.h>
6
#include <stdlib.h>
7
7
8
#include <qglobal.h>
8
#include <qglobal.h>
9
#if QT_VERSION < 0x040000
10
#define QFRAME_INCLUDE <qframe.h>
11
#define QFILEDIALOG_INCLUDE <qfiledialog.h>
12
#define QLISTBOX_INCLUDE <qlistbox.h>
13
#define QFILEDIALOG QFileDialog 
14
#define QFRAME QFrame
15
#define QHBOXLAYOUT QHBoxLayout
16
#define QLISTBOX QListBox
17
#define QLISTBOXITEM QListBoxItem
18
#define QLBEXACTMATCH Qt::ExactMatch
19
#define QVBOXLAYOUT QVBoxLayout
20
#else
21
#include <Q3HBoxLayout>
9
#include <QHBoxLayout>
22
#include <Q3VBoxLayout>
10
#include <QVBoxLayout>
23
24
#include <QFrame>
11
#include <QFrame>
25
#define QFRAME_INCLUDE <q3frame.h>
26
27
#include <QFileDialog>
12
#include <QFileDialog>
28
#define QFILEDIALOG_INCLUDE <q3filedialog.h>
13
#include <QListWidget>
29
30
#define QLISTBOX_INCLUDE <q3listbox.h>
31
32
#define QFILEDIALOG Q3FileDialog 
33
#define QFRAME Q3Frame
34
#define QHBOXLAYOUT Q3HBoxLayout
35
#define QLISTBOX Q3ListBox
36
#define QLISTBOXITEM Q3ListBoxItem
37
#define QLBEXACTMATCH Q3ListBox::ExactMatch
38
#define QVBOXLAYOUT Q3VBoxLayout
39
#endif
40
14
41
#include <qobject.h>
15
#include <qobject.h>
42
#include <qlayout.h>
16
#include <qlayout.h>
43
#include <qsize.h>
17
#include <qsize.h>
44
#include <qsizepolicy.h>
18
#include <qsizepolicy.h>
45
#include <qlabel.h>
19
#include <qlabel.h>
46
#include <qspinbox.h>
20
#include <qspinbox.h>
47
#include <qtooltip.h>
21
#include <qtooltip.h>
48
#include <qlineedit.h>
22
#include <qlineedit.h>
49
#include <qcheckbox.h>
23
#include <qcheckbox.h>
50
#include QFILEDIALOG_INCLUDE
51
#include <qinputdialog.h>
24
#include <qinputdialog.h>
52
#include <qpushbutton.h>
25
#include <qpushbutton.h>
53
#include <qstringlist.h>
26
#include <qstringlist.h>
54
#include QLISTBOX_INCLUDE
55
#include <qcombobox.h>
27
#include <qcombobox.h>
56
#include QFRAME_INCLUDE
57
28
58
#include "confgui.h"
29
#include "confgui.h"
59
#include "smallut.h"
30
#include "smallut.h"
60
#include "debuglog.h"
31
#include "debuglog.h"
61
#include "rcldb.h"
32
#include "rcldb.h"
...
...
63
#include <list>
34
#include <list>
64
using std::list;
35
using std::list;
65
36
66
namespace confgui {
37
namespace confgui {
67
38
68
const static int spacing = 4;
39
const static int spacing = 2;
69
const static int margin = 6;
40
const static int margin = 2;
70
41
71
void ConfParamW::setValue(const QString& value)
42
void ConfParamW::setValue(const QString& value)
72
{
43
{
73
    if (m_fsencoding)
44
    if (m_fsencoding)
74
        m_cflink->set(string((const char *)value.local8Bit()));
45
        m_cflink->set(string((const char *)value.toLocal8Bit()));
75
    else
46
    else
76
        m_cflink->set(string((const char *)value.utf8()));
47
        m_cflink->set(string((const char *)value.toUtf8()));
77
}
48
}
78
49
79
void ConfParamW::setValue(int value)
50
void ConfParamW::setValue(int value)
80
{
51
{
81
    char buf[30];
52
    char buf[30];
...
...
87
    char buf[30];
58
    char buf[30];
88
    sprintf(buf, "%d", value);
59
    sprintf(buf, "%d", value);
89
    m_cflink->set(string(buf));
60
    m_cflink->set(string(buf));
90
}
61
}
91
62
63
void setSzPol(QWidget *w, QSizePolicy::Policy hpol, 
64
         QSizePolicy::Policy vpol,
65
         int hstretch, int vstretch)
66
{
67
    QSizePolicy policy(hpol, vpol);
68
    policy.setHorizontalStretch(hstretch);
69
    policy.setVerticalStretch(vstretch);
70
    policy.setHeightForWidth(w->sizePolicy().hasHeightForWidth());
71
    w->setSizePolicy(policy);
72
}
73
92
bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
74
bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
93
{
75
{
94
    m_hl = new QHBOXLAYOUT(this);
76
    m_hl = new QHBoxLayout(this);
95
    m_hl->setSpacing(spacing);
77
    m_hl->setSpacing(spacing);
96
78
97
    QLabel *tl = new QLabel(this);
79
    QLabel *tl = new QLabel(this);
98
    tl->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
80
    setSzPol(tl, QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0);
99
                QSizePolicy::Fixed,
100
                0,  // Horizontal stretch
101
                0,  // Vertical stretch
102
                tl->sizePolicy().hasHeightForWidth() ) );
103
    tl->setText(lbltxt);
81
    tl->setText(lbltxt);
104
    QToolTip::add(tl, tltptxt);
82
    tl->setToolTip(tltptxt);
105
83
106
    m_hl->addWidget(tl);
84
    m_hl->addWidget(tl);
107
85
108
    return true;
86
    return true;
109
}
87
}
...
...
118
{
96
{
119
    if (!createCommon(lbltxt, tltptxt))
97
    if (!createCommon(lbltxt, tltptxt))
120
    return;
98
    return;
121
99
122
    m_sb = new QSpinBox(this);
100
    m_sb = new QSpinBox(this);
123
    m_sb->setMinValue(minvalue);
101
    m_sb->setMinimum(minvalue);
124
    m_sb->setMaxValue(maxvalue);
102
    m_sb->setMaximum(maxvalue);
125
    m_sb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
103
    setSzPol(m_sb, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
126
                  QSizePolicy::Fixed,
127
                  0,  // Horizontal stretch
128
                  0,  // Vertical stretch
129
                  m_sb->sizePolicy().hasHeightForWidth()));
130
    m_hl->addWidget(m_sb);
104
    m_hl->addWidget(m_sb);
131
105
132
    QFRAME *fr = new QFRAME(this);
106
    QFrame *fr = new QFrame(this);
133
    fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
107
    setSzPol(fr, QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0);
134
                QSizePolicy::Fixed,
135
                1,  // Horizontal stretch
136
                0,  // Vertical stretch
137
                fr->sizePolicy().hasHeightForWidth() ) );
138
    m_hl->addWidget(fr);
108
    m_hl->addWidget(fr);
139
109
140
    loadValue();
110
    loadValue();
141
    QObject::connect(m_sb, SIGNAL(valueChanged(int)), 
111
    QObject::connect(m_sb, SIGNAL(valueChanged(int)), 
142
             this, SLOT(setValue(int)));
112
             this, SLOT(setValue(int)));
...
...
156
                 const QString& tltptxt)
126
                 const QString& tltptxt)
157
    : ConfParamW(parent, cflink)
127
    : ConfParamW(parent, cflink)
158
{
128
{
159
    if (!createCommon(lbltxt, tltptxt))
129
    if (!createCommon(lbltxt, tltptxt))
160
    return;
130
    return;
131
161
    m_le = new QLineEdit(this);
132
    m_le = new QLineEdit(this);
162
    m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
133
    setSzPol(m_le, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
163
                  QSizePolicy::Fixed,
134
164
                  1,  // Horizontal stretch
165
                  0,  // Vertical stretch
166
                  m_le->sizePolicy().hasHeightForWidth()));
167
    m_hl->addWidget(m_le);
135
    m_hl->addWidget(m_le);
168
136
169
    loadValue();
137
    loadValue();
170
    QObject::connect(m_le, SIGNAL(textChanged(const QString&)), 
138
    QObject::connect(m_le, SIGNAL(textChanged(const QString&)), 
171
             this, SLOT(setValue(const QString&)));
139
             this, SLOT(setValue(const QString&)));
...
...
188
                   )
156
                   )
189
    : ConfParamW(parent, cflink)
157
    : ConfParamW(parent, cflink)
190
{
158
{
191
    if (!createCommon(lbltxt, tltptxt))
159
    if (!createCommon(lbltxt, tltptxt))
192
    return;
160
    return;
193
    m_cmb = new QComboBox(false, this);
161
    m_cmb = new QComboBox(this);
162
    m_cmb->setEditable(FALSE);
194
    m_cmb->insertStringList(sl);
163
    m_cmb->insertItems(0, sl);
195
    //    m_cmb->setEditable(false);
164
196
    m_cmb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
165
    setSzPol(m_cmb, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
197
                   QSizePolicy::Fixed,
166
198
                   1,  // Horizontal stretch
199
                   0,  // Vertical stretch
200
                   m_cmb->sizePolicy().hasHeightForWidth()));
201
    m_hl->addWidget(m_cmb);
167
    m_hl->addWidget(m_cmb);
202
168
203
    loadValue();
169
    loadValue();
204
    QObject::connect(m_cmb, SIGNAL(activated(const QString&)), 
170
    QObject::connect(m_cmb, SIGNAL(activated(const QString&)), 
205
             this, SLOT(setValue(const QString&)));
171
             this, SLOT(setValue(const QString&)));
...
...
214
        cs = QString::fromLocal8Bit(s.c_str());
180
        cs = QString::fromLocal8Bit(s.c_str());
215
    else
181
    else
216
        cs = QString::fromUtf8(s.c_str());
182
        cs = QString::fromUtf8(s.c_str());
217
        
183
        
218
    for (int i = 0; i < m_cmb->count(); i++) {
184
    for (int i = 0; i < m_cmb->count(); i++) {
219
    if (!cs.compare(m_cmb->text(i))) {
185
    if (!cs.compare(m_cmb->itemText(i))) {
220
        m_cmb->setCurrentItem(i);
186
        m_cmb->setCurrentIndex(i);
221
        break;
187
        break;
222
    }
188
    }
223
    }
189
    }
224
}
190
}
225
191
...
...
227
                   const QString& lbltxt,
193
                   const QString& lbltxt,
228
                   const QString& tltptxt)
194
                   const QString& tltptxt)
229
    : ConfParamW(parent, cflink)
195
    : ConfParamW(parent, cflink)
230
{
196
{
231
    // No createCommon because the checkbox has a label
197
    // No createCommon because the checkbox has a label
232
    m_hl = new QHBOXLAYOUT(this);
198
    m_hl = new QHBoxLayout(this);
233
    m_hl->setSpacing(spacing);
199
    m_hl->setSpacing(spacing);
234
200
235
    m_cb = new QCheckBox(lbltxt, this);
201
    m_cb = new QCheckBox(lbltxt, this);
236
    m_cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, 
202
    setSzPol(m_cb, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
237
                QSizePolicy::Fixed,
203
    m_cb->setToolTip(tltptxt);
238
                0,  // Horizontal stretch
239
                0,  // Vertical stretch
240
                m_cb->sizePolicy().hasHeightForWidth()));
241
    QToolTip::add(m_cb, tltptxt);
242
    m_hl->addWidget(m_cb);
204
    m_hl->addWidget(m_cb);
243
205
244
    QFRAME *fr = new QFRAME(this);
206
    QFrame *fr = new QFrame(this);
245
    fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
207
    setSzPol(fr, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
246
                QSizePolicy::Fixed,
247
                1,  // Horizontal stretch
248
                0,  // Vertical stretch
249
                fr->sizePolicy().hasHeightForWidth()));
250
    m_hl->addWidget(fr);
208
    m_hl->addWidget(fr);
251
209
252
    loadValue();
210
    loadValue();
253
    QObject::connect(m_cb, SIGNAL(toggled(bool)), 
211
    QObject::connect(m_cb, SIGNAL(toggled(bool)), this, SLOT(setValue(bool)));
254
           this, SLOT(setValue(bool)));
255
}
212
}
256
213
257
void ConfParamBoolW::loadValue()
214
void ConfParamBoolW::loadValue()
258
{
215
{
259
    string s;
216
    string s;
...
...
270
{
227
{
271
    if (!createCommon(lbltxt, tltptxt))
228
    if (!createCommon(lbltxt, tltptxt))
272
    return;
229
    return;
273
230
274
    m_fsencoding = true;
231
    m_fsencoding = true;
232
275
    m_le = new QLineEdit(this);
233
    m_le = new QLineEdit(this);
276
    m_le->setMinimumSize(QSize(150, 0 ));
234
    m_le->setMinimumSize(QSize(150, 0 ));
277
    m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
235
    setSzPol(m_le, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
278
                  QSizePolicy::Fixed,
279
                  1,  // Horizontal stretch
280
                  0,  // Vertical stretch
281
                  m_le->sizePolicy().hasHeightForWidth()));
282
    m_hl->addWidget(m_le);
236
    m_hl->addWidget(m_le);
283
237
284
    m_pb = new QPushButton(this);
238
    m_pb = new QPushButton(this);
285
    m_pb->setText(tr("Browse"));
239
    setSzPol(m_pb, QSizePolicy::Fixed, QSizePolicy::Fixed, 1, 0);
286
    m_pb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, 
287
                                    QSizePolicy::Fixed,
288
                                    0,  // Horizontal stretch
289
                                    0,  // Vertical stretch
290
                                    m_pb->sizePolicy().hasHeightForWidth()));
291
    m_hl->addWidget(m_pb);
240
    m_hl->addWidget(m_pb);
292
241
293
    loadValue();
242
    loadValue();
294
    QObject::connect(m_pb, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
243
    QObject::connect(m_pb, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
295
    QObject::connect(m_le, SIGNAL(textChanged(const QString&)), 
244
    QObject::connect(m_le, SIGNAL(textChanged(const QString&)), 
...
...
304
}
253
}
305
254
306
void ConfParamFNW::showBrowserDialog()
255
void ConfParamFNW::showBrowserDialog()
307
{
256
{
308
    QString s = m_isdir ?  
257
    QString s = m_isdir ?  
309
    QFILEDIALOG::getExistingDirectory() : QFILEDIALOG::getSaveFileName();
258
    QFileDialog::getExistingDirectory() : QFileDialog::getSaveFileName();
310
    if (!s.isEmpty()) 
259
    if (!s.isEmpty()) 
311
    m_le->setText(s);
260
    m_le->setText(s);
312
}
261
}
262
263
class SmallerListWidget: public QListWidget 
264
{
265
public:
266
    SmallerListWidget(QWidget *parent)
267
  : QListWidget(parent) {}
268
    virtual QSize sizeHint() {return QSize(150, 40);}
269
};
313
270
314
ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink, 
271
ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink, 
315
               const QString& lbltxt,
272
               const QString& lbltxt,
316
               const QString& tltptxt)
273
               const QString& tltptxt)
317
    : ConfParamW(parent, cflink)
274
    : ConfParamW(parent, cflink)
318
{
275
{
319
    // Can't use createCommon here cause we want the buttons below the label
276
    // Can't use createCommon here cause we want the buttons below the label
320
    m_hl = new QHBOXLAYOUT(this);
277
    m_hl = new QHBoxLayout(this);
321
    m_hl->setSpacing(spacing);
278
    m_hl->setSpacing(spacing);
322
279
323
    QVBOXLAYOUT *vl1 = new QVBOXLAYOUT();
280
    QVBoxLayout *vl1 = new QVBoxLayout();
324
    QHBOXLAYOUT *hl1 = new QHBOXLAYOUT();
281
    QHBoxLayout *hl1 = new QHBoxLayout();
325
282
326
    QLabel *tl = new QLabel(this);
283
    QLabel *tl = new QLabel(this);
327
    tl->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
284
    setSzPol(tl, QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0);
328
                QSizePolicy::Fixed,
329
                0,  // Horizontal stretch
330
                0,  // Vertical stretch
331
                tl->sizePolicy().hasHeightForWidth()));
332
    tl->setText(lbltxt);
285
    tl->setText(lbltxt);
333
    QToolTip::add(tl, tltptxt);
286
    tl->setToolTip(tltptxt);
334
    vl1->addWidget(tl);
287
    vl1->addWidget(tl);
335
288
336
    QPushButton *pbA = new QPushButton(this);
289
    QPushButton *pbA = new QPushButton(this);
337
    pbA->setText(tr("+"));
290
    pbA->setText(tr("+"));
338
    pbA->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, 
291
    setSzPol(pbA, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
339
                 QSizePolicy::Fixed,
340
                 0,  // Horizontal stretch
341
                 0,  // Vertical stretch
342
                 pbA->sizePolicy().hasHeightForWidth()));
343
    hl1->addWidget(pbA);
292
    hl1->addWidget(pbA);
293
344
    QPushButton *pbD = new QPushButton(this);
294
    QPushButton *pbD = new QPushButton(this);
295
    setSzPol(pbD, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
345
    pbD->setText(tr("-"));
296
    pbD->setText(tr("-"));
346
    pbD->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, 
347
                 QSizePolicy::Fixed,
348
                 0,  // Horizontal stretch
349
                 0,  // Vertical stretch
350
                 pbD->sizePolicy().hasHeightForWidth()));
351
    hl1->addWidget(pbD);
297
    hl1->addWidget(pbD);
352
298
353
    vl1->addLayout(hl1);
299
    vl1->addLayout(hl1);
354
    m_hl->addLayout(vl1);
300
    m_hl->addLayout(vl1);
355
301
356
    m_lb = new QLISTBOX(this);
302
    m_lb = new SmallerListWidget(this);
357
    m_lb->setSelectionMode(QLISTBOX::Extended);
303
    m_lb->setSelectionMode(QAbstractItemView::ExtendedSelection);
358
    m_lb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
304
    setSzPol(m_lb, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 1);
359
                  QSizePolicy::Preferred,
360
                  1,  // Horizontal stretch
361
                  1,  // Vertical stretch
362
                  m_lb->sizePolicy().hasHeightForWidth()));
363
    m_hl->addWidget(m_lb);
305
    m_hl->addWidget(m_lb);
364
306
365
    this->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, 
307
    setSzPol(this, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 1);
366
                  QSizePolicy::Preferred,
367
                  1,  // Horizontal stretch
368
                  1,  // Vertical stretch
369
                  this->sizePolicy().hasHeightForWidth()));
370
371
    loadValue();
308
    loadValue();
372
    QObject::connect(pbA, SIGNAL(clicked()), this, SLOT(showInputDialog()));
309
    QObject::connect(pbA, SIGNAL(clicked()), this, SLOT(showInputDialog()));
373
    QObject::connect(pbD, SIGNAL(clicked()), this, SLOT(deleteSelected()));
310
    QObject::connect(pbD, SIGNAL(clicked()), this, SLOT(deleteSelected()));
374
}
311
}
375
312
...
...
385
            qls.push_back(QString::fromLocal8Bit(it->c_str()));
322
            qls.push_back(QString::fromLocal8Bit(it->c_str()));
386
        else
323
        else
387
            qls.push_back(QString::fromUtf8(it->c_str()));
324
            qls.push_back(QString::fromUtf8(it->c_str()));
388
    }
325
    }
389
    m_lb->clear();
326
    m_lb->clear();
390
    m_lb->insertStringList(qls);
327
    m_lb->insertItems(0, qls);
391
}
328
}
392
329
393
void ConfParamSLW::showInputDialog()
330
void ConfParamSLW::showInputDialog()
394
{
331
{
395
    bool ok;
332
    bool ok;
396
    QString s = QInputDialog::getText("", // Caption
333
    QString s = QInputDialog::getText (this, 
334
                     "", // title 
397
                      "", // Label
335
                       "", // label, 
398
                      QLineEdit::Normal, // Mode
336
                       QLineEdit::Normal, // EchoMode mode
399
                    QString::null, // text
337
                     "", // const QString & text 
400
                      &ok,
338
                       &ok);
401
                    this);
339
402
    if (ok && !s.isEmpty()) {
340
    if (ok && !s.isEmpty()) {
403
  if (m_lb->findItem(s, QLBEXACTMATCH) == 0) {
341
  QList<QListWidgetItem *>items = 
342
      m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
343
  if (items.empty()) {
404
        m_lb->insertItem(s);
344
        m_lb->insertItem(0, s);
405
        m_lb->sort();
345
        m_lb->sortItems();
406
        listToConf();
346
        listToConf();
407
    }
347
    }
408
    }
348
    }
409
}
349
}
410
350
411
void ConfParamSLW::listToConf()
351
void ConfParamSLW::listToConf()
412
{
352
{
413
    list<string> ls;
353
    list<string> ls;
414
    for (unsigned int i = 0; i < m_lb->count(); i++) {
354
    for (int i = 0; i < m_lb->count(); i++) {
415
        // General parameters are encoded as utf-8. File names as
355
        // General parameters are encoded as utf-8. File names as
416
        // local8bit There is no hope for 8bit file names anyway
356
        // local8bit There is no hope for 8bit file names anyway
417
        // except for luck: the original encoding is unknown.
357
        // except for luck: the original encoding is unknown.
358
  QString text = m_lb->item(i)->text();
418
        if (m_fsencoding)
359
        if (m_fsencoding)
419
            ls.push_back((const char *)(m_lb->text(i).local8Bit()));
360
            ls.push_back((const char *)(text.toLocal8Bit()));
420
        else
361
        else
421
            ls.push_back((const char *)(m_lb->text(i).utf8()));
362
            ls.push_back((const char *)(text.toUtf8()));
422
    }
363
    }
423
    string s;
364
    string s;
424
    stringsToString(ls, s);
365
    stringsToString(ls, s);
425
    m_cflink->set(s);
366
    m_cflink->set(s);
426
}
367
}
...
...
428
void ConfParamSLW::deleteSelected()
369
void ConfParamSLW::deleteSelected()
429
{
370
{
430
    bool didone;
371
    bool didone;
431
    do {
372
    do {
432
    didone = false;
373
    didone = false;
433
    for (unsigned int i = 0; i < m_lb->count(); i++) {
374
    for (int i = 0; i < m_lb->count(); i++) {
434
        if (m_lb->isSelected(i)) {
375
        if (m_lb->item(i)->isSelected()) {
435
        emit entryDeleted(m_lb->text(i));
376
        emit entryDeleted(m_lb->item(i)->text());
436
      m_lb->removeItem(i);
377
      QListWidgetItem *item = m_lb->takeItem(i);
378
      delete item;
437
        didone = true;
379
        didone = true;
438
        break;
380
        break;
439
        }
381
        }
440
    }
382
    }
441
    } while (didone);
383
    } while (didone);
...
...
443
}
385
}
444
386
445
// "Add entry" dialog for a file name list
387
// "Add entry" dialog for a file name list
446
void ConfParamDNLW::showInputDialog()
388
void ConfParamDNLW::showInputDialog()
447
{
389
{
448
    QString s = QFILEDIALOG::getExistingDirectory();
390
    QString s = QFileDialog::getExistingDirectory();
449
    if (!s.isEmpty()) {
391
    if (!s.isEmpty()) {
450
  if (m_lb->findItem(s, QLBEXACTMATCH) == 0) {
392
  QList<QListWidgetItem *>items = 
393
      m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
394
  if (items.empty()) {
451
        m_lb->insertItem(s);
395
        m_lb->insertItem(0, s);
452
        m_lb->sort();
396
        m_lb->sortItems();
453
      QLISTBOXITEM *item = m_lb->findItem(s, QLBEXACTMATCH);
397
      QList<QListWidgetItem *>items = 
454
      if (m_lb->selectionMode() == QLISTBOX::Single && item)
398
      m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
455
      m_lb->setSelected(item, true);
399
      if (m_lb->selectionMode() == QAbstractItemView::SingleSelection && 
400
      !items.empty())
401
      (*items.begin())->setSelected(TRUE);
456
        listToConf();
402
        listToConf();
457
    }
403
    }
458
    }
404
    }
459
}
405
}
460
406
461
// "Add entry" dialog for a constrained string list
407
// "Add entry" dialog for a constrained string list
462
void ConfParamCSLW::showInputDialog()
408
void ConfParamCSLW::showInputDialog()
463
{
409
{
464
    bool ok;
410
    bool ok;
465
    QString s = QInputDialog::getItem("", // Caption
411
    QString s = QInputDialog::getItem (this, // parent
412
                     "", // title 
466
                      "", // Label
413
                       "", // label, 
467
                      m_sl, // List
414
                       m_sl, // items, 
468
                      0, // current
415
                       0, // current = 0
469
                    false, // editable,
416
                     FALSE, // editable = true, 
470
                      &ok);
417
                       &ok);
418
471
    if (ok && !s.isEmpty()) {
419
    if (ok && !s.isEmpty()) {
472
  if (m_lb->findItem(s, QLBEXACTMATCH) == 0) {
420
  QList<QListWidgetItem *>items = 
421
      m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
422
  if (items.empty()) {
473
        m_lb->insertItem(s);
423
        m_lb->insertItem(0, s);
474
        m_lb->sort();
424
        m_lb->sortItems();
475
        listToConf();
425
        listToConf();
476
    }
426
    }
477
    }
427
    }
478
}
428
}
479
429