Ejemplo 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_())
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 13
0
 def delete(self):
     DBManager.delete_project(self)
Ejemplo n.º 14
0
 def save(self):
     if not self.id:
         DBManager.create_project(self)
     else:
         DBManager.update_project(self)
Ejemplo n.º 15
0
 def delete(self):
     DBManager.delete_project(self)
Ejemplo 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))
Ejemplo n.º 17
0
 def delete(self):
     DBManager.delete_context(self)
Ejemplo n.º 18
0
 def delete(self):
     DBManager.delete_action(self)
Ejemplo n.º 19
0
 def save(self):
     if not self.id:
         DBManager.create_action(self)
     else:
         DBManager.update_action(self)
Ejemplo n.º 20
0
 def save(self):
     if not self.id:
         DBManager.create_context(self)
     else:
         DBManager.update_context(self)
Ejemplo n.º 21
0
 def save(self):
     if not self.id:
         DBManager.create_context(self)
     else:
         DBManager.update_context(self)
Ejemplo n.º 22
0
 def delete(self):
     DBManager.delete_context(self)
Ejemplo 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))
Ejemplo n.º 24
0
 def save(self):
     if not self.id:
         DBManager.create_action(self)
     else:
         DBManager.update_action(self)
Ejemplo n.º 25
0
 def delete(self):
     DBManager.delete_action(self)
Ejemplo n.º 26
0
 def save(self):
     if not self.id:
         DBManager.create_project(self)
     else:
         DBManager.update_project(self)
Ejemplo 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
Ejemplo 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))