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

Improve quickopen performance

parent 7cb6078b
...@@ -67,13 +67,10 @@ protected: ...@@ -67,13 +67,10 @@ protected:
return true; return true;
} }
const auto idx = sourceModel()->index(sourceRow, 0, sourceParent); const auto idx = sourceModel()->index(sourceRow, 0, sourceParent);
const QString fileName = idx.data().toString(); const QString name = idx.data(KateQuickOpenModel::FileName).toString();
const auto nameAndPath = fileName.splitRef(QStringLiteral("{[split]}")); const QString path = idx.data(KateQuickOpenModel::FilePath).toString();
const auto &name = nameAndPath.at(0);
const auto &path = nameAndPath.at(1);
int score = 0; int score = 0;
bool res = false; bool res = false;
if (mode == FilterMode::FilterByName) { if (mode == FilterMode::FilterByName) {
res = filterByName(name, score); res = filterByName(name, score);
...@@ -103,12 +100,12 @@ public Q_SLOTS: ...@@ -103,12 +100,12 @@ public Q_SLOTS:
} }
private: private:
inline bool filterByPath(const QStringRef &path, int &score) const inline bool filterByPath(const QString &path, int &score) const
{ {
return kfts::fuzzy_match(pattern, path, score); return kfts::fuzzy_match(pattern, path, score);
} }
inline bool filterByName(const QStringRef &name, int &score) const inline bool filterByName(const QString &name, int &score) const
{ {
return kfts::fuzzy_match(pattern, name, score); return kfts::fuzzy_match(pattern, name, score);
} }
...@@ -133,11 +130,8 @@ public: ...@@ -133,11 +130,8 @@ public:
QTextDocument doc; QTextDocument doc;
QString str = index.data().toString(); QString name = index.data(KateQuickOpenModel::FileName).toString();
QString path = index.data(KateQuickOpenModel::FilePath).toString();
auto namePath = str.split(QStringLiteral("{[split]}"));
QString name = namePath.at(0);
QString path = namePath.at(1);
path.remove(QStringLiteral("/") + name); path.remove(QStringLiteral("/") + name);
......
...@@ -44,11 +44,14 @@ QVariant KateQuickOpenModel::data(const QModelIndex &idx, int role) const ...@@ -44,11 +44,14 @@ QVariant KateQuickOpenModel::data(const QModelIndex &idx, int role) const
} }
const ModelEntry &entry = m_modelEntries.at(idx.row()); const ModelEntry &entry = m_modelEntries.at(idx.row());
if (role == Qt::DisplayRole) { if (role == Role::FileName) {
switch (idx.column()) { return entry.fileName;
case Columns::FileName: } else if (role == Role::FilePath) {
return QString(entry.fileName + QStringLiteral("{[split]}") + entry.filePath); return entry.filePath;
} } else if (role == Qt::DisplayRole) {
// Shouldn't ask for displayrole
Q_ASSERT(false);
return {};
} else if (role == Qt::FontRole) { } else if (role == Qt::FontRole) {
if (entry.bold) { if (entry.bold) {
QFont font; QFont font;
......
...@@ -32,8 +32,7 @@ class KateQuickOpenModel : public QAbstractTableModel ...@@ -32,8 +32,7 @@ class KateQuickOpenModel : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
public: public:
enum Columns : int { FileName, FilePath, Bold }; enum Role { FileName = Qt::UserRole + 1, FilePath, Score };
enum Role { Score = Qt::UserRole + 1 };
explicit KateQuickOpenModel(KateMainWindow *mainWindow, QObject *parent = nullptr); explicit KateQuickOpenModel(KateMainWindow *mainWindow, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override;
......
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