-rw-r--r-- | core/pim/today/plugins/todolist/todopluginconfig.cpp | 35 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginconfig.h | 3 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginwidget.cpp | 2 |
3 files changed, 26 insertions, 14 deletions
diff --git a/core/pim/today/plugins/todolist/todopluginconfig.cpp b/core/pim/today/plugins/todolist/todopluginconfig.cpp index 2d8f1b6..69ad727 100644 --- a/core/pim/today/plugins/todolist/todopluginconfig.cpp +++ b/core/pim/today/plugins/todolist/todopluginconfig.cpp | |||
@@ -1,70 +1,79 @@ | |||
1 | /* | 1 | /* |
2 | * todopluginconfig.cpp | 2 | * todopluginconfig.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
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 | #include "todopluginconfig.h" | 17 | #include "todopluginconfig.h" |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | ||
22 | #include <qtoolbutton.h> | 23 | #include <qtoolbutton.h> |
23 | #include <qlabel.h> | 24 | #include <qlabel.h> |
24 | 25 | ||
25 | 26 | ||
27 | |||
26 | TodolistPluginConfig::TodolistPluginConfig( QWidget *parent, const char* name) | 28 | TodolistPluginConfig::TodolistPluginConfig( QWidget *parent, const char* name) |
27 | : ConfigWidget(parent, name ) { | 29 | : ConfigWidget(parent, name ) { |
28 | 30 | ||
29 | QVBoxLayout * layout = new QVBoxLayout( this ); | 31 | QVBoxLayout * layout = new QVBoxLayout( this ); |
32 | layout->setMargin( 20 ); | ||
30 | 33 | ||
31 | QFrame* Frame9 = new QFrame( this, "Frame9" ); | 34 | QHBox *box1 = new QHBox( this ); |
32 | Frame9->setGeometry( QRect( -5, 0, 230, 310 ) ); | ||
33 | Frame9->setFrameShape( QFrame::StyledPanel ); | ||
34 | Frame9->setFrameShadow( QFrame::Raised ); | ||
35 | 35 | ||
36 | QLabel* TextLabel6 = new QLabel( Frame9, "TextLabel6" ); | 36 | QLabel* TextLabel6 = new QLabel( box1, "TextLabel6" ); |
37 | TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) ); | 37 | TextLabel6->setText( tr( "How many\n tasks should \n" |
38 | TextLabel6->setText( tr( "How many\n" | ||
39 | "tasks should \n" | ||
40 | "be shown?" ) ); | 38 | "be shown?" ) ); |
41 | 39 | ||
42 | SpinBox2 = new QSpinBox( Frame9, "SpinBox2" ); | 40 | SpinBox2 = new QSpinBox( box1, "SpinBox2" ); |
43 | SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) ); | 41 | SpinBox2->setMaxValue( 40 ); |
44 | SpinBox2->setMaxValue( 20 ); | 42 | |
45 | SpinBox2->setValue( 5 ); | 43 | QHBox *box2 = new QHBox( this ); |
44 | |||
45 | QLabel* clipLabel = new QLabel( box2, "" ); | ||
46 | clipLabel->setText( tr( "Clip line after\n X chars" ) ); | ||
47 | |||
48 | SpinBoxClip = new QSpinBox( box2, "SpinClip" ); | ||
49 | SpinBoxClip->setMaxValue( 200 ); | ||
46 | 50 | ||
47 | layout->addWidget( Frame9 ); | 51 | layout->addWidget( box1 ); |
52 | layout->addWidget( box2 ); | ||
48 | 53 | ||
49 | readConfig(); | 54 | readConfig(); |
50 | } | 55 | } |
51 | 56 | ||
52 | void TodolistPluginConfig::readConfig() { | 57 | void TodolistPluginConfig::readConfig() { |
53 | Config cfg( "todaytodoplugin" ); | 58 | Config cfg( "todaytodoplugin" ); |
54 | cfg.setGroup( "config" ); | 59 | cfg.setGroup( "config" ); |
55 | m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 ); | 60 | m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 ); |
56 | SpinBox2->setValue( m_max_lines_task ); | 61 | SpinBox2->setValue( m_max_lines_task ); |
62 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | ||
63 | SpinBoxClip->setValue( m_maxCharClip ); | ||
57 | } | 64 | } |
58 | 65 | ||
59 | 66 | ||
60 | void TodolistPluginConfig::writeConfig() { | 67 | void TodolistPluginConfig::writeConfig() { |
61 | Config cfg( "todaytodoplugin" ); | 68 | Config cfg( "todaytodoplugin" ); |
62 | cfg.setGroup( "config" ); | 69 | cfg.setGroup( "config" ); |
63 | m_max_lines_task = SpinBox2->value(); | 70 | m_max_lines_task = SpinBox2->value(); |
64 | cfg.writeEntry( "maxlinestask", m_max_lines_task ); | 71 | cfg.writeEntry( "maxlinestask", m_max_lines_task ); |
72 | m_maxCharClip = SpinBoxClip->value(); | ||
73 | cfg.writeEntry( "maxcharclip", m_maxCharClip ); | ||
65 | cfg.write(); | 74 | cfg.write(); |
66 | } | 75 | } |
67 | 76 | ||
68 | 77 | ||
69 | TodolistPluginConfig::~TodolistPluginConfig() { | 78 | TodolistPluginConfig::~TodolistPluginConfig() { |
70 | } | 79 | } |
diff --git a/core/pim/today/plugins/todolist/todopluginconfig.h b/core/pim/today/plugins/todolist/todopluginconfig.h index 6be4b1e..934b319 100644 --- a/core/pim/today/plugins/todolist/todopluginconfig.h +++ b/core/pim/today/plugins/todolist/todopluginconfig.h | |||
@@ -1,54 +1,57 @@ | |||
1 | /* | 1 | /* |
2 | * todopluginconfig.h | 2 | * todopluginconfig.h |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
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 | #ifndef TODOLIST_PLUGIN_CONFIG_H | 17 | #ifndef TODOLIST_PLUGIN_CONFIG_H |
18 | #define TODOLIST_PLUGIN_CONFIG_H | 18 | #define TODOLIST_PLUGIN_CONFIG_H |
19 | 19 | ||
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
22 | 22 | ||
23 | #include "../../configwidget.h" | 23 | #include "../../configwidget.h" |
24 | 24 | ||
25 | class TodolistPluginConfig : public ConfigWidget { | 25 | class TodolistPluginConfig : public ConfigWidget { |
26 | 26 | ||
27 | 27 | ||
28 | public: | 28 | public: |
29 | 29 | ||
30 | TodolistPluginConfig( QWidget *parent, const char *name ); | 30 | TodolistPluginConfig( QWidget *parent, const char *name ); |
31 | ~TodolistPluginConfig(); | 31 | ~TodolistPluginConfig(); |
32 | 32 | ||
33 | private: | 33 | private: |
34 | /** | 34 | /** |
35 | * if changed then save | 35 | * if changed then save |
36 | */ | 36 | */ |
37 | bool changed(); | 37 | bool changed(); |
38 | void readConfig(); | 38 | void readConfig(); |
39 | void writeConfig(); | 39 | void writeConfig(); |
40 | 40 | ||
41 | QSpinBox* SpinBox2; | 41 | QSpinBox* SpinBox2; |
42 | QSpinBox* SpinBoxClip; | ||
42 | 43 | ||
43 | // how many lines should be showed in the todolist section | 44 | // how many lines should be showed in the todolist section |
44 | int m_max_lines_task; | 45 | int m_max_lines_task; |
46 | // clip the lines after X chars | ||
47 | int m_maxCharClip; | ||
45 | 48 | ||
46 | 49 | ||
47 | 50 | ||
48 | }; | 51 | }; |
49 | 52 | ||
50 | 53 | ||
51 | 54 | ||
52 | 55 | ||
53 | 56 | ||
54 | #endif | 57 | #endif |
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp index 4731b43..d793aae 100644 --- a/core/pim/today/plugins/todolist/todopluginwidget.cpp +++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp | |||
@@ -1,134 +1,134 @@ | |||
1 | /* | 1 | /* |
2 | * todopluginwidget.cpp | 2 | * todopluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
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 | #include "todopluginwidget.h" | 17 | #include "todopluginwidget.h" |
18 | 18 | ||
19 | #include <qvaluelist.h> | 19 | #include <qvaluelist.h> |
20 | #include <qtl.h> | 20 | #include <qtl.h> |
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; | 33 | todoLabel= 0l; |
34 | todo = 0l; | 34 | todo = 0l; |
35 | 35 | ||
36 | if ( todo ) { | 36 | if ( todo ) { |
37 | delete todo; | 37 | delete todo; |
38 | } | 38 | } |
39 | todo = new ToDoDB(); | 39 | todo = new ToDoDB(); |
40 | 40 | ||
41 | readConfig(); | 41 | readConfig(); |
42 | m_maxCharClip = 36; | ||
43 | getTodo(); | 42 | getTodo(); |
44 | } | 43 | } |
45 | 44 | ||
46 | TodolistPluginWidget::~TodolistPluginWidget() { | 45 | TodolistPluginWidget::~TodolistPluginWidget() { |
47 | delete todo; | 46 | delete todo; |
48 | } | 47 | } |
49 | 48 | ||
50 | 49 | ||
51 | void TodolistPluginWidget::readConfig() { | 50 | void TodolistPluginWidget::readConfig() { |
52 | Config cfg( "todaytodoplugin" ); | 51 | Config cfg( "todaytodoplugin" ); |
53 | cfg.setGroup( "config" ); | 52 | cfg.setGroup( "config" ); |
54 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); | 53 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); |
54 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | ||
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Get the todos | 59 | * Get the todos |
60 | */ | 60 | */ |
61 | void TodolistPluginWidget::getTodo() { | 61 | void TodolistPluginWidget::getTodo() { |
62 | 62 | ||
63 | QVBoxLayout* layoutTodo = new QVBoxLayout( this ); | 63 | QVBoxLayout* layoutTodo = new QVBoxLayout( this ); |
64 | 64 | ||
65 | if ( todoLabel ) { | 65 | if ( todoLabel ) { |
66 | delete todoLabel; | 66 | delete todoLabel; |
67 | } | 67 | } |
68 | 68 | ||
69 | todoLabel = new OClickableLabel( this ); | 69 | todoLabel = new OClickableLabel( this ); |
70 | todoLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | 70 | todoLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); |
71 | connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); | 71 | connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); |
72 | 72 | ||
73 | QString output; | 73 | QString output; |
74 | QString tmpout; | 74 | QString tmpout; |
75 | int count = 0; | 75 | int count = 0; |
76 | int ammount = 0; | 76 | int ammount = 0; |
77 | 77 | ||
78 | // get overdue todos first | 78 | // get overdue todos first |
79 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 79 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
80 | qBubbleSort( overDueList ); | 80 | qBubbleSort( overDueList ); |
81 | for ( QValueList<ToDoEvent>::Iterator it = overDueList.begin(); | 81 | for ( QValueList<ToDoEvent>::Iterator it = overDueList.begin(); |
82 | it != overDueList.end(); ++it ) { | 82 | it != overDueList.end(); ++it ) { |
83 | if (!(*it).isCompleted() && ( ammount < m_maxLinesTask ) ) { | 83 | if (!(*it).isCompleted() && ( ammount < m_maxLinesTask ) ) { |
84 | QString desc = (*it).summary(); | 84 | QString desc = (*it).summary(); |
85 | if( desc.isEmpty() ) { | 85 | if( desc.isEmpty() ) { |
86 | desc = (*it).description(); | 86 | desc = (*it).description(); |
87 | } | 87 | } |
88 | tmpout += "<font color=#e00000><b>-" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>"; | 88 | tmpout += "<font color=#e00000><b>-" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>"; |
89 | ammount++; | 89 | ammount++; |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | // get total number of still open todos | 93 | // get total number of still open todos |
94 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); | 94 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); |
95 | qBubbleSort( openTodo ); | 95 | qBubbleSort( openTodo ); |
96 | for ( QValueList<ToDoEvent>::Iterator it = openTodo.begin(); | 96 | for ( QValueList<ToDoEvent>::Iterator it = openTodo.begin(); |
97 | it != openTodo.end(); ++it ) { | 97 | it != openTodo.end(); ++it ) { |
98 | if ( !(*it).isCompleted() ){ | 98 | if ( !(*it).isCompleted() ){ |
99 | count +=1; | 99 | count +=1; |
100 | // not the overdues, we allready got them, and not if we are | 100 | // not the overdues, we allready got them, and not if we are |
101 | // over the maxlines | 101 | // over the maxlines |
102 | if ( !(*it).isOverdue() && ( ammount < m_maxLinesTask ) ) { | 102 | if ( !(*it).isOverdue() && ( ammount < m_maxLinesTask ) ) { |
103 | QString desc = (*it).summary(); | 103 | QString desc = (*it).summary(); |
104 | if( desc.isEmpty() ) { | 104 | if( desc.isEmpty() ) { |
105 | desc = (*it).description(); | 105 | desc = (*it).description(); |
106 | } | 106 | } |
107 | tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>"; | 107 | tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>"; |
108 | ammount++; | 108 | ammount++; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | if ( count > 0 ) { | 114 | if ( count > 0 ) { |
115 | if( count == 1 ) { | 115 | if( count == 1 ) { |
116 | output += QObject::tr( "There is <b> 1</b> active task: <br>" ); | 116 | output += QObject::tr( "There is <b> 1</b> active task: <br>" ); |
117 | } else { | 117 | } else { |
118 | output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); | 118 | output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); |
119 | } | 119 | } |
120 | output += tmpout; | 120 | output += tmpout; |
121 | } else { | 121 | } else { |
122 | output = QObject::tr( "No active tasks" ); | 122 | output = QObject::tr( "No active tasks" ); |
123 | } | 123 | } |
124 | todoLabel->setText( output ); | 124 | todoLabel->setText( output ); |
125 | layoutTodo->addWidget( todoLabel ); | 125 | layoutTodo->addWidget( todoLabel ); |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * start the todolist | 129 | * start the todolist |
130 | */ | 130 | */ |
131 | void TodolistPluginWidget::startTodolist() { | 131 | void TodolistPluginWidget::startTodolist() { |
132 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 132 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
133 | e << QString( "todolist" ); | 133 | e << QString( "todolist" ); |
134 | } | 134 | } |