1 /***************************************************************************
2 * *
3 * copyright : (C) 2007 The University of Toronto *
4 * netterfield@astro.utoronto.ca *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 ***************************************************************************/
12
13 #include "scalarlistselector.h"
14
15 namespace Kst {
16
ScalarListSelector(QWidget * parent)17 ScalarListSelector::ScalarListSelector(QWidget *parent)
18 : QDialog(parent) {
19
20 setupUi(this);
21 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
22 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
23
24 connect(_search, SIGNAL(textChanged(QString)), this, SLOT(filter(QString)));
25 }
26
27
~ScalarListSelector()28 ScalarListSelector::~ScalarListSelector() {
29 }
30
31
selectedScalar() const32 QString ScalarListSelector::selectedScalar() const {
33 if (_scalars->currentItem()) {
34 return _scalars->currentItem()->text();
35 }
36 return QString();
37 }
38
39
fillScalars(QStringList & scalars)40 void ScalarListSelector::fillScalars(QStringList &scalars) {
41 _scalars->addItems(scalars);
42 }
43
44
clear()45 void ScalarListSelector::clear() {
46 _scalars->clear();
47 }
48
49
filter(const QString & filter)50 void ScalarListSelector::filter(const QString& filter) {
51 for (int i = 0; i < _scalars->count(); i++) {
52 QListWidgetItem *item = _scalars->item(i);
53 item->setHidden(!item->text().contains(filter, Qt::CaseInsensitive));
54 }
55 }
56
57
58 }
59
60 // vim: ts=2 sw=2 et
61