-rw-r--r-- | libopie/libopie.pro | 4 | ||||
-rw-r--r-- | libopie/ofontmenu.cc | 78 | ||||
-rw-r--r-- | libopie/ofontmenu.h | 77 | ||||
-rw-r--r-- | libopie/tododb.cpp | 1 |
4 files changed, 158 insertions, 2 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 3c8da78..ddc0c33 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro @@ -1,8 +1,8 @@ TEMPLATE = lib CONFIG += qte warn_on release -HEADERS = ofileselector.h ofiledialog.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h oconfig.h -SOURCES = ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp oconfig.cpp +HEADERS = ofontmenu.h ofileselector.h ofiledialog.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h oconfig.h +SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp oconfig.cpp TARGET = opie INCLUDEPATH += $(OPIEDIR)/include DESTDIR = $(QTDIR)/lib$(PROJMAK) #VERSION = 1.0.0
\ No newline at end of file diff --git a/libopie/ofontmenu.cc b/libopie/ofontmenu.cc new file mode 100644 index 0000000..2acae1c --- a/dev/null +++ b/libopie/ofontmenu.cc @@ -0,0 +1,78 @@ + +#include "ofontmenu.h" + + + +OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) + : QPopupMenu( parent, name ) +{ + m_list = list; + 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 ); +} +void OFontMenu::setWidgets(const QList<QWidget> &list ) +{ + m_list = list; +} +void OFontMenu::addWidget( QWidget *wid ) +{ + m_list.append(wid ); +} +void OFontMenu::removeWidget( QWidget *wid ) +{ + m_list.remove( wid ); +} +const QList<QWidget> &OFontMenu::widgets()const +{ + return m_list; +} +void OFontMenu::forceSize(QWidget *wid, int size ) +{ + WidSize *widz = new WidSize; + widz->wid = wid; + widz->size = size; + m_wids.append( widz ); +} +void OFontMenu::slotSmall() +{ + setItemChecked(10, false ); + setItemChecked(11, false ); + setItemChecked(12, true ); + setFontSize( 8 ); +} +void OFontMenu::slotMedium() +{ + setItemChecked(10, false ); + setItemChecked(11, true ); + setItemChecked(12, false ); + setFontSize(10 ); +} +void OFontMenu::slotLarge() +{ + setItemChecked(10, true ); + setItemChecked(11, false ); + setItemChecked(12, false ); + setFontSize(14 ); +} +void OFontMenu::setFontSize(int size ) +{ + QWidget *wid; + for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ + QFont font = wid->font(); + font.setPointSize( size ); + wid->setFont( font ); + } + if(!m_wids.isEmpty() ){ + WidSize *wids; + for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ + QFont font = wids->wid->font(); + font.setPointSize( wids->size ); + wids->wid->setFont( font ); + } + } +} diff --git a/libopie/ofontmenu.h b/libopie/ofontmenu.h new file mode 100644 index 0000000..37a628e --- a/dev/null +++ b/libopie/ofontmenu.h @@ -0,0 +1,77 @@ + +/* + + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 zekce <zecke@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This library is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + + + + +#ifndef ofontmenu_h +#define ofontmenu_h + +#include <qpopupmenu.h> +#include <qlist.h> + + +namespace { + struct WidSize { + QWidget *wid; + int size; + }; + +}; + +// if i would be on kde this would be a KActionMenu... +class OFontMenu : public QPopupMenu { + Q_OBJECT + public: + OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); + 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; + + private: + QList<QWidget> m_list; + QList<WidSize> m_wids; + class OFontMenuPrivate; + OFontMenuPrivate *d; + private slots: + virtual void slotSmall(); + virtual void slotMedium(); + virtual void slotLarge(); + void setFontSize(int size ); +}; + +#endif + + + + + diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 7814c4f..3f6dc30 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp @@ -19,64 +19,65 @@ public: XMLElement::AttributeMap map; XMLElement *task = new XMLElement(); map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); map.insert( "Priority", QString::number( (*it).priority() ) ); QArray<int> arrat = (*it).categories(); QString attr; for(uint i=0; i < arrat.count(); i++ ){ attr.append(QString::number(arrat[i])+";" ); } if(!attr.isEmpty() ) // remove the last ; attr.remove(attr.length()-1, 1 ); map.insert( "Categories", attr ); //else //map.insert( "Categories", QString::null ); map.insert( "Description", (*it).description() ); if( (*it).hasDate() ){ map.insert("DateYear", QString::number( (*it).date().year() ) ); map.insert("DateMonth", QString::number( (*it).date().month() ) ); map.insert("DateDay", QString::number( (*it).date().day() ) ); } map.insert("Uid", QString::number( (*it).uid() ) ); task->setTagName("Task" ); task->setAttributes( map ); tasks->appendChild(task); } QFile file( name); if( file.open(IO_WriteOnly ) ){ QTextStream stream(&file ); stream << "<!DOCTYPE Tasks>" << endl; tasks->save(stream ); delete tasks; + stream << "</Tasks>" << endl; file.close(); return true; } return false; } QValueList<ToDoEvent> load( const QString &name ){ qWarning("loading tododb" ); QValueList<ToDoEvent> m_todos; XMLElement *root = XMLElement::load( name ); if(root != 0l ){ // start parsing qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start XMLElement *element = root->firstChild(); element = element->firstChild(); while( element ){ qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); QString dummy; ToDoEvent event; bool ok; int dumInt; // completed dummy = element->attribute("Completed" ); dumInt = dummy.toInt(&ok ); if(ok ) event.setCompleted( dumInt == 0 ? false : true ); // hasDate dummy = element->attribute("HasDate" ); dumInt = dummy.toInt(&ok ); if(ok ) event.setHasDate( dumInt == 0 ? false: true ); // set the date bool hasDa = dumInt; if ( hasDa ) { //parse the date int year, day, month = 0; |