-rw-r--r-- | libopie/ofontmenu.cc | 34 | ||||
-rw-r--r-- | libopie/ofontmenu.h | 6 | ||||
-rw-r--r-- | libopie/tododb.cpp | 20 | ||||
-rw-r--r-- | libopie/tododb.h | 4 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 2 |
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,24 +1,56 @@ | |||
1 | 1 | ||
2 | |||
3 | #include <qpe/config.h> | ||
2 | #include "ofontmenu.h" | 4 | #include "ofontmenu.h" |
3 | 5 | ||
4 | 6 | ||
5 | 7 | ||
6 | OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) | 8 | OFontMenu::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 | } | ||
23 | void OFontMenu::save(Config *cfg ) | ||
24 | { | ||
25 | cfg->setGroup("OFontMenu" ); | ||
26 | cfg->writeEntry("size", m_size ); | ||
27 | } | ||
28 | void 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 | } |
18 | void OFontMenu::setWidgets(const QList<QWidget> &list ) | 50 | void OFontMenu::setWidgets(const QList<QWidget> &list ) |
19 | { | 51 | { |
20 | m_list = list; | 52 | m_list = list; |
21 | } | 53 | } |
22 | void OFontMenu::addWidget( QWidget *wid ) | 54 | void OFontMenu::addWidget( QWidget *wid ) |
23 | { | 55 | { |
24 | m_list.append(wid ); | 56 | m_list.append(wid ); |
@@ -56,23 +88,25 @@ void 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 | } |
62 | void OFontMenu::setFontSize(int size ) | 94 | void 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 | |||
@@ -42,29 +42,35 @@ namespace { | |||
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... |
50 | class Config; | ||
50 | class OFontMenu : public QPopupMenu { | 51 | class 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 | }; |
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 3f6dc30..4d6711d 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -192,20 +192,40 @@ void 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 | } |
196 | void ToDoDB::removeEvent( const ToDoEvent &event ) | 196 | void ToDoDB::removeEvent( const ToDoEvent &event ) |
197 | { | 197 | { |
198 | m_todos.remove( event ); | 198 | m_todos.remove( event ); |
199 | } | 199 | } |
200 | void 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 | } | ||
200 | void ToDoDB::reload() | 213 | void ToDoDB::reload() |
201 | { | 214 | { |
202 | load(); | 215 | load(); |
203 | } | 216 | } |
217 | void 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 | } | ||
204 | void ToDoDB::setFileName(const QString &file ) | 224 | void ToDoDB::setFileName(const QString &file ) |
205 | { | 225 | { |
206 | m_fileName =file; | 226 | m_fileName =file; |
207 | } | 227 | } |
208 | QString ToDoDB::fileName()const | 228 | QString ToDoDB::fileName()const |
209 | { | 229 | { |
210 | return m_fileName; | 230 | return m_fileName; |
211 | } | 231 | } |
diff --git a/libopie/tododb.h b/libopie/tododb.h index e77a0f4..7fd9f96 100644 --- a/libopie/tododb.h +++ b/libopie/tododb.h | |||
@@ -18,17 +18,19 @@ class ToDoDB | |||
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: |
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 28b2e98..a5dba4f 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -7,17 +7,16 @@ | |||
7 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 7 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) |
8 | { | 8 | { |
9 | *this = event; | 9 | *this = event; |
10 | } | 10 | } |
11 | 11 | ||
12 | ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, | 12 | ToDoEvent::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(); |
@@ -65,17 +64,16 @@ void ToDoEvent::insertCategory(const QString &str ) | |||
65 | } | 64 | } |
66 | void ToDoEvent::clearCategories() | 65 | void ToDoEvent::clearCategories() |
67 | { | 66 | { |
68 | m_category.clear(); | 67 | m_category.clear(); |
69 | } | 68 | } |
70 | void ToDoEvent::setCategories(const QStringList &list ) | 69 | void ToDoEvent::setCategories(const QStringList &list ) |
71 | { | 70 | { |
72 | m_category = list; | 71 | m_category = list; |
73 | qWarning("todoevent: %s", list.join(";" ).latin1() ); | ||
74 | } | 72 | } |
75 | QDate ToDoEvent::date()const | 73 | QDate ToDoEvent::date()const |
76 | { | 74 | { |
77 | return m_date; | 75 | return m_date; |
78 | } | 76 | } |
79 | 77 | ||
80 | QString ToDoEvent::description()const | 78 | QString ToDoEvent::description()const |
81 | { | 79 | { |