]> danix's work - publisher.git/commitdiff
feat: show type, date, tags, categories in article list rows
authorDanilo M. <redacted>
Sun, 3 May 2026 10:58:15 +0000 (12:58 +0200)
committerDanilo M. <redacted>
Sun, 3 May 2026 10:58:15 +0000 (12:58 +0200)
ui/articles_view.py

index f45e736aeeb8e84a96a686848fee61f386657ea3..36ca5ec7507c54e00bbafd7d7810dc59a56663b1 100644 (file)
@@ -3,7 +3,7 @@ from PyQt6.QtWidgets import (
     QWidget, QVBoxLayout, QTabWidget,
     QListWidget, QListWidgetItem, QLabel,
 )
-from PyQt6.QtCore import Qt, pyqtSignal
+from PyQt6.QtCore import Qt, pyqtSignal, QSize
 from PyQt6.QtGui import QColor
 from core.models import Article
 
@@ -13,12 +13,30 @@ class ArticleItem(QListWidgetItem):
         self.article = article
         if article.has_translation:
             badge = f"🇬🇧 âœ“" if article.lang == "it" else "🇮🇹 âœ“"
-            status = f"{article.slug}  [{badge}]"
         else:
             badge = f"🇬🇧 âœ—" if article.lang == "it" else "🇮🇹 âœ—"
-            status = f"{article.slug}  [{badge}]"
-        self.setText(status)
-        if not article.has_translation:
+        line1 = f"{article.slug}  [{badge}]"
+        if article.draft:
+            line1 = f"[DRAFT]  {line1}"
+
+        parts = []
+        if article.meta_type:
+            parts.append(article.meta_type)
+        if article.meta_date:
+            parts.append(article.meta_date)
+        if article.meta_tags:
+            parts.append(f"#{article.meta_tags.replace(', ', '  #')}")
+        if article.meta_categories:
+            parts.append(f"[{article.meta_categories}]")
+        line2 = "  ".join(parts) if parts else ""
+
+        text = f"{line1}\n{line2}" if line2 else line1
+        self.setText(text)
+        self.setSizeHint(QSize(0, 42) if line2 else QSize(0, 26))
+
+        if article.draft:
+            self.setForeground(QColor("#f59e0b"))
+        elif not article.has_translation:
             self.setForeground(QColor("#ff6b6b"))
 
 class ArticlesView(QWidget):