Created
December 26, 2014 06:28
-
-
Save SRomansky/11524983a3fd1d1e0e41 to your computer and use it in GitHub Desktop.
TalkEditor time stamp translating delegate diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/freeseer/frontend/talkeditor/talkeditor.py b/src/freeseer/frontend/talkeditor/talkeditor.py | |
index c7228bb..99818e7 100644 | |
--- a/src/freeseer/frontend/talkeditor/talkeditor.py | |
+++ b/src/freeseer/frontend/talkeditor/talkeditor.py | |
@@ -28,6 +28,7 @@ import logging | |
from PyQt4.QtCore import SIGNAL | |
from PyQt4.QtCore import QPersistentModelIndex | |
from PyQt4.QtCore import QStringList | |
+from PyQt4.QtCore import QString | |
from PyQt4.QtCore import Qt | |
from PyQt4.QtGui import QAbstractItemView | |
from PyQt4.QtGui import QAction | |
@@ -39,6 +40,8 @@ from PyQt4.QtGui import QIcon | |
from PyQt4.QtGui import QMessageBox | |
from PyQt4.QtGui import QPixmap | |
from PyQt4.QtGui import QSortFilterProxyModel | |
+from PyQt4.QtGui import QStyledItemDelegate | |
+from PyQt4.QtGui import QStyleOptionViewItem | |
from PyQt4.QtGui import QTableView | |
from PyQt4.QtGui import QVBoxLayout | |
from PyQt4.QtGui import QWidget | |
@@ -56,6 +59,18 @@ from freeseer.frontend.talkeditor.ImportTalksWidget import ImportTalksWidget | |
log = logging.getLogger(__name__) | |
+class HumanReadableDelegate(QStyledItemDelegate): | |
+ def paint(self, painter, option, index): # This thing draws/renders each element in the talk editor table | |
+ if index.column() == 8 or index.column() == 9: | |
+ humanTime = index.data().toTime().toString('hh:mm ap') # hh:mm:ss -> hh:mm ap | |
+ # Setup painter? | |
+ QStyledItemDelegate.paint(self, painter, option, index) | |
+ else: | |
+ QStyledItemDelegate.paint(self, painter, option, index) | |
+ | |
+ | |
+ | |
+ | |
class TalkEditorApp(FreeseerApp): | |
'''Freeseer talk database editor main gui class''' | |
def __init__(self, config, db): | |
@@ -91,6 +106,8 @@ class TalkEditorApp(FreeseerApp): | |
self.mainLayout.addWidget(self.tableView) | |
self.mainLayout.addWidget(self.talkDetailsWidget) | |
self.mainLayout.addWidget(self.importTalksWidget) | |
+ | |
+ self.tableView.setItemDelegate(HumanReadableDelegate()) | |
# --- End Layout | |
# Keep track of index of the most recently selected talk | |
@@ -272,6 +289,8 @@ class TalkEditorApp(FreeseerApp): | |
# Hide the ID field | |
self.tableView.setColumnHidden(0, True) | |
+ # Use custom QItemDelegate with the QDataWidgetMapper object? | |
+ | |
# Map data to widgets | |
self.mapper = QDataWidgetMapper() | |
self.mapper.setModel(self.proxy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code needed to get the application to use the human friendly formatted time stamps through out the application, excluding unit test updates.