Ejemplo n.º 1
0
QModelIndex DiscoItemsModel::modelIndex(DiscoItemIndex *AIndex, int AColumn) const
{
	return AIndex!=NULL && AIndex!=FRootIndex ? createIndex(AIndex->parent->childs.indexOf(AIndex),AColumn,AIndex) : QModelIndex();
}
Ejemplo n.º 2
0
void DivePlannerPointsModel::emitDataChanged()
{
	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
//! [2]
QXmlNodeModelIndex QObjectXmlModel::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &n) const
{
    switch (toNodeType(n))
    {
        case IsQObject:
        {
            switch (axis)
            {
                case Parent:
                    return createIndex(asQObject(n)->parent());

                case FirstChild:
                {
                    if (!asQObject(n) || asQObject(n)->children().isEmpty())
                        return QXmlNodeModelIndex();
                    else
                        return createIndex(asQObject(n)->children().first());
                }
                
                case NextSibling:
                    return qObjectSibling(1, n);

//! [10]                    
                case PreviousSibling:
                {
                    if (asQObject(n) == m_root)
                        return createIndex(qint64(0), MetaObjects);
                    else
                        return qObjectSibling(-1, n);
                }
//! [10]                    
            }
            Q_ASSERT(false);
        }

//! [7]
        case QObjectClassName:
        case QObjectProperty:
        {
            Q_ASSERT(axis == Parent);
            return createIndex(asQObject(n));
        }
//! [7]
//! [2]
//! [3]

//! [11]        
        case MetaObjects:
        {
            switch (axis)
            {
                case Parent:
                    return QXmlNodeModelIndex();
                case PreviousSibling:
                    return QXmlNodeModelIndex();
                case NextSibling:
                    return root();
                case FirstChild:
                {
                    return createIndex(const_cast<QMetaObject*>(m_allMetaObjects.first()),MetaObject);
                }
            }
            Q_ASSERT(false);
        }
//! [11]        

        case MetaObject:
        {
            switch (axis)
            {
                case FirstChild:
                    return QXmlNodeModelIndex();
                case Parent:
                    return createIndex(qint64(0), MetaObjects);
                case PreviousSibling:
                    return metaObjectSibling(-1, n);
                case NextSibling:
                    return metaObjectSibling(1, n);
            }
        }

        case MetaObjectClassName:
        case MetaObjectSuperClass:
        {
            Q_ASSERT(axis == Parent);
            return createIndex(asQObject(n), MetaObject);
        }
//! [3]
//! [4]
    }

    Q_ASSERT(false);
    return QXmlNodeModelIndex();
}
QModelIndex CompleterTestModel::index(int row, int column, const QModelIndex &parent) const
{
    return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex();
}
Ejemplo n.º 5
0
	QModelIndex PluginManager::index (int row, int column, const QModelIndex&) const
	{
		return createIndex (row, column);
	}
Ejemplo n.º 6
0
bool ParamModelBase::IsFreeze(size_t idx) const
{
    return data(createIndex((int)idx,FREEZE),Qt::CheckStateRole).toBool();
}
Ejemplo n.º 7
0
/*!
    \since 5.0

    Refreshes \a row in the model with values from the database table row matching
    on primary key values. Without a primary key, all column values must match. If
    no matching row is found, the model will show an empty row.

    Returns \c true if successful; otherwise returns \c false.

    \sa select()
*/
bool QSqlTableModel::selectRow(int row)
{
    Q_D(QSqlTableModel);

    if (row < 0 || row >= rowCount())
        return false;

    const int table_sort_col = d->sortColumn;
    d->sortColumn = -1;
    const QString table_filter = d->filter;
    d->filter = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,
                                              d->tableName,
                                              primaryValues(row),
                                              false);
    static const QString wh = Sql::where() + Sql::sp();
    if (d->filter.startsWith(wh, Qt::CaseInsensitive))
        d->filter.remove(0, wh.length());

    QString stmt;

    if (!d->filter.isEmpty())
        stmt = selectStatement();

    d->sortColumn = table_sort_col;
    d->filter = table_filter;

    if (stmt.isEmpty())
        return false;

    bool exists;
    QSqlRecord newValues;

    {
        QSqlQuery q(d->db);
        q.setForwardOnly(true);
        if (!q.exec(stmt))
            return false;

        exists = q.next();
        newValues = q.record();
    }

    bool needsAddingToCache = !exists || d->cache.contains(row);

    if (!needsAddingToCache) {
        const QSqlRecord curValues = record(row);
        needsAddingToCache = curValues.count() != newValues.count();
        if (!needsAddingToCache) {
            // Look for changed values. Primary key fields are customarily first
            // and probably change less often than other fields, so start at the end.
            for (int f = curValues.count() - 1; f >= 0; --f) {
                if (curValues.value(f) != newValues.value(f)) {
                    needsAddingToCache = true;
                    break;
                }
            }
        }
    }

    if (needsAddingToCache) {
        d->cache[row].refresh(exists, newValues);
        emit headerDataChanged(Qt::Vertical, row, row);
        emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
    }

    return true;
}
Ejemplo n.º 8
0
QModelIndex PrimerLibraryModel::index(int row, int column, const QModelIndex & /*parent*/) const {
    CHECK(row < primers.size(), QModelIndex());
    return createIndex(row, column);
}
Ejemplo n.º 9
0
QVariant DeviceExplorerModel::getData(Device::NodePath node, Column column, int role)
{
    QModelIndex index = createIndex(convertPathToIndex(node).row(), (int)column, node.toNode(&rootNode())->parent());
    return data(index, role);
}
Ejemplo n.º 10
0
QModelIndex DhQDirModel::DvhcreateIndex(int x1, int x2) const {
  return createIndex(x1, x2);
}
Ejemplo n.º 11
0
QModelIndex DhQDirModel::DvhcreateIndex(int x1, int x2, void* x3) const {
  return createIndex(x1, x2, x3);
}
Ejemplo n.º 12
0
void NewsFeedModel::replaceNews(int i, const Vreen::NewsItem &news)
{
    auto index = createIndex(i, 0);
    m_newsList[i] = news;
    emit dataChanged(index, index);
}
QModelIndex MtpObjectsModel::findObject(const QString &filename) const
{
	auto idx = std::find_if(_rows.begin(), _rows.end(), [filename, this](Row & row) { return fromUtf8(row.GetInfo(_session)->Filename) == filename; } );
	return idx != _rows.end()? createIndex(std::distance(_rows.begin(), idx), 0): QModelIndex();
}
QModelIndex MtpObjectsModel::findObject(mtp::u32 objectId) const
{
	auto idx = std::find_if(_rows.begin(), _rows.end(), [objectId](const Row & row) { return row.ObjectId == objectId; } );
	return idx != _rows.end()? createIndex(std::distance(_rows.begin(), idx), 0): QModelIndex();
}
Ejemplo n.º 15
0
void ParamModelBase::SetFreeze(int i, bool is_freeze)
{
    setData( createIndex(i,FREEZE), is_freeze, Qt::CheckStateRole );
}
Ejemplo n.º 16
0
void ApiTraceModel::beginLoadingFrame(ApiTraceFrame *frame, int numAdded)
{
    QModelIndex index = createIndex(frame->number, 0, frame);
    beginInsertRows(index, 0, numAdded - 1);
}
Ejemplo n.º 17
0
void ParamModelBase::SetValue(int i, const std::string& value)
{
    setData( createIndex(i,VALUE), value.c_str(), Qt::EditRole );
}
Ejemplo n.º 18
0
QModelIndex ParameterListModel::index(int row, int column, const QModelIndex &) const {
  return createIndex(row, column);
}
Ejemplo n.º 19
0
QModelIndex cceMaterialShaderBindingTreeModel::index (int row, int column, const QModelIndex &parent) const
{
  if (parent.isValid()) return QModelIndex ();

  return createIndex(row, column, 0);
}
Ejemplo n.º 20
0
WModelIndex WAbstractTableModel::index(int row, int column,
				       const WModelIndex& parent) const
{
  return createIndex(row, column, nullptr);
}
Ejemplo n.º 21
0
/*! \internal */
QModelIndex KDPropertyModel::buddy(const QModelIndex& index) const
{
  if (index.column() == 0 && privateData(index) && !privateData(index)->isCategory() )
    return createIndex(index.row(), 1, index.internalPointer());
  return index;
}
void QgsGraduatedSymbolRendererV2Model::updateLabels()
{
  emit dataChanged( createIndex( 0, 2 ), createIndex( mRenderer->ranges().size(), 2 ) );
}
Ejemplo n.º 23
0
QModelIndex RulesModel::index(int row, int column, const QModelIndex &parent) const
{
	if(!hasIndex(row, column, parent))return QModelIndex();
	return createIndex(row,column);
}
QModelIndex CategoriesModel::index(int row, int column, const QModelIndex& parent) const
{

    return createIndex(row,column);
}
Ejemplo n.º 25
0
QModelIndex MemEditModel::index(int row, int column, const QModelIndex& parent) const
{
    Q_UNUSED(parent);
    return createIndex(row, column);
}
Ejemplo n.º 26
0
QModelIndex FcitxIMPage::Private::IMModel::index(int row, int column, const QModelIndex& parent) const
{
    Q_UNUSED(parent);

    return createIndex(row, column, (row < filteredIMEntryList.count()) ? (void*) &filteredIMEntryList.at(row) : 0);
}
Ejemplo n.º 27
0
void DivePlannerPointsModel::setSafetyStop(bool value)
{
	auto planner = SettingsObjectWrapper::instance()->planner_settings;
	planner->setSafetyStop(value);
	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS -1));
}
Ejemplo n.º 28
0
QModelIndex Log::index(int row, int column, const QModelIndex &) const
{
    return createIndex(row, column);
}
//! [0]
QXmlNodeModelIndex QObjectXmlModel::root() const
{
    return createIndex(m_root);
}
Ejemplo n.º 30
0
QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent) const
{
#ifdef RDM_DEBUG
	std::cerr << "RetroshareDirModel::index(): " << parent.internalPointer();
	std::cerr << ": row:" << row << " col:" << column << " ";
#endif

	if(row < 0)
		return QModelIndex() ;

	void *ref = (parent.isValid()) ? parent.internalPointer() : NULL;

	/********
	  if (!RemoteMode)
	  {
	  remote = &(rsiface->getLocalDirectoryList());
	  }
	 ********/

	DirDetails details;
	uint32_t flags = DIR_FLAGS_CHILDREN;
	if (RemoteMode)
		flags |= DIR_FLAGS_REMOTE;
	else
		flags |= DIR_FLAGS_LOCAL;

	if (!requestDirDetails(ref, details, flags))
	{
#ifdef RDM_DEBUG
		std::cerr << "lookup failed -> invalid";
		std::cerr << std::endl;
#endif
		return QModelIndex();
	}


	/* now iterate through the details to
	 * get the reference number
	 */

	std::list<DirStub>::iterator it;
	int i = 0;
	for(it = details.children.begin(); ((i < row) && (it != details.children.end())); ++it,++i) ;

	if (it == details.children.end())
	{
#ifdef RDM_DEBUG
		std::cerr << "wrong number of children -> invalid";
		std::cerr << std::endl;
#endif
		return QModelIndex();
	}

#ifdef RDM_DEBUG
	std::cerr << "success index(" << row << "," << column << "," << it->ref << ")";
	std::cerr << std::endl;
#endif

	/* we can just grab the reference now */

	return createIndex(row, column, it->ref);
}