void GtkTorrentTreeView::setSelectedPaused(bool isPaused) { vector<shared_ptr<Torrent> > t = Application::getSingleton()->getCore()->getTorrents(); for (auto i : selectedIndices()) t[i]->setPaused(isPaused);// the pause button switches the status }
//_______________________________________________________ void ExceptionListWidget::down( void ) { InternalSettingsList selection( model().get( m_ui.exceptionListView->selectionModel()->selectedRows() ) ); if( selection.empty() ) { return; } // retrieve selected indexes in list and store in model QModelIndexList selectedIndices( m_ui.exceptionListView->selectionModel()->selectedIndexes() ); InternalSettingsList selectedExceptions( model().get( selectedIndices ) ); InternalSettingsList currentExceptions( model().get() ); InternalSettingsList newExceptions; InternalSettingsListIterator iter( currentExceptions ); iter.toBack(); while( iter.hasPrevious() ) { InternalSettingsPtr current( iter.previous() ); // check if new list is not empty, current index is selected and last index is not. // if yes, move. if( !( newExceptions.empty() || selectedIndices.indexOf( model().index( current ) ) == -1 || selectedIndices.indexOf( model().index( newExceptions.front() ) ) != -1 ) ) { InternalSettingsPtr first( newExceptions.front() ); newExceptions.removeFirst(); newExceptions.prepend( current ); newExceptions.prepend( first ); } else newExceptions.prepend( current ); } model().set( newExceptions ); // restore selection m_ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows ); for( InternalSettingsList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter ) { m_ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); } setChanged( true ); return; }
//_______________________________________________________ void ExceptionListWidget::up( void ) { ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) ); if( selection.empty() ) { return; } // retrieve selected indexes in list and store in model QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedRows() ); ConfigurationList selectedExceptions( model().get( selectedIndices ) ); ConfigurationList currentException( model().get() ); ConfigurationList newExceptions; for( ConfigurationList::const_iterator iter = currentException.constBegin(); iter != currentException.constEnd(); ++iter ) { // check if new list is not empty, current index is selected and last index is not. // if yes, move. if( !( newExceptions.empty() || selectedIndices.indexOf( model().index( *iter ) ) == -1 || selectedIndices.indexOf( model().index( newExceptions.back() ) ) != -1 ) ) { ConfigurationPtr last( newExceptions.back() ); newExceptions.removeLast(); newExceptions.append( *iter ); newExceptions.append( last ); } else newExceptions.append( *iter ); } model().set( newExceptions ); // restore selection ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows ); for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter ) { ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); } setChanged( true ); return; }