src/model.cpp

changeset 1425
5354313b9958
parent 1402
8bbf2af8c3f5
child 1440
265b2e95a8e8
--- a/src/model.cpp	Fri Jun 22 15:03:50 2018 +0300
+++ b/src/model.cpp	Sat Jun 23 13:57:04 2018 +0300
@@ -311,6 +311,8 @@
 
 QVariant Model::data(const QModelIndex& index, int role) const
 {
+	static QMap<QString, QPixmap> scaledIcons;
+
 	if (index.row() < 0 or index.row() >= size())
 		return {};
 
@@ -337,7 +339,17 @@
 		}
 
 	case Qt::DecorationRole:
-		return MainWindow::getIcon(object->iconName());
+		{
+			QString iconName = object->iconName();
+			auto it = scaledIcons.find(iconName);
+			if (it == scaledIcons.end())
+			{
+				QPixmap pixmap = MainWindow::getIcon(object->iconName())
+					.scaled({24, 24}, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+				it = scaledIcons.insert(iconName, pixmap);
+			}
+			return *it;
+		}
 
 	case Qt::BackgroundColorRole:
 		if (object->type() == LDObjectType::Error)

mercurial