Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
edd799c2
Commit
edd799c2
authored
Feb 06, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Feb 07, 2021
Browse files
Improve quickopen performance
parent
7cb6078b
Changes
3
Hide whitespace changes
Inline
Side-by-side
kate/quickopen/katequickopen.cpp
View file @
edd799c2
...
...
@@ -67,13 +67,10 @@ protected:
return
true
;
}
const
auto
idx
=
sourceModel
()
->
index
(
sourceRow
,
0
,
sourceParent
);
const
QString
fileN
ame
=
idx
.
data
().
toString
();
const
auto
nameAndPath
=
fileName
.
splitRef
(
QStringLiteral
(
"{[split]}"
)
);
const
QString
n
ame
=
idx
.
data
(
KateQuickOpenModel
::
FileName
).
toString
();
const
QString
path
=
idx
.
data
(
KateQuickOpenModel
::
FilePath
).
toString
(
);
const
auto
&
name
=
nameAndPath
.
at
(
0
);
const
auto
&
path
=
nameAndPath
.
at
(
1
);
int
score
=
0
;
bool
res
=
false
;
if
(
mode
==
FilterMode
::
FilterByName
)
{
res
=
filterByName
(
name
,
score
);
...
...
@@ -103,12 +100,12 @@ public Q_SLOTS:
}
private:
inline
bool
filterByPath
(
const
QString
Ref
&
path
,
int
&
score
)
const
inline
bool
filterByPath
(
const
QString
&
path
,
int
&
score
)
const
{
return
kfts
::
fuzzy_match
(
pattern
,
path
,
score
);
}
inline
bool
filterByName
(
const
QString
Ref
&
name
,
int
&
score
)
const
inline
bool
filterByName
(
const
QString
&
name
,
int
&
score
)
const
{
return
kfts
::
fuzzy_match
(
pattern
,
name
,
score
);
}
...
...
@@ -133,11 +130,8 @@ public:
QTextDocument
doc
;
QString
str
=
index
.
data
().
toString
();
auto
namePath
=
str
.
split
(
QStringLiteral
(
"{[split]}"
));
QString
name
=
namePath
.
at
(
0
);
QString
path
=
namePath
.
at
(
1
);
QString
name
=
index
.
data
(
KateQuickOpenModel
::
FileName
).
toString
();
QString
path
=
index
.
data
(
KateQuickOpenModel
::
FilePath
).
toString
();
path
.
remove
(
QStringLiteral
(
"/"
)
+
name
);
...
...
kate/quickopen/katequickopenmodel.cpp
View file @
edd799c2
...
...
@@ -44,11 +44,14 @@ QVariant KateQuickOpenModel::data(const QModelIndex &idx, int role) const
}
const
ModelEntry
&
entry
=
m_modelEntries
.
at
(
idx
.
row
());
if
(
role
==
Qt
::
DisplayRole
)
{
switch
(
idx
.
column
())
{
case
Columns
::
FileName
:
return
QString
(
entry
.
fileName
+
QStringLiteral
(
"{[split]}"
)
+
entry
.
filePath
);
}
if
(
role
==
Role
::
FileName
)
{
return
entry
.
fileName
;
}
else
if
(
role
==
Role
::
FilePath
)
{
return
entry
.
filePath
;
}
else
if
(
role
==
Qt
::
DisplayRole
)
{
// Shouldn't ask for displayrole
Q_ASSERT
(
false
);
return
{};
}
else
if
(
role
==
Qt
::
FontRole
)
{
if
(
entry
.
bold
)
{
QFont
font
;
...
...
kate/quickopen/katequickopenmodel.h
View file @
edd799c2
...
...
@@ -32,8 +32,7 @@ class KateQuickOpenModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum
Columns
:
int
{
FileName
,
FilePath
,
Bold
};
enum
Role
{
Score
=
Qt
::
UserRole
+
1
};
enum
Role
{
FileName
=
Qt
::
UserRole
+
1
,
FilePath
,
Score
};
explicit
KateQuickOpenModel
(
KateMainWindow
*
mainWindow
,
QObject
*
parent
=
nullptr
);
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
int
columnCount
(
const
QModelIndex
&
parent
)
const
override
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment