diff --git a/kate/kateconfigdialog.h b/kate/kateconfigdialog.h --- a/kate/kateconfigdialog.h +++ b/kate/kateconfigdialog.h @@ -34,6 +34,7 @@ class QSpinBox; class KateMainWindow; class KPluralHandlingSpinBox; +class KComboBox; namespace Ui { class SessionConfigWidget; @@ -83,6 +84,7 @@ QCheckBox *m_modCloseAfterLast; QCheckBox *m_saveMetaInfos; KPluralHandlingSpinBox *m_daysMetaInfos; + KComboBox * m_cmbQuickOpenMatchMode; // Sessions Page Ui::SessionConfigWidget *sessionConfigUi; diff --git a/kate/kateconfigdialog.cpp b/kate/kateconfigdialog.cpp --- a/kate/kateconfigdialog.cpp +++ b/kate/kateconfigdialog.cpp @@ -30,6 +30,7 @@ #include "kateapp.h" #include "katesessionmanager.h" #include "katedebug.h" +#include "katequickopenmodel.h" #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include @@ -146,6 +148,21 @@ vbox->addWidget(metaInfos); buttonGroup->setLayout(vbox); + // quick search + buttonGroup = new QGroupBox(i18n("&Quick Open"), generalFrame); + hlayout = new QHBoxLayout(buttonGroup); + label = new QLabel(i18n("&Match Mode:"), buttonGroup); + hlayout->addWidget(label); + m_cmbQuickOpenMatchMode = new KComboBox(buttonGroup); + hlayout->addWidget(m_cmbQuickOpenMatchMode); + label->setBuddy(m_cmbQuickOpenMatchMode); + m_cmbQuickOpenMatchMode->addItem(i18n("Filename"), QVariant(KateQuickOpenModel::Columns::FileName)); + m_cmbQuickOpenMatchMode->addItem(i18n("Filepath"), QVariant(KateQuickOpenModel::Columns::FilePath)); + m_cmbQuickOpenMatchMode->setCurrentIndex(m_cmbQuickOpenMatchMode->findData(m_mainWindow->quickOpenMatchMode())); + m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt()); + connect(m_cmbQuickOpenMatchMode, static_cast(&KComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged); + layout->addWidget(buttonGroup); + layout->addStretch(1); // :-] works correct without autoadd //END General page @@ -334,6 +351,9 @@ cg.writeEntry("Close After Last", m_modCloseAfterLast->isChecked()); m_mainWindow->setModCloseAfterLast(m_modCloseAfterLast->isChecked()); + cg.writeEntry("Quick Open Search Mode", m_cmbQuickOpenMatchMode->currentData().toInt()); + m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt()); + // patch document modified warn state const QList &docs = KateApp::self()->documentManager()->documentList(); foreach(KTextEditor::Document * doc, docs) diff --git a/kate/katemainwindow.h b/kate/katemainwindow.h --- a/kate/katemainwindow.h +++ b/kate/katemainwindow.h @@ -292,6 +292,9 @@ m_modCloseAfterLast = e; } + void setQuickOpenMatchMode(int mode); + int quickOpenMatchMode(); + KRecentFilesAction *fileOpenRecent() const { return m_fileOpenRecent; } diff --git a/kate/katemainwindow.cpp b/kate/katemainwindow.cpp --- a/kate/katemainwindow.cpp +++ b/kate/katemainwindow.cpp @@ -38,6 +38,7 @@ #include "katedebug.h" #include "katecolorschemechooser.h" #include "katefileactions.h" +#include "katequickopenmodel.h" #include #include @@ -628,6 +629,8 @@ m_paShowMenuBar->setChecked(generalGroup.readEntry("Show Menu Bar", true)); m_paShowTabBar->setChecked(generalGroup.readEntry("Show Tab Bar", true)); + m_quickOpen->setMatchMode(generalGroup.readEntry("Quick Open Search Mode", (int)KateQuickOpenModel::Columns::FileName)); + // emit signal to hide/show statusbars toggleShowStatusBar(); toggleShowTabBar(); @@ -1260,3 +1263,12 @@ return KateMDI::MainWindow::hideToolView(qobject_cast(widget)); } +void KateMainWindow::setQuickOpenMatchMode(int mode) +{ + m_quickOpen->setMatchMode(mode); +} + +int KateMainWindow::quickOpenMatchMode() +{ + return m_quickOpen->matchMode(); +} diff --git a/kate/katequickopen.h b/kate/katequickopen.h --- a/kate/katequickopen.h +++ b/kate/katequickopen.h @@ -42,6 +42,14 @@ */ void update(); + void setMatchMode(int mode) { + m_matchMode = mode; + } + + int matchMode() { + return m_matchMode; + } + protected: bool eventFilter(QObject *obj, QEvent *event) override; @@ -68,6 +76,8 @@ * filtered model we search in */ QSortFilterProxyModel *m_model; + + int m_matchMode; }; #endif diff --git a/kate/katequickopen.cpp b/kate/katequickopen.cpp --- a/kate/katequickopen.cpp +++ b/kate/katequickopen.cpp @@ -53,6 +53,7 @@ KateQuickOpen::KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow) : QWidget(parent) , m_mainWindow(mainWindow) + , m_matchMode(0) { QVBoxLayout *layout = new QVBoxLayout(); layout->setSpacing(0); @@ -76,6 +77,7 @@ m_model->setSortRole(Qt::DisplayRole); m_model->setFilterCaseSensitivity(Qt::CaseInsensitive); m_model->setSortCaseSensitivity(Qt::CaseInsensitive); + m_model->setFilterKeyColumn(m_matchMode); connect(m_inputLine, &KLineEdit::textChanged, m_model, &QSortFilterProxyModel::setFilterWildcard); connect(m_inputLine, &KLineEdit::returnPressed, this, &KateQuickOpen::slotReturnPressed);