Skip to content

Commit

Permalink
Close: chris2511#366 Not Responding after upgrade
Browse files Browse the repository at this point in the history
cache the results of visibility check as long as the search text remains.
This function is called many times when displaying the data,
even if the search string does not change.
  • Loading branch information
chris2511 committed Aug 3, 2022
1 parent 21536e6 commit 186657f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/db_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ void db_base::updateItem(pki_base *pki, const QString &name,
TransDone(e);
pki->setIntName(name);
pki->setComment(comment);
pki->recheckVisibility();

QModelIndex i, j;
i = index(pki);
Expand Down
3 changes: 2 additions & 1 deletion lib/pki_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ QString pki_base::getUnderlinedName() const

bool pki_base::visible() const
{
if (limitPattern.isEmpty())
if (limitPattern.isEmpty() || limitPattern == lastPattern)
return true;
lastPattern = limitPattern;
return getIntName().contains(limitPattern) ||
comment.contains(limitPattern);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/pki_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class pki_base : public QObject
virtual QByteArray PEM_comment() const;
virtual void collect_properties(QMap<QString, QString> &) const;
QList<pki_base*> childItems;
mutable QRegExp lastPattern;

public:
enum msg_type {
Expand All @@ -89,12 +90,17 @@ class pki_base : public QObject

QList<pki_base*> getChildItems() const;
void clear();
void recheckVisibility()
{
lastPattern = QRegExp();
}
QString getIntName() const
{
return desc;
}
void setFilename(const QString &s)
{
recheckVisibility();
filename = s;
}
QString getFilename() const
Expand All @@ -110,6 +116,7 @@ class pki_base : public QObject
QString getUnderlinedName() const;
void setIntName(const QString &d)
{
recheckVisibility();
desc = d;
}
virtual void autoIntName(const QString &file);
Expand All @@ -119,6 +126,7 @@ class pki_base : public QObject
}
void setComment(const QString &c)
{
recheckVisibility();
comment = c;
}
QVariant getSqlItemId() const
Expand Down

0 comments on commit 186657f

Please sign in to comment.