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


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

本文整理汇总了C++中WModelIndex::row方法的典型用法代码示例。如果您正苦于以下问题:C++ WModelIndex::row方法的具体用法?C++ WModelIndex::row怎么用?C++ WModelIndex::row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WModelIndex的用法示例。


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

示例1: modelDataChanged

void WSuggestionPopup::modelDataChanged(const WModelIndex& topLeft,
					const WModelIndex& bottomRight)
{
  if (topLeft.parent().isValid())
    return;

  if (modelColumn_ < topLeft.column() || modelColumn_ > bottomRight.column())
    return;

  for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
    WContainerWidget *w = dynamic_cast<WContainerWidget *>(impl_->widget(i));
    WAnchor *anchor = dynamic_cast<WAnchor *>(w->widget(0));
    WText *value = dynamic_cast<WText *>(anchor->widget(0));

    WModelIndex index = model_->index(i, modelColumn_);

    boost::any d = index.data();
    value->setText(asString(d));

    TextFormat format = index.flags() & ItemIsXHTMLText ? XHTMLText : PlainText;
    value->setTextFormat(format);

    boost::any d2 = model_->data(i, modelColumn_, UserRole);
    if (d2.empty())
      d2 = d;

    value->setAttributeValue("sug", asString(d2));
  }
}
开发者ID:Unss,项目名称:wt,代码行数:29,代码来源:WSuggestionPopup.C

示例2: dropEvent

void WAbstractItemModel::dropEvent(const WDropEvent& e, DropAction action,
				   int row, int column,
				   const WModelIndex& parent)
{
  // TODO: For now, we assumes selectionBehavior() == RowSelection !

  WItemSelectionModel *selectionModel
    = dynamic_cast<WItemSelectionModel *>(e.source());
  if (selectionModel) {
    WAbstractItemModel *sourceModel = selectionModel->model();

    /*
     * (1) Insert new rows (or later: cells ?)
     */
    if (action == MoveAction || row == -1) {
      if (row == -1)
	row = rowCount(parent);

      insertRows(row, selectionModel->selectedIndexes().size(), parent);
    }

    /*
     * (2) Copy data
     */
    WModelIndexSet selection = selectionModel->selectedIndexes();

    int r = row;
    for (WModelIndexSet::const_iterator i = selection.begin();
	 i != selection.end(); ++i) {
      WModelIndex sourceIndex = *i;
      if (selectionModel->selectionBehavior() == SelectRows) {
	WModelIndex sourceParent = sourceIndex.parent();

	for (int col = 0; col < sourceModel->columnCount(sourceParent); ++col) {
	  WModelIndex s = sourceModel->index(sourceIndex.row(), col,
					     sourceParent);
	  WModelIndex d = index(r, col, parent);
	  copyData(sourceModel, s, this, d);
	}

	++r;
      } else {
	  
      }
    }

    /*
     * (3) Remove original data
     */
    if (action == MoveAction) {
      while (!selectionModel->selectedIndexes().empty()) {
	WModelIndex i = Utils::last(selectionModel->selectedIndexes());

	sourceModel->removeRow(i.row(), i.parent());
      }
    }
  }
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:58,代码来源:WAbstractItemModel.C

示例3: sourceDataChanged

void WSortFilterProxyModel::sourceDataChanged(const WModelIndex& topLeft,
					      const WModelIndex& bottomRight)
{
  bool refilter
    = dynamic_ && (filterKeyColumn_ >= topLeft.column() 
		   && filterKeyColumn_ <= bottomRight.column());

  bool resort
    = dynamic_ && (sortKeyColumn_ >= topLeft.column() 
		   && sortKeyColumn_ <= bottomRight.column());

  WModelIndex parent = mapFromSource(topLeft.parent());
  Item *item = itemFromIndex(parent);

  for (int row = topLeft.row(); row <= bottomRight.row(); ++row) {
    int oldMappedRow = item->sourceRowMap_[row];
    bool propagateDataChange = oldMappedRow != -1;

    if (refilter || resort) {
      // Determine new insertion point: erase it temporarily for this
      if (oldMappedRow != -1)
	item->proxyRowMap_.erase(item->proxyRowMap_.begin() + oldMappedRow);
      int newMappedRow = mappedInsertionPoint(row, item);
      if (oldMappedRow != -1)
	item->proxyRowMap_.insert(item->proxyRowMap_.begin() + oldMappedRow, row);

      if (newMappedRow != oldMappedRow) {
	if (oldMappedRow != -1) {
	  beginRemoveRows(parent, oldMappedRow, oldMappedRow);
	  item->proxyRowMap_.erase
	    (item->proxyRowMap_.begin() + oldMappedRow);
	  rebuildSourceRowMap(item);
	  endRemoveRows();
	}

	if (newMappedRow != -1) {
	  beginInsertRows(parent, newMappedRow, newMappedRow);
	  item->proxyRowMap_.insert
	    (item->proxyRowMap_.begin() + newMappedRow, row);
	  rebuildSourceRowMap(item);
	  endInsertRows();
	}

	propagateDataChange = false;
      }
    }

    if (propagateDataChange) {
      WModelIndex l = sourceModel()->index(row, topLeft.column(),
					   topLeft.parent());
      WModelIndex r = sourceModel()->index(row, bottomRight.column(),
					   topLeft.parent());

      dataChanged().emit(mapFromSource(l), mapFromSource(r));
    }
  }
}
开发者ID:Dinesh-Ramakrishnan,项目名称:wt,代码行数:57,代码来源:WSortFilterProxyModel.C

示例4: doDelete

void gdContainerBar::doDelete()
{
  WModelIndexSet pSet = m_pView->selectedIndexes();
  if ( pSet.empty() ) return;
  // TODO : Dialog confirm
  for (WModelIndexSet::iterator it = pSet.begin(); it != pSet.end(); ++it) {
    WModelIndex    pIdx = *it;
    rowDeleted_.emit(pIdx.row());
    m_pView->model()->removeRows(pIdx.row(), 1);
  }
}
开发者ID:Wittyshare,项目名称:gdwtcore,代码行数:11,代码来源:gdContainerBar.cpp

示例5: updateModelIndex

// Updates the model index of the gdSqlComboBoxCustomItem
void gdSqlComboBoxDelegate::updateModelIndex(WWidget* widget, const WModelIndex& index)
{
  if ( isFirstRowReserved() )
    if ( index.row() == 0 ) {
      if ( m_bDebug )
        wApp->log("notice") << " gdSqlComboBoxDelegate::updateModelIndex firstRow reserved and row = 0 ";
      WItemDelegate* pItem = dynamic_cast<WItemDelegate*>(widget);
      return pItem->updateModelIndex(widget, index);
    }
  if ( m_bDebug )
    wApp->log("notice") << " gdSqlComboBoxDelegate::updateModelIndex row =  " << index.row();
  gdSqlComboBoxCustomItem*    item = dynamic_cast<gdSqlComboBoxCustomItem*>(widget);
  item->setIndex(index);
  WItemDelegate::updateModelIndex(widget, index);
}
开发者ID:Wittyshare,项目名称:gdwtcore,代码行数:16,代码来源:gdSqlComboBoxDelegate.cpp

示例6: rowCount

int GitModel::rowCount(const WModelIndex& index) const
{
  // we are looking for the git SHA1 id of a tree object (since only folders
  // may contain children).
  Git::ObjectId objectId;
  int treeId;

  if (index.isValid()) {
    // only column 0 items may contain children
    if (index.column() != 0)
      return 0;

    Git::Object o = getObject(index);
    if (o.type == Git::Tree) {
      objectId = o.id;
      treeId = getTreeId(index.internalId(), index.row());
    } else
      // not a folder: no children
      return 0;
  } else {
    treeId = 0;
    // the index corresponds to the root object
    if (treeData_.empty())
      // model not yet loaded !
      return 0;
    else
      objectId = treeData_[0].treeObject();
  }

  return treeData_[treeId].rowCount();
}
开发者ID:weyrick,项目名称:caw,代码行数:31,代码来源:sourceTreeModel.cpp

示例7: match

WModelIndexList WAbstractItemModel::match(const WModelIndex& start,
					  int role,
					  const boost::any& value,
					  int hits,
					  WFlags<MatchFlag> flags)
  const
{
  WModelIndexList result;

  const int rc = rowCount(start.parent());

  for (int i = 0; i < rc; ++i) {
    int row = start.row() + i;

    if (row >= rc) {
      if (!(flags & MatchWrap))
	break;
      else
	row -= rc;
    }

    WModelIndex idx = index(row, start.column(), start.parent());
    boost::any v = data(idx, role);

    if (Impl::matchValue(v, value, flags))
      result.push_back(idx);
  }

  return result;
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:30,代码来源:WAbstractItemModel.C

示例8: mapFromSource

WModelIndex WIdentityProxyModel::mapFromSource(const WModelIndex &sourceIndex) const
{
  if (!sourceIndex.isValid())
    return WModelIndex();

  return createIndex(sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
}
开发者ID:LifeGo,项目名称:wt,代码行数:7,代码来源:WIdentityProxyModel.C

示例9: setData

bool ChannelsModel::setData(const WModelIndex &index, const boost::any &value, int role)
{
  if (index.column() == 3)
  {
    QSharedPointer<common::User> du;
    QSharedPointer<Channel> ch;
    ch = m_availableChannels->at(index.row());
    du = common::DbSession::getInstance().getTokensMap().find(std::string(m_token))->second;
    bool subscribed=false;
    for (int i = 0; i < m_subscribedChannels->size(); i++)
    {
      if (m_subscribedChannels->at(i) == ch)
      {
        subscribed = true;
        break;
      }
    }
    if (subscribed)
    {
      //unsubscribe
      common::DbSession::getInstance().unsubscribe(du,ch);
    }
    else
    {
      //subscribe
      common::DbSession::getInstance().subscribe(du,ch);
    }
    //		index.data(Wt::CheckStateRole)=;
    dataChanged().emit(index, index);
    this->channelsUpdated.emit();
    return true;
  }
  return false;
}
开发者ID:aygerim,项目名称:geo2tag,代码行数:34,代码来源:ChannelsModel.cpp

示例10: handleFinish

  void handleFinish(DialogCode result)
  {
    if (result == WDialog::Accepted) {
      /*
       * Update the model with data from the edit widgets.
       *
       * You will want to do some validation here...
       *
       * Note that we directly update the source model to avoid
       * problems caused by the dynamic sorting of the proxy model,
       * which reorders row numbers, and would cause us to switch to editing
       * the wrong data.
       */
      WAbstractItemModel *m = model_;
      int modelRow = item_.row();

      WAbstractProxyModel *proxyModel = dynamic_cast<WAbstractProxyModel *>(m);
      if (proxyModel) {
	m = proxyModel->sourceModel();
	modelRow = proxyModel->mapToSource(item_).row();
      }

      m->setData(modelRow, 1, boost::any(nameEdit_->text()));
      m->setData(modelRow, 2, boost::any(typeEdit_->currentText()));
      m->setData(modelRow, 3, boost::any(boost::lexical_cast<int>
					 (sizeEdit_->text().toUTF8())));
      m->setData(modelRow, 4, boost::any(createdPicker_->date()));
      m->setData(modelRow, 5, boost::any(modifiedPicker_->date()));
    }

    delete this;
  }
开发者ID:USP,项目名称:wtcpp,代码行数:32,代码来源:TreeViewDragDrop.C

示例11: data

boost::any ChannelsModel::data(const WModelIndex & index,
int role) const
{
  if (role == Wt::DisplayRole || role == Wt::EditRole
    || role == ToolTipRole || CheckStateRole)
  {
    switch (index.column())
    {
      case 0:
        return m_availableChannels->at(index.row())->getName();
      case 1:
        return m_availableChannels->at(index.row())->getDescription();
      case 2:
        return m_availableChannels->at(index.row())->getRadius();
      case 3:
      {

        //	  WCheckBox *Check;
        //  	  Check = new WCheckBox(/*dynamic_cast<WContainerWidget*>(WObject::parent())*/);
        for (int i=0;i<m_subscribedChannels->size();i++)
        {
          if (m_subscribedChannels->at(i)==m_availableChannels->at(index.row()))
          {
            //			Check->setChecked(true);
            //	return boost::any(Check);
            if (role == Wt::CheckStateRole) return true;
            return "";
          }
        }
        //	  return *Check;
        if (role == Wt::CheckStateRole) return false;
        return "";
      }
      default:
        return "undefined";
    }
    return "indefined";
  }
  else
  {
    return boost::any();
  }
}
开发者ID:aygerim,项目名称:geo2tag,代码行数:43,代码来源:ChannelsModel.cpp

示例12: mapToSource

WModelIndex WSortFilterProxyModel::mapToSource(const WModelIndex& proxyIndex)
  const
{
  if (proxyIndex.isValid()) {
    Item *parentItem = parentItemFromIndex(proxyIndex);
    return sourceModel()->index(parentItem->proxyRowMap_[proxyIndex.row()],
				proxyIndex.column(),
				parentItem->sourceIndex_);
  } else
    return WModelIndex();
}
开发者ID:chr-thien,项目名称:wt,代码行数:11,代码来源:WSortFilterProxyModel.C

示例13: updateModelIndex

void gDoubledSpinBoxDelegate::updateModelIndex(WWidget* widget, const WModelIndex& index)
{
  if ( isFirstRowReserved() )
    if ( index.row() == 0 ) {
      WItemDelegate* pItem = dynamic_cast<WItemDelegate*>(widget);
      return pItem->updateModelIndex(widget, index);
    }
  gdDoubleSpinBoxCustomItem*    item = dynamic_cast<gdDoubleSpinBoxCustomItem*>(widget);
  item->setIndex(index);
  WItemDelegate::updateModelIndex(widget, index);
}
开发者ID:Wittyshare,项目名称:gdwtcore,代码行数:11,代码来源:gdDoubleSpinBoxDelegate.cpp

示例14: index

    virtual WModelIndex index(int row, int column,
                                  const WModelIndex& parent = WModelIndex()) const {
	int parentId;

	if (!parent.isValid())
	    parentId = 0;
	else {
	    int grandParentId = parent.internalId();
	    parentId = getTreeId(grandParentId, parent.row());
	}

	return createIndex(row, column, parentId);
    }
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:13,代码来源:GitModel.cpp

示例15: modelDataChanged

void WSuggestionPopup::modelDataChanged(const WModelIndex& topLeft,
					const WModelIndex& bottomRight)
{
  if (topLeft.parent().isValid())
    return;

  if (modelColumn_ < topLeft.column() || modelColumn_ > bottomRight.column())
    return;

  for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
    WContainerWidget *w = dynamic_cast<WContainerWidget *>(content_->widget(i));
    WText *value = dynamic_cast<WText *>(w->widget(0));

    boost::any d = model_->data(i, modelColumn_);
    value->setText(asString(d));

    boost::any d2 = model_->data(i, modelColumn_, UserRole);
    if (d2.empty())
      d2 = d;

    value->setAttributeValue("sug", asString(d2));
  }
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:23,代码来源:WSuggestionPopup.C


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