summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-20 21:45:51 (UTC)
committer zecke <zecke>2002-03-20 21:45:51 (UTC)
commite9189f8d0cc46b0532fdcbcb2377ae3d108666d5 (patch) (side-by-side diff)
tree20af6104c262510595b82e619ee69b0958596ddd
parent0b39bb8d62f67a86128a6bd16afbd2aae004637c (diff)
downloadopie-e9189f8d0cc46b0532fdcbcb2377ae3d108666d5.zip
opie-e9189f8d0cc46b0532fdcbcb2377ae3d108666d5.tar.gz
opie-e9189f8d0cc46b0532fdcbcb2377ae3d108666d5.tar.bz2
vCal Resource for the tododb
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp8
-rw-r--r--core/pim/todo/mainwindow.h3
-rw-r--r--core/pim/todo/todoentryimpl.cpp2
-rw-r--r--libopie/libopie.pro2
-rw-r--r--libopie/tododb.cpp8
-rw-r--r--libopie/todoevent.cpp6
-rw-r--r--libopie/todovcalresource.cpp153
7 files changed, 175 insertions, 7 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index fb85a09..6709811 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -9,24 +9,26 @@
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#define QTOPIA_INTERNAL_FD
+
#include "mainwindow.h"
#include "todoentryimpl.h"
#include "todotable.h"
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/finddialog.h>
#include <qpe/global.h>
#include <qpe/ir.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
@@ -113,33 +115,35 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
catMenu = new QPopupMenu( this );
QPopupMenu *edit = new QPopupMenu( this );
contextMenu = new QPopupMenu( this );
bar = new QPEToolBar( this );
QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ),
this, SLOT( slotNew() ) );
a->addTo( bar );
a->addTo( edit );
+
a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ),
this, SLOT( slotEdit() ) );
a->addTo( bar );
a->addTo( edit );
a->addTo( contextMenu );
a->setEnabled( FALSE );
editAction = a;
+
a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ),
this, SLOT( slotDelete() ) );
a->addTo( bar );
a->addTo( edit );
a->addTo( contextMenu );
a->setEnabled( FALSE );
deleteAction = a;
if ( Ir::supported() ) {
a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
@@ -317,47 +321,47 @@ void TodoWindow::currentEntryChanged( int r, int )
}
void TodoWindow::setCategory( int c )
{
if ( c <= 0 ) return;
if ( !table->isUpdatesEnabled() )
return;
table->setPaintingEnabled( false );
for ( unsigned int i = 1; i < catMenu->count(); i++ )
catMenu->setItemChecked( i, c == (int)i );
if ( c == 1 ) {
table->setShowCategory( QString::null );
- setCaption( tr("Todo") + " - " + tr( "All" ) );
+ setCaption( tr("Todo") + " - " + tr( "All Categories" ) );
} else if ( c == (int)catMenu->count() - 1 ) {
table->setShowCategory( tr( "Unfiled" ) );
setCaption( tr("Todo") + " - " + tr( "Unfiled" ) );
} else {
QString cat = table->categories()[c - 2];
table->setShowCategory( cat );
setCaption( tr("Todo") + " - " + cat );
}
table->setPaintingEnabled( true );
}
void TodoWindow::populateCategories()
{
catMenu->clear();
completedAction->addTo( catMenu );
completedAction->setOn( table->showCompleted() );
int id,
rememberId;
id = 1;
- catMenu->insertItem( tr( "All" ), id++ );
+ catMenu->insertItem( tr( "All Categories" ), id++ );
// catMenu->insertSeparator();
QStringList categories = table->categories();
categories.append( tr( "Unfiled" ) );
for ( QStringList::Iterator it = categories.begin();
it != categories.end(); ++it ) {
catMenu->insertItem( *it, id );
if ( *it == table->showCategory() )
rememberId = id;
++id;
}
if ( table->showCategory().isEmpty() )
setCategory( 1 );
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index f4fcd1b..856dcb4 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -1,16 +1,17 @@
/**********************************************************************
+ Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org>
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of Qtopia and Opi Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
index 79206de..c957715 100644
--- a/core/pim/todo/todoentryimpl.cpp
+++ b/core/pim/todo/todoentryimpl.cpp
@@ -124,19 +124,19 @@ Task NewTaskDialog::todoEntry()
return todo;
}
/*!
*/
void NewTaskDialog::accept()
{
QString strText = txtTodo->text();
- if ( !strText || strText == "") {
+ if ( strText.isEmpty() ) {
// hmm... just decline it then, the user obviously didn't care about it
QDialog::reject();
return;
}
QDialog::accept();
}
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index fb00422..1c0bf7b 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,7 +1,7 @@
TEMPLATE = lib
CONFIG += qte warn_on release
HEADERS = $(OPIEDIR)/include/opie/xmltree.h
-SOURCES = xmltree.cc tododb.cpp todoevent.cpp
+SOURCES = xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp
TARGET = opie
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(QTDIR)/lib$(PROJMAK)
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index b1b35d0..f9756c6 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -129,24 +129,32 @@ public:
ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){
m_fileName = fileName;
if( fileName.isEmpty() && res == 0 ){
m_fileName = Global::applicationFileName("todolist","todolist.xml");
res = new FileToDoResource();
//qWarning("%s", m_fileName.latin1() );
}else if(res == 0 ){ // let's create a ToDoResource for xml
res = new FileToDoResource();
}
m_res = res;
load();
}
+ToDoResource* ToDoDB::resource(){
+ return m_res;
+};
+void ToDoDB::setResource( ToDoResource *res )
+{
+ delete m_res;
+ m_res = res;
+}
ToDoDB::~ToDoDB()
{
delete m_res;
}
QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to,
bool all )
{
QValueList<ToDoEvent> events;
for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
if( (*it).hasDate() ){
if( (*it).date() >= from && (*it).date() <= to )
events.append( (*it) );
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index 4cfe1c0..5fa4472 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -1,26 +1,28 @@
#include <opie/todoevent.h>
#include <qpe/palmtopuidgen.h>
+#include <qpe/stringutil.h>
+//#include <qpe/palmtoprecord.h>
ToDoEvent::ToDoEvent(bool completed, int priority, const QString &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 = description;
+ m_desc = Qtopia::simplifyMultiLineSpace(description );
if (uid == -1 ) {
Qtopia::UidGen *uidgen = new Qtopia::UidGen();
uid = uidgen->generate();
delete uidgen;
}// generate the ids
m_uid = uid;
}
bool ToDoEvent::isCompleted() const
{
return m_isCompleted;
}
bool ToDoEvent::hasDate() const
@@ -44,25 +46,25 @@ QString ToDoEvent::description()const
return m_desc;
}
void ToDoEvent::setCompleted( bool completed )
{
m_isCompleted = completed;
}
void ToDoEvent::setHasDate( bool hasDate )
{
m_hasDate = hasDate;
}
void ToDoEvent::setDescription(const QString &desc )
{
- m_desc = desc;
+ m_desc = Qtopia::simplifyMultiLineSpace(desc );
}
void ToDoEvent::setCategory( const QString &cat )
{
m_category = cat;
}
void ToDoEvent::setPriority(int prio )
{
m_priority = prio;
}
void ToDoEvent::setDate( QDate date )
{
m_date = date;
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp
new file mode 100644
index 0000000..a6afe68
--- a/dev/null
+++ b/libopie/todovcalresource.cpp
@@ -0,0 +1,153 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org>
+           .>+-= the use of vobject was inspired by libkcal
+ _;:,     .>    :=|. 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.
+
+*/
+
+#include <qfile.h>
+#include <qvaluelist.h>
+#include <opie/todoevent.h>
+#include <opie/todovcalresource.h>
+
+#include "../library/backend/vobject_p.h"
+#include "../library/backend/timeconversion.h"
+#include "../library/backend/qfiledirect_p.h"
+
+static VObject *vobjByEvent( const ToDoEvent &event )
+{
+ VObject *task = newVObject( VCTodoProp );
+ if( task == 0 )
+ return 0l;
+ if( event.hasDate() )
+ addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) );
+
+ if( event.isCompleted() )
+ addPropValue( task, VCStatusProp, "COMPLETED");
+
+ QString string = QString::number(event.priority() );
+ addPropValue( task, VCPriorityProp, string.local8Bit() );
+ addPropValue( task, VCCategoriesProp, event.category().local8Bit() );
+ addPropValue( task, VCDescriptionProp, event.description().local8Bit() );
+ addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() );
+ return task;
+};
+
+static ToDoEvent eventByVObj( VObject *obj ){
+ ToDoEvent event;
+ VObject *ob;
+ QCString name;
+ // no uid, attendees, ... and no fun
+ // description
+ if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
+ name = vObjectStringZValue( ob );
+ event.setDescription( name );
+ }
+ // completed
+ if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
+ name = vObjectStringZValue( ob );
+ if( name == "COMPLETED" ){
+ event.setCompleted( true );
+ }else{
+ event.setCompleted( false );
+ }
+ }else
+ event.setCompleted( false );
+ // priority
+ if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
+ name = vObjectStringZValue( ob );
+ bool ok;
+ event.setPriority(name.toInt(&ok) );
+ }
+ //due date
+ if((ob = isAPropertyOf(obj, VCDueProp)) ){
+ event.setHasDate( true );
+ name = vObjectStringZValue( ob );
+ event.setDate( TimeConversion::fromISO8601( name).date() );
+ }
+ // categories
+ if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
+ name = vObjectStringZValue( ob );
+ qWarning("Categories:%s", name.data() );
+ }
+
+ return event;
+};
+
+
+QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file)
+{
+ QValueList<ToDoEvent> events;
+ VObject *vcal = 0l;
+ vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject
+ if(!vcal )
+ return events;
+ // start parsing
+
+ VObjectIterator it;
+ VObject *vobj;
+ initPropIterator(&it, vcal);
+
+ while( moreIteration( &it ) ) {
+ vobj = ::nextVObject( &it );
+ QCString name = ::vObjectName( vobj );
+ //QCString objVal = ::vObjectStringZValue( vobj );
+ // let's find out the type
+ if( name == VCTodoProp ){
+ events.append( eventByVObj( vobj ) );
+
+ } // parse the value
+ }
+ return events;
+}
+bool ToDoVCalResource::save(const QString &fileName, const QValueList<ToDoEvent>&list )
+{
+ QFileDirect file ( fileName );
+ if(!file.open(IO_WriteOnly ) )
+ return false;
+ // obj
+ VObject *obj;
+ obj = newVObject( VCCalProp );
+ addPropValue( obj, VCVersionProp, "1.0" );
+ VObject *vo;
+ for(QValueList<ToDoEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ){
+ vo = vobjByEvent( (*it) );
+ addVObjectProp(obj, vo );
+ }
+ writeVObject( file.directHandle(), obj );
+ cleanVObject( obj );
+ cleanStrTbl();
+
+ return true;
+}
+
+
+
+
+
+
+
+
+
+