author | zautrix <zautrix> | 2005-07-27 23:40:19 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-27 23:40:19 (UTC) |
commit | 27ffa2e08ebb38e71f613af3a214750442418e2c (patch) (side-by-side diff) | |
tree | de2bb4c541ab8795ee3739526e82ca8f4e952c09 | |
parent | 0e38cffd7ba745f237c659e1c48080fcb25b126c (diff) | |
download | kdepimpi-27ffa2e08ebb38e71f613af3a214750442418e2c.zip kdepimpi-27ffa2e08ebb38e71f613af3a214750442418e2c.tar.gz kdepimpi-27ffa2e08ebb38e71f613af3a214750442418e2c.tar.bz2 |
fixcxcx
-rw-r--r-- | korganizer/komonthview.cpp | 6 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 1 | ||||
-rw-r--r-- | libkcal/icalformat.cpp | 9 | ||||
-rw-r--r-- | libkcal/icalformat.h | 3 | ||||
-rw-r--r-- | libkcal/todo.cpp | 5 |
5 files changed, 19 insertions, 5 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index eea9a4d..4aeb20c 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -1080,65 +1080,69 @@ void MonthViewCell::defaultAction( QListBoxItem *item ) } void MonthViewCell::showDay() { emit showDaySignal( date() ); } void MonthViewCell::newEvent() { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); } void MonthViewCell::cellClicked( QListBoxItem *item ) { mMonthView->setSelectedCell( this ); if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } } void MonthViewCell::contextMenu( QListBoxItem *item ) { mMonthView->setPopupCell( this ); if ( !item ) { mMonthView->showContextMenu( 0 ); return; } //selection( item ); //qApp->processEvents(); MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); - if ( incidence ) mMonthView->showContextMenu( incidence ); + if ( incidence ) { + mMonthView->showContextMenu( incidence ); + selection( item ); + doHighLight( incidence ); + } } void MonthViewCell::selection( QListBoxItem *item ) { if ( !item ) { emit highlightIncidence( 0 , this, 0 ); return; } MonthViewItem * it = (static_cast<MonthViewItem *>( item )); emit highlightIncidence( it->incidence(), this, it->multiDay() ); mMonthView->setSelectedCell( this ); } void MonthViewCell::deHighLight() { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->setHighlightedFalse() ) updateItem ( mitem ); mitem = (MonthViewItem *)mitem->next(); } } // returns true if no inc found bool MonthViewCell::doHighLight( Incidence * inc ) { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->incidence() == inc ) { if ( mitem->setHighlighted( inc ) ) updateItem ( mitem ); return false; diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e37a7ad..eef8327 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -36,64 +36,65 @@ #include "incidence.h" #include "journal.h" #include "filestorage.h" #include "calfilter.h" #include "calendarlocal.h" // #ifndef DESKTOP_VERSION // #include <qtopia/alarmserver.h> // #endif using namespace KCal; CalendarLocal::CalendarLocal() : Calendar() { init(); } CalendarLocal::CalendarLocal(const QString &timeZoneId) : Calendar(timeZoneId) { init(); } void CalendarLocal::init() { mNextAlarmIncidence = 0; } CalendarLocal::~CalendarLocal() { + registerObserver( 0 ); if ( mDeleteIncidencesOnClose ) close(); } bool CalendarLocal::mergeCalendarFile( QString name ) { CalendarLocal calendar( timeZoneId() ); calendar.setDefaultCalendar( 1 ); if ( calendar.load( name ) ) { mergeCalendar( &calendar ); return true; } return false; } Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) { Todo *todo;; Incidence *retVal = 0; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->uid() == uid ) { if ( doNotCheckDuplicates ) return todo; if ( retVal ) { if ( retVal->calID() > todo->calID() ) { retVal = todo; } } else { retVal = todo; } } } if ( retVal ) return retVal; Event *event; diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp index 5877406..6f3a799 100644 --- a/libkcal/icalformat.cpp +++ b/libkcal/icalformat.cpp @@ -21,66 +21,67 @@ #include <qdatetime.h> #include <qstring.h> #include <qptrlist.h> #include <qregexp.h> #include <qclipboard.h> #include <qfile.h> #include <qtextstream.h> #include <qtextcodec.h> #include <stdlib.h> #include <kdebug.h> #include <kglobal.h> #include <klocale.h> extern "C" { #include <ical.h> #include <icalss.h> #include <icalparser.h> #include <icalrestriction.h> } #include "calendar.h" #include "calendarlocal.h" #include "journal.h" #include "icalformat.h" #include "icalformatimpl.h" #define _ICAL_VERSION "2.0" using namespace KCal; -ICalFormat::ICalFormat( ) +ICalFormat::ICalFormat( bool pe ) { + mProcessEvents = pe; mImpl = new ICalFormatImpl( this ); tzOffsetMin = 0; //qDebug("new ICalFormat() "); } ICalFormat::~ICalFormat() { delete mImpl; //qDebug("delete ICalFormat "); } bool ICalFormat::load( Calendar *calendar, const QString &fileName) { clearException(); QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { setException(new ErrorFormat(ErrorFormat::LoadError)); return false; } QTextStream ts( &file ); QString text; ts.setEncoding( QTextStream::Latin1 ); text = ts.read(); file.close(); return fromString( calendar, text ); } //#include <qdatetime.h> @@ -160,88 +161,94 @@ Incidence *ICalFormat::fromString( const QString &text ) ical = elist.first(); } else { QPtrList<Todo> tlist = cal.todos(); if ( tlist.count() > 0 ) { ical = tlist.first(); } else { QPtrList<Journal> jlist = cal.journals(); if ( jlist.count() > 0 ) { ical = jlist.first(); } } } return ical; } #include <qapp.h> QString ICalFormat::toString( Calendar *cal ) { setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); icalcomponent *calendar = mImpl->createCalendarComponent(cal); icalcomponent *component; // todos QPtrList<Todo> todoList = cal->rawTodos(); QPtrListIterator<Todo> qlt(todoList); for (; qlt.current(); ++qlt) { component = mImpl->writeTodo(qlt.current()); icalcomponent_add_component(calendar,component); //qDebug(" todos "); + if ( mProcessEvents ) { + //qDebug("mProcessEvents "); qApp->processEvents(); } + } // events QPtrList<Event> events = cal->rawEvents(); Event *ev; for(ev=events.first();ev;ev=events.next()) { component = mImpl->writeEvent(ev); icalcomponent_add_component(calendar,component); //qDebug("events "); + if ( mProcessEvents ) qApp->processEvents(); } // journals QPtrList<Journal> journals = cal->journals(); Journal *j; for(j=journals.first();j;j=journals.next()) { component = mImpl->writeJournal(j); icalcomponent_add_component(calendar,component); //qDebug("journals "); + if ( mProcessEvents ) qApp->processEvents(); } const char *text; QString ret =""; text = icalcomponent_as_ical_string( calendar ); + if ( mProcessEvents ) qApp->processEvents(); // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n"; if ( text ) { ret = QString ( text ); } icalcomponent_free( calendar ); if (!text) { setException(new ErrorFormat(ErrorFormat::SaveError, i18n("libical error"))); icalmemory_free_ring(); return QString::null; } icalmemory_free_ring(); return ret; } QString ICalFormat::toICalString( Incidence *incidence ) { CalendarLocal cal( mTimeZoneId ); cal.addIncidence( incidence->clone() ); return toString( &cal ); } QString ICalFormat::toString( Incidence *incidence ) { icalcomponent *component; component = mImpl->writeIncidence( incidence ); diff --git a/libkcal/icalformat.h b/libkcal/icalformat.h index 485ab6e..a770dbb 100644 --- a/libkcal/icalformat.h +++ b/libkcal/icalformat.h @@ -11,105 +11,106 @@ 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 ICALFORMAT_H #define ICALFORMAT_H #include <qstring.h> #include "scheduler.h" #include "calformat.h" namespace KCal { class ICalFormatImpl; /** This class implements the iCalendar format. It provides methods for loading/saving/converting iCalendar format data into the internal KOrganizer representation as Calendar and Events. @short iCalendar format implementation */ class ICalFormat : public CalFormat { public: /** Create new iCalendar format. */ - ICalFormat( ); + ICalFormat( bool pe = true); virtual ~ICalFormat(); /** Loads a calendar on disk in iCalendar format into calendar. Returns true if successful, else returns false. Provides more error information by exception(). @param calendar Calendar object to be filled. @param fileName The name of the calendar file on disk. */ bool load( Calendar *, const QString &fileName ); /** Writes out the calendar to disk in iCalendar format. Returns true if successful and false on error. @param calendar The Calendar object to be written. @param fileName The name of the calendar file on disk. */ bool save( Calendar *, const QString &fileName ); /** Parse string and populate calendar with that information. */ bool fromString( Calendar *, const QString & ); /** Parse string and return first ical component. */ Incidence *fromString( const QString & ); /** Return calendar information as string. */ QString toString( Calendar * ); /** Return incidence as full iCalendar formatted text. */ QString toICalString( Incidence * ); /** Return incidence as iCalendar formatted text. */ QString toString( Incidence * ); /** Return recurrence as iCalendar formatted text. */ QString toString( Recurrence * ); /** Parse string and fill recurrence object with that information */ //bool fromString ( Recurrence *, const QString& ); /** Create a scheduling message for event \a e using method \m */ QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m); /** Parse scheduling message provided as string \s */ ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s); /** Set id of used time zone and whether this time zone is UTC or not. */ void setTimeZone( const QString &id, bool utc ); QString timeZoneId() const; int timeOffset(); const char * tzString(); bool utc() const; private: + bool mProcessEvents; ICalFormatImpl *mImpl; QString mTimeZoneId; QCString mTzString; int tzOffsetMin; bool mUtc; }; } #endif diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 4ada2d8..7bf756a 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -37,64 +37,65 @@ Todo::Todo(): QObject(), Incidence() mHasDueDate = false; setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; mRunning = false; mRunSaveTimer = 0; } Todo::Todo(const Todo &t) : QObject(),Incidence(t) { mDtDue = t.mDtDue; mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; mHasCompletedDate = t.mHasCompletedDate; mPercentComplete = t.mPercentComplete; mRunning = false; mRunSaveTimer = 0; } Todo::~Todo() { setRunning( false ); //qDebug("Todo::~Todo() "); } void Todo::setRunningFalse( QString s ) { if ( ! mRunning ) return; mRunning = false; + if ( mRunSaveTimer ) mRunSaveTimer->stop(); saveRunningInfoToFile( s ); } void Todo::stopRunning() { if ( !mRunning ) return; if ( mRunSaveTimer ) mRunSaveTimer->stop(); mRunning = false; } void Todo::setRunning( bool run ) { if ( run == mRunning ) return; //qDebug("Todo::setRunning %d ", run); if ( !mRunSaveTimer ) { mRunSaveTimer = new QTimer ( this ); connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); } mRunning = run; if ( mRunning ) { mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min mRunStart = QDateTime::currentDateTime(); } else { mRunSaveTimer->stop(); saveRunningInfoToFile(); } } void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) { if ( !mRunning) return; @@ -110,93 +111,93 @@ void Todo::saveRunningInfoToFile() } void Todo::saveRunningInfoToFile( QString comment ) { //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); if ( mRunStart.secsTo ( mRunEnd) < 15 ) { qDebug("Running time < 15 seconds. Skipped. "); return; } QString dir = KGlobalSettings::timeTrackerDir(); //qDebug("%s ", dir.latin1()); QString file = "%1%2%3-%4%5%6-"; file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); file.replace ( QRegExp (" "), "0" ); file += uid(); //qDebug("File %s ",file.latin1() ); CalendarLocal cal; cal.setLocalTime(); Todo * to = (Todo*) clone(); to->setFloats( false ); to->setDtStart( mRunStart ); to->setHasStartDate( true ); to->setDtDue( mRunEnd ); to->setHasDueDate( true ); to->setUid( file ); if ( !comment.isEmpty() ) { QString des = to->description(); if ( des.isEmpty () ) to->setDescription( "TT-Note: " + comment ); else to->setDescription( "TT-Note: " + comment +"\n" + des ); } cal.addIncidence( to ); - ICalFormat format; + ICalFormat format( false ); file = dir +"/" +file +".ics"; format.save( &cal, file ); saveParents(); } void Todo::saveParents() { if (!relatedTo() ) return; Incidence * inc = relatedTo(); if ( inc->typeID() != todoID ) return; Todo* to = (Todo*)inc; bool saveTodo = false; QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; QFileInfo fi ( file ); if ( fi.exists() ) { if ( fi.lastModified () < to->lastModified ()) saveTodo = true; } else { saveTodo = true; } if ( saveTodo ) { CalendarLocal cal; cal.setLocalTime(); Todo * par = (Todo *) to->clone(); cal.addIncidence( par ); - ICalFormat format; + ICalFormat format( false ); format.save( &cal, file ); } to->saveParents(); } int Todo::runTime() { if ( !mRunning ) return 0; return mRunStart.secsTo( QDateTime::currentDateTime() ); } bool Todo::hasRunningSub() { if ( mRunning ) return true; Incidence *aTodo; for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { if ( ((Todo*)aTodo)->hasRunningSub() ) return true; } return false; } Incidence *Todo::clone() { return new Todo(*this); } bool Todo::contains ( Todo* from ) { if ( !from->summary().isEmpty() ) if ( !summary().startsWith( from->summary() )) |