summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-04-15 20:53:57 (UTC)
committer zecke <zecke>2002-04-15 20:53:57 (UTC)
commite010d922ac415558e5efd35e69e39e45908b5501 (patch) (unidiff)
tree7b6dac3a82613fdefb15c818541891f577ecf48d /libopie
parent15244683bb97d303d0d3b6104b46a9b429aaed85 (diff)
downloadopie-e010d922ac415558e5efd35e69e39e45908b5501.zip
opie-e010d922ac415558e5efd35e69e39e45908b5501.tar.gz
opie-e010d922ac415558e5efd35e69e39e45908b5501.tar.bz2
updates?
too much to remember
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,22 +1,54 @@
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 )
@@ -58,12 +90,13 @@ void OFontMenu::slotLarge()
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 }
@@ -72,7 +105,8 @@ void OFontMenu::setFontSize(int size )
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
@@ -44,25 +44,31 @@ namespace {
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();
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 3f6dc30..4d6711d 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -194,16 +194,36 @@ void ToDoDB::editEvent( const ToDoEvent &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{
diff --git a/libopie/tododb.h b/libopie/tododb.h
index e77a0f4..7fd9f96 100644
--- a/libopie/tododb.h
+++ b/libopie/tododb.h
@@ -20,13 +20,15 @@ class ToDoDB
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);
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index 28b2e98..a5dba4f 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -9,13 +9,12 @@ ToDoEvent::ToDoEvent(const ToDoEvent &event )
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 );
@@ -67,13 +66,12 @@ void 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