~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/scripting/python/taskmanager.sip

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
class TaskManager : QObject {
2
 
 
3
 
%TypeHeaderCode
4
 
#include "core/taskmanager.h"
5
 
%End
6
 
 
7
 
%Docstring
8
 
API for managing progress notifications in Clementine's status bar.
9
 
 
10
 
When you are performing a slow operation, such as downloading data from the
11
 
network or parsing a file, it is useful to be able to provide progress
12
 
information to the user.  Clementine displays information about any running
13
 
tasks with a spinner animation in the status bar.
14
 
 
15
 
When you start a new task, the TaskManager will give you an ID which you must
16
 
keep and use again later to update the task's progress or to mark it as
17
 
completed.
18
 
 
19
 
This is a singleton class, you can access its methods directly through the
20
 
C{clementine.task_manager} object:
21
 
 
22
 
  >>> id = clementine.task_manager.StartTask("Finding some awesome music")
23
 
  >>> clementine.task_manager.SetTaskProgress(id, 33, 100)
24
 
  >>> clementine.task_manager.SetTaskProgress(id, 66, 100)
25
 
  >>> clementine.task_manager.SetTaskFinished(id)
26
 
 
27
 
@group Signals: TasksChanged, PauseLibraryWatchers, ResumeLibraryWatchers
28
 
%End
29
 
 
30
 
public:
31
 
  struct Task {
32
 
%Docstring
33
 
Object containing information about a running task.
34
 
%End
35
 
 
36
 
    int id;
37
 
    QString name;
38
 
    int progress;
39
 
    int progress_max;
40
 
    bool blocks_library_scans;
41
 
  };
42
 
 
43
 
  QList<TaskManager::Task> GetTasks();
44
 
%Docstring
45
 
GetTasks() -> list of L{Task}s
46
 
Returns a list of all the tasks that are currently running.
47
 
 
48
 
Modifying the items in this list will have no effect - you have to use the other
49
 
methods in this class to update the status of a task.
50
 
%End
51
 
 
52
 
  int StartTask(const QString& name);
53
 
%Docstring
54
 
StartTask(name) -> int
55
 
Begins a new task.
56
 
 
57
 
@param name: A descriptive name of the task that will be displayed in the
58
 
  status bar.
59
 
@type name: str
60
 
@return: A new ID for this task.  Use this ID when calling L{SetTaskFinished}
61
 
  later.
62
 
@note: Do not include ellipsis (...) in the name of the task, this is added
63
 
  for you by the status bar.
64
 
%End
65
 
 
66
 
  void SetTaskBlocksLibraryScans(int id);
67
 
%Docstring
68
 
SetTaskBlocksLibraryScans(id)
69
 
Forces any library scans to wait until this task is complete.
70
 
 
71
 
It may be useful to set this flag on a task that modifies files in the library.
72
 
The LibraryWatcher will wait until the task is complete before starting to
73
 
rescan the Library.
74
 
%End
75
 
 
76
 
  void SetTaskProgress(int id, int progress, int max = 0);
77
 
%Docstring
78
 
SetTaskProgress(id, progress, max=0)
79
 
Updates the progress for this task.
80
 
 
81
 
The status bar shows the percentage progress of this task, calculated by
82
 
C{(progress / max * 100)}.  C{max} must be provided the first time this
83
 
method is called for a given task, but after that it can be omitted to keep the
84
 
old value.
85
 
%End
86
 
 
87
 
  void SetTaskFinished(int id);
88
 
%Docstring
89
 
SetTaskFinished(id)
90
 
Marks the given task as finished, removing it from the status bar.
91
 
%End
92
 
 
93
 
signals:
94
 
  void TasksChanged();
95
 
%Docstring
96
 
TasksChanged()
97
 
Emitted when the list of tasks returned by L{GetTasks()} is changed.
98
 
%End
99
 
 
100
 
  void PauseLibraryWatchers();
101
 
%Docstring
102
 
PauseLibraryWatchers()
103
 
Emitted when L{SetTaskBlocksLibraryScans()} is called on a task.
104
 
%End
105
 
 
106
 
  void ResumeLibraryWatchers();
107
 
%Docstring
108
 
ResumeLibraryWatchers()
109
 
Emitted when all tasks that blocked library scans have finished.
110
 
%End
111
 
 
112
 
private:
113
 
  TaskManager();
114
 
};