本文整理汇总了C++中QStandardItem::row方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::row方法的具体用法?C++ QStandardItem::row怎么用?C++ QStandardItem::row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeDocument
// 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);
}
}
示例2: getSetChild
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));
}
示例3: dropMimeData
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;
}
示例4: addDocument
// 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);
}
示例5: on_MoveUp__released
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));
}
示例6: on_MoveDown__released
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);
}
示例7: slotLeft
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);
}
示例8: findLayer
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);
}
示例9: updateValue
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);
}
示例10: MoveRight
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);
}
示例11: dlg
/////////////////////////////////////////
// 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();
}
示例12: slotDeleteSelected
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);
}
}
示例13: clearPlanetConnectionError
void Window::clearPlanetConnectionError(const Planet &planet)
{
QStandardItem* planetItem = getPlanetTreeWidgetItem(planet);
QStandardItem* errorItem = planetTreeModel->item(planetItem->row(), 1);
errorItem->setText("");
resizeColumnsToContents();
}
示例14: MoveDown
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);
}
示例15: AddEntry
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);
}