Commit e3d5f8c7 authored by Christoph Cullmann's avatar Christoph Cullmann

Merge branch 'quickopen-list-mode' into 'master'

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

See merge request kde/kate!2
parents 46414b8b fc65fab0
...@@ -150,7 +150,10 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi ...@@ -150,7 +150,10 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi
// quick search // quick search
buttonGroup = new QGroupBox(i18n("&Quick Open"), generalFrame); 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); label = new QLabel(i18n("&Match Mode:"), buttonGroup);
hlayout->addWidget(label); hlayout->addWidget(label);
m_cmbQuickOpenMatchMode = new QComboBox(buttonGroup); m_cmbQuickOpenMatchMode = new QComboBox(buttonGroup);
...@@ -161,6 +164,20 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi ...@@ -161,6 +164,20 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi
m_cmbQuickOpenMatchMode->setCurrentIndex(m_cmbQuickOpenMatchMode->findData(m_mainWindow->quickOpenMatchMode())); m_cmbQuickOpenMatchMode->setCurrentIndex(m_cmbQuickOpenMatchMode->findData(m_mainWindow->quickOpenMatchMode()));
m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt()); m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt());
connect(m_cmbQuickOpenMatchMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged); 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(static_cast<KateQuickOpenModel::List>(m_cmbQuickOpenListMode->currentData().toInt()));
connect(m_cmbQuickOpenListMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged);
vbox->addLayout(hlayout);
layout->addWidget(buttonGroup); layout->addWidget(buttonGroup);
layout->addStretch(1); // :-] works correct without autoadd layout->addStretch(1); // :-] works correct without autoadd
...@@ -354,6 +371,9 @@ void KateConfigDialog::slotApply() ...@@ -354,6 +371,9 @@ void KateConfigDialog::slotApply()
cg.writeEntry("Quick Open Search Mode", m_cmbQuickOpenMatchMode->currentData().toInt()); cg.writeEntry("Quick Open Search Mode", m_cmbQuickOpenMatchMode->currentData().toInt());
m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt()); m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt());
cg.writeEntry("Quick Open List Mode", m_cmbQuickOpenListMode->currentData().toInt());
m_mainWindow->setQuickOpenListMode(static_cast<KateQuickOpenModel::List>(m_cmbQuickOpenListMode->currentData().toInt()));
// patch document modified warn state // patch document modified warn state
const QList<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList(); const QList<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList();
foreach(KTextEditor::Document * doc, docs) foreach(KTextEditor::Document * doc, docs)
......
...@@ -85,6 +85,7 @@ private: ...@@ -85,6 +85,7 @@ private:
QCheckBox *m_saveMetaInfos; QCheckBox *m_saveMetaInfos;
KPluralHandlingSpinBox *m_daysMetaInfos; KPluralHandlingSpinBox *m_daysMetaInfos;
QComboBox * m_cmbQuickOpenMatchMode; QComboBox * m_cmbQuickOpenMatchMode;
QComboBox * m_cmbQuickOpenListMode;
// Sessions Page // Sessions Page
Ui::SessionConfigWidget *sessionConfigUi; Ui::SessionConfigWidget *sessionConfigUi;
......
...@@ -634,6 +634,8 @@ void KateMainWindow::readOptions() ...@@ -634,6 +634,8 @@ void KateMainWindow::readOptions()
m_paShowTabBar->setChecked(generalGroup.readEntry("Show Tab Bar", true)); m_paShowTabBar->setChecked(generalGroup.readEntry("Show Tab Bar", true));
m_quickOpen->setMatchMode(generalGroup.readEntry("Quick Open Search Mode", (int)KateQuickOpenModel::Columns::FileName)); m_quickOpen->setMatchMode(generalGroup.readEntry("Quick Open Search Mode", (int)KateQuickOpenModel::Columns::FileName));
int listMode = generalGroup.readEntry("Quick Open List Mode", (int)KateQuickOpenModel::List::CurrentProject);
m_quickOpen->setListMode(static_cast<KateQuickOpenModel::List>(listMode));
// emit signal to hide/show statusbars // emit signal to hide/show statusbars
toggleShowStatusBar(); toggleShowStatusBar();
...@@ -1283,3 +1285,13 @@ int KateMainWindow::quickOpenMatchMode() ...@@ -1283,3 +1285,13 @@ int KateMainWindow::quickOpenMatchMode()
{ {
return m_quickOpen->matchMode(); return m_quickOpen->matchMode();
} }
void KateMainWindow::setQuickOpenListMode(KateQuickOpenModel::List mode)
{
m_quickOpen->setListMode(mode);
}
KateQuickOpenModel::List KateMainWindow::quickOpenListMode() const
{
return m_quickOpen->listMode();
}
...@@ -54,6 +54,7 @@ class KRecentFilesAction; ...@@ -54,6 +54,7 @@ class KRecentFilesAction;
class KateViewManager; class KateViewManager;
class KateMwModOnHdDialog; class KateMwModOnHdDialog;
class KateQuickOpen; class KateQuickOpen;
enum KateQuickOpenModelList : int;
// Helper layout class to always provide minimum size // Helper layout class to always provide minimum size
class KateContainerStackedLayout : public QStackedLayout class KateContainerStackedLayout : public QStackedLayout
...@@ -298,6 +299,9 @@ public: ...@@ -298,6 +299,9 @@ public:
void setQuickOpenMatchMode(int mode); void setQuickOpenMatchMode(int mode);
int quickOpenMatchMode(); int quickOpenMatchMode();
void setQuickOpenListMode(KateQuickOpenModelList mode);
KateQuickOpenModelList quickOpenListMode() const;
KRecentFilesAction *fileOpenRecent() const { KRecentFilesAction *fileOpenRecent() const {
return m_fileOpenRecent; return m_fileOpenRecent;
} }
......
...@@ -181,3 +181,13 @@ int KateQuickOpen::matchMode() ...@@ -181,3 +181,13 @@ int KateQuickOpen::matchMode()
{ {
return m_model->filterKeyColumn(); return m_model->filterKeyColumn();
} }
void KateQuickOpen::setListMode(KateQuickOpenModel::List mode)
{
m_base_model->setListMode(mode);
}
KateQuickOpenModel::List KateQuickOpen::listMode() const
{
return m_base_model->listMode();
}
...@@ -30,6 +30,7 @@ class QStandardItemModel; ...@@ -30,6 +30,7 @@ class QStandardItemModel;
class QSortFilterProxyModel; class QSortFilterProxyModel;
class QTreeView; class QTreeView;
class KateQuickOpenModel; class KateQuickOpenModel;
enum KateQuickOpenModelList : int;
class KateQuickOpen : public QWidget class KateQuickOpen : public QWidget
{ {
...@@ -45,6 +46,9 @@ public: ...@@ -45,6 +46,9 @@ public:
int matchMode(); int matchMode();
void setMatchMode(int mode); void setMatchMode(int mode);
KateQuickOpenModelList listMode() const;
void setListMode(KateQuickOpenModelList mode);
protected: protected:
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
......
...@@ -79,7 +79,10 @@ void KateQuickOpenModel::refresh() ...@@ -79,7 +79,10 @@ void KateQuickOpenModel::refresh()
QObject *projectView = m_mainWindow->pluginView(QStringLiteral("kateprojectplugin")); QObject *projectView = m_mainWindow->pluginView(QStringLiteral("kateprojectplugin"));
const QList<KTextEditor::View *> sortedViews = m_mainWindow->viewManager()->sortedViews(); const QList<KTextEditor::View *> sortedViews = m_mainWindow->viewManager()->sortedViews();
const QList<KTextEditor::Document *> openDocs = KateApp::self()->documentManager()->documentList(); 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; QVector<ModelEntry> allDocuments;
allDocuments.reserve(sortedViews.size() + openDocs.size() + projectDocs.size()); allDocuments.reserve(sortedViews.size() + openDocs.size() + projectDocs.size());
......
...@@ -35,6 +35,9 @@ struct ModelEntry { ...@@ -35,6 +35,9 @@ struct ModelEntry {
size_t sort_id; size_t sort_id;
}; };
// needs to be defined outside of class to support forward declaration elsewhere
enum KateQuickOpenModelList : int { CurrentProject, AllProjects };
class KateQuickOpenModel : public QAbstractTableModel { class KateQuickOpenModel : public QAbstractTableModel {
Q_OBJECT Q_OBJECT
public: public:
...@@ -44,6 +47,10 @@ public: ...@@ -44,6 +47,10 @@ public:
int columnCount(const QModelIndex& parent) const override; int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& idx, int role) const override; QVariant data(const QModelIndex& idx, int role) const override;
void refresh(); void refresh();
// add a convenient in-class alias
using List = KateQuickOpenModelList;
List listMode() const { return m_listMode; }
void setListMode(List mode) { m_listMode = mode; }
private: private:
QVector<ModelEntry> m_modelEntries; QVector<ModelEntry> m_modelEntries;
...@@ -54,6 +61,7 @@ private: ...@@ -54,6 +61,7 @@ private:
* code. * code.
*/ */
KateMainWindow *m_mainWindow; KateMainWindow *m_mainWindow;
List m_listMode;
}; };
#endif #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