blob: 355ed00580c5b72b9718defbf3d54dae20a6c346 (
plain)
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
|
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2008 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/searchdialog/chistorycombobox.h"
#include <QCompleter>
#include <QString>
namespace Search {
CHistoryComboBox::CHistoryComboBox( QWidget* parent)
: QComboBox(parent) {
setEditable(true);
completer()->setCompletionMode(QCompleter::PopupCompletion);
}
CHistoryComboBox::~CHistoryComboBox() {
}
void CHistoryComboBox::addToHistory(const QString& text) {
int index = findText(text);
if ( index >= 0)
removeItem(index);
insertItem(1, text);
setCurrentIndex(1);
}
QStringList CHistoryComboBox::historyItems() const {
QStringList items;
for (int i = 0; i < count(); i++) {
QString text = itemText(i);
if (text.size() > 0)
items << text;
}
return items;
}
} //end of namespace Search
|