当前位置: 首页>>代码示例>>C++>>正文


C++ QStandardItem::row方法代码示例

本文整理汇总了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);
    }
}
开发者ID:photron,项目名称:zero-editor,代码行数:31,代码来源:fileswidget.cpp

示例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));
}
开发者ID:maxxant,项目名称:qt,代码行数:33,代码来源:tst_qstandarditem.cpp

示例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;
}
开发者ID:kenschweller,项目名称:qtmaze,代码行数:34,代码来源:TrialTreeModel.cpp

示例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);
}
开发者ID:photron,项目名称:zero-editor,代码行数:58,代码来源:fileswidget.cpp

示例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));
	}
开发者ID:AlexWMF,项目名称:leechcraft,代码行数:9,代码来源:acceptlangwidget.cpp

示例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);
	}
开发者ID:AlexWMF,项目名称:leechcraft,代码行数:10,代码来源:acceptlangwidget.cpp

示例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);
}
开发者ID:anchowee,项目名称:rabbitim,代码行数:14,代码来源:FrmGroupChatList.cpp

示例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);


}
开发者ID:MartinSchouwenburg,项目名称:IlwisTest,代码行数:14,代码来源:layermanager.cpp

示例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);
}
开发者ID:KingLee2015,项目名称:RedisDesktopManager,代码行数:50,代码来源:SortedSetKeyModel.cpp

示例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);
}
开发者ID:Doug0212,项目名称:Sigil,代码行数:32,代码来源:EditTOC.cpp

示例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();
}
开发者ID:GPUWorks,项目名称:skytechx,代码行数:27,代码来源:ccomdlg.cpp

示例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);
	}
}
开发者ID:FreeDegree,项目名称:Zhang,代码行数:31,代码来源:PlantBrushDockWidget.cpp

示例13: clearPlanetConnectionError

void Window::clearPlanetConnectionError(const Planet &planet)
{
    QStandardItem* planetItem = getPlanetTreeWidgetItem(planet);
    QStandardItem* errorItem = planetTreeModel->item(planetItem->row(), 1);
    errorItem->setText("");
    resizeColumnsToContents();
}
开发者ID:nurupo,项目名称:nfk-lobby,代码行数:7,代码来源:planetscannerwindow.cpp

示例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);
}
开发者ID:Doug0212,项目名称:Sigil,代码行数:29,代码来源:EditTOC.cpp

示例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);
}
开发者ID:Doug0212,项目名称:Sigil,代码行数:30,代码来源:EditTOC.cpp


注:本文中的QStandardItem::row方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。