Skip to content
This repository has been archived by the owner on Sep 24, 2023. It is now read-only.

Commit

Permalink
Display subscribed subtasks even if parent is not subscribed
Browse files Browse the repository at this point in the history
Reset the view after tasks list was updated
Fixes #230

Change-Id: Iadb2d6540f7b86bb7d31fa32e9c597210bb12983
Reviewed-on: https://codereview.kdab.com/25809
Tested-by: Continuous Integration <build@kdab.com>
Reviewed-by: Frank Osterfeld <frank.osterfeld@kdab.com>
  • Loading branch information
mgiroday authored and frankosterfeld committed Sep 29, 2015
1 parent 8c02322 commit 7039416
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Charm/TaskModelAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ bool TaskModelAdapter::taskHasChildren( const Task& task ) const
return item.childCount() > 0;
}

TaskIdList TaskModelAdapter::childrenIds( const Task& task ) const
TaskList TaskModelAdapter::children( const Task& task ) const
{
const TaskTreeItem& item = m_dataModel->taskTreeItem( task.id() );
return item.childIds();
return item.children();
}

bool TaskModelAdapter::taskIdExists( TaskId taskId ) const
Expand Down
2 changes: 1 addition & 1 deletion Charm/TaskModelAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TaskModelAdapter : public QAbstractItemModel,
bool taskIsActive( const Task& task ) const override;
bool taskHasChildren( const Task& task ) const override;
bool taskIdExists( TaskId taskId ) const override;
TaskIdList childrenIds( const Task& task ) const;
TaskList children( const Task& task ) const;

// reimplement CommandEmitterInterface:
void commitCommand( CharmCommand* ) override;
Expand Down
22 changes: 12 additions & 10 deletions Charm/ViewFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ bool ViewFilter::filterAcceptsRow( int source_row, const QModelIndex& parent ) c
case Configuration::TaskPrefilter_ShowAll:
break;
case Configuration::TaskPrefilter_CurrentOnly: {
const bool ok = ( task.isCurrentlyValid() || hasValidChildren( task ) );
const bool ok = ( task.isCurrentlyValid() || checkChildren( task, HaveValidChild ) );
accepted &= ok;
break;
}
case Configuration::TaskPrefilter_SubscribedOnly:
accepted &= task.subscribed();
case Configuration::TaskPrefilter_SubscribedOnly: {
const bool ok = ( task.subscribed() || checkChildren( task, HaveSubscribedChild ) );
accepted &= ok;
break;
}
case Configuration::TaskPrefilter_SubscribedAndCurrentOnly:
accepted &= ( task.subscribed() && task.isCurrentlyValid() );
accepted &= ( (task.subscribed() || checkChildren( task, HaveSubscribedChild ) ) && ( task.isCurrentlyValid() || checkChildren( task, HaveValidChild ) ) );
break;
default:
break;
Expand All @@ -126,15 +128,15 @@ bool ViewFilter::taskIdExists( TaskId taskId ) const
return m_model.taskIdExists( taskId );
}

bool ViewFilter::hasValidChildren( Task task ) const
bool ViewFilter::checkChildren( Task task, CheckFor checkFor ) const
{
if ( taskHasChildren( task ) ) {
const TaskIdList idList = m_model.childrenIds( task );
for ( int i = 0; i < idList.count(); ++i ) {
const Task childTask = DATAMODEL->getTask( idList[i] );
if ( childTask.isCurrentlyValid() ) {
const TaskList taskList = m_model.children( task );
for ( const Task taskChild : taskList ) {
if ( checkFor == HaveSubscribedChild && taskChild.subscribed() )
return true;
else if ( checkFor == HaveValidChild && taskChild.isCurrentlyValid() )
return true;
}
}
}
return false;
Expand Down
7 changes: 6 additions & 1 deletion Charm/ViewFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ class ViewFilter : public QSortFilterProxyModel,
void eventDeactivationNotice( EventId id );

private:
bool hasValidChildren(Task task) const;
enum CheckFor {
HaveValidChild,
HaveSubscribedChild
};

bool checkChildren( Task task, CheckFor checkFor ) const;
TaskModelAdapter m_model;
};

Expand Down
2 changes: 2 additions & 0 deletions Charm/Widgets/TasksView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ void TasksView::configureUi()
SLOT(slotEventActivated(EventId)) );
connect( filter, SIGNAL(eventDeactivationNotice(EventId)),
SLOT(slotEventDeactivated(EventId)) );
connect( MODEL.charmDataModel(), SIGNAL(resetGUIState()),
SLOT(restoreGuiState()) );
}
break;
case Connected:
Expand Down

0 comments on commit 7039416

Please sign in to comment.