// private slot void FilesWidget::removeDocument(Document *document) { Q_ASSERT(document != NULL); disconnect(document, &Document::modificationChanged, this, &FilesWidget::updateModificationMarkerOfSender); disconnect(document, &Document::locationChanged, this, &FilesWidget::updateLocationOfSender); QStandardItem *child = m_children.value(document, NULL); Q_ASSERT(child != NULL); Q_ASSERT(child != m_currentChild); QStandardItem *parent = child->parent(); Q_ASSERT(parent != NULL); parent->removeRow(child->row()); if (parent->rowCount() > 0) { updateParentItemMarkers(parent); } else { m_model.removeRow(parent->row()); } m_children.remove(document); if (m_currentChild != NULL) { m_treeFiles->selectionModel()->select(m_currentChild->index(), QItemSelectionModel::ClearAndSelect); } }
void tst_QStandardItem::getSetChild() { QFETCH(int, rows); QFETCH(int, columns); QFETCH(int, row); QFETCH(int, column); QStandardItem item(rows, columns); bool shouldHaveChildren = (rows > 0) && (columns > 0); QCOMPARE(item.hasChildren(), shouldHaveChildren); QCOMPARE(item.child(row, column), static_cast<QStandardItem*>(0)); QStandardItem *child = new QStandardItem; item.setChild(row, column, child); if ((row >= 0) && (column >= 0)) { QCOMPARE(item.rowCount(), qMax(rows, row + 1)); QCOMPARE(item.columnCount(), qMax(columns, column + 1)); QCOMPARE(item.child(row, column), child); QCOMPARE(child->row(), row); QCOMPARE(child->column(), column); QStandardItem *anotherChild = new QStandardItem; item.setChild(row, column, anotherChild); QCOMPARE(item.child(row, column), anotherChild); QCOMPARE(anotherChild->row(), row); QCOMPARE(anotherChild->column(), column); item.setChild(row, column, 0); } else { delete child; } QCOMPARE(item.child(row, column), static_cast<QStandardItem*>(0)); }
bool TrialTreeModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) { if (QStandardItemModel::dropMimeData(mimeData, action, row, column, parent)) return true; if (mimeData->hasUrls()) { const QList<QUrl> urls = mimeData->urls(); QStandardItem * dropInto = itemFromIndex(parent); if (dropInto && !dropInto->data().isNull()) { // printf("Dropping onto '%s'\n", dropInto->data().toString().toAscii().data()); QStandardItem * const tmp = new QStandardItem("Group"); QStandardItem * const p = (dropInto->parent() ? dropInto->parent() : invisibleRootItem()); p->insertRow(dropInto->row(), tmp); tmp->setChild(0, 0, dropInto->clone()); p->removeRow(dropInto->row()); dropInto = tmp; } if (!dropInto) dropInto = invisibleRootItem(); int i = 0; for (QList<QUrl>::const_iterator it = urls.begin(); it != urls.end(); ++it, i++) { QFileInfo fileInfo(it->toLocalFile()); QStandardItem * const newItem = new QStandardItem(fileInfo.fileName()); newItem->setData(QDir::current().relativeFilePath(fileInfo.filePath())); newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled/* | Qt::ItemIsDropEnabled*/); dropInto->appendRow(newItem); } return true; } return false; }
// private slot void FilesWidget::addDocument(Document *document) { Q_ASSERT(document != NULL); Q_ASSERT(document != DocumentManager::current()); const Location &location = document->location(); const QString &filePath = location.filePath("unnamed"); const QString &directoryPath = location.directoryPath("unnamed"); const QString &fileName = location.fileName("unnamed"); // Find or create parent item const QModelIndexList &parents = m_model.match(m_model.index(0, 0, QModelIndex()), DirectoryPathRole, directoryPath, 1, Qt::MatchExactly); QStandardItem *parent; if (parents.isEmpty()) { parent = new QStandardItem(QIcon(":/icons/16x16/folder.png"), directoryPath); parent->setToolTip(directoryPath); parent->setData(directoryPath, DirectoryPathRole); parent->setData(location.isEmpty() ? "" : directoryPath.toLower(), LowerCaseNameRole); m_model.appendRow(parent); m_model.sort(0); } else { parent = m_model.itemFromIndex(parents.first()); } // Create child item QStandardItem *child = new QStandardItem(QIcon(":/icons/16x16/file.png"), fileName); child->setToolTip(filePath); child->setData(qVariantFromValue((void *)document), DocumentPointerRole); child->setData(fileName, FileNameRole); child->setData(location.isEmpty() ? "" : fileName.toLower(), LowerCaseNameRole); m_children.insert(document, child); parent->appendRow(child); parent->sortChildren(0); connect(document, &Document::locationChanged, this, &FilesWidget::updateLocationOfSender); connect(document, &Document::modificationChanged, this, &FilesWidget::updateModificationMarkerOfSender); // Apply current filter if (!filterAcceptsChild(child->index())) { m_treeFiles->setRowHidden(child->row(), parent->index(), true); if (parent->rowCount() == 1) { m_treeFiles->setRowHidden(parent->row(), m_model.invisibleRootItem()->index(), true); } } // Show modification marker, if necessary updateModificationMarker(document); updateParentItemMarkers(parent); }
void AcceptLangWidget::on_MoveUp__released () { QStandardItem *item = Model_->itemFromIndex (Ui_.LangsTree_->currentIndex ()); if (!item || !item->row ()) return; const int row = item->row (); Model_->insertRow (row - 1, Model_->takeRow (row)); }
void AcceptLangWidget::on_MoveDown__released () { QStandardItem *item = Model_->itemFromIndex (Ui_.LangsTree_->currentIndex ()); if (!item || item->row () == Model_->rowCount () - 1) return; const int row = item->row (); auto items = Model_->takeRow (row); Model_->insertRow (row + 1, items); }
void CFrmGroupChatList::slotLeft(const QString &jid, CFrmGroupChat *pChat) { QList<QStandardItem* > item = pChat->GetItem(); if(!item.isEmpty()) { QStandardItem* pItem = *item.begin(); if(pItem) if(-1 != pItem->row()) { m_pModel->removeRow(pItem->row()); } } m_Group.remove(jid); }
void Ilwis::Ui::LayerManager::move(int nodeId, const QModelIndex & targetLocation) { QStandardItem *currentLayer = findLayer(nodeId); auto startRow = currentLayer->index(); // int shift = startRow.row() < targetLocation.row() ? -1 : 0; QStandardItem *targetItem = _tree->itemFromIndex(targetLocation); QList<QStandardItem *> layers = _tree->takeRow(currentLayer->row()); // _tree->insertRow(targetLocation.row() + shift, layers); _tree->insertRow(targetItem->row(), layers); }
void SortedSetKeyModel::updateValue(const QString& value, const QModelIndex *cellIndex) { QStandardItem * currentItem = itemFromIndex(*cellIndex); QString itemType = currentItem->data(KeyModel::KEY_VALUE_TYPE_ROLE).toString(); if (itemType == "member") { QStringList removeCmd; removeCmd << "ZREM" << keyName << currentItem->text(); db->addCommand(Command(removeCmd, this, dbIndex)); QStandardItem * scoreItem = item(currentItem->row(), 1); QStringList addCmd; addCmd << "ZADD" << keyName << scoreItem->text() << value; db->addCommand(Command(addCmd, this, CALLMETHOD("loadedUpdateStatus"), dbIndex)); } else if (itemType == "score") { bool converted = false; double changedScore = value.toDouble(&converted); if (!converted) return; double currentScore = currentItem->text().toDouble(); double incr = changedScore - currentScore; QStandardItem * memberItem = item(currentItem->row(), 0); QStringList updateCmd; updateCmd << "ZINCRBY" << keyName << QString::number(incr) << memberItem->text(); db->addCommand(Command(updateCmd, this, CALLMETHOD("loadedUpdateStatus"), dbIndex)); } currentItem->setText(value); }
void EditTOC::MoveRight() { QModelIndex index = CheckSelection(0); if (!index.isValid()) { return; } QStandardItem *item = m_TableOfContents->itemFromIndex(index); int item_row = item->row(); // Can't indent if row above is already parent if (item_row == 0) { return; } QStandardItem *parent_item = item->parent(); if (!parent_item) { parent_item = m_TableOfContents->invisibleRootItem(); } // Make the item above the parent of this item QList<QStandardItem *> row_items = parent_item->takeRow(item_row); QStandardItem *new_parent = parent_item->child(item_row - 1, 0); new_parent->insertRow(new_parent->rowCount(), row_items); QStandardItem *new_item = new_parent->child(new_parent->rowCount() - 1, 0); // Reselect the item ui.TOCTree->selectionModel()->clear(); ui.TOCTree->setCurrentIndex(item->index()); ui.TOCTree->selectionModel()->select(item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); ExpandChildren(new_item); }
///////////////////////////////////////// // edit comet void CComDlg::on_pushButton_5_clicked() ///////////////////////////////////////// { QStandardItemModel *model = (QStandardItemModel *)ui->listView->model(); QModelIndexList il = ui->listView->selectionModel()->selectedIndexes(); if (il.count() == 0) return; QStandardItem *item = model->itemFromIndex(il.at(0)); int index = item->row(); comet_t *a = &tComets[index]; CComEdit dlg(this, false, a); if (dlg.exec() == DL_OK) { item->setText(a->name); if (a->perihelionDate < minJD) minJD = a->perihelionDate; if (a->perihelionDate > maxJD) maxJD = a->perihelionDate; } updateDlg(); }
void VegetationWidget::slotDeleteSelected() { QListView* view = qobject_cast<QListView*>(sender()); QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model()); QString dirString(""); if (view == _treeListView) { std::string plantDir = g_SystemContext._workContextDir; plantDir.append(CONTEXT_DIR); plantDir.append("/Plant/"); dirString = chineseTextUTF8ToQString(plantDir + "Tree/"); } else { std::string plantDir = g_SystemContext._workContextDir; plantDir.append(CONTEXT_DIR); plantDir.append("/Plant/"); dirString = chineseTextUTF8ToQString(plantDir + "Grass/"); } QItemSelectionModel* selectionModel = view->selectionModel(); QModelIndexList modelList = selectionModel->selectedIndexes(); if (modelList.size() < 1) return; for (int i = 0; i < modelList.size(); ++i) { QStandardItem* everyItem = model->itemFromIndex(modelList.at(i)); QFile::remove(dirString + everyItem->text()); int row = everyItem->row(); model->removeRow(row); } }
void Window::clearPlanetConnectionError(const Planet &planet) { QStandardItem* planetItem = getPlanetTreeWidgetItem(planet); QStandardItem* errorItem = planetTreeModel->item(planetItem->row(), 1); errorItem->setText(""); resizeColumnsToContents(); }
void EditTOC::MoveDown() { QModelIndex index = CheckSelection(0); if (!index.isValid()) { return; } QStandardItem *item = m_TableOfContents->itemFromIndex(index); QStandardItem *parent_item = item->parent(); if (!parent_item) { parent_item = m_TableOfContents->invisibleRootItem(); } int item_row = item->row(); // Can't move down if this row is already the last one of its parent if (item_row == parent_item->rowCount() - 1) { return; } QList<QStandardItem *> row_items = parent_item->takeRow(item_row); parent_item->insertRow(item_row + 1, row_items); // Reselect the item ui.TOCTree->selectionModel()->clear(); ui.TOCTree->setCurrentIndex(item->index()); ui.TOCTree->selectionModel()->select(item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); ExpandChildren(item); }
void EditTOC::AddEntry(bool above) { QModelIndex index = CheckSelection(0); if (!index.isValid()) { return; } QStandardItem *item = m_TableOfContents->itemFromIndex(index); QStandardItem *parent_item = item->parent(); if (!parent_item) { parent_item = m_TableOfContents->invisibleRootItem(); } // Add a new empty row of items QStandardItem *entry_item = new QStandardItem(); QStandardItem *target_item = new QStandardItem(); QList<QStandardItem *> row_items; row_items << entry_item << target_item ; int location = 1; if (above) { location = 0; } parent_item->insertRow(item->row() + location,row_items); // Select the new row ui.TOCTree->selectionModel()->clear(); ui.TOCTree->setCurrentIndex(entry_item->index()); ui.TOCTree->selectionModel()->select(entry_item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); }
void AccountsListWidget::handleAccountValidated (QObject *accObj, bool validated) { IAccount *acc = qobject_cast<IAccount*> (accObj); if (!acc) { qWarning () << Q_FUNC_INFO << accObj << "is not an IAccount"; return; } if (!Account2Item_.contains (acc)) { qWarning () << Q_FUNC_INFO << "account" << acc->GetAccountName () << acc->GetObject () << "from" << sender () << "not found here"; return; } QStandardItem *item = Account2Item_ [acc]; AccountsModel_->item (item->row (), Columns::IsValidated)->setText (validated ? tr ("Validated") : tr ("Not validated")); Ui_.Accounts_->header ()->setResizeMode (QHeaderView::ResizeToContents); }
void AlbumCoverSearcher::ImageLoaded(quint64 id, const QImage& image) { if (!cover_loading_tasks_.contains(id)) return; QStandardItem* item = cover_loading_tasks_.take(id); if (cover_loading_tasks_.isEmpty()) ui_->busy->hide(); if (image.isNull()) { model_->removeRow(item->row()); return; } QIcon icon(QPixmap::fromImage(image)); // Create a pixmap that's padded and exactly the right size for the icon. QImage scaled_image(image.scaled(ui_->covers->iconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); QImage padded_image(ui_->covers->iconSize(), QImage::Format_ARGB32_Premultiplied); padded_image.fill(0); QPainter p(&padded_image); p.drawImage((padded_image.width() - scaled_image.width()) / 2, (padded_image.height() - scaled_image.height()) / 2, scaled_image); p.end(); icon.addPixmap(QPixmap::fromImage(padded_image)); item->setData(true, Role_ImageFetchFinished); item->setData(image.width() * image.height(), Role_ImageDimensions); item->setData(image.size(), Role_ImageSize); item->setIcon(icon); }
void TrackListView::updatePartSelection(Part* part)/*{{{*/ { if(part) { MidiTrack* track = part->track(); Part* curPart = m_editor->curCanvasPart(); if (curPart) { song->setRecordFlag(curPart->track(), false); } m_editor->setCurCanvasPart(part); Song::movePlaybackToPart(part); // and turn it on for the new parts track song->setRecordFlag(track, true); song->deselectTracks(); song->deselectAllParts(); track->setSelected(true); part->setSelected(true); song->update(SC_SELECTION); int psn = part->sn(); for(int i = 0; i < m_model->rowCount(); ++i) { QStandardItem* item = m_model->item(i, 0); if(item) { int type = item->data(TrackRole).toInt(); if(type == 1) {//TrackMode continue; } else {//PartMode int sn = item->data(PartRole).toInt(); if(psn == sn) { m_selectedIndex = item->row(); m_tempColor = item->foreground(); m_model->blockSignals(true); item->setForeground(QColor(99, 36, 36)); m_model->blockSignals(false); update(); m_table->selectRow(m_selectedIndex); m_table->scrollTo(m_model->index(m_selectedIndex, 0)); m_colorRows.append(m_selectedIndex); QTimer::singleShot(350, this, SLOT(updateColor())); break; } } } } } }/*}}}*/
void QgsMapLayerStyleManagerWidget::styleRemoved( QString name ) { QList<QStandardItem*> items = mModel->findItems( name ); if ( items.isEmpty() ) return; QStandardItem* item = items.at( 0 ); mModel->removeRow( item->row() ); }
void CFrmGroupChat::slotParticipantRemoved(const QString &jid) { LOG_MODEL_DEBUG("Group chat", "CFrmGroupChat::slotParticipantRemoved:jid:%s", qPrintable(jid)); QList<QStandardItem*> items = m_pModelMembers->findItems(QXmppUtils::jidToResource(jid)); QStandardItem* item; foreach(item, items) { m_pModelMembers->removeRow(item->row()); }
void Channel::removeUser(QString inUser) { User* user = getUser(inUser); if(user != NULL) { QStandardItem *menuItem = user->getMenuItem(); int row = menuItem->row(); users->removeRow(row); user->deleteLater(); } }
void PlaylistListContainer::RemovePlaylist(int id) { QStandardItem* item = model_->PlaylistById(id); if (item) { QStandardItem* parent = item->parent(); if (!parent) { parent = model_->invisibleRootItem(); } parent->removeRow(item->row()); } }
void HistoryContentsWidget::removeEntry(qint64 entry) { QStandardItem *entryItem = findEntry(entry); if (entryItem) { QStandardItem *groupItem = entryItem->parent(); if (groupItem) { m_model->removeRow(entryItem->row(), groupItem->index()); if (groupItem->rowCount() == 0) { m_ui->historyView->setRowHidden(groupItem->row(), m_model->invisibleRootItem()->index(), true); } } } }
int ClientController::GetModelIndexFromId(qint32 clientId) { if(m_clientItemMap.count(clientId) != 1) { return -1; } QStandardItem *item = m_clientItemMap.at(clientId)->m_modelItem; return item->row(); }
void Server::removeChannel(QString inChannel) { Channel *channel = getChannel(inChannel); if(channel != NULL) { QStandardItem *chanMenuItem = channel->getMenuItem(); int row = chanMenuItem->row(); menuItem->removeRow(row); channel->deleteLater(); } }
bool DebuggerItemModel::removeDebuggerStandardItem(const QVariant &id) { QStandardItem *sitem = findStandardItemById(id); QTC_ASSERT(sitem, return false); QStandardItem *parent = sitem->parent(); QTC_ASSERT(parent, return false); // This will trigger a change of m_currentDebugger via changing the // view selection. parent->removeRow(sitem->row()); return true; }
void MainWindowImpl::OnRemovePreset(void) { //Find which preset is selected QModelIndexList indices = Presets->selectionModel()->selectedRows(); QModelIndexList::iterator i; for(i = indices.begin();i!=indices.end();++i) { QStandardItem* item = m_Presets.itemFromIndex(*i); m_Presets.removeRow(item->row(),QModelIndex()); } }
template<class T> static QStandardItem * appendRow( QStandardItem * parent, const char * label, const T& value ) { QStandardItem * item = new QStandardItem( label ); item->setEditable( false ); if ( parent ) { parent->appendRow( item ); QStandardItemModel& model = *item->model(); if ( parent->columnCount() <= ( item->column() + 1 ) ) model.insertColumn( item->column() + 1, parent->index() ); model.setData( model.index( item->row(), item->column() + 1, parent->index() ), value ); } return item; }
void removeExistingItem(const QString& path) { if (!itemsByPath.contains(path)) { return; } QStandardItem *existingItem = itemsByPath[path]; //kDebug() << "Removing existing item" << existingItem; Q_ASSERT(existingItem->parent()); existingItem->parent()->removeRow(existingItem->row()); itemsByPath.remove(path); }
void CookiesEditModel::RemoveCookie (const QModelIndex& index) { if (!index.isValid ()) return; QStandardItem *item = itemFromIndex (index); int i = item->data ().toInt (); if (i == -1) { for (int j = 0; j < item->rowCount (); ++j) { Cookies_.remove (item->child (j)->data ().toInt ()); } qDeleteAll (takeRow (item->row ())); } else { Cookies_.remove (i); qDeleteAll (item->parent ()->takeRow (item->row ())); } Jar_->setAllCookies (Cookies_.values ()); }