Tasks/TaskPropertiesDialog.py

Sun, 23 Jun 2013 13:12:38 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 23 Jun 2013 13:12:38 +0200
changeset 2736
86cd4d14b58e
parent 2302
f29e9405c851
child 2525
8b507a9a2d40
child 2997
7f0ef975da9e
child 3163
9f50365a0870
permissions
-rw-r--r--

Added a wizard for the Qt5 QRegularExpression class.

# -*- coding: utf-8 -*-

# Copyright (c) 2005 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the task properties dialog.
"""

import time

from PyQt4.QtGui import QDialog

from E5Gui.E5Completers import E5FileCompleter

from .Ui_TaskPropertiesDialog import Ui_TaskPropertiesDialog


class TaskPropertiesDialog(QDialog, Ui_TaskPropertiesDialog):
    """
    Class implementing the task properties dialog.
    """
    def __init__(self, task=None, parent=None, projectOpen=False):
        """
        Constructor
        
        @param task the task object to be shown
        @param parent the parent widget (QWidget)
        @param projectOpen flag indicating status of the project (boolean)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.filenameCompleter = E5FileCompleter(self.filenameEdit)
        
        if not projectOpen:
            self.projectCheckBox.setEnabled(False)
        if task is not None:
            self.summaryEdit.setText(task.summary)
            self.descriptionEdit.setText(task.description)
            self.creationLabel.setText(time.strftime("%Y-%m-%d, %H:%M:%S",
                                                     time.localtime(task.created)))
            self.priorityCombo.setCurrentIndex(task.priority)
            self.projectCheckBox.setChecked(task._isProjectTask)
            self.completedCheckBox.setChecked(task.completed)
            self.filenameEdit.setText(task.filename)
            if task.lineno:
                self.linenoEdit.setText(str(task.lineno))
        else:
            self.projectCheckBox.setChecked(projectOpen)
    
    def setReadOnly(self):
        """
        Public slot to set the dialog to read only mode.
        """
        self.summaryEdit.setReadOnly(True)
        self.completedCheckBox.setEnabled(False)
        self.priorityCombo.setEnabled(False)
        self.projectCheckBox.setEnabled(False)
        
    def getData(self):
        """
        Public method to retrieve the dialogs data.
        
        @return tuple of description, priority, completion flag,
                project flag and long text (string, string, boolean, boolean, string)
        """
        return (self.summaryEdit.text(), self.priorityCombo.currentIndex(),
                self.completedCheckBox.isChecked(), self.projectCheckBox.isChecked(),
                self.descriptionEdit.toPlainText())

eric ide

mercurial