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


C++ TreeModelItem类代码示例

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


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

示例1: qDebug

void
ArtistView::onScrollTimeout()
{
    qDebug() << Q_FUNC_INFO;
    if ( m_timer.isActive() )
        m_timer.stop();

    QModelIndex left = indexAt( viewport()->rect().topLeft() );
    while ( left.isValid() && left.parent().isValid() )
        left = left.parent();

    QModelIndex right = indexAt( viewport()->rect().bottomLeft() );
    while ( right.isValid() && right.parent().isValid() )
        right = right.parent();

    int max = m_proxyModel->trackCount();
    if ( right.isValid() )
        max = right.row() + 1;

    for ( int i = left.row(); i < max; i++ )
    {
        TreeModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( m_proxyModel->index( i, 0 ) ) );

        Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
        trackInfo["artist"] = item->artist()->name();
        trackInfo["pptr"] = QString::number( (qlonglong)item );

        Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
            s_tmInfoIdentifier, Tomahawk::InfoSystem::InfoArtistImages,
            QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
    }
}
开发者ID:pauloppenheim,项目名称:tomahawk,代码行数:32,代码来源:artistview.cpp

示例2: itemFromIndex

bool
TreeModel::hasChildren( const QModelIndex& parent ) const
{
    TreeModelItem* parentItem = itemFromIndex( parent );
    if ( !parentItem )
        return false;

    if ( parentItem == m_rootItem )
        return true;

    return ( !parentItem->artist().isNull() || !parentItem->album().isNull() );
}
开发者ID:seezer,项目名称:tomahawk,代码行数:12,代码来源:TreeModel.cpp

示例3: is_logged_in

int OtrInternal::is_logged_in(const char *accountname, const char *protocol,
                              const char *recipient)
{
	TreeModelItem item;
	item.m_protocol_name = QString::fromUtf8(protocol);
	item.m_account_name = QString::fromUtf8(accountname);
	item.m_item_name = QString::fromUtf8(recipient);
	Buddy *buddy = item.unit();
	if (buddy && buddy->status() != Status::Offline)
		return 1;
	else
		return 0;
}
开发者ID:dganic,项目名称:qutim,代码行数:13,代码来源:otrinternal.cpp

示例4: itemFromIndex

void
TreeModel::removeIndex( const QModelIndex& index )
{
    if ( index.column() > 0 )
        return;

    TreeModelItem* item = itemFromIndex( index );
    if ( item )
    {
        DownloadManager::instance()->removeJob( item->job() );
        emit beginRemoveRows( index.parent(), index.row(), index.row() );
        delete item;
        emit endRemoveRows();
    }
}
开发者ID:emusic-eng,项目名称:DLM-6,代码行数:15,代码来源:treemodel.cpp

示例5: connect

void
TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int /* end */ )
{
    if ( m_filter.isEmpty() )
        return;
    if ( sender() != m_model )
        return;

    TreeModelItem* pi = m_model->itemFromIndex( m_model->index( parent.row(), 0, parent.parent() ) );
    if ( pi->artist().isNull() )
        return;

    DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_model->collection() );
    cmd->setArtist( pi->artist() );
    cmd->setFilter( m_filter );

    connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
                    SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );

    Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
开发者ID:MechanisM,项目名称:tomahawk,代码行数:21,代码来源:treeproxymodel.cpp

示例6: itemFromIndex

void
TreeModel::getCover( const QModelIndex& index )
{
    TreeModelItem* item = itemFromIndex( index );
    if ( !item->cover.isNull() )
        return;

    Tomahawk::InfoSystem::InfoStringHash trackInfo;
    Tomahawk::InfoSystem::InfoRequestData requestData;

    if ( !item->artist().isNull() )
    {
        trackInfo["artist"] = item->artist()->name();
        requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
    }
    else if ( !item->album().isNull() )
    {
        trackInfo["artist"] = item->album()->artist()->name();
        trackInfo["album"] = item->album()->name();
        requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
    }
    else
        return;

    trackInfo["pptr"] = QString::number( (qlonglong)item );
    m_coverHash.insert( (qlonglong)item, index );

    requestData.caller = m_infoId;
    requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
    requestData.customData = QVariantMap();
    Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
开发者ID:chakra-project,项目名称:tomahawk,代码行数:32,代码来源:treemodel.cpp

示例7: qDebug

void
TreeModel::setCurrentItem( const QModelIndex& index )
{
    qDebug() << Q_FUNC_INFO;

    TreeModelItem* oldEntry = itemFromIndex( m_currentIndex );
    if ( oldEntry )
    {
        oldEntry->setIsPlaying( false );
    }

    TreeModelItem* entry = itemFromIndex( index );
    if ( entry )
    {
        m_currentIndex = index;
        entry->setIsPlaying( true );
    }
    else
    {
        m_currentIndex = QModelIndex();
    }
}
开发者ID:seezer,项目名称:tomahawk,代码行数:22,代码来源:TreeModel.cpp

示例8: qDebug

void TreeModel::addItem(QString label, QVariantList data, QString path)
{
    qDebug() << "Adding item" << label << path;

    if (data.count() != m_roles.count())
        qDebug() << "Adding an item with a different number of roles" << data.count() << m_roles.count();

    if (path.isEmpty())
    {
        TreeModelItem *item = new TreeModelItem(label);
        QQmlEngine::setObjectOwnership(item, QQmlEngine::CppOwnership);
        item->setData(data);
        int addIndex = getItemIndex(label);
        beginInsertRows(QModelIndex(), addIndex, addIndex);
        m_items.insert(addIndex, item);
        endInsertRows();
    }
    else
    {
        TreeModelItem *item = NULL;
        QStringList pathList = path.split("/");
        if (m_itemsPathMap.contains(pathList.at(0)))
        {
            item = m_itemsPathMap[pathList.at(0)];
        }
        else
        {
            item = new TreeModelItem(pathList.at(0));
            item->setPath(pathList.at(0));
            QQmlEngine::setObjectOwnership(item, QQmlEngine::CppOwnership);
            if (item->setChildrenColumns(m_roles) == true)
            {
                connect(item->children(), SIGNAL(singleSelection(TreeModelItem*)),
                        this, SLOT(setSingleSelection(TreeModelItem*)));
                qDebug() << "Tree" << this << "connected to tree" << item->children();
            }

            int addIndex = getFolderIndex(label);
            beginInsertRows(QModelIndex(), addIndex, addIndex);
            m_items.insert(addIndex, item);
            endInsertRows();
            m_itemsPathMap[pathList.at(0)] = item;
        }

        if (pathList.count() == 1)
        {
            if (item->addChild(label, data, m_sorting) == true)
            {
                connect(item->children(), SIGNAL(singleSelection(TreeModelItem*)),
                        this, SLOT(setSingleSelection(TreeModelItem*)));
                qDebug() << "Tree" << this << "connected to tree" << item->children();
            }
        }
开发者ID:alainsauvanet,项目名称:qlcplus,代码行数:53,代码来源:treemodel.cpp

示例9: if

void
ArtistView::onItemActivated( const QModelIndex& index )
{
    TreeModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
    if ( item )
    {
        if ( !item->artist().isNull() )
            ViewManager::instance()->show( item->artist() );
        else if ( !item->album().isNull() )
            ViewManager::instance()->show( item->album(), m_model->mode() );
        else if ( !item->result().isNull() && item->result()->isOnline() )
        {
            m_model->setCurrentItem( item->index );
            AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->result() );
        }
    }
}
开发者ID:excieve,项目名称:tomahawk,代码行数:17,代码来源:artistview.cpp

示例10: addFunctionTreeItem

void FunctionManager::addFunctionTreeItem(Function *func)
{
    if (func == NULL || func->isVisible() == false)
        return;

    bool expandAll = m_searchFilter.length() >= SEARCH_MIN_CHARS;

    QQmlEngine::setObjectOwnership(func, QQmlEngine::CppOwnership);

    if ((m_filter == 0 || m_filter & func->type()) &&
        (m_searchFilter.length() < SEARCH_MIN_CHARS || func->name().toLower().contains(m_searchFilter)))
    {
        QVariantList params;
        params.append(QVariant::fromValue(func));
        QString fPath = func->path(true).replace("/", TreeModel::separator());
        TreeModelItem *item = m_functionTree->addItem(func->name(), params, fPath, expandAll ? TreeModel::Expanded : 0);
        if (m_selectedIDList.contains(QVariant(func->id())))
            item->setFlag(TreeModel::Selected, true);
    }

    switch (func->type())
    {
        case Function::SceneType: m_sceneCount++; break;
        case Function::ChaserType: m_chaserCount++; break;
        case Function::SequenceType: m_sequenceCount++; break;
        case Function::EFXType: m_efxCount++; break;
        case Function::CollectionType: m_collectionCount++; break;
        case Function::RGBMatrixType: m_rgbMatrixCount++; break;
        case Function::ScriptType: m_scriptCount++; break;
        case Function::ShowType: m_showCount++; break;
        case Function::AudioType: m_audioCount++; break;
        case Function::VideoType: m_videoCount++; break;
        default:
        break;
    }
}
开发者ID:ming-hai,项目名称:qlcplus,代码行数:36,代码来源:functionmanager.cpp

示例11: if

void
ArtistView::onItemActivated( const QModelIndex& index )
{
    TreeModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
    if ( item )
    {
        if ( !item->artist().isNull() )
            ViewManager::instance()->show( item->artist() );
        else if ( !item->album().isNull() )
            ViewManager::instance()->show( item->album() );
        else if ( !item->result().isNull() )
            AudioEngine::instance()->playItem( 0, item->result() );
    }
}
开发者ID:pauloppenheim,项目名称:tomahawk,代码行数:14,代码来源:artistview.cpp

示例12: indexAt

void
ArtistView::onCustomContextMenu( const QPoint& pos )
{
    m_contextMenu->clear();

    QModelIndex idx = indexAt( pos );
    idx = idx.sibling( idx.row(), 0 );
    m_contextMenuIndex = idx;

    if ( !idx.isValid() )
        return;

    QList<query_ptr> queries;
    QList<artist_ptr> artists;
    QList<album_ptr> albums;

    foreach ( const QModelIndex& index, selectedIndexes() )
    {
        if ( index.column() || selectedIndexes().contains( index.parent() ) )
            continue;

        TreeModelItem* item = m_proxyModel->itemFromIndex( m_proxyModel->mapToSource( index ) );

        if ( item && !item->result().isNull() )
            queries << item->result()->toQuery();
        else if ( item && !item->query().isNull() )
            queries << item->query();
        if ( item && !item->artist().isNull() )
            artists << item->artist();
        if ( item && !item->album().isNull() )
            albums << item->album();
    }

    m_contextMenu->setQueries( queries );
    m_contextMenu->setArtists( artists );
    m_contextMenu->setAlbums( albums );

    m_contextMenu->exec( mapToGlobal( pos ) );
}
开发者ID:excieve,项目名称:tomahawk,代码行数:39,代码来源:artistview.cpp

示例13: sendCustomNessage

void OtrInternal::sendCustomNessage(TreeModelItem &item, QString msg)
{
	Message message;
	message.setChatUnit(item.unit());
	message.setProperty("service", true);
	message.setProperty("store", false);
	message.setIncoming(true);
	message.setText(msg);
	ChatLayer::get(message.chatUnit(), true)->append(message);
	
//    msg.replace("<b>"," ");
//    msg.replace("</b>"," ");
//    msg.replace("<i>"," ");
//    msg.replace("</i>"," ");
//    m_plugin->addServiceMessage(item,msg);
//    m_plugin->systemNotification(item,msg);
}
开发者ID:dganic,项目名称:qutim,代码行数:17,代码来源:otrinternal.cpp

示例14: startSession

//-----------------------------------------------------------------------------
void OtrInternal::startSession(const QString& account, const QString& jid, TreeModelItem &item, int pol)
{
    Q_UNUSED(jid);
    OtrlPolicy policy = (OtrlPolicy)pol;
    char fingerprint[45];
    if (!otrl_privkey_fingerprint(m_userstate, fingerprint,
                                  account.toStdString().c_str(),
                                  item.m_protocol_name.toStdString().c_str()))
    {
        create_privkey(account.toStdString().c_str(), item.m_protocol_name.toStdString().c_str());
    }
    if (!otrl_privkey_fingerprint(m_userstate, fingerprint,
                                  account.toStdString().c_str(),
                                  item.m_protocol_name.toStdString().c_str()))
        return;

    //TODO: make allowed otr versions configureable
    char* msg = otrl_proto_default_query_msg(account.toStdString().c_str(),
                                             policy);

	item.unit()->send(QString::fromUtf8(msg));
	free(msg);
}
开发者ID:dganic,项目名称:qutim,代码行数:24,代码来源:otrinternal.cpp

示例15: if

void
TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    TreeModelItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
    if ( !item )
        return;

    QString text;
    if ( !item->artist().isNull() )
    {
        text = item->artist()->name();
    }
    else if ( !item->album().isNull() )
    {
        text = item->album()->name();
    }
    else if ( !item->result().isNull() || !item->query().isNull() )
    {
        float opacity = item->result().isNull() ? 0.0 : item->result()->score();
        opacity = qMax( (float)0.3, opacity );
        QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity );

        {
            QStyleOptionViewItemV4 o = option;
            initStyleOption( &o, QModelIndex() );

            painter->save();
            o.palette.setColor( QPalette::Text, textColor );

            if ( o.state & QStyle::State_Selected && o.state & QStyle::State_Active )
            {
                o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
            }

            if ( item->isPlaying() )
            {
                o.palette.setColor( QPalette::Highlight, o.palette.color( QPalette::Mid ) );
                if ( o.state & QStyle::State_Selected )
                    o.palette.setColor( QPalette::Text, textColor );
                o.state |= QStyle::State_Selected;
            }

            int oldX = 0;
            if ( m_view->header()->visualIndex( index.column() ) == 0 )
            {
                oldX = o.rect.x();
                o.rect.setX( 0 );
            }
            qApp->style()->drawControl( QStyle::CE_ItemViewItem, &o, painter );
            if ( oldX > 0 )
                o.rect.setX( oldX );

            {
                QRect r = o.rect.adjusted( 3, 0, 0, 0 );

                // Paint Now Playing Speaker Icon
                if ( item->isPlaying() && m_view->header()->visualIndex( index.column() ) == 0 )
                {
                    r.adjust( 0, 0, 0, -3 );
                    painter->drawPixmap( r.adjusted( 3, 1, 18 - r.width(), 1 ), m_nowPlayingIcon );
                    r.adjust( 25, 0, 0, 3 );
                }

                painter->setPen( o.palette.text().color() );

                QTextOption to( Qt::AlignVCenter );
                QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
                painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, to );
            }
            painter->restore();
        }

        return;
    }
    else
        return;

    if ( text.trimmed().isEmpty() )
        text = tr( "Unknown" );

    QStyleOptionViewItemV4 opt = option;
    initStyleOption( &opt, QModelIndex() );
    qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );

    if ( option.state & QStyle::State_Selected )
    {
        opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
    }

    if ( index.column() > 0 )
        return;

    painter->save();
    painter->setRenderHint( QPainter::Antialiasing );
    painter->setPen( opt.palette.color( QPalette::Text ) );

    QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 );
//    painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );

    QPixmap cover;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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