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


C++ endRemoveRows函数代码示例

本文整理汇总了C++中endRemoveRows函数的典型用法代码示例。如果您正苦于以下问题:C++ endRemoveRows函数的具体用法?C++ endRemoveRows怎么用?C++ endRemoveRows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了endRemoveRows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: emit

void trn_mdl::rsz()
{
	int c_rws = hstr_.size() / 2;
	//c_rws = std::max(c_rws, 1);
	
	if (c_rws == rw_cnt_ - 1) /* no need to insert or remove rows */
	{
		emit(dataChanged(createIndex(c_rws, 0), createIndex(c_rws, 1)));
	}
	else if (c_rws > rw_cnt_ - 1) /* we have to insert some rows */
	{
		beginInsertRows(QModelIndex(), rw_cnt_, c_rws);
		endInsertRows();
		emit(dataChanged(createIndex(rw_cnt_ - 1, 0), createIndex(c_rws, 1)));
	}
	else /* we have to remove some rows */
	{
		beginRemoveRows(QModelIndex(), c_rws + 1, rw_cnt_ -1);
		endRemoveRows();
		emit(dataChanged(createIndex(rw_cnt_ - 1, 0), createIndex(c_rws, 1)));
	}
 
	rw_cnt_ = c_rws + 1;
}
开发者ID:NikolaYolov,项目名称:fmi-reversi,代码行数:24,代码来源:trn_mdl.cpp

示例2: beginRemoveRows

bool FormularModel::removeRows(int row, int count, const QModelIndex &parent) {
    if (row >= 0) {
        beginRemoveRows(parent, row, row + count - 1);
        for(int i = 0; i < count; i++) {
            FieldData *field = m_formularData.takeAt(row);
            if(field != NULL) {
                switch(field->getType()) {
                    case FieldData::Integer:
                    case FieldData::Real:
                    case FieldData::Boolean:
                    case FieldData::String:
                    case FieldData::Unused: {
                        delete field;
                        break;
                    }
                    case FieldData::Scalable: {
                        delete static_cast<FieldScalable*>(field);
                        break;
                    }
                    case FieldData::Enumeration: {
                        delete static_cast<FieldEnumeration*>(field);
                        break;
                    }
                    case FieldData::Constant: {
                        delete static_cast<FieldConstant*>(field);
                        break;
                    }
                }
            }
        }
        endRemoveRows();
        emit dataChanged(index(row), index(row + count - 1, formularHeaderSections.size() - 1));
        return true;
    }
    return false;
}
开发者ID:twister9893,项目名称:home,代码行数:36,代码来源:formularmodel.cpp

示例3: beginRemoveRows

bool MatrixModel::removeRows(int row, int count, const QModelIndex &parent) {
  beginRemoveRows(parent, row, row + count - 1);

  d_rows -= count;
  d_data_block_size = QSize(d_rows, d_cols);

  int removedCells = count * d_cols;
  int size = d_rows * d_cols;
  for (int i = row * d_cols; i < size; i++)
    d_data[i] = d_data[i + removedCells];

  double *new_data = (double *)realloc(d_data, size * sizeof(double));
  if (new_data == NULL) {
    // could not realloc, but orig still valid
    QMessageBox::critical(d_matrix, tr("MantidPlot") + " - " +
                                        tr("Memory Allocation Error"),
                          tr("Not enough memory, operation aborted!"));
  } else {
    d_data = new_data;
  }

  endRemoveRows();
  return true;
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:24,代码来源:MatrixModel.cpp

示例4: while

void WindowListModel::onWindowRemoved(WId id)
{
    int count = m_winList.count();
    
    int iter = 0;
    bool found = false;
    
    while( iter < count )
    {
        if( m_winList[iter].win() == id ) {
            found = true;
            break;
        }
        
        ++iter;
    }
    
    if( found )
    {
        beginRemoveRows( QModelIndex(), iter, iter + 1 );
        m_winList.removeAt(iter);
        endRemoveRows();
    }
}
开发者ID:taskstruct,项目名称:kdevwindowviewer,代码行数:24,代码来源:windowlistmodel.cpp

示例5: Q_D

void KPageWidgetModel::removePage(KPageWidgetItem *item)
{
    if (!item) {
        return;
    }

    Q_D(KPageWidgetModel);

    PageItem *pageItem = d->rootItem->findChild(item);
    if (!pageItem) {
        qDebug("Invalid KPageWidgetItem passed!");
        return;
    }

    emit layoutAboutToBeChanged();

    disconnect(item, SIGNAL(changed()), this, SLOT(_k_itemChanged()));
    disconnect(item, SIGNAL(toggled(bool)), this, SLOT(_k_itemToggled(bool)));

    PageItem *parentPageItem = pageItem->parent();
    int row = parentPageItem->row();

    QModelIndex index;
    if (parentPageItem != d->rootItem) {
        index = createIndex(row, 0, parentPageItem);
    }

    beginRemoveRows(index, pageItem->row(), pageItem->row());

    parentPageItem->removeChild(pageItem->row());
    delete pageItem;

    endRemoveRows();

    emit layoutChanged();
}
开发者ID:KDE,项目名称:kwidgetsaddons,代码行数:36,代码来源:kpagewidgetmodel.cpp

示例6: while

void QDBusModel::refresh(const QModelIndex &aIndex)
{
    QModelIndex index = aIndex;
    while (index.isValid() && static_cast<QDBusItem *>(index.internalPointer())->type != PathItem) {
        index = index.parent();
    }

    QDBusItem *item = static_cast<QDBusItem *>(index.internalPointer());
    if (!item)
        item = root;

    if (!item->children.isEmpty()) {
        beginRemoveRows(index, 0, item->children.count() - 1);
        qDeleteAll(item->children);
        item->children.clear();
        endRemoveRows();
    }

    addPath(item);
    if (!item->children.isEmpty()) {
        beginInsertRows(index, 0, item->children.count() - 1);
        endInsertRows();
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:24,代码来源:qdbusmodel.cpp

示例7: Q_FOREACH

void LauncherModel::unpin(const QString &appId)
{
    if (!m_includePinnedApps)
        return;

    Application *found = Q_NULLPTR;

    Q_FOREACH (Application *item, m_list) {
        if (!item->isPinned())
            break;

        if (item->appId() != appId)
            continue;

        found = item;
    }

    if (!found)
        return;

    Q_ASSERT(found->isPinned());

    int i = m_list.indexOf(found);

    // Remove the item when unpinned and not running
    if (found->isRunning()) {
        found->setPinned(false);
        moveRows(i, 1, m_list.size() - 1);
    } else {
        beginRemoveRows(QModelIndex(), i, i);
        m_list.takeAt(i)->deleteLater();
        endRemoveRows();
    }

    pinLauncher(appId, false);
}
开发者ID:papyros,项目名称:protoshell,代码行数:36,代码来源:launchermodel.cpp

示例8: beginRemoveRows

void QgsMapLayerModel::setAdditionalItems( const QStringList &items )
{
  if ( items == mAdditionalItems )
    return;

  int offset = 0;
  if ( mAllowEmpty )
    offset++;

  offset += mLayers.count();

  //remove existing
  if ( !mAdditionalItems.isEmpty() )
  {
    beginRemoveRows( QModelIndex(), offset, offset + mAdditionalItems.count() - 1 );
    mAdditionalItems.clear();
    endRemoveRows();
  }

  //add new
  beginInsertRows( QModelIndex(), offset, offset + items.count() - 1 );
  mAdditionalItems = items;
  endInsertRows();
}
开发者ID:CS-SI,项目名称:QGIS,代码行数:24,代码来源:qgsmaplayermodel.cpp

示例9: beginRemoveRows

void ColumnNameResult::setColumnValues(QList<QStringList> columns)
{
	if (rowCount() != 1) {
		beginRemoveRows(QModelIndex(), 1, rowCount()-1);
		columnValues.clear();
		endRemoveRows();
	}
	if (columnCount() != 0) {
		beginRemoveColumns(QModelIndex(), 0, columnCount()-1);
		columnNames.clear();
		endRemoveColumns();
	}

	QStringList first = columns.first();
	beginInsertColumns(QModelIndex(), 0, first.count()-1);
	for(int i = 0; i < first.count(); i++)
		columnNames.append(QString());

	endInsertColumns();

	beginInsertRows(QModelIndex(), 0, columns.count()-1);
	columnValues = columns;
	endInsertRows();
}
开发者ID:torvalds,项目名称:subsurface,代码行数:24,代码来源:divelogimportdialog.cpp

示例10: Application

Application *LauncherModel::addApplication(const QString &appId, bool pinned)
{
    auto app = new Application(appId, pinned, this);

    if (pinned && !app->isValid()) {
        pinLauncher(appId, false);
        return nullptr;
    }

    QObject::connect(app, &Application::launched, [=]() {
        QModelIndex modelIndex = index(indexFromAppId(appId));
        emit dataChanged(modelIndex, modelIndex);

        QTimer::singleShot(5000, [=]() {
            if (app->isStarting()) {
                qDebug() << "Application failed to start!" << appId;
                auto i = indexFromAppId(appId);
                if (app->isPinned()) {
                    QModelIndex modelIndex = index(i);
                    app->setState(Application::NotRunning);
                    emit dataChanged(modelIndex, modelIndex);
                } else {
                    beginRemoveRows(QModelIndex(), i, i);
                    m_list.takeAt(i)->deleteLater();
                    endRemoveRows();
                }
            } else {
                qDebug() << "Application is now running" << appId;
            }
        });
    });

    m_list.append(app);

    return app;
}
开发者ID:papyros,项目名称:protoshell,代码行数:36,代码来源:launchermodel.cpp

示例11: Q_UNUSED

bool CategoryListModel::removeRows(int position, int rows, const QModelIndex &index)
{
	Q_UNUSED(index);

	beginRemoveRows(QModelIndex(), position, position+rows-1);

	for (int row = 0; row < rows; ++row)
	{
		boost::shared_ptr<Category> category = d_category_list.at(position);

		if (category->resourceList().count() > 0)
		{
			//TODO: Popup msgbox, Please delete all attached resources of this category before deleting it.
		}
		else
		{
			d_category_list.removeAt(position);
		}
	}

	endRemoveRows();

	return true;
}
开发者ID:hugweb,项目名称:keep-stored,代码行数:24,代码来源:category_list_model.cpp

示例12: beginRemoveRows

void RoutesTableModel::_removeRoute(int index)
{
    beginRemoveRows(QModelIndex(), index, index);

    QPoint from = m_routes[index].first;
    QPoint to = m_routes[index].second;

    m_from[from].removeOne(index);
    if (m_from[from].empty())
    {
        m_from.remove(from);
    }

    m_to[to].removeOne(index);
    if (m_to[to].empty())
    {
        m_to.remove(to);
    }

    m_routes.removeAt(index);
    m_factors.removeAt(index);

    endRemoveRows();
}
开发者ID:TheFakeCake,项目名称:SELECTOR-GUI,代码行数:24,代码来源:RoutesTableModel.cpp

示例13: beginRemoveRows

void HWStubContextModel::EnableDummy(bool en, const QString& text)
{
    /* if needed, create/remove raw */
    if(m_has_dummy && !en)
    {
        /* remove row */
        beginRemoveRows(QModelIndex(), 0, 0);
        m_has_dummy = false;
        endRemoveRows();
    }
    else if(!m_has_dummy && en)
    {
        /* add row */
        beginInsertRows(QModelIndex(), 0, 0);
        m_has_dummy = true;
        m_dummy_text = text;
        endInsertRows();
    }
    else if(en)
    {
        /* text change only */
        emit dataChanged(index(0, GetNameColumn()), index(0, GetNameColumn()));
    }
}
开发者ID:Rockbox,项目名称:rockbox,代码行数:24,代码来源:backend.cpp

示例14: LOCK

bool MessageModel::removeRows(int row, int count, const QModelIndex & parent)
{
    MessageTableEntry *rec = priv->index(row);
    if(count != 1 || !rec)
        // Can only remove one row at a time, and cannot remove rows not in model.
        return false;

    {
        LOCK(cs_smsgDB);
        SecMsgDB dbSmsg;

        if (!dbSmsg.Open("cr+"))
            //throw runtime_error("Could not open DB.");
            return false;

        dbSmsg.EraseSmesg(&rec->chKey[0]);
    }

    beginRemoveRows(parent, row, row);
    priv->cachedMessageTable.removeAt(row);
    endRemoveRows();

    return true;
}
开发者ID:ArtzGalore,项目名称:okcash,代码行数:24,代码来源:messagemodel.cpp

示例15: FindModel

	void MergeModel::RemoveModel (QAbstractItemModel *model)
	{
		auto i = FindModel (model);

		if (i == Models_.end ())
		{
			qWarning () << Q_FUNC_INFO << "not found model" << model;
			return;
		}

		for (auto r = Root_->begin (); r != Root_->end (); )
			if ((*r)->GetModel () == model)
			{
				const auto idx = std::distance (Root_->begin (), r);

				beginRemoveRows ({}, idx, idx);
				r = Root_->EraseChild (r);
				endRemoveRows ();
			}
			else
				++r;

		Models_.erase (i);
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:24,代码来源:mergemodel.cpp


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