Commit 86e6b7cb authored by Michal Humpula's avatar Michal Humpula

quick open: allow match on file path

Closes: D19480
parent 5bcf467e
......@@ -30,6 +30,7 @@
#include "kateapp.h"
#include "katesessionmanager.h"
#include "katedebug.h"
#include "katequickopenmodel.h"
#include <KTextEditor/ConfigPage>
......@@ -38,6 +39,7 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include <KPluralHandlingSpinBox>
#include <KComboBox>
#include <QDesktopServices>
#include <QCheckBox>
......@@ -146,6 +148,21 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi
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<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged);
layout->addWidget(buttonGroup);
layout->addStretch(1); // :-] works correct without autoadd
//END General page
......@@ -334,6 +351,9 @@ void KateConfigDialog::slotApply()
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<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList();
foreach(KTextEditor::Document * doc, docs)
......
......@@ -34,6 +34,7 @@ class QCheckBox;
class QSpinBox;
class KateMainWindow;
class KPluralHandlingSpinBox;
class KComboBox;
namespace Ui {
class SessionConfigWidget;
......@@ -83,6 +84,7 @@ private:
QCheckBox *m_modCloseAfterLast;
QCheckBox *m_saveMetaInfos;
KPluralHandlingSpinBox *m_daysMetaInfos;
KComboBox * m_cmbQuickOpenMatchMode;
// Sessions Page
Ui::SessionConfigWidget *sessionConfigUi;
......
......@@ -38,6 +38,7 @@
#include "katedebug.h"
#include "katecolorschemechooser.h"
#include "katefileactions.h"
#include "katequickopenmodel.h"
#include <KActionMenu>
#include <KAboutApplicationDialog>
......@@ -628,6 +629,8 @@ void KateMainWindow::readOptions()
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 @@ bool KateMainWindow::hideToolView(QWidget *widget)
return KateMDI::MainWindow::hideToolView(qobject_cast<KateMDI::ToolView *>(widget));
}
void KateMainWindow::setQuickOpenMatchMode(int mode)
{
m_quickOpen->setMatchMode(mode);
}
int KateMainWindow::quickOpenMatchMode()
{
return m_quickOpen->matchMode();
}
......@@ -292,6 +292,9 @@ public:
m_modCloseAfterLast = e;
}
void setQuickOpenMatchMode(int mode);
int quickOpenMatchMode();
KRecentFilesAction *fileOpenRecent() const {
return m_fileOpenRecent;
}
......
......@@ -53,6 +53,7 @@ Q_DECLARE_METATYPE(QPointer<KTextEditor::Document>)
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 @@ KateQuickOpen::KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow)
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);
......
......@@ -42,6 +42,14 @@ public:
*/
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 @@ private:
* filtered model we search in
*/
QSortFilterProxyModel *m_model;
int m_matchMode;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment