Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/quickselectdialog.cpp
Show All 19 Lines | 1 | /* This file is part of Zanshin | |||
---|---|---|---|---|---|
20 | along with this program; if not, write to the Free Software | 20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
22 | USA. | 22 | USA. | ||
23 | */ | 23 | */ | ||
24 | 24 | | |||
25 | 25 | | |||
26 | #include "quickselectdialog.h" | 26 | #include "quickselectdialog.h" | ||
27 | 27 | | |||
28 | #include <KRecursiveFilterProxyModel> | | |||
29 | | ||||
30 | #include <QDialogButtonBox> | 28 | #include <QDialogButtonBox> | ||
31 | #include <QEvent> | 29 | #include <QEvent> | ||
32 | #include <QHeaderView> | 30 | #include <QHeaderView> | ||
33 | #include <QKeyEvent> | 31 | #include <QKeyEvent> | ||
34 | #include <QLabel> | 32 | #include <QLabel> | ||
35 | #include <QTreeView> | 33 | #include <QTreeView> | ||
36 | #include <QVBoxLayout> | 34 | #include <QVBoxLayout> | ||
37 | 35 | | |||
36 | #include <KLocalizedString> | ||||
37 | #include <KRecursiveFilterProxyModel> | ||||
38 | | ||||
38 | using namespace Widgets; | 39 | using namespace Widgets; | ||
39 | 40 | | |||
40 | QuickSelectDialog::QuickSelectDialog(QWidget *parent) | 41 | QuickSelectDialog::QuickSelectDialog(QWidget *parent) | ||
41 | : QDialog(parent), | 42 | : QDialog(parent), | ||
42 | m_model(Q_NULLPTR), | 43 | m_model(Q_NULLPTR), | ||
43 | m_filterProxyModel(new KRecursiveFilterProxyModel(this)), | 44 | m_filterProxyModel(new KRecursiveFilterProxyModel(this)), | ||
44 | m_label(new QLabel(this)), | 45 | m_label(new QLabel(this)), | ||
45 | m_tree(new QTreeView(this)) | 46 | m_tree(new QTreeView(this)) | ||
46 | { | 47 | { | ||
47 | setWindowTitle(tr("Quick Select Dialog")); | 48 | setWindowTitle(i18n("Quick Select Dialog")); | ||
48 | 49 | | |||
49 | m_label->setText(tr("You can start typing to filter the list of available pages")); | 50 | m_label->setText(i18n("You can start typing to filter the list of available pages")); | ||
50 | m_filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); | 51 | m_filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); | ||
51 | 52 | | |||
52 | m_tree->setModel(m_filterProxyModel); | 53 | m_tree->setModel(m_filterProxyModel); | ||
53 | m_tree->setObjectName(QStringLiteral("pagesView")); | 54 | m_tree->setObjectName(QStringLiteral("pagesView")); | ||
54 | m_tree->header()->hide(); | 55 | m_tree->header()->hide(); | ||
55 | m_tree->expandAll(); | 56 | m_tree->expandAll(); | ||
56 | m_tree->setFocus(); | 57 | m_tree->setFocus(); | ||
57 | m_tree->setSelectionMode(QAbstractItemView::SingleSelection); | 58 | m_tree->setSelectionMode(QAbstractItemView::SingleSelection); | ||
Show All 21 Lines | |||||
79 | { | 80 | { | ||
80 | QModelIndex selected = m_tree->currentIndex(); | 81 | QModelIndex selected = m_tree->currentIndex(); | ||
81 | return m_filterProxyModel->mapToSource(selected); | 82 | return m_filterProxyModel->mapToSource(selected); | ||
82 | } | 83 | } | ||
83 | 84 | | |||
84 | void QuickSelectDialog::applyFilterChanged(const QString &textFilter) | 85 | void QuickSelectDialog::applyFilterChanged(const QString &textFilter) | ||
85 | { | 86 | { | ||
86 | if (textFilter.isEmpty()) | 87 | if (textFilter.isEmpty()) | ||
87 | m_label->setText(tr("You can start typing to filter the list of available pages")); | 88 | m_label->setText(i18n("You can start typing to filter the list of available pages")); | ||
88 | else | 89 | else | ||
89 | m_label->setText(tr("Path: %1").arg(textFilter)); | 90 | m_label->setText(i18n("Path: %1", textFilter)); | ||
90 | 91 | | |||
91 | m_filterProxyModel->setFilterFixedString(textFilter); | 92 | m_filterProxyModel->setFilterFixedString(textFilter); | ||
92 | m_tree->expandAll(); | 93 | m_tree->expandAll(); | ||
93 | } | 94 | } | ||
94 | 95 | | |||
95 | bool QuickSelectDialog::eventFilter(QObject *, QEvent *ev) | 96 | bool QuickSelectDialog::eventFilter(QObject *, QEvent *ev) | ||
96 | { | 97 | { | ||
97 | if (ev->type() == QEvent::KeyPress) { | 98 | if (ev->type() == QEvent::KeyPress) { | ||
Show All 31 Lines |