void MashListModel::addMash(Mash* m) { if( !m || !m->display() || m->deleted() ) return; if( !mashes.contains(m) ) { int size = mashes.size(); beginInsertRows( QModelIndex(), size, size ); mashes.append(m); connect( m, SIGNAL(changed(QMetaProperty,QVariant)), this, SLOT(mashChanged(QMetaProperty,QVariant)) ); endInsertRows(); } }
void MashStepTableModel::setMash( Mash* m ) { int i; if( mashObs && steps.size() > 0) { beginRemoveRows( QModelIndex(), 0, steps.size()-1 ); // Remove mashObs and all steps. disconnect( mashObs, 0, this, 0 ); for( i = 0; i < steps.size(); ++i ) disconnect( steps[i], 0, this, 0 ); steps.clear(); endRemoveRows(); } mashObs = m; if( mashObs ) { // This has to happen outside of the if{} block to make sure the mash // signal is connected. Otherwise, empty mashes will never be not empty. connect( mashObs, SIGNAL(mashStepsChanged()), this, SLOT(mashChanged()) ); QList<MashStep*> tmpSteps = mashObs->mashSteps(); if(tmpSteps.size() > 0){ beginInsertRows( QModelIndex(), 0, tmpSteps.size()-1 ); //connect( mashObs, SIGNAL(changed(QMetaProperty,QVariant)), this, SLOT(mashChanged(QMetaProperty,QVariant)) ); steps = tmpSteps; for( i = 0; i < steps.size(); ++i ) connect( steps[i], SIGNAL(changed(QMetaProperty,QVariant)), this, SLOT(mashStepChanged(QMetaProperty,QVariant)) ); endInsertRows(); } } if( parentTableWidget ) { parentTableWidget->resizeColumnsToContents(); parentTableWidget->resizeRowsToContents(); } }
void MashListModel::addMashes(QList<Mash*> m) { QList<Mash*>::iterator i; QList<Mash*> tmp; for( i = m.begin(); i != m.end(); i++ ) { if( !mashes.contains(*i) && (*i)->display() && ! (*i)->deleted()) tmp.append(*i); } int size = mashes.size(); if (size+tmp.size()) { beginInsertRows( QModelIndex(), size, size+tmp.size()-1 ); mashes.append(tmp); for( i = tmp.begin(); i != tmp.end(); i++ ) connect( *i, SIGNAL(changed(QMetaProperty,QVariant)), this, SLOT(mashChanged(QMetaProperty,QVariant)) ); endInsertRows(); } }