Diffstat (limited to 'core/pim/today/plugins/todolist') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/today/plugins/todolist/todoplugin.cpp | 16 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todoplugin.h | 6 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginwidget.cpp | 32 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginwidget.h | 4 |
4 files changed, 44 insertions, 14 deletions
diff --git a/core/pim/today/plugins/todolist/todoplugin.cpp b/core/pim/today/plugins/todolist/todoplugin.cpp index b5abbd3..1238f92 100644 --- a/core/pim/today/plugins/todolist/todoplugin.cpp +++ b/core/pim/today/plugins/todolist/todoplugin.cpp | |||
@@ -9,53 +9,63 @@ | |||
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
19 | #include "todoplugin.h" | 19 | #include "todoplugin.h" |
20 | #include "todopluginconfig.h" | 20 | #include "todopluginconfig.h" |
21 | #include "todopluginwidget.h" | ||
22 | 21 | ||
23 | 22 | ||
24 | TodolistPlugin::TodolistPlugin() { | 23 | TodolistPlugin::TodolistPlugin() { |
24 | m_widget = 0l; | ||
25 | } | 25 | } |
26 | 26 | ||
27 | TodolistPlugin::~TodolistPlugin() { | 27 | TodolistPlugin::~TodolistPlugin() { |
28 | delete m_widget; | ||
28 | } | 29 | } |
29 | 30 | ||
30 | QString TodolistPlugin::pluginName() const { | 31 | QString TodolistPlugin::pluginName() const { |
31 | return QObject::tr( "Todolist plugin" ); | 32 | return QObject::tr( "Todolist plugin" ); |
32 | } | 33 | } |
33 | 34 | ||
34 | double TodolistPlugin::versionNumber() const { | 35 | double TodolistPlugin::versionNumber() const { |
35 | return 0.8; | 36 | return 0.9; |
36 | } | 37 | } |
37 | 38 | ||
38 | QString TodolistPlugin::pixmapNameWidget() const { | 39 | QString TodolistPlugin::pixmapNameWidget() const { |
39 | return "TodoList"; | 40 | return "TodoList"; |
40 | } | 41 | } |
41 | 42 | ||
42 | QWidget* TodolistPlugin::widget( QWidget *wid ) { | 43 | QWidget* TodolistPlugin::widget( QWidget *wid ) { |
43 | return new TodolistPluginWidget( wid, "Todolist" ); | 44 | if(!m_widget) { |
45 | m_widget = new TodolistPluginWidget( wid, "Todolist" ); | ||
46 | } | ||
47 | return m_widget; | ||
44 | } | 48 | } |
45 | 49 | ||
46 | QString TodolistPlugin::pixmapNameConfig() const { | 50 | QString TodolistPlugin::pixmapNameConfig() const { |
47 | return "TodoList"; | 51 | return "TodoList"; |
48 | } | 52 | } |
49 | 53 | ||
50 | TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) { | 54 | TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) { |
51 | return new TodolistPluginConfig( wid , "Todolist" ); | 55 | return new TodolistPluginConfig( wid , "Todolist" ); |
52 | } | 56 | } |
53 | 57 | ||
54 | QString TodolistPlugin::appName() const { | 58 | QString TodolistPlugin::appName() const { |
55 | return "todolist"; | 59 | return "todolist"; |
56 | } | 60 | } |
57 | 61 | ||
58 | 62 | ||
59 | bool TodolistPlugin::excludeFromRefresh() const { | 63 | bool TodolistPlugin::excludeFromRefresh() const { |
60 | return false; | 64 | return false; |
61 | } | 65 | } |
66 | |||
67 | void TodolistPlugin::refresh() { | ||
68 | if ( m_widget ) { | ||
69 | m_widget->refresh(); | ||
70 | } | ||
71 | } | ||
diff --git a/core/pim/today/plugins/todolist/todoplugin.h b/core/pim/today/plugins/todolist/todoplugin.h index f98afdb..6106d0c 100644 --- a/core/pim/today/plugins/todolist/todoplugin.h +++ b/core/pim/today/plugins/todolist/todoplugin.h | |||
@@ -15,29 +15,35 @@ | |||
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #ifndef TODOLIST_PLUGIN_H | 17 | #ifndef TODOLIST_PLUGIN_H |
18 | #define TODOLIST_PLUGIN_H | 18 | #define TODOLIST_PLUGIN_H |
19 | 19 | ||
20 | #include <qstring.h> | 20 | #include <qstring.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | 22 | ||
23 | #include <opie/tododb.h> | 23 | #include <opie/tododb.h> |
24 | #include <opie/oclickablelabel.h> | 24 | #include <opie/oclickablelabel.h> |
25 | #include <opie/todayplugininterface.h> | 25 | #include <opie/todayplugininterface.h> |
26 | 26 | ||
27 | #include "todopluginwidget.h" | ||
28 | |||
27 | class TodolistPlugin : public TodayPluginObject { | 29 | class TodolistPlugin : public TodayPluginObject { |
28 | 30 | ||
29 | public: | 31 | public: |
30 | TodolistPlugin(); | 32 | TodolistPlugin(); |
31 | ~TodolistPlugin(); | 33 | ~TodolistPlugin(); |
32 | 34 | ||
33 | QString pluginName() const; | 35 | QString pluginName() const; |
34 | double versionNumber() const; | 36 | double versionNumber() const; |
35 | QString pixmapNameWidget() const; | 37 | QString pixmapNameWidget() const; |
36 | QWidget* widget(QWidget *); | 38 | QWidget* widget(QWidget *); |
37 | QString pixmapNameConfig() const; | 39 | QString pixmapNameConfig() const; |
38 | TodayConfigWidget* configWidget(QWidget *); | 40 | TodayConfigWidget* configWidget(QWidget *); |
39 | QString appName() const; | 41 | QString appName() const; |
40 | bool excludeFromRefresh() const; | 42 | bool excludeFromRefresh() const; |
43 | void refresh(); | ||
44 | |||
45 | private: | ||
46 | TodolistPluginWidget *m_widget; | ||
41 | }; | 47 | }; |
42 | 48 | ||
43 | #endif | 49 | #endif |
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp index 773e5cf..3242dac 100644 --- a/core/pim/today/plugins/todolist/todopluginwidget.cpp +++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp | |||
@@ -21,64 +21,75 @@ | |||
21 | #include <qstring.h> | 21 | #include <qstring.h> |
22 | #include <qscrollview.h> | 22 | #include <qscrollview.h> |
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | 25 | ||
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/timestring.h> | 27 | #include <qpe/timestring.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | 29 | ||
30 | TodolistPluginWidget::TodolistPluginWidget( QWidget *parent, const char* name ) | 30 | TodolistPluginWidget::TodolistPluginWidget( QWidget *parent, const char* name ) |
31 | : QWidget( parent, name ) { | 31 | : QWidget( parent, name ) { |
32 | 32 | ||
33 | todoLabel = 0l; | ||
34 | todo = 0l; | 33 | todo = 0l; |
34 | layoutTodo = 0l; | ||
35 | todoLabel = 0l; | ||
35 | 36 | ||
36 | if ( todo ) { | 37 | if ( todo ) { |
37 | delete todo; | 38 | delete todo; |
38 | } | 39 | } |
39 | |||
40 | todo = new OTodoAccess(); | 40 | todo = new OTodoAccess(); |
41 | todo->load(); | 41 | todo->load(); |
42 | 42 | ||
43 | if ( layoutTodo ) { | ||
44 | delete layoutTodo; | ||
45 | } | ||
46 | layoutTodo = new QVBoxLayout( this ); | ||
47 | layoutTodo->setAutoAdd( true ); | ||
48 | |||
49 | |||
50 | if ( todoLabel ) { | ||
51 | delete todoLabel; | ||
52 | } | ||
53 | todoLabel = new OClickableLabel( this ); | ||
54 | |||
55 | connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); | ||
56 | |||
43 | readConfig(); | 57 | readConfig(); |
44 | getTodo(); | 58 | getTodo(); |
45 | } | 59 | } |
46 | 60 | ||
47 | TodolistPluginWidget::~TodolistPluginWidget() { | 61 | TodolistPluginWidget::~TodolistPluginWidget() { |
48 | delete todo; | 62 | delete todo; |
63 | delete todoLabel; | ||
64 | delete layoutTodo; | ||
49 | } | 65 | } |
50 | 66 | ||
51 | 67 | ||
52 | void TodolistPluginWidget::readConfig() { | 68 | void TodolistPluginWidget::readConfig() { |
53 | Config cfg( "todaytodoplugin" ); | 69 | Config cfg( "todaytodoplugin" ); |
54 | cfg.setGroup( "config" ); | 70 | cfg.setGroup( "config" ); |
55 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); | 71 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); |
56 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | 72 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); |
57 | } | 73 | } |
58 | 74 | ||
75 | void TodolistPluginWidget:: refresh() { | ||
76 | getTodo(); | ||
77 | } | ||
59 | 78 | ||
60 | /** | 79 | /** |
61 | * Get the todos | 80 | * Get the todos |
62 | */ | 81 | */ |
63 | void TodolistPluginWidget::getTodo() { | 82 | void TodolistPluginWidget::getTodo() { |
64 | 83 | ||
65 | QVBoxLayout* layoutTodo = new QVBoxLayout( this ); | ||
66 | |||
67 | if ( todoLabel ) { | ||
68 | delete todoLabel; | ||
69 | } | ||
70 | |||
71 | todoLabel = new OClickableLabel( this ); | ||
72 | connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); | ||
73 | 84 | ||
74 | QString output; | 85 | QString output; |
75 | QString tmpout; | 86 | QString tmpout; |
76 | int count = 0; | 87 | int count = 0; |
77 | int ammount = 0; | 88 | int ammount = 0; |
78 | 89 | ||
79 | // get overdue todos first | 90 | // get overdue todos first |
80 | m_list = todo->overDue(); | 91 | m_list = todo->overDue(); |
81 | 92 | ||
82 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 93 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
83 | if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) { | 94 | if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) { |
84 | QString desc = (*m_it).summary(); | 95 | QString desc = (*m_it).summary(); |
@@ -109,22 +120,21 @@ void TodolistPluginWidget::getTodo() { | |||
109 | 120 | ||
110 | if ( count > 0 ) { | 121 | if ( count > 0 ) { |
111 | if( count == 1 ) { | 122 | if( count == 1 ) { |
112 | output += QObject::tr( "There is <b> 1</b> active task: <br>" ); | 123 | output += QObject::tr( "There is <b> 1</b> active task: <br>" ); |
113 | } else { | 124 | } else { |
114 | output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); | 125 | output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); |
115 | } | 126 | } |
116 | output += tmpout; | 127 | output += tmpout; |
117 | } else { | 128 | } else { |
118 | output = QObject::tr( "No active tasks" ); | 129 | output = QObject::tr( "No active tasks" ); |
119 | } | 130 | } |
120 | todoLabel->setText( output ); | 131 | todoLabel->setText( output ); |
121 | layoutTodo->addWidget( todoLabel ); | ||
122 | } | 132 | } |
123 | 133 | ||
124 | /** | 134 | /** |
125 | * start the todolist | 135 | * start the todolist |
126 | */ | 136 | */ |
127 | void TodolistPluginWidget::startTodolist() { | 137 | void TodolistPluginWidget::startTodolist() { |
128 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 138 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
129 | e << QString( "todolist" ); | 139 | e << QString( "todolist" ); |
130 | } | 140 | } |
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.h b/core/pim/today/plugins/todolist/todopluginwidget.h index 37b0ee1..0d0deb5 100644 --- a/core/pim/today/plugins/todolist/todopluginwidget.h +++ b/core/pim/today/plugins/todolist/todopluginwidget.h | |||
@@ -10,43 +10,47 @@ | |||
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #ifndef TODOLIST_PLUGIN_WIDGET_H | 17 | #ifndef TODOLIST_PLUGIN_WIDGET_H |
18 | #define TODOLIST_PLUGIN_WIDGET_H | 18 | #define TODOLIST_PLUGIN_WIDGET_H |
19 | 19 | ||
20 | #include <qstring.h> | 20 | #include <qstring.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qlayout.h> | ||
22 | 23 | ||
23 | #include <opie/otodo.h> | 24 | #include <opie/otodo.h> |
24 | #include <opie/otodoaccess.h> | 25 | #include <opie/otodoaccess.h> |
25 | #include <opie/oclickablelabel.h> | 26 | #include <opie/oclickablelabel.h> |
26 | 27 | ||
27 | 28 | ||
28 | class TodolistPluginWidget : public QWidget { | 29 | class TodolistPluginWidget : public QWidget { |
29 | 30 | ||
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | 32 | ||
32 | public: | 33 | public: |
33 | TodolistPluginWidget( QWidget *parent, const char *name ); | 34 | TodolistPluginWidget( QWidget *parent, const char *name ); |
34 | ~TodolistPluginWidget(); | 35 | ~TodolistPluginWidget(); |
35 | 36 | ||
37 | void refresh(); | ||
38 | |||
36 | protected slots: | 39 | protected slots: |
37 | void startTodolist(); | 40 | void startTodolist(); |
38 | 41 | ||
39 | private: | 42 | private: |
40 | OClickableLabel *todoLabel; | 43 | OClickableLabel *todoLabel; |
44 | QVBoxLayout* layoutTodo; | ||
41 | 45 | ||
42 | OTodoAccess *todo; | 46 | OTodoAccess *todo; |
43 | OTodoAccess::List m_list; | 47 | OTodoAccess::List m_list; |
44 | OTodoAccess::List::Iterator m_it; | 48 | OTodoAccess::List::Iterator m_it; |
45 | 49 | ||
46 | void readConfig(); | 50 | void readConfig(); |
47 | void getTodo(); | 51 | void getTodo(); |
48 | int m_maxLinesTask; | 52 | int m_maxLinesTask; |
49 | int m_maxCharClip; | 53 | int m_maxCharClip; |
50 | }; | 54 | }; |
51 | 55 | ||
52 | #endif | 56 | #endif |