# eric7.Tasks.TaskViewer

Module implementing a task viewer and associated classes.

Tasks can be defined manually or automatically. Automatically generated tasks are derived from a comment with a special introductory text. This text is configurable.

### Global Attributes

None

### Classes

ProjectTaskExtractionThread | Class implementing a thread to extract tasks related to a project.
TaskViewer | Class implementing the task viewer.

### Functions

None

## ProjectTaskExtractionThread

Class implementing a thread to extract tasks related to a project.

### Signals

taskFound(str, str, int, TaskType)
  emitted with the task description, the file name, the line number and task type to signal the presence of a task

### Derived from

QThread

### Class Attributes

None

### Class Methods

None

### Methods

ProjectTaskExtractionThread | Constructor
requestInterrupt | Public method to request iterruption of the thread.
run | Public thread method to scan the given files.
scan | Public method to scan the given list of files for tasks.

### Static Methods

None

#### ProjectTaskExtractionThread (Constructor)

ProjectTaskExtractionThread(parent=None)

Constructor

parent
  reference to the parent object (QObject)

#### ProjectTaskExtractionThread.requestInterrupt

requestInterrupt()

Public method to request iterruption of the thread.

#### ProjectTaskExtractionThread.run

run()

Public thread method to scan the given files.

#### ProjectTaskExtractionThread.scan

scan(markers, files)

Public method to scan the given list of files for tasks.

markers (dict of lists of str)
  dictionary of defined task markers
files (list of str)
  list of file names to be scanned

Up

## TaskViewer

Class implementing the task viewer.

### Signals

displayFile(str, int)
  emitted to go to a file task

### Derived from

QTreeWidget

### Class Attributes

None

### Class Methods

None

### Methods

TaskViewer | Constructor
__activateFilter | Private slot to handle the "Filtered display" context menu entry.
__checkTopLevelItems | Private slot to check the 'Extracted Tasks' item for children.
__configure | Private method to open the configuration dialog.
__configureFilter | Private slot to handle the "Configure filter" context menu entry.
__configureProjectTasksScanOptions | Private slot to configure scan options for project tasks.
__copyTask | Private slot to handle the "Copy" context menu entry.
__deleteCompleted | Private slot to handle the "Delete Completed Tasks" context menu entry.
__deleteSubTasks | Private method to delete all sub-tasks.
__deleteTask | Private slot to delete a task.
__editTaskProperties | Private slot to handle the "Properties" context menu entry.
__generateTopLevelItems | Private method to generate the 'Extracted Tasks' item.
__goToTask | Private slot to handle the "Go To" context menu entry.
__markCompleted | Private slot to handle the "Mark Completed" context menu entry.
__newSubTask | Private slot to handle the "New Sub-Task" context menu entry.
__newTask | Private slot to handle the "New Task" context menu entry.
__pasteMainTask | Private slot to handle the "Paste as Main Task" context menu entry.
__pasteTask | Private slot to handle the "Paste" context menu entry.
__refreshDisplay | Private method to refresh the display.
__resizeColumns | Private method to resize the list columns.
__resort | Private method to resort the tree.
__showContextMenu | Private slot to show the context menu of the list.
__taskItemActivated | Private slot to handle the activation of an item.
addFileTask | Public slot to add a file related task.
addTask | Public slot to add a task.
clearFileTasks | Public slot to clear all tasks related to a file.
clearProjectTasks | Public slot to clear project related tasks.
clearTasks | Public slot to clear all tasks from display.
containsTask | Public method to test, if a task is already in the tasks list.
findParentTask | Public method to find a parent task by its ID.
getGlobalTasks | Public method to retrieve all non project related tasks.
getProjectTasks | Public method to retrieve all project related tasks.
getTasksScanFilter | Public method to get the project scan filter.
handlePreferencesChanged | Public slot to react to changes of the preferences.
regenerateProjectTasks | Public slot to regenerate project related tasks.
saveProjectTasks | Public method to write the project tasks.
setProjectOpen | Public slot to set the project status.
setTasksScanFilter | Public method to set the project scan filter.
stopProjectTaskExtraction | Public method to stop the project task extraction thread.

### Static Methods

None

#### TaskViewer (Constructor)

TaskViewer(parent, project)

Constructor

parent
  the parent (QWidget)
project
  reference to the project object

#### TaskViewer.__activateFilter

__activateFilter(on)

Private slot to handle the "Filtered display" context menu entry.

on
  flag indicating the filter state (boolean)

#### TaskViewer.__checkTopLevelItems

__checkTopLevelItems()

Private slot to check the 'Extracted Tasks' item for children.

#### TaskViewer.__configure

__configure()

Private method to open the configuration dialog.

#### TaskViewer.__configureFilter

__configureFilter()

Private slot to handle the "Configure filter" context menu entry.

#### TaskViewer.__configureProjectTasksScanOptions

__configureProjectTasksScanOptions()

Private slot to configure scan options for project tasks.

#### TaskViewer.__copyTask

__copyTask()

Private slot to handle the "Copy" context menu entry.

#### TaskViewer.__deleteCompleted

__deleteCompleted()

Private slot to handle the "Delete Completed Tasks" context menu entry.

#### TaskViewer.__deleteSubTasks

__deleteSubTasks(task)

Private method to delete all sub-tasks.

task
  task to delete sub-tasks of (Task)

#### TaskViewer.__deleteTask

__deleteTask(task=None)

Private slot to delete a task.

task (Task)
  task to be deleted

#### TaskViewer.__editTaskProperties

__editTaskProperties()

Private slot to handle the "Properties" context menu entry.

#### TaskViewer.__generateTopLevelItems

__generateTopLevelItems()

Private method to generate the 'Extracted Tasks' item.

#### TaskViewer.__goToTask

__goToTask()

Private slot to handle the "Go To" context menu entry.

#### TaskViewer.__markCompleted

__markCompleted()

Private slot to handle the "Mark Completed" context menu entry.

#### TaskViewer.__newSubTask

__newSubTask()

Private slot to handle the "New Sub-Task" context menu entry.

#### TaskViewer.__newTask

__newTask()

Private slot to handle the "New Task" context menu entry.

#### TaskViewer.__pasteMainTask

__pasteMainTask()

Private slot to handle the "Paste as Main Task" context menu entry.

#### TaskViewer.__pasteTask

__pasteTask()

Private slot to handle the "Paste" context menu entry.

#### TaskViewer.__refreshDisplay

__refreshDisplay()

Private method to refresh the display.

#### TaskViewer.__resizeColumns

__resizeColumns()

Private method to resize the list columns.

#### TaskViewer.__resort

__resort()

Private method to resort the tree.

#### TaskViewer.__showContextMenu

__showContextMenu(coord)

Private slot to show the context menu of the list.

coord
  the position of the mouse pointer (QPoint)

#### TaskViewer.__taskItemActivated

__taskItemActivated(itm, col)

Private slot to handle the activation of an item.

itm
  reference to the activated item (QTreeWidgetItem)
col
  column the item was activated in (integer)

#### TaskViewer.addFileTask

addFileTask(summary, filename, lineno, taskType=TaskType.TODO, description="")

Public slot to add a file related task.

summary (str)
  summary text of the task
filename (str)
  filename containing the task
lineno (int)
  line number containing the task
taskType (TaskType)
  type of the task
description (str)
  explanatory text of the task

#### TaskViewer.addTask

addTask(summary, priority=TaskPriority.NORMAL, filename="", lineno=0, completed=False, _time=0, isProjectTask=False, taskType=TaskType.TODO, description="", uid="", parentTask=None)

Public slot to add a task.

summary (str)
  summary text of the task
priority (TaskPriority)
  priority of the task
filename (str)
  filename containing the task
lineno (int)
  line number containing the task
completed (bool)
  flag indicating completion status
_time (float)
  creation time of the task (if 0 use current time)
isProjectTask (bool)
  flag indicating a task related to the current project
taskType (TaskType)
  type of the task
description (str)
  explanatory text of the task
uid (str)
  unique id of the task
parentTask (Task or str)
  reference to the parent task item or the UID of the parent task

Return:
  reference to the task item

Return Type:
  Task

#### TaskViewer.clearFileTasks

clearFileTasks(filename, conditionally=False)

Public slot to clear all tasks related to a file.

filename
  name of the file (string)
conditionally
  flag indicating to clear the tasks of the file checking some conditions (boolean)

#### TaskViewer.clearProjectTasks

clearProjectTasks(fileOnly=False)

Public slot to clear project related tasks.

fileOnly
  flag indicating to clear only file related project tasks (boolean)

#### TaskViewer.clearTasks

clearTasks()

Public slot to clear all tasks from display.

#### TaskViewer.containsTask

containsTask(taskToTest)

Public method to test, if a task is already in the tasks list.

taskToTest (Task)
  task to look for

Return:
  flag indicating the existence of the task

Return Type:
  bool

#### TaskViewer.findParentTask

findParentTask(parentUid)

Public method to find a parent task by its ID.

parentUid
  uid of the parent task (string)

Return:
  reference to the task (Task)

#### TaskViewer.getGlobalTasks

getGlobalTasks()

Public method to retrieve all non project related tasks.

Return:
  copy of tasks (list of Task)

#### TaskViewer.getProjectTasks

getProjectTasks()

Public method to retrieve all project related tasks.

Return:
  copy of tasks (list of Task)

#### TaskViewer.getTasksScanFilter

getTasksScanFilter()

Public method to get the project scan filter.

Return:
  project scan filter

Return Type:
  str

#### TaskViewer.handlePreferencesChanged

handlePreferencesChanged()

Public slot to react to changes of the preferences.

#### TaskViewer.regenerateProjectTasks

regenerateProjectTasks(quiet=False)

Public slot to regenerate project related tasks.

quiet (bool)
  flag indicating quiet operation

#### TaskViewer.saveProjectTasks

saveProjectTasks()

Public method to write the project tasks.

#### TaskViewer.setProjectOpen

setProjectOpen(o=False)

Public slot to set the project status.

o
  flag indicating the project status

#### TaskViewer.setTasksScanFilter

setTasksScanFilter(filterStr: str)

Public method to set the project scan filter.

filterStr (str)
  project scan filter

#### TaskViewer.stopProjectTaskExtraction

stopProjectTaskExtraction()

Public method to stop the project task extraction thread.

Up