summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofontmenu.cc34
-rw-r--r--libopie/ofontmenu.h6
-rw-r--r--libopie/tododb.cpp20
-rw-r--r--libopie/tododb.h4
-rw-r--r--libopie/todoevent.cpp2
5 files changed, 63 insertions, 3 deletions
diff --git a/libopie/ofontmenu.cc b/libopie/ofontmenu.cc
index 2acae1c..52ff3ee 100644
--- a/libopie/ofontmenu.cc
+++ b/libopie/ofontmenu.cc
@@ -1,32 +1,64 @@
1 1
2
3#include <qpe/config.h>
2#include "ofontmenu.h" 4#include "ofontmenu.h"
3 5
4 6
5 7
6OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) 8OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list )
7 : QPopupMenu( parent, name ) 9 : QPopupMenu( parent, name )
8{ 10{
9 m_list = list; 11 m_list = list;
12 m_wids.setAutoDelete( TRUE );
13
10 insertItem(tr("Large"), this, SLOT(slotLarge() ), 14 insertItem(tr("Large"), this, SLOT(slotLarge() ),
11 0, 10); 15 0, 10);
12 insertItem(tr("Medium"), this, SLOT(slotMedium() ), 16 insertItem(tr("Medium"), this, SLOT(slotMedium() ),
13 0, 11 ); 17 0, 11 );
14 insertItem(tr("Small"), this, SLOT(slotSmall() ), 18 insertItem(tr("Small"), this, SLOT(slotSmall() ),
15 0, 12 ); 19 0, 12 );
16 setCheckable( true ); 20 setCheckable( true );
21 m_size=10;
22}
23void OFontMenu::save(Config *cfg )
24{
25 cfg->setGroup("OFontMenu" );
26 cfg->writeEntry("size", m_size );
27}
28void OFontMenu::restore(Config *cfg )
29{
30 cfg->setGroup("OFontMeny" );
31 m_size = cfg->readNumEntry("size" );
32 setItemChecked(10, false );
33 setItemChecked(11, false );
34 setItemChecked(12, false );
35 switch( m_size ){
36 case 8:
37 setItemChecked(12, true );
38 break;
39 case 14:
40 setItemChecked(10, true );
41 break;
42 case 10:// fall through
43 default:
44 setItemChecked(11, true );
45 m_size = 10;
46 break;
47 }
48 setFontSize( m_size );
17} 49}
18void OFontMenu::setWidgets(const QList<QWidget> &list ) 50void OFontMenu::setWidgets(const QList<QWidget> &list )
19{ 51{
20 m_list = list; 52 m_list = list;
21} 53}
22void OFontMenu::addWidget( QWidget *wid ) 54void OFontMenu::addWidget( QWidget *wid )
23{ 55{
24 m_list.append(wid ); 56 m_list.append(wid );
25} 57}
26void OFontMenu::removeWidget( QWidget *wid ) 58void OFontMenu::removeWidget( QWidget *wid )
27{ 59{
28 m_list.remove( wid ); 60 m_list.remove( wid );
29} 61}
30const QList<QWidget> &OFontMenu::widgets()const 62const QList<QWidget> &OFontMenu::widgets()const
31{ 63{
32 return m_list; 64 return m_list;
@@ -48,31 +80,33 @@ void OFontMenu::slotSmall()
48void OFontMenu::slotMedium() 80void OFontMenu::slotMedium()
49{ 81{
50 setItemChecked(10, false ); 82 setItemChecked(10, false );
51 setItemChecked(11, true ); 83 setItemChecked(11, true );
52 setItemChecked(12, false ); 84 setItemChecked(12, false );
53 setFontSize(10 ); 85 setFontSize(10 );
54} 86}
55void OFontMenu::slotLarge() 87void OFontMenu::slotLarge()
56{ 88{
57 setItemChecked(10, true ); 89 setItemChecked(10, true );
58 setItemChecked(11, false ); 90 setItemChecked(11, false );
59 setItemChecked(12, false ); 91 setItemChecked(12, false );
60 setFontSize(14 ); 92 setFontSize(14 );
61} 93}
62void OFontMenu::setFontSize(int size ) 94void OFontMenu::setFontSize(int size )
63{ 95{
96 m_size = size;
64 QWidget *wid; 97 QWidget *wid;
65 for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ 98 for(wid = m_list.first(); wid !=0; wid = m_list.next() ){
66 QFont font = wid->font(); 99 QFont font = wid->font();
67 font.setPointSize( size ); 100 font.setPointSize( size );
68 wid->setFont( font ); 101 wid->setFont( font );
69 } 102 }
70 if(!m_wids.isEmpty() ){ 103 if(!m_wids.isEmpty() ){
71 WidSize *wids; 104 WidSize *wids;
72 for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ 105 for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){
73 QFont font = wids->wid->font(); 106 QFont font = wids->wid->font();
74 font.setPointSize( wids->size ); 107 font.setPointSize( wids->size );
75 wids->wid->setFont( font ); 108 wids->wid->setFont( font );
76 } 109 }
77 } 110 }
111 emit fontChanged(size );
78} 112}
diff --git a/libopie/ofontmenu.h b/libopie/ofontmenu.h
index 37a628e..609f240 100644
--- a/libopie/ofontmenu.h
+++ b/libopie/ofontmenu.h
@@ -34,44 +34,50 @@
34#ifndef ofontmenu_h 34#ifndef ofontmenu_h
35#define ofontmenu_h 35#define ofontmenu_h
36 36
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qlist.h> 38#include <qlist.h>
39 39
40 40
41namespace { 41namespace {
42 struct WidSize { 42 struct WidSize {
43 QWidget *wid; 43 QWidget *wid;
44 int size; 44 int size;
45 }; 45 };
46 46
47}; 47};
48 48
49// if i would be on kde this would be a KActionMenu... 49// if i would be on kde this would be a KActionMenu...
50class Config;
50class OFontMenu : public QPopupMenu { 51class OFontMenu : public QPopupMenu {
51 Q_OBJECT 52 Q_OBJECT
52 public: 53 public:
53 OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); 54 OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list );
55 void save(Config *cfg );
56 void restore(Config *cfg );
54 void setWidgets(const QList<QWidget> &list ); 57 void setWidgets(const QList<QWidget> &list );
55 void addWidget(QWidget *wid ); 58 void addWidget(QWidget *wid );
56 void forceSize(QWidget *wid, int size ); 59 void forceSize(QWidget *wid, int size );
57 void removeWidget(QWidget *wid ); 60 void removeWidget(QWidget *wid );
58 const QList<QWidget> &widgets()const; 61 const QList<QWidget> &widgets()const;
59 62
63 signals:
64 void fontChanged(int size );
60 private: 65 private:
61 QList<QWidget> m_list; 66 QList<QWidget> m_list;
62 QList<WidSize> m_wids; 67 QList<WidSize> m_wids;
68 int m_size;
63 class OFontMenuPrivate; 69 class OFontMenuPrivate;
64 OFontMenuPrivate *d; 70 OFontMenuPrivate *d;
65 private slots: 71 private slots:
66 virtual void slotSmall(); 72 virtual void slotSmall();
67 virtual void slotMedium(); 73 virtual void slotMedium();
68 virtual void slotLarge(); 74 virtual void slotLarge();
69 void setFontSize(int size ); 75 void setFontSize(int size );
70}; 76};
71 77
72#endif 78#endif
73 79
74 80
75 81
76 82
77 83
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 3f6dc30..4d6711d 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -184,36 +184,56 @@ QValueList<ToDoEvent> ToDoDB::rawToDos()
184{ 184{
185 return m_todos; 185 return m_todos;
186} 186}
187void ToDoDB::addEvent( const ToDoEvent &event ) 187void ToDoDB::addEvent( const ToDoEvent &event )
188{ 188{
189 m_todos.append( event ); 189 m_todos.append( event );
190} 190}
191void ToDoDB::editEvent( const ToDoEvent &event ) 191void ToDoDB::editEvent( const ToDoEvent &event )
192{ 192{
193 m_todos.remove( event ); 193 m_todos.remove( event );
194 m_todos.append( event ); 194 m_todos.append( event );
195} 195}
196void ToDoDB::removeEvent( const ToDoEvent &event ) 196void ToDoDB::removeEvent( const ToDoEvent &event )
197{ 197{
198 m_todos.remove( event ); 198 m_todos.remove( event );
199} 199}
200void ToDoDB::replaceEvent(const ToDoEvent &event )
201{
202 QValueList<ToDoEvent>::Iterator it;
203 int uid = event.uid();
204 // == is not overloaded as we would like :( so let's search for the uid
205 for(it = m_todos.begin(); it != m_todos.end(); ++it ){
206 if( (*it).uid() == uid ){
207 m_todos.remove( (*it) );
208 break; // should save us the iterate is now borked
209 }
210 }
211 m_todos.append(event);
212}
200void ToDoDB::reload() 213void ToDoDB::reload()
201{ 214{
202 load(); 215 load();
203} 216}
217void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events )
218{
219 QValueList<ToDoEvent>::ConstIterator it;
220 for( it = events.begin(); it != events.end(); ++it ){
221 replaceEvent( (*it) );
222 }
223}
204void ToDoDB::setFileName(const QString &file ) 224void ToDoDB::setFileName(const QString &file )
205{ 225{
206 m_fileName =file; 226 m_fileName =file;
207} 227}
208QString ToDoDB::fileName()const 228QString ToDoDB::fileName()const
209{ 229{
210 return m_fileName; 230 return m_fileName;
211} 231}
212void ToDoDB::load() 232void ToDoDB::load()
213{ 233{
214 m_todos = m_res->load( m_fileName ); 234 m_todos = m_res->load( m_fileName );
215} 235}
216bool ToDoDB::save() 236bool ToDoDB::save()
217{ 237{
218 return m_res->save( m_fileName, m_todos ); 238 return m_res->save( m_fileName, m_todos );
219} 239}
diff --git a/libopie/tododb.h b/libopie/tododb.h
index e77a0f4..7fd9f96 100644
--- a/libopie/tododb.h
+++ b/libopie/tododb.h
@@ -10,33 +10,35 @@ class ToDoResource;
10class ToDoDB 10class ToDoDB
11{ 11{
12 public: 12 public:
13 // if no argument is supplied pick the default book 13 // if no argument is supplied pick the default book
14 ToDoDB(const QString &fileName = QString::null, ToDoResource* resource= 0 ); 14 ToDoDB(const QString &fileName = QString::null, ToDoResource* resource= 0 );
15 ~ToDoDB(); 15 ~ToDoDB();
16 QValueList<ToDoEvent> effectiveToDos(const QDate &from, 16 QValueList<ToDoEvent> effectiveToDos(const QDate &from,
17 const QDate &to, 17 const QDate &to,
18 bool includeNoDates = true); 18 bool includeNoDates = true);
19 QValueList<ToDoEvent> effectiveToDos(const QDate &start, bool includeNoDates = true ); 19 QValueList<ToDoEvent> effectiveToDos(const QDate &start, bool includeNoDates = true );
20 QValueList<ToDoEvent> rawToDos(); // all events 20 QValueList<ToDoEvent> rawToDos(); // all events
21 QValueList<ToDoEvent> overDue(); 21 QValueList<ToDoEvent> overDue();
22 22
23 void addEvent(const ToDoEvent &event ); 23 void addEvent(const ToDoEvent &event );
24 void editEvent(const ToDoEvent &editEvent ); 24 void editEvent(const ToDoEvent &editEvent );
25 void removeEvent(const ToDoEvent &event); 25 void removeEvent(const ToDoEvent &event);
26 26 void replaceEvent(const ToDoEvent &event );
27 // QValueList<ToDoEvents will overwrite existing ones no smart code at all ;)
28 void mergeWith(const QValueList<ToDoEvent>& );
27 void reload(); 29 void reload();
28 void setFileName(const QString & ); 30 void setFileName(const QString & );
29 QString fileName()const; 31 QString fileName()const;
30 bool save(); 32 bool save();
31 ToDoResource *resource(); 33 ToDoResource *resource();
32 void setResource(ToDoResource* res); 34 void setResource(ToDoResource* res);
33 35
34 private: 36 private:
35 class ToDoDBPrivate; 37 class ToDoDBPrivate;
36 ToDoDBPrivate *d; 38 ToDoDBPrivate *d;
37 QString m_fileName; 39 QString m_fileName;
38 ToDoResource *m_res; 40 ToDoResource *m_res;
39 QValueList<ToDoEvent> m_todos; 41 QValueList<ToDoEvent> m_todos;
40 void load(); 42 void load();
41}; 43};
42 44
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index 28b2e98..a5dba4f 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -1,31 +1,30 @@
1 1
2#include <opie/todoevent.h> 2#include <opie/todoevent.h>
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/stringutil.h> 4#include <qpe/stringutil.h>
5#include <qpe/palmtoprecord.h> 5#include <qpe/palmtoprecord.h>
6 6
7ToDoEvent::ToDoEvent(const ToDoEvent &event ) 7ToDoEvent::ToDoEvent(const ToDoEvent &event )
8{ 8{
9 *this = event; 9 *this = event;
10} 10}
11 11
12ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, 12ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category,
13 const QString &description, bool hasDate, QDate date, int uid ) 13 const QString &description, bool hasDate, QDate date, int uid )
14{ 14{
15 qWarning("todoEvent c'tor" );
16 m_date = date; 15 m_date = date;
17 m_isCompleted = completed; 16 m_isCompleted = completed;
18 m_hasDate = hasDate; 17 m_hasDate = hasDate;
19 m_priority = priority; 18 m_priority = priority;
20 m_category = category; 19 m_category = category;
21 m_desc = Qtopia::simplifyMultiLineSpace(description ); 20 m_desc = Qtopia::simplifyMultiLineSpace(description );
22 if (uid == -1 ) { 21 if (uid == -1 ) {
23 Qtopia::UidGen *uidgen = new Qtopia::UidGen(); 22 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
24 uid = uidgen->generate(); 23 uid = uidgen->generate();
25 delete uidgen; 24 delete uidgen;
26 }// generate the ids 25 }// generate the ids
27 m_uid = uid; 26 m_uid = uid;
28} 27}
29QArray<int> ToDoEvent::categories()const 28QArray<int> ToDoEvent::categories()const
30{ 29{
31 QArray<int> array(m_category.count() ); // currently the datebook can be only in one category 30 QArray<int> array(m_category.count() ); // currently the datebook can be only in one category
@@ -57,33 +56,32 @@ int ToDoEvent::priority()const
57} 56}
58QStringList ToDoEvent::allCategories()const 57QStringList ToDoEvent::allCategories()const
59{ 58{
60 return m_category; 59 return m_category;
61} 60}
62void ToDoEvent::insertCategory(const QString &str ) 61void ToDoEvent::insertCategory(const QString &str )
63{ 62{
64 m_category.append( str ); 63 m_category.append( str );
65} 64}
66void ToDoEvent::clearCategories() 65void ToDoEvent::clearCategories()
67{ 66{
68 m_category.clear(); 67 m_category.clear();
69} 68}
70void ToDoEvent::setCategories(const QStringList &list ) 69void ToDoEvent::setCategories(const QStringList &list )
71{ 70{
72 m_category = list; 71 m_category = list;
73 qWarning("todoevent: %s", list.join(";" ).latin1() );
74} 72}
75QDate ToDoEvent::date()const 73QDate ToDoEvent::date()const
76{ 74{
77 return m_date; 75 return m_date;
78} 76}
79 77
80QString ToDoEvent::description()const 78QString ToDoEvent::description()const
81{ 79{
82 return m_desc; 80 return m_desc;
83} 81}
84void ToDoEvent::setCompleted( bool completed ) 82void ToDoEvent::setCompleted( bool completed )
85{ 83{
86 m_isCompleted = completed; 84 m_isCompleted = completed;
87} 85}
88void ToDoEvent::setHasDate( bool hasDate ) 86void ToDoEvent::setHasDate( bool hasDate )
89{ 87{