Todo::List KOTodoView::selectedTodos() { Todo::List selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; }
void EventArchiver::run(Calendar *calendar, const QDate &limitDate, QWidget *widget, bool withGUI, bool errorIfNone) { // We need to use rawEvents, otherwise events hidden by filters will not be archived. Incidence::List incidences; Event::List events; Todo::List todos; Journal::List journals; if(KOPrefs::instance()->mArchiveEvents) { events = calendar->rawEvents( QDate(1769, 12, 1), // #29555, also advertised by the "limitDate not included" in the class docu limitDate.addDays(-1), true); } if(KOPrefs::instance()->mArchiveTodos) { Todo::List t = calendar->rawTodos(); Todo::List::ConstIterator it; for(it = t.begin(); it != t.end(); ++it) { if((*it) && ((*it)->isCompleted()) && ((*it)->completed().date() < limitDate)) { todos.append(*it); } } } incidences = Calendar::mergeIncidenceList(events, todos, journals); kdDebug(5850) << "EventArchiver: archiving incidences before " << limitDate << " -> " << incidences.count() << " incidences found." << endl; if(incidences.isEmpty()) { if(withGUI && errorIfNone) KMessageBox::information(widget, i18n("There are no items before %1") .arg(KGlobal::locale()->formatDate(limitDate)), "ArchiverNoIncidences"); return; } switch(KOPrefs::instance()->mArchiveAction) { case KOPrefs::actionDelete: deleteIncidences(calendar, limitDate, widget, incidences, withGUI); break; case KOPrefs::actionArchive: archiveIncidences(calendar, limitDate, widget, incidences, withGUI); break; } }
void SearchDialog::search(const QRegExp &re) { QDate startDt = mStartDate->date(); QDate endDt = mEndDate->date(); Event::List events; if(mEventsCheck->isChecked()) { events = mCalendar->events(startDt, endDt, mInclusiveCheck->isChecked()); } Todo::List todos; if(mTodosCheck->isChecked()) { if(mIncludeUndatedTodos->isChecked()) { Todo::List alltodos = mCalendar->todos(); Todo::List::iterator it; Todo *todo; for(it = alltodos.begin(); it != alltodos.end(); ++it) { todo = *it; if((!todo->hasStartDate() && !todo->hasDueDate()) || // undated (todo->hasStartDate() && (todo->dtStart() >= startDt) && (todo->dtStart() <= endDt)) || // start dt in range (todo->hasDueDate() && (todo->dtDue().date() >= startDt) && (todo->dtDue() <= endDt)) || // due dt in range (todo->hasCompletedDate() && (todo->completed().date() >= startDt) && (todo->completed() <= endDt))) // completed dt in range { todos.append(todo); } } } else { QDate dt = startDt; while(dt <= endDt) { todos += mCalendar->todos(dt); dt = dt.addDays(1); } } } Journal::List journals; if(mJournalsCheck->isChecked()) { QDate dt = startDt; while(dt <= endDt) { journals += mCalendar->journals(dt); dt = dt.addDays(1); } } Incidence::List allIncidences = Calendar::mergeIncidenceList(events, todos, journals); mMatchedEvents.clear(); Incidence::List::ConstIterator it; for(it = allIncidences.begin(); it != allIncidences.end(); ++it) { Incidence *ev = *it; if(mSummaryCheck->isChecked()) { #if QT_VERSION >= 300 if(re.search(ev->summary()) != -1) { #else if(re.match(ev->summary()) != -1) { #endif mMatchedEvents.append(ev); continue; } } if(mDescriptionCheck->isChecked()) { #if QT_VERSION >= 300 if(re.search(ev->description()) != -1) { #else if(re.match(ev->description()) != -1) { #endif mMatchedEvents.append(ev); continue; } } if(mCategoryCheck->isChecked()) { #if QT_VERSION >= 300 if(re.search(ev->categoriesStr()) != -1) { #else if(re.match(ev->categoriesStr()) != -1) { #endif mMatchedEvents.append(ev); continue; } } } }
void HtmlExport::createTodoList ( QTextStream *ts ) { Todo::List rawTodoList = mCalendar->todos(); Todo::List::Iterator it = rawTodoList.begin(); while ( it != rawTodoList.end() ) { Todo *ev = *it; Todo *subev = ev; if ( ev->relatedTo() ) { if ( ev->relatedTo()->type()=="Todo" ) { if ( rawTodoList.find( static_cast<Todo *>( ev->relatedTo() ) ) == rawTodoList.end() ) { rawTodoList.append( static_cast<Todo *>( ev->relatedTo() ) ); } } } it = rawTodoList.find( subev ); ++it; } // FIXME: Sort list by priorities. This is brute force and should be // replaced by a real sorting algorithm. Todo::List todoList; for ( int i = 1; i <= 9; ++i ) { for( it = rawTodoList.begin(); it != rawTodoList.end(); ++it ) { if ( (*it)->priority() == i && checkSecrecy( *it ) ) { todoList.append( *it ); } } } for( it = rawTodoList.begin(); it != rawTodoList.end(); ++it ) { if ( (*it)->priority() == 0 && checkSecrecy( *it ) ) { todoList.append( *it ); } } int columns = 3; *ts << "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">\n"; *ts << " <tr>\n"; *ts << " <th class=\"sum\">" << i18n("Task") << "</th>\n"; *ts << " <th>" << i18n("Priority") << "</th>\n"; *ts << " <th>" << i18n("Completed") << "</th>\n"; if ( mSettings->taskDueDate() ) { *ts << " <th>" << i18n("Due Date") << "</th>\n"; ++columns; } if ( mSettings->taskLocation() ) { *ts << " <th>" << i18n("Location") << "</th>\n"; ++columns; } if ( mSettings->taskCategories() ) { *ts << " <th>" << i18n("Categories") << "</th>\n"; ++columns; } if ( mSettings->taskAttendees() ) { *ts << " <th>" << i18n("Attendees") << "</th>\n"; ++columns; } *ts << " </tr>\n"; // Create top-level list. for( it = todoList.begin(); it != todoList.end(); ++it ) { if ( !(*it)->relatedTo() ) createTodo( ts, *it ); } // Create sub-level lists for( it = todoList.begin(); it != todoList.end(); ++it ) { Incidence::List relations = (*it)->relations(); if (relations.count()) { // Generate sub-task list of event ev *ts << " <tr>\n"; *ts << " <td class=\"subhead\" colspan="; *ts << "\"" << QString::number(columns) << "\""; *ts << "><a name=\"sub" << (*it)->uid() << "\"></a>" << i18n("Sub-Tasks of: ") << "<a href=\"#" << (*it)->uid() << "\"><b>" << cleanChars( (*it)->summary()) << "</b></a></td>\n"; *ts << " </tr>\n"; Todo::List sortedList; // FIXME: Sort list by priorities. This is brute force and should be // replaced by a real sorting algorithm. for ( int i = 1; i <= 9; ++i ) { Incidence::List::ConstIterator it2; for( it2 = relations.begin(); it2 != relations.end(); ++it2 ) { Todo *ev3 = dynamic_cast<Todo *>( *it2 ); if ( ev3 && ev3->priority() == i ) sortedList.append( ev3 ); } } Incidence::List::ConstIterator it2; for( it2 = relations.begin(); it2 != relations.end(); ++it2 ) { Todo *ev3 = dynamic_cast<Todo *>( *it2 ); if ( ev3 && ev3->priority() == 0 ) sortedList.append( ev3 ); } Todo::List::ConstIterator it3; for( it3 = sortedList.begin(); it3 != sortedList.end(); ++it3 ) { createTodo( ts, *it3 ); } } } *ts << "</table>\n"; }
void HtmlExport::createTodoList(QTextStream *ts) { Todo::List rawTodoList = d->mCalendar->todos(); int index = 0; while (index < rawTodoList.count()) { Todo::Ptr ev = rawTodoList[ index ]; Todo::Ptr subev = ev; const QString uid = ev->relatedTo(); if (!uid.isEmpty()) { Incidence::Ptr inc = d->mCalendar->incidence(uid); if (inc && inc->type() == Incidence::TypeTodo) { Todo::Ptr todo = inc.staticCast<Todo>(); if (!rawTodoList.contains(todo)) { rawTodoList.append(todo); } } } index = rawTodoList.indexOf(subev); ++index; } // FIXME: Sort list by priorities. This is brute force and should be // replaced by a real sorting algorithm. Todo::List todoList; Todo::List::ConstIterator it; for (int i = 1; i <= 9; ++i) { for (it = rawTodoList.constBegin(); it != rawTodoList.constEnd(); ++it) { if ((*it)->priority() == i && checkSecrecy(*it)) { todoList.append(*it); } } } for (it = rawTodoList.constBegin(); it != rawTodoList.constEnd(); ++it) { if ((*it)->priority() == 0 && checkSecrecy(*it)) { todoList.append(*it); } } int columns = 3; *ts << "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">" << endl; *ts << " <tr>" << endl; *ts << " <th class=\"sum\">" << i18nc("@title:column", "To-do") << "</th>" << endl; *ts << " <th>" << i18nc("@title:column to-do priority", "Priority") << "</th>" << endl; *ts << " <th>" << i18nc("@title:column to-do percent completed", "Completed") << "</th>" << endl; if (d->mSettings->taskDueDate()) { *ts << " <th>" << i18nc("@title:column to-do due date", "Due Date") << "</th>" << endl; ++columns; } if (d->mSettings->taskLocation()) { *ts << " <th>" << i18nc("@title:column to-do location", "Location") << "</th>" << endl; ++columns; } if (d->mSettings->taskCategories()) { *ts << " <th>" << i18nc("@title:column to-do categories", "Categories") << "</th>" << endl; ++columns; } if (d->mSettings->taskAttendees()) { *ts << " <th>" << i18nc("@title:column to-do attendees", "Attendees") << "</th>" << endl; ++columns; } *ts << " </tr>" << endl; // Create top-level list. for (it = todoList.constBegin(); it != todoList.constEnd(); ++it) { if ((*it)->relatedTo().isEmpty()) { createTodo(ts, *it); } } // Create sub-level lists for (it = todoList.constBegin(); it != todoList.constEnd(); ++it) { Incidence::List relations = d->mCalendar->relations((*it)->uid()); if (relations.count()) { // Generate sub-to-do list *ts << " <tr>" << endl; *ts << " <td class=\"subhead\" colspan="; *ts << "\"" << QString::number(columns) << "\""; *ts << "><a name=\"sub" << (*it)->uid() << "\"></a>" << i18nc("@title:column sub-to-dos of the parent to-do", "Sub-To-dos of: ") << "<a href=\"#" << (*it)->uid() << "\"><b>" << cleanChars((*it)->summary()) << "</b></a></td>" << endl; *ts << " </tr>" << endl; Todo::List sortedList; // FIXME: Sort list by priorities. This is brute force and should be // replaced by a real sorting algorithm. for (int i = 1; i <= 9; ++i) { Incidence::List::ConstIterator it2; for (it2 = relations.constBegin(); it2 != relations.constEnd(); ++it2) { Todo::Ptr ev3 = (*it2).staticCast<Todo>(); if (ev3 && ev3->priority() == i) { sortedList.append(ev3); } } } Incidence::List::ConstIterator it2; for (it2 = relations.constBegin(); it2 != relations.constEnd(); ++it2) { Todo::Ptr ev3 = (*it2).staticCast<Todo>(); if (ev3 && ev3->priority() == 0) { sortedList.append(ev3); } } Todo::List::ConstIterator it3; for (it3 = sortedList.constBegin(); it3 != sortedList.constEnd(); ++it3) { createTodo(ts, *it3); } } } *ts << "</table>" << endl; }