Commit 7bdbad54 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

katequickopen: add config option to present current or all project files

... which is especially useful/needed when dealing with a large number of small
repos as opposed to one or few large repos.
parent 915789a6
......@@ -150,7 +150,10 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi
// quick search
buttonGroup = new QGroupBox(i18n("&Quick Open"), generalFrame);
hlayout = new QHBoxLayout(buttonGroup);
vbox = new QVBoxLayout;
buttonGroup->setLayout(vbox);
// quick open match mode
hlayout = new QHBoxLayout;
label = new QLabel(i18n("&Match Mode:"), buttonGroup);
hlayout->addWidget(label);
m_cmbQuickOpenMatchMode = new QComboBox(buttonGroup);
......@@ -161,6 +164,20 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi
m_cmbQuickOpenMatchMode->setCurrentIndex(m_cmbQuickOpenMatchMode->findData(m_mainWindow->quickOpenMatchMode()));
m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt());
connect(m_cmbQuickOpenMatchMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged);
vbox->addLayout(hlayout);
// quick open list mode
hlayout = new QHBoxLayout;
label = new QLabel(i18n("&List Mode:"), buttonGroup);
hlayout->addWidget(label);
m_cmbQuickOpenListMode = new QComboBox(buttonGroup);
hlayout->addWidget(m_cmbQuickOpenListMode);
label->setBuddy(m_cmbQuickOpenListMode);
m_cmbQuickOpenListMode->addItem(i18n("Current Project Files"), QVariant(KateQuickOpenModel::List::CurrentProject));
m_cmbQuickOpenListMode->addItem(i18n("All Projects Files"), QVariant(KateQuickOpenModel::List::AllProjects));
m_cmbQuickOpenListMode->setCurrentIndex(m_cmbQuickOpenListMode->findData(m_mainWindow->quickOpenListMode()));
m_mainWindow->setQuickOpenListMode(m_cmbQuickOpenListMode->currentData().toInt());
connect(m_cmbQuickOpenListMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged);
vbox->addLayout(hlayout);
layout->addWidget(buttonGroup);
layout->addStretch(1); // :-] works correct without autoadd
......@@ -354,6 +371,9 @@ void KateConfigDialog::slotApply()
cg.writeEntry("Quick Open Search Mode", m_cmbQuickOpenMatchMode->currentData().toInt());
m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt());
cg.writeEntry("Quick Open List Mode", m_cmbQuickOpenListMode->currentData().toInt());
m_mainWindow->setQuickOpenListMode(m_cmbQuickOpenListMode->currentData().toInt());
// patch document modified warn state
const QList<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList();
foreach(KTextEditor::Document * doc, docs)
......
......@@ -85,6 +85,7 @@ private:
QCheckBox *m_saveMetaInfos;
KPluralHandlingSpinBox *m_daysMetaInfos;
QComboBox * m_cmbQuickOpenMatchMode;
QComboBox * m_cmbQuickOpenListMode;
// Sessions Page
Ui::SessionConfigWidget *sessionConfigUi;
......
......@@ -634,6 +634,7 @@ void KateMainWindow::readOptions()
m_paShowTabBar->setChecked(generalGroup.readEntry("Show Tab Bar", true));
m_quickOpen->setMatchMode(generalGroup.readEntry("Quick Open Search Mode", (int)KateQuickOpenModel::Columns::FileName));
m_quickOpen->setListMode(generalGroup.readEntry("Quick Open List Mode", (int)KateQuickOpenModel::List::CurrentProject));
// emit signal to hide/show statusbars
toggleShowStatusBar();
......@@ -1283,3 +1284,13 @@ int KateMainWindow::quickOpenMatchMode()
{
return m_quickOpen->matchMode();
}
void KateMainWindow::setQuickOpenListMode(int mode)
{
m_quickOpen->setListMode(mode);
}
int KateMainWindow::quickOpenListMode()
{
return m_quickOpen->listMode();
}
......@@ -298,6 +298,9 @@ public:
void setQuickOpenMatchMode(int mode);
int quickOpenMatchMode();
void setQuickOpenListMode(int mode);
int quickOpenListMode();
KRecentFilesAction *fileOpenRecent() const {
return m_fileOpenRecent;
}
......
......@@ -181,3 +181,13 @@ int KateQuickOpen::matchMode()
{
return m_model->filterKeyColumn();
}
void KateQuickOpen::setListMode(int mode)
{
m_base_model->setListMode(mode);
}
int KateQuickOpen::listMode()
{
return m_base_model->listMode();
}
......@@ -45,6 +45,9 @@ public:
int matchMode();
void setMatchMode(int mode);
int listMode();
void setListMode(int mode);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
......
......@@ -79,7 +79,10 @@ void KateQuickOpenModel::refresh()
QObject *projectView = m_mainWindow->pluginView(QStringLiteral("kateprojectplugin"));
const QList<KTextEditor::View *> sortedViews = m_mainWindow->viewManager()->sortedViews();
const QList<KTextEditor::Document *> openDocs = KateApp::self()->documentManager()->documentList();
const QStringList projectDocs = projectView ? projectView->property("projectFiles").toStringList() : QStringList();
const QStringList projectDocs = projectView
? (m_listMode == CurrentProject
? projectView->property("projectFiles") : projectView->property("allProjectsFiles")).toStringList()
: QStringList();
QVector<ModelEntry> allDocuments;
allDocuments.reserve(sortedViews.size() + openDocs.size() + projectDocs.size());
......
......@@ -44,6 +44,9 @@ public:
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& idx, int role) const override;
void refresh();
enum List : int { CurrentProject, AllProjects };
int listMode() { return m_listMode; }
void setListMode(int mode) { m_listMode = mode; }
private:
QVector<ModelEntry> m_modelEntries;
......@@ -54,6 +57,7 @@ private:
* code.
*/
KateMainWindow *m_mainWindow;
int m_listMode;
};
#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