summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-11-05 00:43:46 (UTC)
committer harlekin <harlekin>2002-11-05 00:43:46 (UTC)
commit4efdcbfa9ae55ba42b10b5003c9e524b2e1f0eef (patch) (unidiff)
tree2c56641bfc494138d3358fb52b22261c5be37e25
parentda417964fde0079e97aa9dfd4ecdde77522d4ad9 (diff)
downloadopie-4efdcbfa9ae55ba42b10b5003c9e524b2e1f0eef.zip
opie-4efdcbfa9ae55ba42b10b5003c9e524b2e1f0eef.tar.gz
opie-4efdcbfa9ae55ba42b10b5003c9e524b2e1f0eef.tar.bz2
transition to new opie pim api, no finished yet, but should allready close bug #1 cvs upcvs up
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/todolist/todolist.pro3
-rw-r--r--core/pim/today/plugins/todolist/todoplugin.cpp2
-rw-r--r--core/pim/today/plugins/todolist/todopluginwidget.cpp46
-rw-r--r--core/pim/today/plugins/todolist/todopluginwidget.h8
4 files changed, 29 insertions, 30 deletions
diff --git a/core/pim/today/plugins/todolist/todolist.pro b/core/pim/today/plugins/todolist/todolist.pro
index 1f9c61c..38db406 100644
--- a/core/pim/today/plugins/todolist/todolist.pro
+++ b/core/pim/today/plugins/todolist/todolist.pro
@@ -1,20 +1,19 @@
1TEMPLATE = lib 1TEMPLATE = lib
2#TEMPLATE = app
3CONFIG -= moc 2CONFIG -= moc
4CONFIG += qt debug 3CONFIG += qt release
5 4
6# Input 5# Input
7HEADERS = todoplugin.h todopluginimpl.h todopluginconfig.h \ 6HEADERS = todoplugin.h todopluginimpl.h todopluginconfig.h \
8 todopluginwidget.h 7 todopluginwidget.h
9SOURCES = todoplugin.cpp todopluginimpl.cpp todopluginconfig.cpp \ 8SOURCES = todoplugin.cpp todopluginimpl.cpp todopluginconfig.cpp \
10 todopluginwidget.cpp 9 todopluginwidget.cpp
11 10
12INCLUDEPATH += $(OPIEDIR)/include \ 11INCLUDEPATH += $(OPIEDIR)/include \
13 ../ ../library 12 ../ ../library
14DEPENDPATH += $(OPIEDIR)/include \ 13DEPENDPATH += $(OPIEDIR)/include \
15 ../ ../library 14 ../ ../library
16 15
17LIBS+= -lqpe -lopie 16LIBS+= -lqpe -lopie
18 17
19DESTDIR = $(OPIEDIR)/plugins/today 18DESTDIR = $(OPIEDIR)/plugins/today
20TARGET = todaytodolistplugin \ No newline at end of file 19TARGET = todaytodolistplugin \ No newline at end of file
diff --git a/core/pim/today/plugins/todolist/todoplugin.cpp b/core/pim/today/plugins/todolist/todoplugin.cpp
index e10b414..b5abbd3 100644
--- a/core/pim/today/plugins/todolist/todoplugin.cpp
+++ b/core/pim/today/plugins/todolist/todoplugin.cpp
@@ -19,33 +19,33 @@
19#include "todoplugin.h" 19#include "todoplugin.h"
20#include "todopluginconfig.h" 20#include "todopluginconfig.h"
21#include "todopluginwidget.h" 21#include "todopluginwidget.h"
22 22
23 23
24TodolistPlugin::TodolistPlugin() { 24TodolistPlugin::TodolistPlugin() {
25} 25}
26 26
27TodolistPlugin::~TodolistPlugin() { 27TodolistPlugin::~TodolistPlugin() {
28} 28}
29 29
30QString TodolistPlugin::pluginName() const { 30QString TodolistPlugin::pluginName() const {
31 return QObject::tr( "Todolist plugin" ); 31 return QObject::tr( "Todolist plugin" );
32} 32}
33 33
34double TodolistPlugin::versionNumber() const { 34double TodolistPlugin::versionNumber() const {
35 return 0.7; 35 return 0.8;
36} 36}
37 37
38QString TodolistPlugin::pixmapNameWidget() const { 38QString TodolistPlugin::pixmapNameWidget() const {
39 return "TodoList"; 39 return "TodoList";
40} 40}
41 41
42QWidget* TodolistPlugin::widget( QWidget *wid ) { 42QWidget* TodolistPlugin::widget( QWidget *wid ) {
43 return new TodolistPluginWidget( wid, "Todolist" ); 43 return new TodolistPluginWidget( wid, "Todolist" );
44} 44}
45 45
46QString TodolistPlugin::pixmapNameConfig() const { 46QString TodolistPlugin::pixmapNameConfig() const {
47 return "TodoList"; 47 return "TodoList";
48} 48}
49 49
50TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) { 50TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) {
51 return new TodolistPluginConfig( wid , "Todolist" ); 51 return new TodolistPluginConfig( wid , "Todolist" );
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp
index 320969e..773e5cf 100644
--- a/core/pim/today/plugins/todolist/todopluginwidget.cpp
+++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp
@@ -23,107 +23,103 @@
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
30TodolistPluginWidget::TodolistPluginWidget( QWidget *parent, const char* name ) 30TodolistPluginWidget::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
40 todo = new OTodoAccess();
41 todo->load();
40 42
41 readConfig(); 43 readConfig();
42 getTodo(); 44 getTodo();
43} 45}
44 46
45TodolistPluginWidget::~TodolistPluginWidget() { 47TodolistPluginWidget::~TodolistPluginWidget() {
46 delete todo; 48 delete todo;
47} 49}
48 50
49 51
50void TodolistPluginWidget::readConfig() { 52void TodolistPluginWidget::readConfig() {
51 Config cfg( "todaytodoplugin" ); 53 Config cfg( "todaytodoplugin" );
52 cfg.setGroup( "config" ); 54 cfg.setGroup( "config" );
53 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); 55 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
54 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 56 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
55} 57}
56 58
57 59
58/** 60/**
59 * Get the todos 61 * Get the todos
60 */ 62 */
61void TodolistPluginWidget::getTodo() { 63void TodolistPluginWidget::getTodo() {
62 64
63 QVBoxLayout* layoutTodo = new QVBoxLayout( this ); 65 QVBoxLayout* layoutTodo = new QVBoxLayout( this );
64 66
65 if ( todoLabel ) { 67 if ( todoLabel ) {
66 delete todoLabel; 68 delete todoLabel;
67 } 69 }
68 70
69 todoLabel = new OClickableLabel( this ); 71 todoLabel = new OClickableLabel( this );
70 todoLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
71 connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); 72 connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) );
72 73
73 QString output; 74 QString output;
74 QString tmpout; 75 QString tmpout;
75 int count = 0; 76 int count = 0;
76 int ammount = 0; 77 int ammount = 0;
77 78
78 // get overdue todos first 79 // get overdue todos first
79 QValueList<ToDoEvent> overDueList = todo->overDue(); 80 m_list = todo->overDue();
80 qBubbleSort( overDueList ); 81
81 for ( QValueList<ToDoEvent>::Iterator it = overDueList.begin(); 82 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
82 it != overDueList.end(); ++it ) { 83 if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) {
83 if (!(*it).isCompleted() && ( ammount < m_maxLinesTask ) ) { 84 QString desc = (*m_it).summary();
84 QString desc = (*it).summary();
85 if( desc.isEmpty() ) { 85 if( desc.isEmpty() ) {
86 desc = (*it).description(); 86 desc = (*m_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 m_list = todo->sorted( true, 1, 4, 1);
95 qBubbleSort( openTodo ); 95
96 for ( QValueList<ToDoEvent>::Iterator it = openTodo.begin(); 96 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
97 it != openTodo.end(); ++it ) { 97 count +=1;
98 if ( !(*it).isCompleted() ){ 98 // not the overdues, we allready got them, and not if we are
99 count +=1; 99 // over the maxlines
100 // not the overdues, we allready got them, and not if we are 100 if ( !(*m_it).isOverdue() && ( ammount < m_maxLinesTask ) ) {
101 // over the maxlines 101 QString desc = (*m_it).summary();
102 if ( !(*it).isOverdue() && ( ammount < m_maxLinesTask ) ) { 102 if( desc.isEmpty() ) {
103 QString desc = (*it).summary(); 103 desc = (*m_it).description();
104 if( desc.isEmpty() ) {
105 desc = (*it).description();
106 }
107 tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>";
108 ammount++;
109 } 104 }
105 tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>";
106 ammount++;
110 } 107 }
111 } 108 }
112 109
113
114 if ( count > 0 ) { 110 if ( count > 0 ) {
115 if( count == 1 ) { 111 if( count == 1 ) {
116 output += QObject::tr( "There is <b> 1</b> active task: <br>" ); 112 output += QObject::tr( "There is <b> 1</b> active task: <br>" );
117 } else { 113 } else {
118 output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); 114 output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count );
119 } 115 }
120 output += tmpout; 116 output += tmpout;
121 } else { 117 } else {
122 output = QObject::tr( "No active tasks" ); 118 output = QObject::tr( "No active tasks" );
123 } 119 }
124 todoLabel->setText( output ); 120 todoLabel->setText( output );
125 layoutTodo->addWidget( todoLabel ); 121 layoutTodo->addWidget( todoLabel );
126} 122}
127 123
128/** 124/**
129 * start the todolist 125 * start the todolist
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.h b/core/pim/today/plugins/todolist/todopluginwidget.h
index 970f430..37b0ee1 100644
--- a/core/pim/today/plugins/todolist/todopluginwidget.h
+++ b/core/pim/today/plugins/todolist/todopluginwidget.h
@@ -7,42 +7,46 @@
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_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 22
23#include <opie/tododb.h> 23#include <opie/otodo.h>
24#include <opie/otodoaccess.h>
24#include <opie/oclickablelabel.h> 25#include <opie/oclickablelabel.h>
25 26
26 27
27class TodolistPluginWidget : public QWidget { 28class TodolistPluginWidget : public QWidget {
28 29
29 Q_OBJECT 30 Q_OBJECT
30 31
31public: 32public:
32 TodolistPluginWidget( QWidget *parent, const char *name ); 33 TodolistPluginWidget( QWidget *parent, const char *name );
33 ~TodolistPluginWidget(); 34 ~TodolistPluginWidget();
34 35
35protected slots: 36protected slots:
36 void startTodolist(); 37 void startTodolist();
37 38
38private: 39private:
39 OClickableLabel *todoLabel; 40 OClickableLabel *todoLabel;
40 ToDoDB *todo; 41
42 OTodoAccess *todo;
43 OTodoAccess::List m_list;
44 OTodoAccess::List::Iterator m_it;
41 45
42 void readConfig(); 46 void readConfig();
43 void getTodo(); 47 void getTodo();
44 int m_maxLinesTask; 48 int m_maxLinesTask;
45 int m_maxCharClip; 49 int m_maxCharClip;
46}; 50};
47 51
48#endif 52#endif