Commit e1292b5d authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Remove FilterByPath/ByName in Quickopen

parent 164a6c53
......@@ -47,11 +47,6 @@ public:
{
}
void changeMode(FilterModes m)
{
mode = m;
}
protected:
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override
{
......@@ -71,11 +66,7 @@ protected:
int score = 0;
bool res = false;
if (mode == FilterMode::FilterByName) {
res = filterByName(name, score);
} else if (mode == FilterMode::FilterByPath) {
res = filterByPath(path, score);
} else {
{
int scorep = 0, scoren = 0;
bool resn = filterByName(name, scoren);
......@@ -116,7 +107,6 @@ private:
private:
QString pattern;
FilterModes mode;
};
class QuickOpenStyleDelegate : public QStyledItemDelegate
......@@ -141,26 +131,21 @@ public:
const QString nameColor = option.palette.color(QPalette::Link).name();
if (mode == FilterMode::FilterByName) {
kfts::to_scored_fuzzy_matched_display_string(
m_filterString, name, QStringLiteral("<b style=\"color:%1;\">").arg(nameColor), QStringLiteral("</b>"));
} else if (mode == FilterMode::FilterByPath) {
kfts::to_scored_fuzzy_matched_display_string(m_filterString, path, QStringLiteral("<b>"), QStringLiteral("</b>"));
// check if there's a / separtion in filter string
// if there is, we use the last part to highlight the
// filename
int pos = m_filterString.lastIndexOf(QLatin1Char('/'));
if (pos > -1) {
++pos;
auto pattern = m_filterString.midRef(pos);
kfts::to_scored_fuzzy_matched_display_string(pattern, name, QStringLiteral("<b style=\"color:%1;\">").arg(nameColor), QStringLiteral("</b>"));
} else {
// check if there's a / separtion in filter string
// if there is, we use the last part to highlight the
// filename
int pos = m_filterString.lastIndexOf(QLatin1Char('/'));
if (pos > -1) {
++pos;
auto pattern = m_filterString.midRef(pos);
kfts::to_scored_fuzzy_matched_display_string(pattern, name, QStringLiteral("<b style=\"color:%1;\">").arg(nameColor), QStringLiteral("</b>"));
} else {
kfts::to_scored_fuzzy_matched_display_string(
m_filterString, name, QStringLiteral("<b style=\"color:%1;\">").arg(nameColor), QStringLiteral("</b>"));
}
kfts::to_scored_fuzzy_matched_display_string(m_filterString, path, QStringLiteral("<b>"), QStringLiteral("</b>"));
kfts::to_scored_fuzzy_matched_display_string(m_filterString,
name,
QStringLiteral("<b style=\"color:%1;\">").arg(nameColor),
QStringLiteral("</b>"));
}
kfts::to_scored_fuzzy_matched_display_string(m_filterString, path, QStringLiteral("<b>"), QStringLiteral("</b>"));
const auto pathFontsize = option.font.pointSize();
doc.setHtml(QStringLiteral("<span style=\"font-size: %1pt;\">").arg(pathFontsize) + name + QStringLiteral("</span>") + QStringLiteral(" &nbsp;")
......@@ -189,11 +174,6 @@ public:
painter->restore();
}
void changeMode(FilterModes m)
{
mode = m;
}
public Q_SLOTS:
void setFilterString(const QString &text)
{
......@@ -202,7 +182,6 @@ public Q_SLOTS:
private:
QString m_filterString;
FilterModes mode;
};
Q_DECLARE_METATYPE(QPointer<KTextEditor::Document>)
......@@ -246,7 +225,6 @@ KateQuickOpen::KateQuickOpen(KateMainWindow *mainWindow)
reselectFirst(); // hacky way
});
connect(m_inputLine, &QuickOpenLineEdit::returnPressed, this, &KateQuickOpen::slotReturnPressed);
connect(m_inputLine, &QuickOpenLineEdit::filterModeChanged, this, &KateQuickOpen::slotfilterModeChanged);
connect(m_inputLine, &QuickOpenLineEdit::listModeChanged, this, &KateQuickOpen::slotListModeChanged);
connect(m_listView, &QTreeView::activated, this, &KateQuickOpen::slotReturnPressed);
......@@ -264,8 +242,6 @@ KateQuickOpen::KateQuickOpen(KateMainWindow *mainWindow)
setHidden(true);
// restore settings
slotfilterModeChanged(m_inputLine->filterMode());
slotListModeChanged(m_inputLine->listMode());
// fill stuff
......@@ -277,7 +253,6 @@ KateQuickOpen::~KateQuickOpen()
KSharedConfig::Ptr cfg = KSharedConfig::openConfig();
KConfigGroup cg(cfg, "General");
cg.writeEntry("Quickopen Filter Mode", static_cast<int>(m_filterMode));
cg.writeEntry("Quickopen List Mode", m_base_model->listMode() == KateQuickOpenModelList::CurrentProject);
}
......@@ -353,14 +328,6 @@ void KateQuickOpen::slotReturnPressed()
m_inputLine->clear();
}
void KateQuickOpen::slotfilterModeChanged(FilterModes mode)
{
m_filterMode = mode;
m_model->changeMode(mode);
m_styleDelegate->changeMode(mode);
m_model->invalidate();
}
void KateQuickOpen::slotListModeChanged(KateQuickOpenModel::List mode)
{
m_base_model->setListMode(mode);
......
......@@ -50,8 +50,6 @@ private Q_SLOTS:
*/
void slotReturnPressed();
void slotfilterModeChanged(FilterModes mode);
void slotListModeChanged(KateQuickOpenModelList mode);
private:
......@@ -59,7 +57,6 @@ private:
QTreeView *m_listView;
QuickOpenLineEdit *m_inputLine;
QuickOpenStyleDelegate *m_styleDelegate;
FilterModes m_filterMode;
/**
* our model we search in
......
......@@ -34,36 +34,8 @@ void QuickOpenLineEdit::setupMenu()
KSharedConfig::Ptr cfg = KSharedConfig::openConfig();
KConfigGroup cg(cfg, "General");
const int cfgFilterMode = cg.readEntry("Quickopen Filter Mode", (FilterMode::FilterByName | FilterMode::FilterByPath));
const bool cfgListMode = cg.readEntry("Quickopen List Mode", true);
menu->addSeparator();
auto act1 = menu->addAction(i18n("Filter By Path"));
act1->setCheckable(true);
connect(act1, &QAction::toggled, this, [this](bool checked) {
m_mode.setFlag(FilterMode::FilterByPath, checked);
emit filterModeChanged(m_mode);
});
auto act2 = menu->addAction(i18n("Filter By Name"));
act2->setCheckable(true);
connect(act2, &QAction::toggled, this, [this](bool checked) {
m_mode.setFlag(FilterMode::FilterByName, checked);
emit filterModeChanged(m_mode);
});
if (cfgFilterMode == FilterMode::FilterByPath) {
m_mode = FilterMode::FilterByPath;
act1->setChecked(true);
} else if (cfgFilterMode == FilterMode::FilterByName) {
m_mode = FilterMode::FilterByName;
act2->setChecked(true);
} else {
m_mode = (FilterMode)(FilterMode::FilterByName | FilterMode::FilterByPath);
act1->setChecked(true);
act2->setChecked(true);
}
menu->addSeparator();
QActionGroup *actGp = new QActionGroup(this);
......
......@@ -12,24 +12,12 @@
#include "katequickopenmodel.h"
enum FilterMode : uint8_t {
FilterByName = 0x01, /* By File Name */
FilterByPath = 0x02 /* By File Path */
};
Q_DECLARE_FLAGS(FilterModes, FilterMode)
Q_FLAGS(FilterModes)
class QuickOpenLineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit QuickOpenLineEdit(QWidget *parent);
FilterModes filterMode() const
{
return m_mode;
}
KateQuickOpenModelList listMode() const
{
return m_listMode;
......@@ -43,11 +31,9 @@ private:
private:
std::unique_ptr<QMenu> menu;
FilterModes m_mode;
KateQuickOpenModelList m_listMode;
Q_SIGNALS:
void filterModeChanged(FilterModes mode);
void listModeChanged(KateQuickOpenModelList mode);
};
......
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