• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QPersistentModelIndex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: QAbstractTableModel

KNMusicModel::KNMusicModel(QObject *parent) :
    QAbstractTableModel(parent),
    m_detailInfos(QList<KNMusicDetailInfo>()),
    m_totalDuration(0),
    m_playingIndex(QPersistentModelIndex()),
    m_playingIcon(QVariant(QIcon(":/plugin/music/public/playingicon.png"))),
    m_cannotPlayIcon(QVariant(QIcon(":/plugin/music/public/cannotplay.png"))),
    m_nullValue(QVariant()),
    m_identifier(QString())
{
    //Build drop mime types for the first time.
    if(m_dropMimeTypes.isEmpty())
    {
        //Set the drop mime types for original types first.
        m_dropMimeTypes=QAbstractTableModel::mimeTypes();
        //Add url format.
        m_dropMimeTypes.append("text/uri-list");
        //Initial cache data.

        //Add music detail info list.
        m_dropMimeTypes.append(ModelMimeType);
        m_dropMimeTypes.append(ModelType);
        m_dropMimeTypes.append(ModelRowData);
        m_dropMimeTypes.append(ModelRowList);
    }
}
开发者ID:Kreogist,项目名称:Mu,代码行数:26,代码来源:knmusicmodel.cpp


示例2: while

void DirModel::delayedPreview()
{
    QHash<QUrl, QPersistentModelIndex>::const_iterator i = m_filesToPreview.constBegin();

    KFileItemList list;

    while (i != m_filesToPreview.constEnd()) {
        QUrl file = i.key();
        QPersistentModelIndex index = i.value();


        if (!m_previewJobs.contains(file) && file.isValid()) {
            list.append(KFileItem(file, QString(), 0));
            m_previewJobs.insert(file, QPersistentModelIndex(index));
        }

        ++i;
    }

    if (list.size() > 0) {
        KIO::PreviewJob* job = KIO::filePreview(list, m_screenshotSize);
        job->setIgnoreMaximumSize(true);
        // qDebug() << "Created job" << job;
        connect(job, &KIO::PreviewJob::gotPreview,
                this, &DirModel::showPreview);
        connect(job, &KIO::PreviewJob::failed,
                this, &DirModel::previewFailed);
    }

    m_filesToPreview.clear();
}
开发者ID:CerebrosuS,项目名称:plasma-desktop,代码行数:31,代码来源:dirmodel.cpp


示例3: Q_Q

void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
{
    Q_Q(QIdentityProxyModel);

    foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
        proxyIndexes << proxyPersistentIndex;
        Q_ASSERT(proxyPersistentIndex.isValid());
        const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
        Q_ASSERT(srcPersistentIndex.isValid());
        layoutChangePersistentIndexes << srcPersistentIndex;
    }

    QList<QPersistentModelIndex> parents;
    parents.reserve(sourceParents.size());
    foreach (const QPersistentModelIndex &parent, sourceParents) {
        if (!parent.isValid()) {
            parents << QPersistentModelIndex();
            continue;
        }
        const QModelIndex mappedParent = q->mapFromSource(parent);
        Q_ASSERT(mappedParent.isValid());
        parents << mappedParent;
    }

    q->layoutAboutToBeChanged(parents, hint);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:26,代码来源:qidentityproxymodel.cpp


示例4: foreach

QList< QPersistentModelIndex > ModelSpy::toPersistent(QModelIndexList list)
{
  QList<QPersistentModelIndex > persistentList;
  foreach(QModelIndex idx, list)
  {
    persistentList << QPersistentModelIndex(idx);
  }
开发者ID:vasi,项目名称:kdelibs,代码行数:7,代码来源:modelspy.cpp


示例5: QVariant

QVariant DirModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid()) {
        return QVariant();
    }

    switch (role) {
    case UrlRole: {
        KFileItem item = itemForIndex(index);
        return item.url().toString();
    }
    case MimeTypeRole: {
        KFileItem item = itemForIndex(index);
        return item.mimetype();
    }
    case Thumbnail: {
        KFileItem item = itemForIndex(index);
        QImage preview = QImage(m_screenshotSize, QImage::Format_ARGB32_Premultiplied);

        if (m_imageCache->findImage(item.url().toString(), &preview)) {
            return preview;
        }

        m_previewTimer->start(100);
        const_cast<DirModel *>(this)->m_filesToPreview[item.url()] = QPersistentModelIndex(index);
    }
    default:
        return KDirModel::data(index, role);
    }
}
开发者ID:CerebrosuS,项目名称:plasma-desktop,代码行数:30,代码来源:dirmodel.cpp


示例6: KNMusicNowPlayingBase

KNMusicNowPlaying::KNMusicNowPlaying(QObject *parent) :
    KNMusicNowPlayingBase(parent),
    m_backend(nullptr),
    m_playingProxyModel(nullptr),
    m_shadowPlayingModel(new KNMusicProxyModel(this)),
    m_temporaryProxyPlaylist(new KNMusicProxyModel(this)),
    m_temporaryPlaylist(new KNMusicTemporaryPlaylistModel(this)),
    m_playingTab(nullptr),
    m_loopState(NoRepeat),
    m_playingIndex(QPersistentModelIndex()),
    m_playingAnalysisItem(KNMusicAnalysisItem()),
    m_manualPlayed(false)
{
    //Set the temporary playlist to the proxy model.
    m_temporaryProxyPlaylist->setSourceModel(m_temporaryPlaylist);
    //Initial the random device and random generator.
    QVector<int> seedData;
    //Generate the random device.
    std::random_device randomDevice;
    //Get the seed array size.
    const int seedCount=(int)std::mt19937::state_size;
    //Resize the seed data.
    seedData.resize(seedCount);
    //Set the data to the seed data.
    for(int i=0; i<seedCount; ++i)
    {
        //Replace the seed data.
        seedData.replace(i, randomDevice());
    }
    //Transform list to seed sequence.
    std::seed_seq seedSequence(std::begin(seedData), std::end(seedData));
    //Initial the Mersenne twister seeds.
    m_mersenneSeed=std::mt19937(seedSequence);
}
开发者ID:guoyu07,项目名称:Mu,代码行数:34,代码来源:knmusicnowplaying.cpp


示例7: QStringLiteral

void QgsGeometryCheckerResultTab::addError( QgsGeometryCheckError *error )
{
  bool sortingWasEnabled = ui.tableWidgetErrors->isSortingEnabled();
  if ( sortingWasEnabled )
    ui.tableWidgetErrors->setSortingEnabled( false );

  int row = ui.tableWidgetErrors->rowCount();
  int prec = 7 - std::floor( std::max( 0., std::log10( std::max( error->location().x(), error->location().y() ) ) ) );
  QString posStr = QStringLiteral( "%1, %2" ).arg( error->location().x(), 0, 'f', prec ).arg( error->location().y(), 0, 'f', prec );

  ui.tableWidgetErrors->insertRow( row );
  QTableWidgetItem *idItem = new QTableWidgetItem();
  idItem->setData( Qt::EditRole, error->featureId() != FID_NULL ? QVariant( error->featureId() ) : QVariant() );
  ui.tableWidgetErrors->setItem( row, 0, new QTableWidgetItem( !error->layerId().isEmpty() ? mChecker->featurePools()[error->layerId()]->layer()->name() : "" ) );
  ui.tableWidgetErrors->setItem( row, 1, idItem );
  ui.tableWidgetErrors->setItem( row, 2, new QTableWidgetItem( error->description() ) );
  ui.tableWidgetErrors->setItem( row, 3, new QTableWidgetItem( posStr ) );
  QTableWidgetItem *valueItem = new QTableWidgetItem();
  valueItem->setData( Qt::EditRole, error->value() );
  ui.tableWidgetErrors->setItem( row, 4, valueItem );
  ui.tableWidgetErrors->setItem( row, 5, new QTableWidgetItem( QString() ) );
  ui.tableWidgetErrors->item( row, 0 )->setData( Qt::UserRole, QVariant::fromValue( error ) );
  ++mErrorCount;
  ui.labelErrorCount->setText( tr( "Total errors: %1, fixed errors: %2" ).arg( mErrorCount ).arg( mFixedCount ) );
  mStatistics.newErrors.insert( error );
  mErrorMap.insert( error, QPersistentModelIndex( ui.tableWidgetErrors->model()->index( row, 0 ) ) );

  if ( sortingWasEnabled )
    ui.tableWidgetErrors->setSortingEnabled( true );
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:30,代码来源:qgsgeometrycheckerresulttab.cpp


示例8: QTreeWidgetItem

void
TransferView::onTransferUpdate()
{
    StreamConnection* sc = (StreamConnection*)sender();
//    qDebug() << Q_FUNC_INFO << sc->track().isNull() << sc->source().isNull();

    if ( sc->track().isNull() || sc->source().isNull() )
        return;

    QTreeWidgetItem* ti = 0;

    if ( m_index.contains( sc ) )
    {
        QPersistentModelIndex i = m_index.value( sc );
        ti = m_tree->invisibleRootItem()->child( i.row() );
    }
    else
    {
        ti = new QTreeWidgetItem( m_tree );
        m_index.insert( sc, QPersistentModelIndex( m_tree->model()->index( m_tree->invisibleRootItem()->childCount() - 1, 0 ) ) );
        emit showWidget();
    }

    if ( !ti )
        return;

    ti->setText( 0, sc->source()->friendlyName() );
    ti->setText( 1, QString( "%1 kb/s" ).arg( sc->transferRate() / 1024 ) );
    ti->setText( 2, QString( "%1 - %2" ).arg( sc->track()->artist()->name() ).arg( sc->track()->track() ) );

    if ( isHidden() )
        emit showWidget();
}
开发者ID:LittleForker,项目名称:tomahawk,代码行数:33,代码来源:transferview.cpp


示例9: layoutAboutToBeChanged

void ModelTest::layoutAboutToBeChanged()
{
    for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i)
    {
        changing.append(QPersistentModelIndex(model->index(i, 0)));
    }
}
开发者ID:UIKit0,项目名称:digikam,代码行数:7,代码来源:modeltest.cpp


示例10: Q_UNUSED

bool
GetNewStuffDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove )
        return false;

    if ( event->type() == QEvent::MouseButtonRelease && m_cachedButtonRects.contains( QPair<int, int>( index.row(), index.column() ) ) )
    {
        QRect rect = m_cachedButtonRects[ QPair<int, int>( index.row(), index.column() ) ];
        QMouseEvent* me = static_cast< QMouseEvent* >( event );

        if ( rect.contains( me->pos() ) )
        {
            model->setData( index, true );

            return true;
        }
    }

    if ( m_cachedStarRects.contains( QPair<int, int>( index.row(), index.column() ) ) )
    {
        QRect fullStars = m_cachedStarRects[ QPair<int, int>( index.row(), index.column() ) ];
        const int starsWidth = 5 * ( m_ratingStarPositive.width() + PADDING_BETWEEN_STARS );
        fullStars.setWidth( starsWidth );

        QMouseEvent* me = static_cast< QMouseEvent* >( event );

        if ( fullStars.contains( me->pos() ) )
        {
            const int eachStar = starsWidth / 5;
            const int clickOffset = me->pos().x() - fullStars.x();
            const int whichStar = (clickOffset / eachStar) + 1;

            if ( event->type() == QEvent::MouseButtonRelease )
            {
                model->setData( index, whichStar, GetNewStuffModel::RatingRole );
            }
            else if ( event->type() == QEvent::MouseMove )
            {
                // 0-indexed
                m_hoveringOver = whichStar;
                m_hoveringItem = index;
            }

            return true;
        }
    }

    if ( m_hoveringOver > -1 )
    {
        emit update( m_hoveringItem );
        m_hoveringOver = -1;
        m_hoveringItem = QPersistentModelIndex();
    }
    return false;
}
开发者ID:Pritoj,项目名称:tomahawk,代码行数:59,代码来源:GetNewStuffDelegate.cpp


示例11: resetCurrentPlayingModelData

inline void KNMusicNowPlaying::resetCurrentPlaying()
{
    //Reset the playing model data.
    resetCurrentPlayingModelData();
    //Clear the current playing index and the analysis item.
    m_playingIndex=QPersistentModelIndex();
    m_playingAnalysisItem=KNMusicAnalysisItem();
}
开发者ID:guoyu07,项目名称:Mu,代码行数:8,代码来源:knmusicnowplaying.cpp


示例12: beginInsertRows

QPersistentModelIndex FloatiesItemModel::addContact(qutim_sdk_0_3::Contact *contact)
{
	beginInsertRows(QModelIndex(), m_contacts.size(), m_contacts.size());
	m_contacts.append(contact);
	endInsertRows();
	QModelIndex modelIndex = index(m_contacts.size() -1, 0, QModelIndex());
	return QPersistentModelIndex(modelIndex);
}
开发者ID:AlexeyProkhin,项目名称:qutim,代码行数:8,代码来源:floatiesitemmodel.cpp


示例13: QPersistentModelIndex

QPersistentModelIndex
PlayableProxyModel::currentIndex() const
{
    if ( !m_model )
        return QPersistentModelIndex();

    return mapFromSource( m_model->currentItem() );
}
开发者ID:Teriq,项目名称:tomahawk,代码行数:8,代码来源:PlayableProxyModel.cpp


示例14: QPersistentModelIndex

void
AlbumItemDelegate::modelChanged()
{
    m_artistNameRects.clear();
    m_hoveringOver = QPersistentModelIndex();

    if ( AlbumView* view = qobject_cast< AlbumView* >( m_view ) )
        m_model = view->proxyModel();
}
开发者ID:mguentner,项目名称:tomahawk,代码行数:9,代码来源:AlbumItemDelegate.cpp


示例15: QPersistentModelIndex

QPersistentModelIndex ModelHelper::bestRepresentativeIndexFromList(const QList<QPersistentModelIndex>& list,
                                                                   const int /*sortKey*/)
{
    // this is only a stub to provide some default implementation
    if (list.isEmpty())
        return QPersistentModelIndex();

    return list.first();
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:9,代码来源:modelhelper.cpp


示例16: QPersistentModelIndex

/**
 * This implementation provides a recursive realtime search over
 * the whole channel tree. It also features delayed selection
 * with with automatic expanding of folded channels.
 */
void UserView::keyboardSearch(const QString &search) {

	if (qtSearch->isActive()) {
		qpmiSearch = QPersistentModelIndex();
		qtSearch->stop();
	}

	bool forceSkip = false;

	if (tSearch.restart() > (QApplication::keyboardInputInterval() * 1000ULL)) {
		qsSearch = QString();
		forceSkip = true;
	}

	bool isBackspace = (search.length() == 1) && (search.at(0).row() == 0) && (search.at(0).cell() == 8);
	if (isBackspace) {
		if (! qsSearch.isEmpty())
			qsSearch = qsSearch.left(qsSearch.length()-1);
	} else {
		qsSearch += search;
	}

	// Try default search (which doesn't recurse non-expanded items) and see if it returns something "valid"
	QTreeView::keyboardSearch(search);
	QModelIndex start = currentIndex();
	if (start.isValid() && model()->data(start, Qt::DisplayRole).toString().startsWith(qsSearch, Qt::CaseInsensitive))
		return;

	if (forceSkip && start.isValid())
		start = indexBelow(start);

	if (! start.isValid())
		start = model()->index(0, 0, QModelIndex());

	QModelIndexList qmil = model()->match(start, Qt::DisplayRole, qsSearch, 1, Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap | Qt::MatchRecursive));
	if (qmil.count() == 0)
		qmil = model()->match(start, Qt::DisplayRole, qsSearch, 1, Qt::MatchFlags(Qt::MatchContains | Qt::MatchWrap | Qt::MatchRecursive));

	if (qmil.isEmpty())
		return;

	QModelIndex qmi = qmil.at(0);

	QModelIndex p = qmi.parent();
	bool visible = true;
	while (visible && p.isValid()) {
		visible = visible && isExpanded(p);
		p = p.parent();
	}

	if (visible)
		selectionModel()->setCurrentIndex(qmi, QItemSelectionModel::ClearAndSelect);
	else {
		qpmiSearch = qmi;
		qtSearch->start();
	}
}
开发者ID:BuddyButterfly,项目名称:mumble,代码行数:62,代码来源:UserView.cpp


示例17: QPersistentModelIndex

void EntryDialog::addDependItem( const QAbstractItemModel* model, const QModelIndex & index, int indent)
{
    indexList << QPersistentModelIndex( index );
    QString str = QString( "%1%2" ).arg( QString().fill( ' ', indent ) ).arg( model->data( index ).toString() );
    ui->depends->addItem( str );
    
    for (int row = 0; row < model->rowCount( index ); ++row )
        addDependItem( model, model->index( row, 0, index ), indent + 2 );
}
开发者ID:KDE,项目名称:kdiagram,代码行数:9,代码来源:entrydialog.cpp


示例18: foreach

 foreach (const QPersistentModelIndex &parent, sourceParents) {
     if (!parent.isValid()) {
         parents << QPersistentModelIndex();
         continue;
     }
     const QModelIndex mappedParent = q->mapFromSource(parent);
     Q_ASSERT(mappedParent.isValid());
     parents << mappedParent;
 }
开发者ID:ske-ableton,项目名称:kitemmodels,代码行数:9,代码来源:kconcatenaterowsproxymodel.cpp


示例19: reset

void CModelRowForwardIterator::restore()
{
	if (m_indexPersist.isValid()) {
		m_indexCurrent = m_indexPersist;
		m_indexParent = m_indexCurrent.parent();
	} else {
		reset();
	}
	m_indexPersist = QPersistentModelIndex();
}
开发者ID:dewhisna,项目名称:KingJamesPureBibleSearch,代码行数:10,代码来源:ModelRowForwardIterator.cpp


示例20: Q_UNUSED

void
KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
        const QModelIndex& previous )
{
    Q_UNUSED( previous );
    if ( !current.isValid() )
        return;

    updateVariants( QPersistentModelIndex( current ) );
}
开发者ID:KaOSx,项目名称:calamares,代码行数:10,代码来源:KeyboardPage.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QPixmap函数代码示例发布时间:2022-05-30
下一篇:
C++ QPen函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap