aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2020-10-18 12:08:48 +0200
committerNao Pross <np@0hm.ch>2020-10-18 12:08:48 +0200
commitccbc5feadc8edb9abc21acd39b0ff56a8a3be180 (patch)
tree2cd40e0223e2cf2a54dbe0f6438eb4198bfbc349
parentImplement MoodleTreeView.onWorkerLoadedItem slot (diff)
downloadMuddle-ccbc5feadc8edb9abc21acd39b0ff56a8a3be180.tar.gz
Muddle-ccbc5feadc8edb9abc21acd39b0ff56a8a3be180.zip
Re-add icons
Diffstat (limited to '')
-rw-r--r--gui.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/gui.py b/gui.py
index cf92fc3..f644c49 100644
--- a/gui.py
+++ b/gui.py
@@ -50,8 +50,6 @@ class MoodleItem(QTreeWidgetItem):
self.metadata = MoodleItem.Metadata(type = nodetype, **kwargs)
self.setupQt()
- # TODO: Qt objects should be on the main thread
- # prob cause of the crash
def setupQt(self):
font = QFont("Monospace")
font.setStyleHint(QFont.Monospace)
@@ -64,7 +62,7 @@ class MoodleItem(QTreeWidgetItem):
MoodleItem.Type.URL : QApplication.style().standardIcon(QStyle.SP_FileLinkIcon),
}
- if icons.get(self.type):
+ if icons.get(self.metadata.type):
self.setIcon(0, icons[self.metadata.type])
if self.metadata.type == MoodleItem.Type.FILE:
@@ -172,9 +170,22 @@ class MoodleTreeView(QTreeWidget):
if type == MoodleItem.Type.SECTION:
moodleItem = MoodleItem(parent = parent, nodetype = type, id = item["id"], title = item["name"])
elif type == MoodleItem.Type.MODULE:
- moodleItem = MoodleItem(parent = parent, nodetype = type, id = item["id"], title = item["name"])
+ moduleType = {
+ "folder" : MoodleItem.Type.FOLDER,
+ "resource" : MoodleItem.Type.RESOURCE,
+ "forum" : MoodleItem.Type.FORUM,
+ "attendance" : MoodleItem.Type.ATTENDANCE,
+ "label" : MoodleItem.Type.LABEL,
+ "quiz" : MoodleItem.Type.QUIZ,
+ }
+
+ moodleItem = MoodleItem(parent = parent, nodetype = moduleType.get(item["modname"]) or type, id = item["id"], title = item["name"])
elif type == MoodleItem.Type.CONTENT:
- moodleItem = MoodleItem(parent = parent, nodetype = type, title = item["filename"], url = item["fileurl"])
+ contentType = {
+ "url" : MoodleItem.Type.URL,
+ "file" : MoodleItem.Type.FILE,
+ }
+ moodleItem = MoodleItem(parent = parent, nodetype = contentType.get(item["type"]) or type, title = item["filename"], url = item["fileurl"])
if not moodleItem:
log.error(f"Could not load item of type {type}")