-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2309ce0
Showing
5 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.pyc | ||
ui_*.py | ||
.*.swp | ||
*.db |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
pyuic4 addtaskdialog.ui -o ui_addtaskdialog.py | ||
|
||
clean: | ||
-rm *.pyc ui_*.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: UTF-8 -*- | ||
from datetime import datetime | ||
|
||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
|
||
from yokadi import dbutils | ||
from yokadi import parseutils | ||
from yokadi.yokadiexception import YokadiException | ||
|
||
from ui_addtaskdialog import Ui_AddTaskDialog | ||
|
||
class AddTaskDialog(QDialog): | ||
def __init__(self): | ||
super(AddTaskDialog, self).__init__() | ||
self.ui = Ui_AddTaskDialog() | ||
self.ui.setupUi(self) | ||
self.ui.errorLabel.hide() | ||
|
||
def showErrorMessage(self, msg): | ||
self.ui.errorLabel.setText(msg) | ||
self.ui.errorLabel.show() | ||
|
||
def accept(self): | ||
line = unicode(self.ui.projectLineEdit.text()) + u" " + unicode(self.ui.titleLineEdit.text()) | ||
projectName, title, keywordDict = parseutils.parseLine(line) | ||
|
||
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 | ||
|
||
if self.ui.statusStarted.isChecked(): | ||
task.status = "started" | ||
elif self.ui.statusDone.isChecked(): | ||
task.status = "done" | ||
qdate = self.ui.doneDateEdit.date() | ||
task.doneDate = datetime(qdate.year(), qdate.month(), qdate.day()) | ||
|
||
super(AddTaskDialog, self).accept() | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>AddTaskDialog</class> | ||
<widget class="QDialog" name="AddTaskDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>300</width> | ||
<height>191</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Add Task</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<layout class="QFormLayout" name="formLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>&Project:</string> | ||
</property> | ||
<property name="buddy"> | ||
<cstring>projectLineEdit</cstring> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QLineEdit" name="projectLineEdit"/> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="label_2"> | ||
<property name="text"> | ||
<string>&Title:</string> | ||
</property> | ||
<property name="buddy"> | ||
<cstring>titleLineEdit</cstring> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QLineEdit" name="titleLineEdit"/> | ||
</item> | ||
<item row="2" column="0"> | ||
<widget class="QLabel" name="label_3"> | ||
<property name="text"> | ||
<string>Status:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="1"> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QRadioButton" name="statusNew"> | ||
<property name="text"> | ||
<string>&New</string> | ||
</property> | ||
<property name="checked"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QRadioButton" name="statusStarted"> | ||
<property name="text"> | ||
<string>&Started</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QRadioButton" name="statusDone"> | ||
<property name="text"> | ||
<string>&Done</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QDateEdit" name="doneDateEdit"> | ||
<property name="enabled"> | ||
<bool>false</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="errorLabel"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="styleSheet"> | ||
<string notr="true">border: 1px solid red; | ||
border-radius: 4px; | ||
background-color: #fcc; | ||
color: black</string> | ||
</property> | ||
<property name="text"> | ||
<string notr="true">An error message</string> | ||
</property> | ||
<property name="textFormat"> | ||
<enum>Qt::PlainText</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>statusDone</sender> | ||
<signal>toggled(bool)</signal> | ||
<receiver>doneDateEdit</receiver> | ||
<slot>setEnabled(bool)</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>76</x> | ||
<y>125</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>155</x> | ||
<y>118</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>AddTaskDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>115</x> | ||
<y>149</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>8</x> | ||
<y>130</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>AddTaskDialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>218</x> | ||
<y>150</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>241</x> | ||
<y>104</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
""" | ||
Command line oriented, sqlite powered, todo list | ||
@author: Aurélien Gâteau <[email protected]> | ||
@license: GPL v3 or later | ||
""" | ||
import os | ||
import sys | ||
from optparse import OptionParser | ||
|
||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
|
||
from yokadi import db | ||
|
||
from addtaskdialog import AddTaskDialog | ||
|
||
def main(argv): | ||
app = QApplication(argv) | ||
parser = OptionParser() | ||
|
||
parser.add_option("-d", "--db", dest="filename", | ||
help="TODO database", metavar="FILE") | ||
|
||
options, args = parser.parse_args(argv) | ||
|
||
db.connectDatabase(options.filename) | ||
|
||
dlg = AddTaskDialog() | ||
return dlg.exec_() | ||
|
||
if __name__ == "__main__": | ||
sys.exit(main(sys.argv)) |