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 !2
parents 46414b8b fc65fab0
......@@ -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(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->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(static_cast<KateQuickOpenModel::List>(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,8 @@ 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));
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
toggleShowStatusBar();
......@@ -1283,3 +1285,13 @@ int KateMainWindow::quickOpenMatchMode()
{
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;
class KateViewManager;
class KateMwModOnHdDialog;
class KateQuickOpen;
enum KateQuickOpenModelList : int;
// Helper layout class to always provide minimum size
class KateContainerStackedLayout : public QStackedLayout
......@@ -298,6 +299,9 @@ public:
void setQuickOpenMatchMode(int mode);
int quickOpenMatchMode();
void setQuickOpenListMode(KateQuickOpenModelList mode);
KateQuickOpenModelList quickOpenListMode() const;
KRecentFilesAction *fileOpenRecent() const {
return m_fileOpenRecent;
}
......
......@@ -181,3 +181,13 @@ int KateQuickOpen::matchMode()
{
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;
class QSortFilterProxyModel;
class QTreeView;
class KateQuickOpenModel;
enum KateQuickOpenModelList : int;
class KateQuickOpen : public QWidget
{
......@@ -45,6 +46,9 @@ public:
int matchMode();
void setMatchMode(int mode);
KateQuickOpenModelList listMode() const;
void setListMode(KateQuickOpenModelList 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());
......
......@@ -35,6 +35,9 @@ struct ModelEntry {
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 {
Q_OBJECT
public:
......@@ -44,6 +47,10 @@ public:
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& idx, int role) const override;
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:
QVector<ModelEntry> m_modelEntries;
......@@ -54,6 +61,7 @@ private:
* code.
*/
KateMainWindow *m_mainWindow;
List 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