Commit 4bc7bb09 authored by Thorsten Staerk's avatar Thorsten Staerk

Set DtEnd with TimeZoneID.

BUGS:245043
parent 176dee1d
......@@ -906,10 +906,7 @@ void timetrackerstorage::stopTimer( const Task* task, const QDateTime &when )
if (!(*i)->hasEndDate())
{
kDebug(5970) << "this event has no enddate";
QString s=when.toString("yyyy-MM-ddThh:mm:ss.zzzZ"); // need the KDE standard from the ISO standard, not the QT one
KDateTime kwhen=KDateTime::fromString(s);
kDebug() << "kwhen ==" << kwhen;
(*i)->setDtEnd(kwhen);
(*i)->setDtEnd(KDateTime(when, KDateTime::Spec::LocalZone()));
}
else
{
......@@ -921,27 +918,6 @@ void timetrackerstorage::stopTimer( const Task* task, const QDateTime &when )
saveCalendar();
}
bool timetrackerstorage::bookTime(const Task* task,
const QDateTime& startDateTime,
const long durationInSeconds)
{
kDebug(5970) << "Entering function";
// Ignores preferences setting re: logging history.
KCal::Event* e;
QDateTime end;
KDateTime start( startDateTime, KDateTime::Spec::LocalZone() ); //??? is LocalZone correct ???
e = baseEvent( task );
e->setDtStart( start );
e->setDtEnd( start.addSecs( durationInSeconds ) );
// Use a custom property to keep a record of negative durations
e->setCustomProperty( KGlobal::mainComponent().componentName().toUtf8(),
QByteArray("duration"),
QString::number(durationInSeconds));
return d->mCalendar->addEvent(e);
}
void timetrackerstorage::changeTime(const Task* task, const long deltaSeconds)
{
kDebug(5970) << "Entering function; deltaSeconds=" << deltaSeconds;
......
......@@ -187,25 +187,6 @@ class timetrackerstorage : public QObject
*/
void changeTime(const Task* task, const long deltaSeconds);
/**
* Book time to a task.
*
* Creates an iCalendar event and adds it to the calendar. Does not write
* calendar to disk, just adds event to calendar in memory. However, the
* resource framework does try to get a lock on the file. After a
* successful lock, the calendar marks this incidence as modified and then
* releases the lock.
*
* @param task Task
* @param startDateTime Date and time the booking starts.
* @param durationInSeconds Duration of time to book, in seconds.
*
* @return true if event was added, false if not (if, for example, the
* attempted file lock failed).
*/
bool bookTime(const Task* task, const QDateTime& startDateTime,
const long durationInSeconds);
/**
* Log a change to a task name.
*
......
......@@ -694,60 +694,6 @@ void TimetrackerWidget::setPercentComplete( const QString &taskId, int percent )
}
}
int TimetrackerWidget::bookTime( const QString &taskId, const QString &dateTime, int minutes )
{
QDate startDate;
QTime startTime;
QDateTime startDateTime;
Task *task = 0, *t = 0;
if ( minutes <= 0 ) return KTIMETRACKER_ERR_INVALID_DURATION;
TaskView *taskView = currentTaskView();
if ( taskView )
{
QTreeWidgetItemIterator it( taskView );
while ( *it )
{
t = static_cast< Task* >( *it );
if ( t && t->uid() == taskId )
{
task = t;
break;
}
++it;
}
}
if ( !task ) return KTIMETRACKER_ERR_UID_NOT_FOUND;
// Parse datetime
startDate = QDate::fromString( dateTime, Qt::ISODate );
if ( dateTime.length() > 10 )
{ // "YYYY-MM-DD".length() = 10
startTime = QTime::fromString( dateTime, Qt::ISODate );
}
else startTime = QTime( 12, 0 );
if ( startDate.isValid() && startTime.isValid() )
{
startDateTime = QDateTime( startDate, startTime );
}
else return KTIMETRACKER_ERR_INVALID_DATE;
// Update task totals (session and total) and save to disk
task->changeTotalTimes( task->sessionTime() + minutes,
task->totalTime() + minutes );
if ( !( task->taskView()->storage()->bookTime( task,
startDateTime,
minutes * 60 ) ) )
return KTIMETRACKER_ERR_GENERIC_SAVE_FAILED;
return 0;
}
int TimetrackerWidget::changeTime( const QString &taskId, int minutes )
{
int result=0;
......
......@@ -158,7 +158,6 @@ class TimetrackerWidget : public QWidget
void addSubTask( const QString& taskName, const QString &taskId );
void deleteTask( const QString &taskId );
void setPercentComplete( const QString &taskId, int percent );
int bookTime( const QString &taskId, const QString &dateTime, int minutes );
int changeTime( const QString &taskId, int minutes );
QString error( int errorCode ) const;
bool isIdleDetectionPossible() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment