BibleTime
src
frontend
searchdialog
chistorycombobox.cpp
Go to the documentation of this file.
1
/*********
2
*
3
* In the name of the Father, and of the Son, and of the Holy Spirit.
4
*
5
* This file is part of BibleTime's source code, https://bibletime.info/
6
*
7
* Copyright 1999-2021 by the BibleTime developers.
8
* The BibleTime source code is licensed under the GNU General Public License
9
* version 2.0.
10
*
11
**********/
12
13
#include "
chistorycombobox.h
"
14
15
#include <QCompleter>
16
#include <QString>
17
18
19
namespace
Search
{
20
21
CHistoryComboBox::CHistoryComboBox
(
QWidget
* parent)
22
:
QComboBox
(parent) {
23
setEditable(
true
);
24
completer()->setCompletionMode(QCompleter::PopupCompletion);
25
}
26
27
CHistoryComboBox::~CHistoryComboBox
() {
28
}
29
30
void
CHistoryComboBox::addToHistory
(
const
QString& text) {
31
int
index = findText(text);
32
if
( index >= 0)
33
removeItem(index);
34
insertItem(1, text);
35
setCurrentIndex(1);
36
}
37
38
QStringList
CHistoryComboBox::historyItems
()
const
{
39
QStringList items;
40
for
(
int
i = 0; i < count(); i++) {
41
QString text = itemText(i);
42
if
(text.size() > 0)
43
items << text;
44
}
45
return
items;
46
}
47
}
//end of namespace Search
48
chistorycombobox.h
QComboBox
QWidget
Search::CHistoryComboBox::CHistoryComboBox
CHistoryComboBox(QWidget *parent=nullptr)
Definition:
chistorycombobox.cpp:21
Search::CHistoryComboBox::~CHistoryComboBox
~CHistoryComboBox() override
Definition:
chistorycombobox.cpp:27
Search::CHistoryComboBox::historyItems
QStringList historyItems() const
Definition:
chistorycombobox.cpp:38
Search::CHistoryComboBox::addToHistory
void addToHistory(const QString &item)
Definition:
chistorycombobox.cpp:30
Search
Definition:
bibletime.h:25
Generated by
1.9.1