Commit fc65fab0 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

katequickopen: sprinkle more const and enum for list mode

parent 7bdbad54
......@@ -175,7 +175,7 @@ KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *vi
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());
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);
......@@ -372,7 +372,7 @@ void KateConfigDialog::slotApply()
m_mainWindow->setQuickOpenMatchMode(m_cmbQuickOpenMatchMode->currentData().toInt());
cg.writeEntry("Quick Open List Mode", m_cmbQuickOpenListMode->currentData().toInt());
m_mainWindow->setQuickOpenListMode(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();
......
......@@ -634,7 +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));
m_quickOpen->setListMode(generalGroup.readEntry("Quick Open List Mode", (int)KateQuickOpenModel::List::CurrentProject));
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();
......@@ -1285,12 +1286,12 @@ int KateMainWindow::quickOpenMatchMode()
return m_quickOpen->matchMode();
}
void KateMainWindow::setQuickOpenListMode(int mode)
void KateMainWindow::setQuickOpenListMode(KateQuickOpenModel::List mode)
{
m_quickOpen->setListMode(mode);
}
int KateMainWindow::quickOpenListMode()
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,8 +299,8 @@ public:
void setQuickOpenMatchMode(int mode);
int quickOpenMatchMode();
void setQuickOpenListMode(int mode);
int quickOpenListMode();
void setQuickOpenListMode(KateQuickOpenModelList mode);
KateQuickOpenModelList quickOpenListMode() const;
KRecentFilesAction *fileOpenRecent() const {
return m_fileOpenRecent;
......
......@@ -182,12 +182,12 @@ int KateQuickOpen::matchMode()
return m_model->filterKeyColumn();
}
void KateQuickOpen::setListMode(int mode)
void KateQuickOpen::setListMode(KateQuickOpenModel::List mode)
{
m_base_model->setListMode(mode);
}
int KateQuickOpen::listMode()
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,8 +46,8 @@ public:
int matchMode();
void setMatchMode(int mode);
int listMode();
void setListMode(int mode);
KateQuickOpenModelList listMode() const;
void setListMode(KateQuickOpenModelList mode);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
......
......@@ -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,9 +47,10 @@ 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; }
// 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;
......@@ -57,7 +61,7 @@ private:
* code.
*/
KateMainWindow *m_mainWindow;
int m_listMode;
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