bool PlayListModel::removeRows(int row, int count, const QModelIndex &parent) { Q_UNUSED(parent) beginRemoveRows( QModelIndex(), row, row + count - 1); PlayListItem *current_item = nullptr; if (current >= 0 && current < items.size()) { current_item = items[current]; } for (int i = 0; i < count; ++i) { items.removeAt(row); } if (current_item) { current = items.indexOf(current_item); if (current == -1) { emit itemUpdated(nullptr); } } endRemoveRows(); return true; }
void JobStatusModel::addJob( JobStatusItem* item ) { connect( item, SIGNAL( statusChanged() ), this, SLOT( itemUpdated() ) ); connect( item, SIGNAL( finished() ), this, SLOT( itemFinished() ) ); if ( item->collapseItem() ) { if ( m_collapseCount.contains( item->type() ) ) { m_collapseCount[ item->type() ].append( item ); // qDebug() << "Adding item:" << item << "TO COLLAPSE ONLY"; return; // we're done, no new rows } else { m_collapseCount.insert( item->type(), QList< JobStatusItem* >() << item ); } } qDebug() << "Adding item:" << item; beginInsertRows( QModelIndex(), m_items.count(), m_items.count() ); m_items.append( item ); endInsertRows(); }
void PlayListModel::prevItem() { if (!items.count()) { emit itemUpdated(nullptr); } else { int previous = current; if (--current < 0) { current = -1; emit itemUpdated(nullptr); emit dataChanged(createIndex(previous, 0), createIndex(previous, PlayListItem::getColumnsCount())); } else { emit itemUpdated(items[current]); emit dataChanged(createIndex(previous, 0), createIndex(previous, PlayListItem::getColumnsCount())); emit dataChanged(createIndex(current, 0), createIndex(current, PlayListItem::getColumnsCount())); } } }
void PlayListModel::clickedItem(const QModelIndex &index) { int previous = current; current = index.row(); emit itemUpdated(items[current]); emit dataChanged(createIndex(previous, 0), createIndex(previous, PlayListItem::getColumnsCount())); emit dataChanged(createIndex(current, 0), createIndex(current, PlayListItem::getColumnsCount())); }
void LfmListModel::addArtist( const Artist& a_artist ) { Artist* artist = new Artist; *artist = a_artist; LfmItem* item = new LfmItem( artist ); item->loadImage( artist->imageUrl( lastfm::Small, true )); beginInsertRows( QModelIndex(), rowCount(), rowCount()); m_items << item; connect( item, SIGNAL(updated()), SLOT( itemUpdated())); endInsertRows(); }
void LfmListModel::addUser( const User& a_user ) { User* user = new User; *user = a_user; LfmItem* item = new LfmItem( user ); item->loadImage( user->imageUrl(lastfm::Small, true )); beginInsertRows( QModelIndex(), rowCount(), rowCount()); m_items << item; connect( item, SIGNAL(updated()), SLOT( itemUpdated())); endInsertRows(); }
/*! * update */ void TTCutList::update(const TTCutItem& cItem, const TTCutItem& uItem) { int index = data.indexOf(cItem); if (index < 0) { //qDebug("TTCutList::update error in updata cut entry!"); return; } data[index].mCutInIndex = uItem.cutInIndex(); data[index].mCutOutIndex = uItem.cutOutIndex(); emit itemUpdated(data[index], uItem); }
void JobStatusModel::addJob( JobStatusItem* item ) { if ( item->concurrentJobLimit() > 0 ) { if ( m_jobTypeCount[ item->type() ] >= item->concurrentJobLimit() ) { m_jobQueue[ item->type() ].enqueue( item ); return; } int currentJobCount = m_jobTypeCount[ item->type() ]; currentJobCount++; m_jobTypeCount[ item->type() ] = currentJobCount; } connect( item, SIGNAL( statusChanged() ), this, SLOT( itemUpdated() ) ); connect( item, SIGNAL( finished() ), this, SLOT( itemFinished() ) ); if ( item->collapseItem() ) { if ( m_collapseCount.contains( item->type() ) ) { m_collapseCount[ item->type() ].append( item ); // qDebug() << "Adding item:" << item << "TO COLLAPSE ONLY"; return; // we're done, no new rows } else { m_collapseCount.insert( item->type(), QList< JobStatusItem* >() << item ); } } qDebug() << "Adding item:" << item; int currentEndRow = m_items.count(); beginInsertRows( QModelIndex(), currentEndRow, currentEndRow ); m_items.append( item ); endInsertRows(); if ( item->hasCustomDelegate() ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "job has custom delegate"; emit customDelegateJobInserted( currentEndRow, item ); } }