void Mash::removeAllMashSteps() { int i, size; QList<MashStep*> tmpSteps = mashSteps(); size = tmpSteps.size(); for( i = 0; i < size; ++i ) Database::instance().removeFrom(this, tmpSteps[i]); emit mashStepsChanged(); }
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(); } }