From bb5b4419cc774973980ca69823b54737a698c0ac Mon Sep 17 00:00:00 2001 From: "gianluca.montecchi" Date: Wed, 12 Dec 2007 14:06:41 +0100 Subject: [PATCH] Completed the gui --- data/qtodo.data | Bin 2048 -> 2048 bytes gui/mainwin.ui | 402 ++++++++++++++++++++++++++++++++++++++++--------------- qtodo.py | 123 +++++++++++++++-- src/AddCatDlg.py | 4 +- src/mainwin.py | 168 +++++++++++++++++++---- 5 files changed, 551 insertions(+), 146 deletions(-) diff --git a/data/qtodo.data b/data/qtodo.data index 363af5a5562269efae4a27fba577bb4a14525151..a7e6503745a5e303e9e5ceff0a63e9637a0e8a0b 100755 GIT binary patch delta 53 zcwTD|Xb_kn&B(h^<^?kc0}BHK^IPWYn*~`;GEWR(oqUU3SeSu 0 0 - 541 - 592 + 575 + 629 QTodo - - + - - - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 12 - 75 - true - + + + + + + + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 12 + 75 + true + + + + QFrame::Panel + + + QFrame::Raised + + + TODO Lists + + + + + + + Qt::Vertical + + + + 20 + 141 + + + + + + + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 - - QFrame::Panel + + 0 - - QFrame::Raised + + 0 - - TODO Lists - - - - - - - Qt::Vertical + + 0 - - - 20 - 141 - + + 0 - - - - - - + + 0 - - - - - Qt::Horizontal + + + + + 0 + 0 + + + + Summary + + + + 9 - - - 40 - 20 - + + 0 - - - - - - - + + 9 + + + 0 + + + 6 + + + 6 + + + + + + 0 + 0 + + + + Active item + + + + + + + + 0 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 5 + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Closed item + + + + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 5 + + + + + + + + 0 + 0 + + + + Overdue + + + + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 5 + + + + + + + + + + Qt::Vertical + + + + 20 + 241 + + + + + + + + + + Filter: + + + + + + + + + + + Priority + + + + + Category + + + + + Status + + + + + Content + + + + + + + + + + - + - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QAbstractItemView::NoDragDrop - - - QListView::Adjust + + + + + Qt::Horizontal - - QListView::ListMode + + + 40 + 20 + - + @@ -143,8 +331,8 @@ 0 0 - 541 - 33 + 575 + 21 diff --git a/qtodo.py b/qtodo.py index d99e218..f5e43ca 100755 --- a/qtodo.py +++ b/qtodo.py @@ -9,7 +9,7 @@ from qtodoIO import * from mainwin import * from AddCatDlg import Ui_D_Add -class TodoList(QtGui.QListWidget): +class TodoLists(QtGui.QListWidget): def __init__(self, parent=None): QtGui.QListWidget.__init__(self, parent) self.setDragEnabled(True) @@ -20,15 +20,15 @@ class TodoList(QtGui.QListWidget): self.setDropIndicatorShown(True) self.setMovement(QtGui.QListView.Free) - def addPiece(self, oid_cat, id_cat): - pieceItem = QtGui.QListWidgetItem(self) + def addList(self, oid_cat, id_cat): + listItem = QtGui.QListWidgetItem(self) pixmap = QtGui.QIcon("pixmaps/todo_list.png") - pieceItem.setIcon(pixmap) - pieceItem.setText(id_cat) - pieceItem.setData(QtCore.Qt.UserRole, QtCore.QVariant(oid_cat)) - pieceItem.setData(QtCore.Qt.UserRole+1, QtCore.QVariant(id_cat)) + listItem.setIcon(pixmap) + listItem.setText(id_cat) + listItem.setData(QtCore.Qt.UserRole, QtCore.QVariant(oid_cat)) + listItem.setData(QtCore.Qt.UserRole+1, QtCore.QVariant(id_cat)) - pieceItem.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsDragEnabled) + listItem.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsDragEnabled) def dragEnterEvent(self, event): @@ -52,7 +52,7 @@ class TodoList(QtGui.QListWidget): location = QtCore.QPoint() dataStream >> pixmap >> location - self.addPiece(pixmap, location) + self.addList(pixmap, location) event.setDropAction(QtCore.Qt.MoveAction) event.accept() @@ -77,7 +77,73 @@ class TodoList(QtGui.QListWidget): if drag.start(QtCore.Qt.MoveAction) == QtCore.Qt.MoveAction: self.takeItem(self.row(item)) +class TodoItems(QtGui.QListWidget): + def __init__(self, parent=None): + QtGui.QListWidget.__init__(self, parent) + self.setDragEnabled(True) + self.setViewMode(QtGui.QListView.ListMode) + self.setIconSize(QtCore.QSize(34, 34 )) + self.setSpacing(5) + self.setAcceptDrops(True) + self.setDropIndicatorShown(True) + self.setMovement(QtGui.QListView.Free) + + def addList(self, oid_cat, id_cat): + todoItem = QtGui.QListWidgetItem(self) + pixmap = QtGui.QIcon("pixmaps/todo_list.png") + todoItem.setIcon(pixmap) + todoItem.setText(id_cat) + todoItem.setData(QtCore.Qt.UserRole, QtCore.QVariant(oid_cat)) + todoItem.setData(QtCore.Qt.UserRole+1, QtCore.QVariant(id_cat)) + + todoItem.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsDragEnabled) + + def dragEnterEvent(self, event): + if event.mimeData().hasFormat("application/x-qtodo"): + event.accept() + else: + event.ignore() + + def dragMoveEvent(self, event): + if event.mimeData().hasFormat("application/x-qtodo"): + event.setDropAction(QtCore.Qt.MoveAction) + event.accept() + else: + event.ignore() + + def dropEvent_(self, event): + if event.mimeData().hasFormat("application/x-qtodo"): + pieceData = event.mimeData().data("application/x-qtodo") + dataStream = QtCore.QDataStream(pieceData, QtCore.QIODevice.ReadOnly) + pixmap = QtGui.QPixmap() + location = QtCore.QPoint() + dataStream >> pixmap >> location + + self.addList(pixmap, location) + + event.setDropAction(QtCore.Qt.MoveAction) + event.accept() + else: + event.ignore() + + def startDrag(self, supportedActions): + item = self.currentItem() + + itemData = QtCore.QByteArray() + dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.WriteOnly) + oid_cat = item.data(QtCore.Qt.UserRole).toString() + id_cat = item.data(QtCore.Qt.UserRole+1).toString() + dataStream << oid_cat << id_cat + + mimeData = QtCore.QMimeData() + mimeData.setData("application/x-qtodo", itemData) + drag = QtGui.QDrag(self) + drag.setMimeData(mimeData) + drag.setPixmap(QtGui.QPixmap("pixmaps/todo_list.png")) + + if drag.start(QtCore.Qt.MoveAction) == QtCore.Qt.MoveAction: + self.takeItem(self.row(item)) class Trash(QtGui.QLabel): def __init__(self, DbEngine, parent=None): @@ -111,6 +177,38 @@ class Trash(QtGui.QLabel): def dragEnterEvent(self, event): event.accept() + +class Trash_(QtGui.QLabel): + def __init__(self, DbEngine, parent=None): + QtGui.QLabel.__init__(self, parent) + self.setAcceptDrops(True) + self.setPixmap(QtGui.QPixmap("pixmaps/eraser.png")) + self.DbEngine = DbEngine + def dropEvent(self, event): + if event.mimeData().hasFormat("application/x-qtodo"): + pieceData = event.mimeData().data("application/x-qtodo") + dataStream = QtCore.QDataStream(pieceData, QtCore.QIODevice.ReadOnly) + + oid_cat = QtCore.QString() + id_cat = QtCore.QString() + + dataStream >> oid_cat >> id_cat + event.setDropAction(QtCore.Qt.MoveAction) + event.accept() + # Delete the category from database + self.DbEngine.DeleteList(oid_cat) + + def dropEvent_(self, event): + if event.mimeData().hasFormat("application/x-qtodo"): + itemData = event.mimeData().data("application/x-qtodo") + dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.ReadOnly) + text = QtCore.QString() + dataStream >> text + print text + + + def dragEnterEvent(self, event): + event.accept() class QTodo(Ui_MainWindow): def __init__(self): @@ -126,14 +224,17 @@ class QTodo(Ui_MainWindow): ui.trash = Trash(self.IOEngine) ui.actions_box.layout().addWidget(ui.trash, 0,0) # set the todo lists area - ui.todo_lists = TodoList() + ui.todo_lists = TodoLists() ui.lists_box.layout().addWidget(ui.todo_lists, 1, 0) + + ui.todo_items = TodoItems() + ui.items_box.layout().addWidget(ui.todo_items, 1, 0) def LoadData(self): categories = self.IOEngine.GetCategories() for [oid_cat, cat] in categories: - ui.todo_lists.addPiece(oid_cat, cat) + ui.todo_lists.addList(oid_cat, cat) def QuitApp(self): diff --git a/src/AddCatDlg.py b/src/AddCatDlg.py index e624ee4..6bbe0d7 100755 --- a/src/AddCatDlg.py +++ b/src/AddCatDlg.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'gui/d_add_cat.ui' # -# Created: Sat Dec 8 01:35:29 2007 -# by: PyQt4 UI code generator 4.3.3 +# Created: Wed Dec 12 14:03:54 2007 +# by: PyQt4 UI code generator 4.3.1 # # WARNING! All changes made in this file will be lost! diff --git a/src/mainwin.py b/src/mainwin.py index 80ebf5d..7067197 100755 --- a/src/mainwin.py +++ b/src/mainwin.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'gui/mainwin.ui' # -# Created: Sat Dec 8 01:35:28 2007 -# by: PyQt4 UI code generator 4.3.3 +# Created: Wed Dec 12 14:03:54 2007 +# by: PyQt4 UI code generator 4.3.1 # # WARNING! All changes made in this file will be lost! @@ -12,14 +12,20 @@ from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") - MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,541,592).size()).expandedTo(MainWindow.minimumSizeHint())) + MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,575,629).size()).expandedTo(MainWindow.minimumSizeHint())) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") - self.hboxlayout = QtGui.QHBoxLayout(self.centralwidget) + self.vboxlayout = QtGui.QVBoxLayout(self.centralwidget) + self.vboxlayout.setObjectName("vboxlayout") + + self.hboxlayout = QtGui.QHBoxLayout() self.hboxlayout.setObjectName("hboxlayout") + self.hboxlayout1 = QtGui.QHBoxLayout() + self.hboxlayout1.setObjectName("hboxlayout1") + self.lists_box = QtGui.QGroupBox(self.centralwidget) self.lists_box.setFlat(True) self.lists_box.setObjectName("lists_box") @@ -43,37 +49,135 @@ class Ui_MainWindow(object): spacerItem = QtGui.QSpacerItem(20,141,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) self.gridlayout.addItem(spacerItem,1,0,1,1) + self.hboxlayout1.addWidget(self.lists_box) + self.hboxlayout.addLayout(self.hboxlayout1) - self.actions_box = QtGui.QGroupBox(self.lists_box) - self.actions_box.setObjectName("actions_box") + self.items_box = QtGui.QFrame(self.centralwidget) + self.items_box.setFrameShape(QtGui.QFrame.NoFrame) + self.items_box.setFrameShadow(QtGui.QFrame.Plain) + self.items_box.setObjectName("items_box") - self.gridlayout1 = QtGui.QGridLayout(self.actions_box) + self.gridlayout1 = QtGui.QGridLayout(self.items_box) + self.gridlayout1.setMargin(0) + self.gridlayout1.setSpacing(0) self.gridlayout1.setObjectName("gridlayout1") - spacerItem1 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum) - self.gridlayout1.addItem(spacerItem1,0,0,1,1) - self.gridlayout.addWidget(self.actions_box,2,0,1,1) - self.hboxlayout.addWidget(self.lists_box) - - self.groupBox_2 = QtGui.QGroupBox(self.centralwidget) - self.groupBox_2.setObjectName("groupBox_2") + self.groupBox = QtGui.QGroupBox(self.items_box) + + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) + self.groupBox.setSizePolicy(sizePolicy) + self.groupBox.setObjectName("groupBox") + + self.gridlayout2 = QtGui.QGridLayout(self.groupBox) + self.gridlayout2.setContentsMargins(9,0,9,0) + self.gridlayout2.setSpacing(6) + self.gridlayout2.setObjectName("gridlayout2") + + self.label_3 = QtGui.QLabel(self.groupBox) + + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) + self.label_3.setSizePolicy(sizePolicy) + self.label_3.setObjectName("label_3") + self.gridlayout2.addWidget(self.label_3,0,0,1,1) + + self.L_ActiveItem = QtGui.QLabel(self.groupBox) + + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.L_ActiveItem.sizePolicy().hasHeightForWidth()) + self.L_ActiveItem.setSizePolicy(sizePolicy) + self.L_ActiveItem.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.L_ActiveItem.setMargin(1) + self.L_ActiveItem.setIndent(5) + self.L_ActiveItem.setObjectName("L_ActiveItem") + self.gridlayout2.addWidget(self.L_ActiveItem,0,1,1,1) + + self.calendarWidget = QtGui.QCalendarWidget(self.groupBox) + + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.calendarWidget.sizePolicy().hasHeightForWidth()) + self.calendarWidget.setSizePolicy(sizePolicy) + self.calendarWidget.setObjectName("calendarWidget") + self.gridlayout2.addWidget(self.calendarWidget,0,2,4,1) + + self.label_5 = QtGui.QLabel(self.groupBox) + + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) + self.label_5.setSizePolicy(sizePolicy) + self.label_5.setObjectName("label_5") + self.gridlayout2.addWidget(self.label_5,1,0,1,1) + + self.L_CloseItem = QtGui.QLabel(self.groupBox) + self.L_CloseItem.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.L_CloseItem.setMargin(1) + self.L_CloseItem.setIndent(5) + self.L_CloseItem.setObjectName("L_CloseItem") + self.gridlayout2.addWidget(self.L_CloseItem,1,1,1,1) + + self.label_7 = QtGui.QLabel(self.groupBox) + + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth()) + self.label_7.setSizePolicy(sizePolicy) + self.label_7.setObjectName("label_7") + self.gridlayout2.addWidget(self.label_7,2,0,1,1) + + self.L_OverdueItem = QtGui.QLabel(self.groupBox) + self.L_OverdueItem.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.L_OverdueItem.setMargin(1) + self.L_OverdueItem.setIndent(5) + self.L_OverdueItem.setObjectName("L_OverdueItem") + self.gridlayout2.addWidget(self.L_OverdueItem,2,1,1,1) + self.gridlayout1.addWidget(self.groupBox,0,0,1,1) + + spacerItem1 = QtGui.QSpacerItem(20,241,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) + self.gridlayout1.addItem(spacerItem1,1,0,1,1) + + self.hboxlayout2 = QtGui.QHBoxLayout() + self.hboxlayout2.setObjectName("hboxlayout2") + + self.label_2 = QtGui.QLabel(self.items_box) + self.label_2.setObjectName("label_2") + self.hboxlayout2.addWidget(self.label_2) + + self.LE_filter = QtGui.QLineEdit(self.items_box) + self.LE_filter.setObjectName("LE_filter") + self.hboxlayout2.addWidget(self.LE_filter) + + self.CB_FilterField = QtGui.QComboBox(self.items_box) + self.CB_FilterField.setObjectName("CB_FilterField") + self.hboxlayout2.addWidget(self.CB_FilterField) + self.gridlayout1.addLayout(self.hboxlayout2,2,0,1,1) + self.hboxlayout.addWidget(self.items_box) + self.vboxlayout.addLayout(self.hboxlayout) + + self.actions_box = QtGui.QGroupBox(self.centralwidget) + self.actions_box.setObjectName("actions_box") - self.vboxlayout = QtGui.QVBoxLayout(self.groupBox_2) - self.vboxlayout.setSpacing(0) - self.vboxlayout.setMargin(0) - self.vboxlayout.setObjectName("vboxlayout") + self.gridlayout3 = QtGui.QGridLayout(self.actions_box) + self.gridlayout3.setObjectName("gridlayout3") - self.todo_items = QtGui.QListWidget(self.groupBox_2) - self.todo_items.setDragDropMode(QtGui.QAbstractItemView.NoDragDrop) - self.todo_items.setResizeMode(QtGui.QListView.Adjust) - self.todo_items.setViewMode(QtGui.QListView.ListMode) - self.todo_items.setObjectName("todo_items") - self.vboxlayout.addWidget(self.todo_items) - self.hboxlayout.addWidget(self.groupBox_2) + spacerItem2 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum) + self.gridlayout3.addItem(spacerItem2,0,0,1,1) + self.vboxlayout.addWidget(self.actions_box) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0,0,541,33)) + self.menubar.setGeometry(QtCore.QRect(0,0,575,21)) self.menubar.setObjectName("menubar") self.menu_File = QtGui.QMenu(self.menubar) @@ -116,6 +220,18 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "QTodo - ", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("MainWindow", "TODO Lists", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Summary", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Active item", None, QtGui.QApplication.UnicodeUTF8)) + self.L_ActiveItem.setText(QtGui.QApplication.translate("MainWindow", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Closed item", None, QtGui.QApplication.UnicodeUTF8)) + self.L_CloseItem.setText(QtGui.QApplication.translate("MainWindow", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.label_7.setText(QtGui.QApplication.translate("MainWindow", "Overdue", None, QtGui.QApplication.UnicodeUTF8)) + self.L_OverdueItem.setText(QtGui.QApplication.translate("MainWindow", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("MainWindow", "Filter:", None, QtGui.QApplication.UnicodeUTF8)) + self.CB_FilterField.addItem(QtGui.QApplication.translate("MainWindow", "Priority", None, QtGui.QApplication.UnicodeUTF8)) + self.CB_FilterField.addItem(QtGui.QApplication.translate("MainWindow", "Category", None, QtGui.QApplication.UnicodeUTF8)) + self.CB_FilterField.addItem(QtGui.QApplication.translate("MainWindow", "Status", None, QtGui.QApplication.UnicodeUTF8)) + self.CB_FilterField.addItem(QtGui.QApplication.translate("MainWindow", "Content", None, QtGui.QApplication.UnicodeUTF8)) self.menu_File.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) self.menu_Help.setTitle(QtGui.QApplication.translate("MainWindow", "&Help", None, QtGui.QApplication.UnicodeUTF8)) self.action_Quit.setText(QtGui.QApplication.translate("MainWindow", "&Quit", None, QtGui.QApplication.UnicodeUTF8)) -- 2.11.4.GIT