BibleTime
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-2025 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
19namespace Search {
20
22 : QComboBox(parent) {
23 setEditable(true);
24 completer()->setCompletionMode(QCompleter::PopupCompletion);
25}
26
29
30void 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
38QStringList 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(QWidget *parent=nullptr)
QStringList historyItems() const
void addToHistory(const QString &item)