Esempio n. 1
0
def main():
    app = QtGui.QApplication(sys.argv)
    dialog = lambda: QtGui.QMessageBox.question(QtGui.QWidget(), 'First time', \
            "It appears you've started the app for the first time. Do you want to load demo data?", QtGui.QMessageBox.No, QtGui.QMessageBox.Yes)
    DBManager.init_dbmanager(dialog)
    main = Main()
    main.show()
    sys.exit(app.exec_())
Esempio n. 2
0
 def _fill_inbox(self):
     self._inbox.clear()
     projects = {project.id: None for project in DBManager.get_projects().values()}
     for action in DBManager.get_actions().values():
         if action.project and not action.completed and action.sched.isValid():
             if len(projects) > action.project.id:
                 if not projects[action.project.id] or projects[action.project.id].sched < action.sched:
                     projects[action.project.id] = action
     for action in projects.values():
         if action:
             item = QtGui.QListWidgetItem(action.desc)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(action))
             self._inbox.addItem(item)
Esempio n. 3
0
 def _fill_detail(self, date):
     self._detail_list.clear()
     for action in DBManager.get_actions().values():
         if action.sched == date and not action.completed:
             item = QtGui.QListWidgetItem(action.desc)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(action))
             self._detail_list.addItem(item)
Esempio n. 4
0
 def _fill_detail(self, date):
     self._detail_list.clear()
     for action in DBManager.get_actions().values():
         if action.sched == date and not action.completed:
             item = QtGui.QListWidgetItem(action.desc)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(action))
             self._detail_list.addItem(item)
Esempio n. 5
0
 def _fill_list(self):
     self._completed.clear()
     for action in DBManager.get_actions().values():
         if action.completed:
             item = QtGui.QListWidgetItem(action.desc)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(action))
             self._completed.addItem(item)
Esempio n. 6
0
 def _fill_inbox(self):
     self._inbox.clear()
     for action in DBManager.get_actions().values():
         if not action.completed:
             item = QtGui.QListWidgetItem(action.desc)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(action))
             self._inbox.addItem(item)
Esempio n. 7
0
 def _fill_inbox(self):
     self._inbox.clear()
     projects = {
         project.id: None
         for project in DBManager.get_projects().values()
     }
     for action in DBManager.get_actions().values():
         if action.project and not action.completed and action.sched.isValid(
         ):
             if len(projects) > action.project.id:
                 if not projects[action.project.id] or projects[
                         action.project.id].sched < action.sched:
                     projects[action.project.id] = action
     for action in projects.values():
         if action:
             item = QtGui.QListWidgetItem(action.desc)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(action))
             self._inbox.addItem(item)
Esempio n. 8
0
 def _fill_tree(self):
     actions = self._get_actions()
     self._tree.clear()    
     for context in DBManager.get_contexts().values():
         item = self._get_context_item(context)
         for action in actions[context.id]:
             if not action.completed:
                 child_item = self._get_action_item(action)
                 item.addChild(child_item)
         self._tree.addTopLevelItem(item)
Esempio n. 9
0
 def _fill_tree(self):
     actions = self._get_actions()
     self._tree.clear()
     for project in DBManager.get_projects().values():
         item = self._get_project_item(project)
         item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(project))
         for action in actions[project.id]:
             if not action.completed:
                 child_item = self._get_action_item(action)
                 item.addChild(child_item)
         self._tree.addTopLevelItem(item)
Esempio n. 10
0
 def _fill_tree(self):
     actions = self._get_actions()
     self._tree.clear()
     for project in DBManager.get_projects().values():
         item = self._get_project_item(project)
         item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(project))
         for action in actions[project.id]:
             if not action.completed:
                 child_item = self._get_action_item(action)
                 item.addChild(child_item)
         self._tree.addTopLevelItem(item)
Esempio n. 11
0
 def paintCell(self, painter, rect, date):
     QtGui.QCalendarWidget.paintCell(self, painter, rect, date)
     brush = QtGui.QBrush(QtGui.QColor("#FFF380"))
     white_brush = QtGui.QBrush(QtGui.QColor("#FFFFFF"))
     task_number = 0
     for action in DBManager.get_actions().values():
         if action.sched == date and not action.completed:
             task_number += 1
     if task_number:
         label = ("%s task" if task_number == 1 else "%s tasks") % task_number
         painter.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.StyleItalic))
         text_format = QtGui.QTextCharFormat(self.dateTextFormat(date))
         text_format.setBackground(brush)
         self.setDateTextFormat(date, text_format)
         painter.drawText(rect, QtCore.Qt.AlignCenter + QtCore.Qt.AlignBottom, label)
     else: 
         text_format = QtGui.QTextCharFormat(self.dateTextFormat(date))
         text_format.setBackground(white_brush)
         self.setDateTextFormat(date, text_format)
Esempio n. 12
0
 def paintCell(self, painter, rect, date):
     QtGui.QCalendarWidget.paintCell(self, painter, rect, date)
     brush = QtGui.QBrush(QtGui.QColor("#FFF380"))
     white_brush = QtGui.QBrush(QtGui.QColor("#FFFFFF"))
     task_number = 0
     for action in DBManager.get_actions().values():
         if action.sched == date and not action.completed:
             task_number += 1
     if task_number:
         label = ("%s task"
                  if task_number == 1 else "%s tasks") % task_number
         painter.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.StyleItalic))
         text_format = QtGui.QTextCharFormat(self.dateTextFormat(date))
         text_format.setBackground(brush)
         self.setDateTextFormat(date, text_format)
         painter.drawText(rect,
                          QtCore.Qt.AlignCenter + QtCore.Qt.AlignBottom,
                          label)
     else:
         text_format = QtGui.QTextCharFormat(self.dateTextFormat(date))
         text_format.setBackground(white_brush)
         self.setDateTextFormat(date, text_format)
Esempio n. 13
0
 def delete(self):
     DBManager.delete_project(self)
Esempio n. 14
0
 def save(self):
     if not self.id:
         DBManager.create_project(self)
     else:
         DBManager.update_project(self)
Esempio n. 15
0
 def delete(self):
     DBManager.delete_project(self)
Esempio n. 16
0
 def _fill_cbx(self):
     self._context_cbx.clear()
     self._context_cbx.addItem("None", QtCore.QVariant())
     for context in DBManager.get_contexts().values():
         self._context_cbx.addItem(context.name, QtCore.QVariant(context))
Esempio n. 17
0
 def delete(self):
     DBManager.delete_context(self)
Esempio n. 18
0
 def delete(self):
     DBManager.delete_action(self)
Esempio n. 19
0
 def save(self):
     if not self.id:
         DBManager.create_action(self)
     else:
         DBManager.update_action(self)
Esempio n. 20
0
 def save(self):
     if not self.id:
         DBManager.create_context(self)
     else:
         DBManager.update_context(self)
Esempio n. 21
0
 def save(self):
     if not self.id:
         DBManager.create_context(self)
     else:
         DBManager.update_context(self)
Esempio n. 22
0
 def delete(self):
     DBManager.delete_context(self)
Esempio n. 23
0
 def _fill_cbx(self):
     self._context_cbx.clear()
     self._context_cbx.addItem("None", QtCore.QVariant())
     for context in DBManager.get_contexts().values():
         self._context_cbx.addItem(context.name, QtCore.QVariant(context))
Esempio n. 24
0
 def save(self):
     if not self.id:
         DBManager.create_action(self)
     else:
         DBManager.update_action(self)
Esempio n. 25
0
 def delete(self):
     DBManager.delete_action(self)
Esempio n. 26
0
 def save(self):
     if not self.id:
         DBManager.create_project(self)
     else:
         DBManager.update_project(self)
Esempio n. 27
0
 def _get_actions(self):
     actions = defaultdict(list)
     for action in DBManager.get_actions().values():
         if action.context:
             actions[action.context.id].append(action) 
     return actions
Esempio n. 28
0
 def _fill_projects(self):
     self._project_cbx.clear()
     self._project_cbx.addItem("None", QtCore.QVariant())
     for project in DBManager.get_projects().values():
         self._project_cbx.addItem(project.name, QtCore.QVariant(project))