CRootItemIterator& CRootItemIterator::operator++() { assert( m_pos_stack.size() == (m_base_stack.size() )); ++m_pos; while( m_pos >= m_base->numChildren() && !m_pos_stack.empty()) { // go back one in increment that, possibly descending in another leave m_pos = m_pos_stack.top(); m_pos_stack.pop(); m_base = m_base_stack.top(); m_base_stack.pop(); ++m_pos; } if( m_pos < m_base->numChildren() ) { // do not ask for m_base->childAt( "too big" ) => that's itertor::end() CItemBase* item = m_base->childAt(m_pos); while(item->type() == CItemType::E_CAT) { m_base_stack.push(m_base); m_base = reinterpret_cast<CCategoryItem*>(item); m_pos_stack.push(m_pos); m_pos = 0; item = m_base->childAt(m_pos); } } return *this; }
void CRenderClientsListView::performDrag() { qDebug() << QString("performDrag"); CRenderClientsListModel* lmodel = reinterpret_cast<CRenderClientsListModel*>(model()); QModelIndexList indexList = selectedIndexes(); CModelDiff md(m_role); for(int i = 0; i < indexList.size(); i++) { comb_hash_t combhash; CItemBase* item = lmodel->itemFromIndex(indexList.at(i)); switch(item->type()) { case CItemType::E_STREAM_CLIENT: { CStreamClientItem* scItem = reinterpret_cast<CStreamClientItem*>(item); combhash.type = scItem->type(); if(m_role == E_OWN_RENDER_CLIENT) { int filteredline = lmodel->own2availIndex(indexList.at(i).row()); combhash.line = filteredline; } else { combhash.line = indexList.at(i).row(); } md.appendToSelectedItems(combhash); } default: break; } } if (md.getNumSelected() > 0) { QMimeData *mimeData = new QMimeData; //mimeData->setText(item->asString()); mimeData->setData(dndMimeType, md.toQByteArray()); m_dragActive = true; QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); // drag->setPixmap(QPixmap(":/images/person.png")); Qt::DropAction action = drag->exec(Qt::MoveAction); m_dragActive = false; qDebug() << QString("DropAction: %1").arg(action); } }
void CPlaylistView::performDrag() { qDebug() << QString("performDrag"); CMuroaListModel* plModel = reinterpret_cast<CMuroaListModel*>(model()); QModelIndexList indexList = selectedIndexes(); CModelDiff md(m_role); for(int i = 0; i < indexList.size(); i++) { comb_hash_t combhash; CItemBase* item = plModel->itemFromIndex(indexList.at(i)); switch(item->type()) { case CItemType::E_PLAYLISTITEM: { CPlaylistItem* plitem = reinterpret_cast<CPlaylistItem*>(item); combhash.type = plitem->type(); combhash.hash = plitem->getMediaItemHash(); combhash.pl_id = plitem->getHash(); combhash.line = indexList.at(i).row(); md.appendToSelectedItems(combhash); break; } default: // error, there should only be playlist items in the playlist. break; } } if (md.getNumSelected() > 0) { QMimeData *mimeData = new QMimeData; //mimeData->setText(item->asString()); mimeData->setData("application/x-muroa-playlist-diff", md.toQByteArray()); m_dragActive = true; QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); // drag->setPixmap(QPixmap(":/images/person.png")); Qt::DropAction action = drag->exec(Qt::MoveAction); m_dragActive = false; qDebug() << QString("DropAction: %1").arg(action); } }
CRootItemIterator::CRootItemIterator(CCategoryItem* base, int pos) : m_base(base), m_pos(pos), m_base_stack(), m_pos_stack() { if(m_pos == 0) { if(m_base->numChildren() > 0) { CItemBase* item = m_base->childAt(0); while(item->type() == CItemType::E_CAT) { m_base_stack.push(m_base); m_base = reinterpret_cast<CCategoryItem*>(item); m_pos_stack.push(0); item = m_base->childAt(0); } } } }