EventModelFilter::EventModelFilter( CharmDataModel* model, QObject* parent ) : QSortFilterProxyModel( parent ) , m_model( model ) { setSourceModel( &m_model ); setDynamicSortFilter( true ); sort( 0, Qt::AscendingOrder ); connect( &m_model, SIGNAL( eventActivationNotice( EventId ) ), SIGNAL( eventActivationNotice( EventId ) ) ); connect( &m_model, SIGNAL( eventDeactivationNotice( EventId ) ), SIGNAL( eventDeactivationNotice( EventId ) ) ); }
void TasksView::stateChanged( State previous ) { switch( Application::instance().state() ) { case Connecting: { // set model on view: ViewFilter* filter = Application::instance().model().taskModel(); m_treeView->setModel( filter ); const QItemSelectionModel* smodel = m_treeView->selectionModel(); connect( smodel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), SLOT( configureUi() ) ); connect( smodel, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( configureUi() ) ); connect( filter, SIGNAL( eventActivationNotice( EventId ) ), SLOT( slotEventActivated( EventId ) ) ); connect( filter, SIGNAL( eventDeactivationNotice( EventId ) ), SLOT( slotEventDeactivated( EventId ) ) ); } break; case Connected: //the model is populated when entering Connected, so delay state restore QMetaObject::invokeMethod( this, "restoreGuiState", Qt::QueuedConnection ); break; case Disconnecting: saveGuiState(); break; case ShuttingDown: case Dead: default: break; }; }
void TaskModelAdapter::eventDeactivated( EventId id ) { // query the model to find out the task: const Event& event = m_dataModel->eventForId( id ); if ( event.isValid() ) { taskModified( event.taskId() ); emit eventDeactivationNotice( id ); } }
void EventView::setModel( ModelConnector* connector ) { EventModelFilter* model = connector->eventModel(); m_listView->setModel( model ); m_listView->setSelectionBehavior( QAbstractItemView::SelectRows ); m_listView->setSelectionMode( QAbstractItemView::SingleSelection ); connect( m_listView->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), SLOT( slotCurrentItemChanged( const QModelIndex&, const QModelIndex& ) ) ); connect( model, SIGNAL( eventActivationNotice( EventId ) ), SLOT( slotEventActivated( EventId ) ) ); connect( model, SIGNAL( eventDeactivationNotice( EventId ) ), SLOT( slotEventDeactivated( EventId ) ) ); connect( model, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ), SLOT( slotUpdateCurrent() ) ); connect( model, SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), SLOT( slotUpdateTotal() ) ); connect( model, SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), SLOT( slotUpdateTotal() ) ); connect( model, SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), SLOT( slotConfigureUi() ) ); connect( model, SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), SLOT( slotConfigureUi() ) ); connect( model, SIGNAL( layoutChanged() ), SLOT( slotUpdateCurrent() ) ); connect( model, SIGNAL( modelReset() ), SLOT( slotUpdateTotal() ) ); m_model = model; // normally, the model is set only once, so this should be no problem: EventEditorDelegate* delegate = new EventEditorDelegate( model, m_listView ); m_listView->setItemDelegate( delegate ); timeSpansChanged(); }
void EventModelAdapter::eventDeactivated(EventId id) { emit eventDeactivationNotice(id); }