aboutsummaryrefslogtreecommitdiff
path: root/notebookmodel.cc
diff options
context:
space:
mode:
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r--notebookmodel.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/notebookmodel.cc b/notebookmodel.cc
index 8a58ebf..bfe183b 100644
--- a/notebookmodel.cc
+++ b/notebookmodel.cc
@@ -291,6 +291,7 @@ void NotebookModel::refreshPen(const QString &name)
return;
}
+ _iconCache.clear();
_watcher.addPath(penDir.canonicalPath());
QStringList &curNotebooks = _notebooks[name];
@@ -359,22 +360,21 @@ QDir NotebookModel::notebookDir(const QString &pen, const QString &notebook) con
QIcon NotebookModel::getNotebookIcon(const QString &pen, const QString &notebook) const
{
- static QStringList candidates;
- if (candidates.isEmpty()) {
- candidates << "userdata/icon/Notebook.png"
- << "userdata/icon/active_64x64.png"
- << "userdata/icon/active_32x32.png"
- << "userdata/icon/active_16x16.png";
- }
- QIcon icon;
-
QDir dir = notebookDir(pen, notebook);
- if (dir.exists()) {
+
+ QIcon icon = _iconCache.value(dir.path());
+ if (icon.isNull() && dir.exists()) {
+ static const QStringList candidates{"userdata/icon/Notebook.png",
+ "userdata/icon/active_64x64.png",
+ "userdata/icon/active_32x32.png",
+ "userdata/icon/active_16x16.png"};
foreach (const QString &candidate, candidates) {
if (dir.exists(candidate)) {
icon.addFile(dir.filePath(candidate));
}
}
+
+ _iconCache.insert(dir.path(), icon);
}
return icon;