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


C++ QPersistentModelIndex函数代码示例

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


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


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