Example #1
0
class TaskWidget(QWidget):

    taskModified = pyqtSignal(tasklib.Task)
    taskDeleted = pyqtSignal(tasklib.Task)
    taskCreated = pyqtSignal(tasklib.Task)

    def __init__(self, parent, task, new=False):
        QWidget.__init__(self, parent)
        self.task = task
        self.new = new
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.layout = QStackedLayout(self)

        self.label = QLabel(self)
        self.label.setTextFormat(Qt.RichText)
        self.label.setOpenExternalLinks(True)
        self._update()
        self.label.setWordWrap(True)
        self.layout.addWidget(self.label)

        self.editor = TaskEditorLineEdit(self, parent.mfile)
        self.layout.addWidget(self.editor)
        self.setLayout(self.layout)
        self.layout.setCurrentIndex(0)
        self.editor.editingFinished.connect(self.editFinished)
        self.task.modified.connect(self._update)

    def sizeHint(self):
        return self.label.size()

    def edit(self):
        self.editor.setText(self.task.text)
        self.layout.setCurrentIndex(1)
        self.editor.setFocus()

    def editFinished(self):
        # qt bug, this method may be called several times for one edit
        self.layout.setCurrentIndex(0)
        text = self.editor.text()
        if not text:
            self.taskDeleted.emit(self.task)
        elif self.new:
            self.task.text = text
            self.new = False
            self.taskCreated.emit(self.task)
        elif text != self.task.text:
            self.task.text = text
            self.taskModified.emit(self)
        self.parent().setFocus()

    def _update(self):
        self.label.setText(self.task.toHtml())

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.editor.setText(self.task.text)
            self.layout.setCurrentIndex(0)
            self.parent().setFocus()
Example #2
0
    def __init__(self, parent, task, new=False):
        QWidget.__init__(self, parent)
        self.task = task
        self.new = new
        self.layout = QStackedLayout(self)

        self.label = QLabel(self)
        self.label.setTextFormat(Qt.RichText)
        self.label.setOpenExternalLinks(True)
        self._update()
        self.label.setWordWrap(True)
        self.layout.addWidget(self.label)

        self.editor = TaskEditorLineEdit(self, parent.mfile)
        self.layout.addWidget(self.editor)
        self.setLayout(self.layout)

        self.layout.setCurrentIndex(0)
        self.editor.focusOut.connect(self.editFinished)
        self.task.modified.connect(self._update)
Example #3
0
    def _initUI(self, values):
        self.setWindowTitle("Task Editor")
        vbox = QtWidgets.QVBoxLayout()

        self._label = QtWidgets.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(values, self.autocomplete_pairs)
        vbox.addWidget(self._edit)

        hbox = QtWidgets.QHBoxLayout()
        okButton = QtWidgets.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtWidgets.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)
Example #4
0
class TaskEditorDialog(QtWidgets.QDialog):

    def __init__(self, parent, mfile):
        QtWidgets.QDialog.__init__(self)
        self._mfile = mfile
        self._initUI()

    def _initUI(self):
        self.setWindowTitle("Task Editor")
        vbox = QtWidgets.QVBoxLayout()

        self._label = QtWidgets.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(self, self._mfile)
        vbox.addWidget(self._edit)

        hbox = QtWidgets.QHBoxLayout()
        okButton = QtWidgets.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtWidgets.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)

    def textValue(self):
        return self._edit.text()

    def setTextValue(self, text):
        self._edit.setText(text)

    def setLabelText(self, text):
        self._label.setText(text)
Example #5
0
class TaskEditorDialog(QtWidgets.QDialog):
    def __init__(self, parent, mfile):
        QtWidgets.QDialog.__init__(self)
        self._mfile = mfile
        self._initUI()

    def _initUI(self):
        self.setWindowTitle("Task Editor")
        vbox = QtWidgets.QVBoxLayout()

        self._label = QtWidgets.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(self, self._mfile)
        vbox.addWidget(self._edit)

        hbox = QtWidgets.QHBoxLayout()
        okButton = QtWidgets.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtWidgets.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)

    def textValue(self):
        return self._edit.text()

    def setTextValue(self, text):
        self._edit.setText(text)

    def setLabelText(self, text):
        self._label.setText(text)
Example #6
0
    def _initUI(self, values):
        self.setWindowTitle("Task Editor")
        vbox = QtGui.QVBoxLayout()

        self._label = QtGui.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(values, self.autocomplete_pairs)
        vbox.addWidget(self._edit)

        hbox = QtGui.QHBoxLayout()
        okButton = QtGui.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtGui.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)
Example #7
0
class TaskEditorDialog(QtGui.QDialog):
    autocomplete_pairs = collections.OrderedDict([
        ('due:Today', ''),
        ('due:Tomorrow', ''),
        ('due:EndOfWeek', ''),
        ('due:EndOfMonth', ''),
        ('due:EndOfYear', ''),
        ('due:January', ''),
        ('due:February', ''),
        ('due:March', ''),
        ('due:April', ''),
        ('due:May', ''),
        ('due:June', ''),
        ('due:July', ''),
        ('due:August', ''),
        ('due:September', ''),
        ('due:October', ''),
        ('due:November', ''),
        ('due:December', '')
    ])

    def __init__(self, values, parent=None):
        super(TaskEditorDialog, self).__init__(parent)
        self._initUI(values)
        self._populateKeys(self.autocomplete_pairs)

    def _endOfMonth(self, month):
        month %= 12

        eom = date.today().replace(month=month + 1, day=1) - timedelta(days=1)
        if eom < date.today():
            eom = eom.replace(year=eom.year + 1)
        return 'due:' + eom.strftime('%Y-%m-%d')

    def _populateKeys(self, keys):
        today = 'due:' + date.today().strftime('%Y-%m-%d')
        tomorrow = 'due:' + (date.today() + timedelta(days=1)).strftime('%Y-%m-%d')
        EOW = 'due:' + (date.today() + timedelta((6 - date.today().weekday()) % 7)).strftime('%Y-%m-%d')
        EOM = 'due:' + ((date.today().replace(day=1) +
                        timedelta(days=32)).replace(day=1) -
                        timedelta(days=1)).strftime('%Y-%m-%d')
        EOY = 'due:' + (date.today().replace(year=date.today().year + 1, month=1, day=1) -
                        timedelta(days=1)).strftime('%Y-%m-%d')

        keys['due:EndOfWeek'] = EOW
        keys['due:EndOfMonth'] = EOM
        keys['due:EndOfYear'] = EOY
        keys['due:Today'] = today
        keys['due:Tomorrow'] = tomorrow
        # keys['due:January'] = self._endOfMonth(1)
        # keys['due:February'] = self._endOfMonth(2)
        # keys['due:March'] = self._endOfMonth(3)
        # keys['due:April'] = self._endOfMonth(4)
        # keys['due:May'] = self._endOfMonth(5)
        # keys['due:June'] = self._endOfMonth(6)
        # keys['due:July'] = self._endOfMonth(7)
        # keys['due:August'] = self._endOfMonth(8)
        # keys['due:September'] = self._endOfMonth(9)
        # keys['due:October'] = self._endOfMonth(10)
        # keys['due:November'] = self._endOfMonth(11)
        # keys['due:December'] = self._endOfMonth(12)
        return keys

    def _initUI(self, values):
        self.setWindowTitle("Task Editor")
        vbox = QtGui.QVBoxLayout()

        self._label = QtGui.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(values, self.autocomplete_pairs)
        vbox.addWidget(self._edit)

        hbox = QtGui.QHBoxLayout()
        okButton = QtGui.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtGui.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)

    def textValue(self):
        return self._edit.text()

    def setTextValue(self, text):
        self._edit.setText(text)

    def setLabelText(self, text):
        self._label.setText(text)
Example #8
0
class TaskEditorDialog(QtWidgets.QDialog):
    autocomplete_pairs = collections.OrderedDict([
        ('due:Today', ''),
        ('due:Tomorrow', ''),
        ('due:EndOfWorkWeek', ''),
        ('due:EndOfNextWorkWeek', ''),
        ('due:EndOfWeek', ''),
        ('due:EndOfNextWeek', ''),
        ('due:EndOfMonth', ''),
        ('due:EndOfNextMonth', ''),
        ('due:EndOfYear', ''),
        ('due:January', ''),
        ('due:February', ''),
        ('due:March', ''),
        ('due:April', ''),
        ('due:May', ''),
        ('due:June', ''),
        ('due:July', ''),
        ('due:August', ''),
        ('due:September', ''),
        ('due:October', ''),
        ('due:November', ''),
        ('t:Today', ''),
        ('t:Tomorrow', ''),
        ('t:EndOfWeek', ''),
        ('t:EndOfNextWeek', ''),
        ('t:EndOfMonth', ''),
        ('t:EndOfNextMonth', ''),
        ('t:EndOfYear', ''),
        ('due:December', '')
    ])

    def __init__(self, values, parent=None):
        super(TaskEditorDialog, self).__init__(parent)
        self._initUI(values)
        self._populateKeys(self.autocomplete_pairs)
        self.setWindowFlags(QtCore.Qt.Dialog
                            | QtCore.Qt.MSWindowsFixedSizeDialogHint
                            | QtCore.Qt.WindowStaysOnBottomHint
                            | QtCore.Qt.WindowSystemMenuHint
                            | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowCloseButtonHint)

    def _populateKeys(self, keys):
        self._populateDues(keys)
        self._populateThresholds(keys)

    def _populateThresholds(self, keys):
        keys['t:Today'] = 't:' + date.today().isoformat()
        keys['t:Tomorrow'] = 't:' + (date.today() + timedelta(days=1)).isoformat()
        keys['t:EndOfWorkWeek'] = 't:' + end_of_work_week()
        keys['t:EndOfNextWorkWeek'] = 't:' + end_of_next_work_week()
        keys['t:EndOfWeek'] = 't:' + end_of_week()
        keys['t:EndOfNextWeek'] = 't:' + end_of_next_week()
        keys['t:EndOfMonth'] = 't:' + end_of_month()
        keys['t:EndOfNextMonth'] = 't:' + end_of_next_month()
        keys['t:EndOfYear'] = 't:' + end_of_year()

    def _populateDues(self, keys):
        keys['due:Today'] = 'due:' + date.today().isoformat()
        keys['due:Tomorrow'] = 'due:' + (date.today() + timedelta(days=1)).isoformat()
        keys['due:EndOfWorkWeek'] = 'due:' + end_of_work_week()
        keys['due:EndOfNextWorkWeek'] = 'due:' + end_of_next_work_week()
        keys['due:EndOfWeek'] = 'due:' + end_of_week()
        keys['due:EndOfNextWeek'] = 'due:' + end_of_next_week()
        keys['due:EndOfMonth'] = 'due:' + end_of_month()
        keys['due:EndOfNextMonth'] = 'due:' + end_of_next_month()
        keys['due:EndOfYear'] = 'due:' + end_of_year()
        keys['due:January'] = "due:" + end_of_month(month=1)
        keys['due:February'] = "due:" + end_of_month(month=2)
        keys['due:March'] = "due:" + end_of_month(month=3)
        keys['due:April'] = "due:" + end_of_month(month=4)
        keys['due:May'] = "due:" + end_of_month(month=5)
        keys['due:June'] = "due:" + end_of_month(month=6)
        keys['due:July'] = "due:" + end_of_month(month=7)
        keys['due:August'] = "due:" + end_of_month(month=8)
        keys['due:September'] = "due:" + end_of_month(month=9)
        keys['due:October'] = "due:" + end_of_month(month=10)
        keys['due:November'] = "due:" + end_of_month(month=11)
        keys['due:December'] = "due:" + end_of_month(month=12)

    def _initUI(self, values):
        self.setWindowTitle("Task Editor")
        vbox = QtWidgets.QVBoxLayout()

        self._label = QtWidgets.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(values, self.autocomplete_pairs)
        vbox.addWidget(self._edit)

        hbox = QtWidgets.QHBoxLayout()
        okButton = QtWidgets.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtWidgets.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)

    def textValue(self):
        return self._edit.text()

    def setTextValue(self, text):
        self._edit.setText(text)

    def setLabelText(self, text):
        self._label.setText(text)
Example #9
0
class TaskEditorDialog(QtWidgets.QDialog):
    autocomplete_pairs = collections.OrderedDict([('due:Today', ''),
                                                  ('due:Tomorrow', ''),
                                                  ('due:EndOfWorkWeek', ''),
                                                  ('due:EndOfNextWorkWeek',
                                                   ''), ('due:EndOfWeek', ''),
                                                  ('due:EndOfNextWeek', ''),
                                                  ('due:EndOfMonth', ''),
                                                  ('due:EndOfNextMonth', ''),
                                                  ('due:EndOfYear', ''),
                                                  ('due:January', ''),
                                                  ('due:February', ''),
                                                  ('due:March', ''),
                                                  ('due:April', ''),
                                                  ('due:May', ''),
                                                  ('due:June', ''),
                                                  ('due:July', ''),
                                                  ('due:August', ''),
                                                  ('due:September', ''),
                                                  ('due:October', ''),
                                                  ('due:November', ''),
                                                  ('t:Today', ''),
                                                  ('t:Tomorrow', ''),
                                                  ('t:EndOfWeek', ''),
                                                  ('t:EndOfNextWeek', ''),
                                                  ('t:EndOfMonth', ''),
                                                  ('t:EndOfNextMonth', ''),
                                                  ('t:EndOfYear', ''),
                                                  ('due:December', '')])

    def __init__(self, values, parent=None):
        super(TaskEditorDialog, self).__init__(parent)
        self._initUI(values)
        self._populateKeys(self.autocomplete_pairs)
        self.setWindowFlags(QtCore.Qt.Dialog
                            | QtCore.Qt.MSWindowsFixedSizeDialogHint
                            | QtCore.Qt.WindowStaysOnBottomHint
                            | QtCore.Qt.WindowSystemMenuHint
                            | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowCloseButtonHint)

    def _populateKeys(self, keys):
        self._populateDues(keys)
        self._populateThresholds(keys)

    def _populateThresholds(self, keys):
        keys['t:Today'] = 't:' + date.today().isoformat()
        keys['t:Tomorrow'] = 't:' + (date.today() +
                                     timedelta(days=1)).isoformat()
        keys['t:EndOfWorkWeek'] = 't:' + end_of_work_week()
        keys['t:EndOfNextWorkWeek'] = 't:' + end_of_next_work_week()
        keys['t:EndOfWeek'] = 't:' + end_of_week()
        keys['t:EndOfNextWeek'] = 't:' + end_of_next_week()
        keys['t:EndOfMonth'] = 't:' + end_of_month()
        keys['t:EndOfNextMonth'] = 't:' + end_of_next_month()
        keys['t:EndOfYear'] = 't:' + end_of_year()

    def _populateDues(self, keys):
        keys['due:Today'] = 'due:' + date.today().isoformat()
        keys['due:Tomorrow'] = 'due:' + (date.today() +
                                         timedelta(days=1)).isoformat()
        keys['due:EndOfWorkWeek'] = 'due:' + end_of_work_week()
        keys['due:EndOfNextWorkWeek'] = 'due:' + end_of_next_work_week()
        keys['due:EndOfWeek'] = 'due:' + end_of_week()
        keys['due:EndOfNextWeek'] = 'due:' + end_of_next_week()
        keys['due:EndOfMonth'] = 'due:' + end_of_month()
        keys['due:EndOfNextMonth'] = 'due:' + end_of_next_month()
        keys['due:EndOfYear'] = 'due:' + end_of_year()
        keys['due:January'] = "due:" + end_of_month(month=1)
        keys['due:February'] = "due:" + end_of_month(month=2)
        keys['due:March'] = "due:" + end_of_month(month=3)
        keys['due:April'] = "due:" + end_of_month(month=4)
        keys['due:May'] = "due:" + end_of_month(month=5)
        keys['due:June'] = "due:" + end_of_month(month=6)
        keys['due:July'] = "due:" + end_of_month(month=7)
        keys['due:August'] = "due:" + end_of_month(month=8)
        keys['due:September'] = "due:" + end_of_month(month=9)
        keys['due:October'] = "due:" + end_of_month(month=10)
        keys['due:November'] = "due:" + end_of_month(month=11)
        keys['due:December'] = "due:" + end_of_month(month=12)

    def _initUI(self, values):
        self.setWindowTitle("Task Editor")
        vbox = QtWidgets.QVBoxLayout()

        self._label = QtWidgets.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(values, self.autocomplete_pairs)
        vbox.addWidget(self._edit)

        hbox = QtWidgets.QHBoxLayout()
        okButton = QtWidgets.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtWidgets.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)

    def textValue(self):
        return self._edit.text()

    def setTextValue(self, text):
        self._edit.setText(text)

    def setLabelText(self, text):
        self._label.setText(text)
Example #10
0
class TaskWidget(QWidget):

    taskModified = pyqtSignal(tasklib.Task)
    taskDeleted = pyqtSignal(tasklib.Task)
    taskCreated = pyqtSignal(tasklib.Task)

    def __init__(self, parent, task, new=False):
        QWidget.__init__(self, parent)
        self.task = task
        self.new = new
        self.layout = QStackedLayout(self)

        self.label = QLabel(self)
        self.label.setTextFormat(Qt.RichText)
        self.label.setOpenExternalLinks(True)
        self._update()
        self.label.setWordWrap(True)
        self.layout.addWidget(self.label)

        self.editor = TaskEditorLineEdit(self, parent.mfile)
        self.layout.addWidget(self.editor)
        self.setLayout(self.layout)

        self.layout.setCurrentIndex(0)
        self.editor.focusOut.connect(self.editFinished)
        self.task.modified.connect(self._update)

    def sizeHint(self):
        new_height = self.label.heightForWidth(self.parent().size().width())
        new_height += 10
        return QSize(self.parent().size().width(), new_height)

    def edit(self):
        self.editor.setText(self.task.text)
        self.layout.setCurrentIndex(1)
        self.editor.setFocus()

    def editFinished(self):
        # qt bug, this method may be called several times for one edit
        self.layout.setCurrentIndex(0)
        text = self.editor.text()
        if not text:
            self.taskDeleted.emit(self.task)
        elif self.new:
            self.task.text = text
            self.new = False
            self.taskCreated.emit(self.task)
        elif text != self.task.text:
            self.task.text = text
            self.taskModified.emit(self)
        self.parent().setFocus()

    def _update(self):
        self.label.setText(self.task.toHtml())

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.editor.setText(self.task.text)
            self.layout.setCurrentIndex(0)
            self.parent().setFocus()
            return
        elif event.key() in (Qt.Key_Enter, Qt.Key_Return):
            self.editFinished()
            return
        QWidget.keyPressEvent(self, event)
Example #11
0
class TaskEditorDialog(QtGui.QDialog):
    autocomplete_pairs = collections.OrderedDict([('due:Today', ''),
                                                  ('due:Tomorrow', ''),
                                                  ('due:EndOfWeek', ''),
                                                  ('due:EndOfMonth', ''),
                                                  ('due:EndOfYear', ''),
                                                  ('due:January', ''),
                                                  ('due:February', ''),
                                                  ('due:March', ''),
                                                  ('due:April', ''),
                                                  ('due:May', ''),
                                                  ('due:June', ''),
                                                  ('due:July', ''),
                                                  ('due:August', ''),
                                                  ('due:September', ''),
                                                  ('due:October', ''),
                                                  ('due:November', ''),
                                                  ('due:December', '')])

    def __init__(self, values, parent=None):
        super(TaskEditorDialog, self).__init__(parent)
        self._initUI(values)
        self._populateKeys(self.autocomplete_pairs)

    def _endOfMonth(self, month):
        month %= 12

        eom = date.today().replace(month=month + 1, day=1) - timedelta(days=1)
        if eom < date.today():
            eom = eom.replace(year=eom.year + 1)
        return 'due:' + eom.strftime('%Y-%m-%d')

    def _populateKeys(self, keys):
        today = 'due:' + date.today().strftime('%Y-%m-%d')
        tomorrow = 'due:' + (date.today() +
                             timedelta(days=1)).strftime('%Y-%m-%d')
        EOW = 'due:' + (date.today() + timedelta(
            (6 - date.today().weekday()) % 7)).strftime('%Y-%m-%d')
        EOM = 'due:' + (
            (date.today().replace(day=1) + timedelta(days=32)).replace(day=1) -
            timedelta(days=1)).strftime('%Y-%m-%d')
        EOY = 'due:' + (
            date.today().replace(year=date.today().year + 1, month=1, day=1) -
            timedelta(days=1)).strftime('%Y-%m-%d')

        keys['due:EndOfWeek'] = EOW
        keys['due:EndOfMonth'] = EOM
        keys['due:EndOfYear'] = EOY
        keys['due:Today'] = today
        keys['due:Tomorrow'] = tomorrow
        keys['due:January'] = self._endOfMonth(1)
        keys['due:February'] = self._endOfMonth(2)
        keys['due:March'] = self._endOfMonth(3)
        keys['due:April'] = self._endOfMonth(4)
        keys['due:May'] = self._endOfMonth(5)
        keys['due:June'] = self._endOfMonth(6)
        keys['due:July'] = self._endOfMonth(7)
        keys['due:August'] = self._endOfMonth(8)
        keys['due:September'] = self._endOfMonth(9)
        keys['due:October'] = self._endOfMonth(10)
        keys['due:November'] = self._endOfMonth(11)
        keys['due:December'] = self._endOfMonth(12)
        return keys

    def _initUI(self, values):
        self.setWindowTitle("Task Editor")
        vbox = QtGui.QVBoxLayout()

        self._label = QtGui.QLabel("Task:")
        vbox.addWidget(self._label)

        self._edit = TaskEditorLineEdit(values, self.autocomplete_pairs)
        vbox.addWidget(self._edit)

        hbox = QtGui.QHBoxLayout()
        okButton = QtGui.QPushButton("Ok")
        okButton.clicked.connect(self.accept)
        cancelButton = QtGui.QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.resize(500, 100)

    def textValue(self):
        return self._edit.text()

    def setTextValue(self, text):
        self._edit.setText(text)

    def setLabelText(self, text):
        self._label.setText(text)