void FilterEdit::updateFilterList() { mRulesList->clear(); CalFilter *filter = mFilters->first(); if(!filter) emit(dataConsistent(false)); else { while(filter) { mRulesList->insertItem(filter->name()); filter = mFilters->next(); } CalFilter *f = mFilters->at(mRulesList->currentItem()); if(f) filterSelected(f); emit(dataConsistent(true)); } if(current == 0L && mFilters->count() > 0) filterSelected(mFilters->at(0)); mDeleteButton->setEnabled(mFilters->count() > 1); }
void KOTodoView::changeIncidenceDisplay(Incidence *incidence, int action) { // The todo view only displays todos, so exit on all other incidences if ( incidence->type() != "Todo" ) return; CalFilter *filter = calendar()->filter(); bool isFiltered = filter && !filter->filterIncidence( incidence ); Todo *todo = static_cast<Todo *>(incidence); if ( todo ) { KOTodoViewItem *todoItem = 0; if ( mTodoMap.contains( todo ) ) { todoItem = mTodoMap[todo]; } switch ( action ) { case KOGlobals::INCIDENCEADDED: case KOGlobals::INCIDENCEEDITED: // If it's already there, edit it, otherwise just add if ( todoItem ) { if ( isFiltered ) { scheduleRemoveTodoItem( todoItem ); } else { // correctly update changes in relations Todo*parent = dynamic_cast<Todo*>( todo->relatedTo() ); KOTodoViewItem*parentItem = 0; if ( parent && mTodoMap.contains(parent) ) { parentItem = mTodoMap[ parent ]; } if ( todoItem->parent() != parentItem ) { // The relations changed if ( parentItem ) { parentItem->insertItem( todoItem ); } else { mTodoListView->insertItem( todoItem ); } } todoItem->construct(); } } else { if ( !isFiltered ) { insertTodoItem( todo ); } } mTodoListView->sort(); break; case KOGlobals::INCIDENCEDELETED: if ( todoItem ) { scheduleRemoveTodoItem( todoItem ); } break; default: QTimer::singleShot( 0, this, SLOT( updateView() ) ); } } else { // use a QTimer here, because when marking todos finished using // the checkbox, this slot gets called, but we cannot update the views // because we're still inside KOTodoViewItem::stateChange QTimer::singleShot(0,this,SLOT(updateView())); } }
void CalFilterTest::testValidity() { CalFilter f; f.setName(QStringLiteral("testfilter")); QVERIFY(f.name() == QLatin1String("testfilter")); CalFilter g(QStringLiteral("fredfilter")); QVERIFY(g.name() == QLatin1String("fredfilter")); CalFilter f1, f2; QVERIFY(f1 == f2); }
void FilterEdit::updateSelectedName(const QString &newText) { mRulesList->blockSignals(true); mRulesList->changeItem(newText, mRulesList->currentItem()); mRulesList->blockSignals(false); bool allOk = true; CalFilter *filter = mFilters->first(); while(allOk && filter) { if(filter->name().isEmpty()) allOk = false; filter = mFilters->next(); } emit dataConsistent(allOk); }
void KOTodoViewQuickSearch::fillCategories() { QStringList currentCategories = mCategoryCombo->checkedItems(); mCategoryCombo->clear(); QStringList categories; if ( mCalendar ) { CalFilter *filter = mCalendar->filter(); if ( filter->criteria() & CalFilter::ShowCategories ) { categories = filter->categoryList(); categories.sort(); } else { categories = KOPrefs::instance()->mCustomCategories; QStringList filterCategories = filter->categoryList(); categories.sort(); filterCategories.sort(); QStringList::Iterator it = categories.begin(); QStringList::Iterator jt = filterCategories.begin(); while ( it != categories.end() && jt != filterCategories.end() ) { if ( *it == *jt ) { it = categories.erase( it ); jt++; } else if ( *it < *jt ) { it++; } else if ( *it > *jt ) { jt++; } } } } CategoryHierarchyReaderQComboBox( mCategoryCombo ).read( categories ); QStandardItemModel *model = qobject_cast<QStandardItemModel *>( mCategoryCombo->model() ); Q_ASSERT( model ); for ( int r = 0; r < model->rowCount(); ++r ) { QStandardItem *item = model->item( r ); item->setCheckable( true ); } mCategoryCombo->setCheckedItems( currentCategories ); }
QWidget *KOTodoCategoriesDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { Q_UNUSED( option ); Q_UNUSED( index ); KCheckComboBox *combo = new KCheckComboBox( parent ); QStringList categories; if ( mCalendar ) { CalFilter *filter = mCalendar->filter(); if ( filter->criteria() & CalFilter::ShowCategories ) { categories = filter->categoryList(); categories.sort(); } else { CalendarSupport::CategoryConfig cc( KOPrefs::instance() ); categories = cc.customCategories(); QStringList filterCategories = filter->categoryList(); categories.sort(); filterCategories.sort(); QStringList::Iterator it = categories.begin(); QStringList::Iterator jt = filterCategories.begin(); while ( it != categories.end() && jt != filterCategories.end() ) { if ( *it == *jt ) { it = categories.erase( it ); jt++; } else if ( *it < *jt ) { it++; } else if ( *it > *jt ) { jt++; } } } } IncidenceEditorNG::CategoryHierarchyReaderQComboBox( combo ).read( categories ); // TODO test again with newer version of Qt, if it manages then to move // the popup together with the combobox. //combo->showPopup(); return combo; }
void KOTodoViewQuickSearch::fillCategories() { QStringList currentCategories = mCategoryCombo->checkedItems( Qt::UserRole ); mCategoryCombo->clear(); QStringList categories; if ( mCalendar ) { CalFilter *filter = mCalendar->filter(); if ( filter->criteria() & CalFilter::ShowCategories ) { categories = filter->categoryList(); categories.sort(); } else { CategoryConfig cc( KOPrefs::instance() ); categories = cc.customCategories(); QStringList filterCategories = filter->categoryList(); categories.sort(); filterCategories.sort(); QStringList::Iterator it = categories.begin(); QStringList::Iterator jt = filterCategories.begin(); while ( it != categories.end() && jt != filterCategories.end() ) { if ( *it == *jt ) { it = categories.erase( it ); jt++; } else if ( *it < *jt ) { it++; } else if ( *it > *jt ) { jt++; } } } } IncidenceEditorNG::CategoryHierarchyReaderQComboBox( mCategoryCombo ).read( categories ); mCategoryCombo->setCheckedItems( currentCategories, Qt::UserRole ); }