コード例 #1
0
ファイル: TasksView.cpp プロジェクト: NicholasVanSickle/Charm
 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;
     };
 }
コード例 #2
0
ファイル: EventView.cpp プロジェクト: katrinaniolet/Charm
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();
}