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


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

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


在下文中一共展示了WModelIndex::column方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: data

boost::any GitModel::data(const WModelIndex& index, int role) const
{
  if (!index.isValid())
    return boost::any();

  /* Only 3 data roles on column 0 data are supported:
   * - DisplayRole: the file name
   * - DecorationRole: an icon (folder or file)
   * - ContentsRole: the file contents
   */
  if (index.column() == 0) {
    Git::Object object = getObject(index);
    if (role == DisplayRole) {
      if (object.type == Git::Tree)
	return object.name + '/';
      else
	return object.name;
    } else if (role == DecorationRole) {
      if (object.type == Git::Blob)
    return static_cast<const char*>("resources/icons/git-blob.png");
      else if (object.type == Git::Tree)
    return static_cast<const char*>("resources/icons/git-tree.png");
    } else if (role == ContentsRole) {
      if (object.type == Git::Blob)
	return git_.catFile(object.id);
    } else if (role == FilePathRole) {
      return boost::any();
    }
  }

  return boost::any();
}
开发者ID:weyrick,项目名称:caw,代码行数:32,代码来源:sourceTreeModel.cpp

示例7:

WFlags<ItemFlag> ChannelsModel::flags(const WModelIndex &index) const
{
  if (index.column() == 3)
  {
    return Wt::ItemIsUserCheckable;
  }
  return 0;
  //    return WFlags<ItemFlag>();
}
开发者ID:aygerim,项目名称:geo2tag,代码行数:9,代码来源:ChannelsModel.cpp

示例8: string

    virtual cpp17::any data(const WModelIndex& index, ItemDataRole role = ItemDataRole::Display) const {
	if (!index.isValid())
	    return cpp17::any();

	Git::Object object = getObject(index);

	switch (index.column()) {
	case 0:
	    if (role == ItemDataRole::Display) {
		if (object.type == Git::Tree)
		    return object.name + '/';
		else
		    return object.name;
	    } else if (role == ItemDataRole::Decoration) {
		if (object.type == Git::Blob)
		    return std::string("icons/git-blob.png");
		else if (object.type == Git::Tree)
		    return std::string("icons/git-tree.png");
	    } else if (role == ContentsRole) {
		if (object.type == Git::Blob)
		    return git_.catFile(object.id);
	    }

	    break;
	case 1:
	    if (role == ItemDataRole::Display) {
		if (object.type == Git::Tree)
		    return std::string("Folder");
		else {
		    std::string suffix = getSuffix(object.name);

		    if (suffix == "C" || suffix == "cpp")
			return std::string("C++ Source");
		    else if (suffix == "h" || 
			     (suffix == "" && !topLevel(index)))
			return std::string("C++ Header");
		    else if (suffix == "css")
			return std::string("CSS Stylesheet");
		    else if (suffix == "js")
			return std::string("JavaScript Source");
		    else if (suffix == "md")
			return std::string("Markdown");
		    else if (suffix == "png" || suffix == "gif")
			return std::string("Image");
		    else if (suffix == "txt")
			return std::string("Text");
		    else
			return cpp17::any();
		}
	    }
	}

        return cpp17::any();
    }
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:54,代码来源:GitModel.cpp

示例9: 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

示例10: flags

WFlags<ItemFlag> ArnModelW::flags(const WModelIndex& index) const
{
    if (!index.isValid()) {
        return WFlags<ItemFlag>(0);
    }
    if (index.column() == 1) {
        return WAbstractItemModel::flags( index) | Wt::ItemIsEditable;
    }
    else {
        return WAbstractItemModel::flags( index);
    }
}
开发者ID:micwik,项目名称:WebArnBrowser,代码行数:12,代码来源:ArnModel.cpp

示例11: if

bool WModelIndex::UnorderedLess::operator() (const WModelIndex& i1,
					     const WModelIndex& i2) const
{
  if (!i1.isValid())
    return i2.isValid();
  else if (!i2.isValid())
    return false;
  else if (i1 == i2)
    return false;
  else if (i1.model() != i2.model()) {
    LOG_ERROR("comparing indexes from different models are you?");
    return false;
  } else if (i1.row() < i2.row())
    return true;
  else if (i1.row() > i2.row())
    return false;
  else if (i1.column() < i2.column())
    return true;
  else if (i1.column() > i2.column())
    return false;
  else
    return i1.internalId_ < i2.internalId_;
}
开发者ID:913862627,项目名称:wt,代码行数:23,代码来源:WModelIndex.C

示例12: 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

示例13: 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

示例14: modelDataChanged

void DataStore::modelDataChanged(const WModelIndex& topLeft,
				 const WModelIndex& bottomRight)
{
  if (dataLocation_ == ClientSide) {
    for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
      if (recordIds_[i] == -1)
	continue;

      for (unsigned j = 0; j < columns_.size(); ++j) {
	const Column& c = columns_[j];

	if (c.modelColumn >= topLeft.column()
	    && c.modelColumn <= bottomRight.column()) {

	  jsChanges_ += "store.getById("
	    + boost::lexical_cast<std::string>(recordIds_[i]) + ").set('"
	    + c.fieldName + "',"
	    + dataAsJSLiteral(i, c.modelColumn) + ");";
	}
      }
    }
  } else
    needRefresh_ = true;
}
开发者ID:USP,项目名称:wtcpp,代码行数:24,代码来源:DataStore.C

示例15: rowCount

int ArnModelW::rowCount(const WModelIndex& parent) const
{
    // qDebug() << "### arnModelW rowCount: Check";
    if (parent.column() > 0)  return 0;

    ArnNode*  parentNode = nodeFromIndex( parent);
    if (!parentNode) {  // Should not be ...
        qDebug() << "### arnModelW rowCount: parent=null Grandparent=" << nodeFromIndex( this->parent( parent))->path();
        return 0;
    }

    int ret = parentNode->_children.size();
    // qDebug() << "### arnModelW rowCount: col0 parent=" << parentNode->path()
    //          << " expand=" << parentNode->_expandState.e << " ret=" << ret;
    return ret;
}
开发者ID:micwik,项目名称:WebArnBrowser,代码行数:16,代码来源:ArnModel.cpp


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