author | zecke <zecke> | 2002-04-15 20:53:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-15 20:53:57 (UTC) |
commit | e010d922ac415558e5efd35e69e39e45908b5501 (patch) (side-by-side diff) | |
tree | 7b6dac3a82613fdefb15c818541891f577ecf48d /libopie | |
parent | 15244683bb97d303d0d3b6104b46a9b429aaed85 (diff) | |
download | opie-e010d922ac415558e5efd35e69e39e45908b5501.zip opie-e010d922ac415558e5efd35e69e39e45908b5501.tar.gz opie-e010d922ac415558e5efd35e69e39e45908b5501.tar.bz2 |
updates?
too much to remember
-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,22 +1,54 @@ + +#include <qpe/config.h> #include "ofontmenu.h" OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) : QPopupMenu( parent, name ) { m_list = list; + m_wids.setAutoDelete( TRUE ); + insertItem(tr("Large"), this, SLOT(slotLarge() ), 0, 10); insertItem(tr("Medium"), this, SLOT(slotMedium() ), 0, 11 ); insertItem(tr("Small"), this, SLOT(slotSmall() ), 0, 12 ); setCheckable( true ); + m_size=10; +} +void OFontMenu::save(Config *cfg ) +{ + cfg->setGroup("OFontMenu" ); + cfg->writeEntry("size", m_size ); +} +void OFontMenu::restore(Config *cfg ) +{ + cfg->setGroup("OFontMeny" ); + m_size = cfg->readNumEntry("size" ); + setItemChecked(10, false ); + setItemChecked(11, false ); + setItemChecked(12, false ); + switch( m_size ){ + case 8: + setItemChecked(12, true ); + break; + case 14: + setItemChecked(10, true ); + break; + case 10:// fall through + default: + setItemChecked(11, true ); + m_size = 10; + break; + } + setFontSize( m_size ); } void OFontMenu::setWidgets(const QList<QWidget> &list ) { m_list = list; } void OFontMenu::addWidget( QWidget *wid ) @@ -58,12 +90,13 @@ void OFontMenu::slotLarge() setItemChecked(11, false ); setItemChecked(12, false ); setFontSize(14 ); } void OFontMenu::setFontSize(int size ) { + m_size = size; QWidget *wid; for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ QFont font = wid->font(); font.setPointSize( size ); wid->setFont( font ); } @@ -72,7 +105,8 @@ void OFontMenu::setFontSize(int size ) for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ QFont font = wids->wid->font(); font.setPointSize( wids->size ); wids->wid->setFont( font ); } } + emit fontChanged(size ); } 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 { int size; }; }; // if i would be on kde this would be a KActionMenu... +class Config; class OFontMenu : public QPopupMenu { Q_OBJECT public: OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); + void save(Config *cfg ); + void restore(Config *cfg ); void setWidgets(const QList<QWidget> &list ); void addWidget(QWidget *wid ); void forceSize(QWidget *wid, int size ); void removeWidget(QWidget *wid ); const QList<QWidget> &widgets()const; + signals: + void fontChanged(int size ); private: QList<QWidget> m_list; QList<WidSize> m_wids; + int m_size; class OFontMenuPrivate; OFontMenuPrivate *d; private slots: virtual void slotSmall(); virtual void slotMedium(); 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 ) m_todos.append( event ); } void ToDoDB::removeEvent( const ToDoEvent &event ) { m_todos.remove( event ); } +void ToDoDB::replaceEvent(const ToDoEvent &event ) +{ + QValueList<ToDoEvent>::Iterator it; + int uid = event.uid(); + // == is not overloaded as we would like :( so let's search for the uid + for(it = m_todos.begin(); it != m_todos.end(); ++it ){ + if( (*it).uid() == uid ){ + m_todos.remove( (*it) ); + break; // should save us the iterate is now borked + } + } + m_todos.append(event); +} void ToDoDB::reload() { load(); } +void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events ) +{ + QValueList<ToDoEvent>::ConstIterator it; + for( it = events.begin(); it != events.end(); ++it ){ + replaceEvent( (*it) ); + } +} void ToDoDB::setFileName(const QString &file ) { m_fileName =file; } QString ToDoDB::fileName()const { 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 QValueList<ToDoEvent> rawToDos(); // all events QValueList<ToDoEvent> overDue(); void addEvent(const ToDoEvent &event ); void editEvent(const ToDoEvent &editEvent ); void removeEvent(const ToDoEvent &event); - + void replaceEvent(const ToDoEvent &event ); + // QValueList<ToDoEvents will overwrite existing ones no smart code at all ;) + void mergeWith(const QValueList<ToDoEvent>& ); void reload(); void setFileName(const QString & ); QString fileName()const; bool save(); ToDoResource *resource(); 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 ) *this = event; } ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, const QString &description, bool hasDate, QDate date, int uid ) { - qWarning("todoEvent c'tor" ); m_date = date; m_isCompleted = completed; m_hasDate = hasDate; m_priority = priority; m_category = category; m_desc = Qtopia::simplifyMultiLineSpace(description ); @@ -67,13 +66,12 @@ void ToDoEvent::clearCategories() { m_category.clear(); } void ToDoEvent::setCategories(const QStringList &list ) { m_category = list; - qWarning("todoevent: %s", list.join(";" ).latin1() ); } QDate ToDoEvent::date()const { return m_date; } |