⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 task.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************ Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.**** This file is part of the Qtopia Environment.** ** This program is free software; you can redistribute it and/or modify it** under the terms of the GNU General Public License as published by the** Free Software Foundation; either version 2 of the License, or (at your** option) any later version.** ** A copy of the GNU GPL license version 2 is included in this package as ** LICENSE.GPL.**** This program 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 General Public License for more details.**** In addition, as a special exception Trolltech gives permission to link** the code of this program with Qtopia applications copyrighted, developed** and distributed by Trolltech under the terms of the Qtopia Personal Use** License Agreement. You must comply with the GNU General Public License** in all respects for all of the code used other than the applications** licensed under the Qtopia Personal Use License Agreement. If you modify** this file, you may extend this exception to your version of the file,** but you are not obligated to do so. If you do not wish to do so, delete** this exception statement from your version.** ** 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.************************************************************************/#include "task.h"#include <qtopia/private/recordfields.h>#include <qtopia/private/vobject_p.h>#include <qtopia/timeconversion.h>#include <qtopia/private/qfiledirect_p.h>#include <qtopia/pim/private/xmlio_p.h>#include <qtopia/pim/private/todoxmlio_p.h>#include <qregexp.h>#include <qstring.h>#include <qtextcodec.h>#include <qstylesheet.h>#include <qapplication.h>#include <stdio.h>/*!  \class PimTask  \module qpepim  \ingroup qpepim  \brief The PimTask class holds the data of a todo entry.  This data includes the priority of the task, a description, an optional due  date, and whether the task is completed or not.*//*!  \fn void PimTask::setPriority( PriorityValue priority )  Sets the priority of the task to \a priority.  \sa priority()*//*!  \fn int PimTask::priority() const  Returns the priority of the task.  \sa setPriority()*//*!  \fn QString PimTask::notes() const  Returns any notes for the task.  \sa setNotes()*//*!  \fn void PimTask::setNotes(const QString &s)  Sets the notes of the task to \a s.  \sa notes()*//*!  \fn void PimTask::setDescription( const QString &description )  Sets the description of the task to \a description.  \sa description() *//*!  \fn const QString &PimTask::description() const  Returns the description of the task.  \sa setDescription() *//*!  \fn void PimTask::setDueDate( const QDate &date )  Sets the due date of the task to \a date.  \sa clearDueDate(), dueDate()*//*!  \fn void PimTask::clearDueDate( )  Clears the due date of the task.  \sa setDueDate()*//*!  \fn void PimTask::setCompleted( bool b )  If \a b is TRUE marks the task as completed.  Otherwise marks the task as  uncompleted.  \sa isCompleted()*//*!  \fn bool PimTask::isCompleted() const  Returns TRUE if the task is completed.  Otherwise returns FALSE.  \sa setCompleted()*//*!  \fn const QDate &PimTask::dueDate() const  Returns the due date of the task.  \sa setDueDate(), clearDueDate() *//*!  \fn bool PimTask::hasDueDate() const  Returns TRUE if there is a due date set for the task.  Otherwise returns  FALSE.  \sa dueDate(), setDueDate(), clearDueDate()*//*!  \fn const QDate &PimTask::startedDate() const  Returns the date the task was started.  If the task has not yet been started, the returned  date is undefined.  \sa hasStartedDate(), setStartedDate()*//*!  \fn void PimTask::setStartedDate(const QDate &date)  Sets the tasks to have started on \a date.  \sa hasStartedDate(), startedDate()*//*!  \fn const QDate &PimTask::completedDate() const  Returns the date the task was completed.  If the task is not completed, the returned  date is undefined.  \sa isCompleted(), setCompletedDate()*//*!  \fn void PimTask::setCompletedDate(const QDate &date)  Sets the tasks completed date to \a date.  \sa isCompleted(), completedDate()*//*!  \enum PimTask::TaskStatus  These enums describe the current \l status() of the Task.  The values are:  \value NotStarted  \value InProgress  \value Completed  \value Waiting  \value Deferred*//*!  \enum PimTask::PriorityValue  These enums describe the current \l priority() of the Task.  The values are:  \value VeryHigh  \value High  \value Normal  \value Low  \value VeryLow*//*!  \enum PimTask::TaskFields  \internal*//*!  \fn QMap<int,QString> PimTask::fields() const  \internal*//*!  Creates a new, empty task.*/PimTask::PimTask()    : PimRecord(), mDue( FALSE ), mDueDate( QDate::currentDate() ),      mCompleted( FALSE ), mPriority( Normal ), mStatus(NotStarted), mPercentCompleted(0){}/*!    \internal*/void PimTask::fromMap ( const QMap<int,QString> & m){    setFields( m );}/*!  Destroys the task*/PimTask::~PimTask(){}/*!  Returns the \l TaskStatus of the task.  \sa setStatus()*/PimTask::TaskStatus PimTask::status() const{    if ( isCompleted() )	return Completed;    return mStatus;}/*!  Sets the \l TaskStatus of the task to \a s.  \sa status()*/void PimTask::setStatus(TaskStatus s){    if ( s == Completed )	setCompleted( TRUE );    else	mStatus = s;}void PimTask::setDueDate( const QDate &date ){    mDueDate = date;    mDue = !(date.isNull());}/*!  Returns an int indicating the percent completed of the task.  For completed tasks, this function will always return 100.  \sa setPercentCompleted(), status()*/uint PimTask::percentCompleted() const{    if ( isCompleted() )	return 100;    return mPercentCompleted;}/*!  Sets the tasks percent completed field to \a percent.  if \a percent is greater than 99 this function will also  set the status to Completed.  \sa percentCompleted(), status()*/void PimTask::setPercentCompleted( uint percent ){    if ( percent > 99 ) {	setCompleted( TRUE );    } else {	mPercentCompleted = percent;    }}/*!  Returns TRUE if the task has a started date.  \sa startedDate(), setStartedDate()*/bool PimTask::hasStartedDate() const{    return !mStartedDate.isNull() && ( mStatus != NotStarted || hasDueDate() );}static QString statusToTrString(PimTask::TaskStatus s){    switch( s ) {	case PimTask::NotStarted: return qApp->translate("QtopiaPim", "Not yet started"); break;	case PimTask::InProgress: return qApp->translate("QtopiaPim", "In progress"); break;	case PimTask::Waiting: return qApp->translate("QtopiaPim", "Waiting"); break;	case PimTask::Deferred: return qApp->translate("QtopiaPim", "Deferred"); break;	default: return qApp->translate("QtopiaPim", "Completed"); break;    }}/*!  Returns TRUE if the part of task matches \a r. Otherwise returns FALSE.*/bool PimTask::match ( const QRegExp &r ) const{    // match on priority, description on due date...    bool match = FALSE;    if ( QString::number( mPriority ).find( r ) > -1 )	match = TRUE;    else if ( mDue && mDueDate.toString().find( r ) > -1 )	match = TRUE;    else if ( mDesc.find( r ) > -1 )	match = TRUE;    else if ( mStatus != NotStarted && mStartedDate.toString().find(r) > -1 )	match = TRUE;    else if ( mStatus == Completed && mCompletedDate.toString().find(r) > -1 )	match = TRUE;    else if ( mStatus != NotStarted && mStatus != Completed && 		QString::number(mPercentCompleted).find(r) > - 1 )	match = TRUE;    else if ( mNotes.find(r) > -1 )	match = TRUE;    else if ( statusToTrString( status() ).find(r) > -1 ) 	match = TRUE;    return match;}// In pimrecord.cppvoid qpe_startVObjectInput();bool qpe_vobjectCompatibility(const char* misfeature);void qpe_endVObjectInput();void qpe_startVObjectOutput();void qpe_endVObjectOutput(VObject *,const char* type,const PimRecord*);void qpe_setVObjectProperty(const QString&, const QString&, const char* type, PimRecord*);VObject *qpe_safeAddPropValue( VObject *o, const char *prop, const QString &value );static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ){ return qpe_safeAddPropValue(o,prop,value); }VObject *qpe_safeAddProp( VObject *o, const char *prop);static inline VObject *safeAddProp( VObject *o, const char *prop){ return qpe_safeAddProp(o,prop); }static VObject *createVObject( const PimTask &t ){    qpe_startVObjectOutput();    VObject *vcal = newVObject( VCCalProp );    safeAddPropValue( vcal, VCVersionProp, "1.0" );    VObject *task = safeAddProp( vcal, VCTodoProp );    if ( t.hasDueDate() )	safeAddPropValue( task, VCDueProp, TimeConversion::toISO8601( t.dueDate(), FALSE ) );    if ( t.isCompleted() ) {	// if we say its completed, then we have a completed date.	safeAddPropValue( task, VCStatusProp, "COMPLETED" );	safeAddPropValue( task, VCCompletedProp, 		TimeConversion::toISO8601( t.completedDate(), FALSE ) );    }    safeAddPropValue( task, VCPriorityProp, QString::number( t.priority() ) );    // status *2 (enum && %)    // ^^ We don't match VCStatusProp and vCal doesn't support ::percent.    safeAddPropValue( task, "X-Qtopia-STATUS", QString::number( t.status() ));    safeAddPropValue( task, "X-Qtopia-PERCOMP", 	    QString::number( t.percentCompleted() ) );    if (t.hasStartedDate())    {	// ok, need to set this one too.	safeAddPropValue( task, "X-Qtopia-STARTED", 		TimeConversion::toISO8601( t.startedDate(), FALSE ) );    }    // vCal spec: VCSummaryProp is required    // Palm m100:     No (violates spec)    // Ericsson T39m: Yes    if ( qpe_vobjectCompatibility("Palm-Task-DN") ) {	safeAddPropValue( task, VCSummaryProp, t.description() );	safeAddPropValue( task, VCDescriptionProp, t.description() );	safeAddPropValue( task, VCAttachProp, t.notes() );    } else {	safeAddPropValue( task, VCSummaryProp, t.description() );	safeAddPropValue( task, VCDescriptionProp, t.notes() );    }    qpe_endVObjectOutput(task,"Todo List",&t); // No tr    return vcal;}static PimTask parseVObject( VObject *obj ){    PimTask t;    VObjectIterator it;    initPropIterator( &it, obj );    QString summary, description, attach; // vCal properties, not Qtopias    while( moreIteration( &it ) ) {	VObject *o = nextVObject( &it );	QCString name = vObjectName( o );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -