Пример #1
0
    def updateQuery(self):
        row = self.ui.queryListWidget.currentRow()
        self.query = self.queryList[row]

        # Project
        projectName, keywordFilters = parseutils.extractKeywords(unicode(self.filterLineEdit.text()))
        self.query.projectName = projectName
        self.query.keywordFilters = keywordFilters

        # Status
        if isinstance(self.query, queries.DoneQuery):
            minDate = datetimeFromQDate(self.ui.fromDateEdit.date())
            maxDate = datetimeFromQDate(self.ui.toDateEdit.date())
            if minDate is not None and maxDate is not None and maxDate < minDate:
                minDate, maxDate = maxDate, minDate

            if maxDate is not None:
                maxDate += timedelta(1)
            self.query.minDate = minDate
            self.query.maxDate = maxDate

        self.updateView()
Пример #2
0
    def updateQuery(self):
        row = self.ui.queryListWidget.currentRow()
        self.query = self.queryList[row]

        # Project
        projectName, keywordFilters = parseutils.extractKeywords(
            unicode(self.filterLineEdit.text()))
        self.query.projectName = projectName
        self.query.keywordFilters = keywordFilters

        # Status
        if isinstance(self.query, queries.DoneQuery):
            minDate = datetimeFromQDate(self.ui.fromDateEdit.date())
            maxDate = datetimeFromQDate(self.ui.toDateEdit.date())
            if minDate is not None and maxDate is not None and maxDate < minDate:
                minDate, maxDate = maxDate, minDate

            if maxDate is not None:
                maxDate += timedelta(1)
            self.query.minDate = minDate
            self.query.maxDate = maxDate

        self.updateView()
Пример #3
0
                                       keywordDict,
                                       interactive=False)
            except YokadiException, exc:
                self.showErrorMessage(str(exc))
                return
            if not task:
                self.showErrorMessage("Task not created.")
                return
        else:
            try:
                project = dbutils.getOrCreateProject(projectName,
                                                     interactive=False)
            except YokadiException, exc:
                self.showErrorMessage(str(exc))
                return
            task = self.task
            dbutils.createMissingKeywords(keywordDict.keys(),
                                          interactive=False)
            dbutils.updateTask(task, project.name, title, keywordDict)

        task.description = unicode(self.ui.descriptionTextEdit.toPlainText())
        task.dueDate = datetimeFromQDate(self.ui.dueDateEdit.date())

        if self.ui.statusStarted.isChecked():
            task.status = "started"
        elif self.ui.statusDone.isChecked():
            task.status = "done"
            task.doneDate = datetimeFromQDate(self.ui.doneDateEdit.date())

        super(AddTaskDialog, self).accept()
Пример #4
0
        if self.task is None:
            try:
                task = dbutils.addTask(projectName, title, keywordDict, interactive=False)
            except YokadiException, exc:
                self.showErrorMessage(str(exc))
                return
            if not task:
                self.showErrorMessage("Task not created.")
                return
        else:
            try:
                project = dbutils.getOrCreateProject(projectName, interactive=False)
            except YokadiException, exc:
                self.showErrorMessage(str(exc))
                return
            task = self.task
            task.title = title
            task.project = project

        task.description = unicode(self.ui.descriptionTextEdit.toPlainText())
        task.dueDate = datetimeFromQDate(self.ui.dueDateEdit.date())

        if self.ui.statusStarted.isChecked():
            task.status = "started"
        elif self.ui.statusDone.isChecked():
            task.status = "done"
            task.doneDate = datetimeFromQDate(self.ui.doneDateEdit.date())

        super(AddTaskDialog, self).accept()

Пример #5
0
    def updateView(self):
        filters = []
        queryType = self.ui.queryListWidget.currentRow()

        # Project
        wantedProject = self.ui.projectLineEdit.text()
        if not wantedProject.isEmpty():
            filters.append(
                IN(
                    Task.q.project,
                    Select(Project.q.id, LIKE(Project.q.name, "%" + unicode(wantedProject) + "%"))
                ))

        # Status
        statusFilters = []
        if queryType == QUERY_DONE:
            minDate = datetimeFromQDate(self.ui.fromDateEdit.date())
            maxDate = datetimeFromQDate(self.ui.toDateEdit.date())
            if maxDate < minDate:
                minDate, maxDate = maxDate, minDate

            maxDate += timedelta(1)
            doneFilter = AND( \
                Task.q.status == "done", \
                Task.q.doneDate >= minDate, \
                Task.q.doneDate < maxDate \
                )
            statusFilters.append(doneFilter)
        else:
            statusFilters.append(Task.q.status == "new")
            statusFilters.append(Task.q.status == "started")

        filters.append(OR(*statusFilters))

        # Due date
        if queryType == QUERY_DUE:
            dueDate = datetimeFromQDate(self.ui.dueDateEdit.date()) + timedelta(1)
            filters.append(Task.q.dueDate < dueDate)

        tasks = Task.select(AND(*filters))

        lst = []
        class Item(object):
            __slots__ = ["task", "grp1", "grp2"]
        for task in tasks:
            item = Item()
            item.task = task
            if queryType == QUERY_DUE:
                item.grp1 = task.dueDate.date()
                item.grp2 = task.project.name
            elif queryType == QUERY_PROJECT:
                item.grp1 = task.project.name
                item.grp2 = ""
            elif queryType == QUERY_DONE:
                item.grp1 = task.doneDate.date()
                item.grp2 = task.project.name
            else:
                raise Exception()
            lst.append(item)

        if queryType == QUERY_DUE:
            fmt1 = formatDate
        elif queryType == QUERY_PROJECT:
            fmt1 = lambda x: x
        elif queryType == QUERY_DONE:
            fmt1 = formatDate
        else:
            raise Exception()

        tmpl = self.jinjaEnv.get_template("index.html")
        html = tmpl.render(lst=lst, fmt1=fmt1)
        baseUrl = QUrl.fromLocalFile(os.path.join(self.dataDir, "static/"))
        self.ui.webView.setHtml(html, baseUrl)
        self.ui.webView.page().mainFrame().addToJavaScriptWindowObject("qtWindow", self)