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


C++ ItemWidget类代码示例

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


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

示例1: max_size

QWidget *ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                                    const QModelIndex &index) const
{
    ItemWidget *w = m_cache[index.row()];
    QWidget *editor = ( w != NULL) ? w->createEditor(parent) : new QPlainTextEdit(parent);
    if (editor == NULL)
        return NULL;

    editor->setPalette(m_editorPalette);
    editor->setFont(m_editorFont);
    editor->setObjectName("editor");

    // maximal editor size
    QRect w_rect = parent->contentsRect();
    QRect o_rect = option.rect;
    QSize max_size( w_rect.width() - o_rect.left() - 4,
                    w_rect.height() - o_rect.top() - 4 );
    editor->setMaximumSize(max_size);
    editor->setMinimumSize(max_size);

    connect( editor, SIGNAL(destroyed()),
             this, SLOT(editingStops()) );
    connect( editor, SIGNAL(textChanged()),
             this, SLOT(editingStarts()) );

    return editor;
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:27,代码来源:itemdelegate.cpp

示例2: startDrag

void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemModel* sourceModel, ItemView* sourceView, int count)
{
    mItem = sourceModel->getItem(index);
    mDraggedCount = count;
    mSourceModel = sourceModel;
    mSourceView = sourceView;
    mSourceSortModel = sortModel;
    mIsOnDragAndDrop = true;

    // If picking up an item that isn't from the player's inventory, the item gets added to player inventory backend
    // immediately, even though it's still floating beneath the mouse cursor. A bit counterintuitive,
    // but this is how it works in vanilla, and not doing so would break quests (BM_beasts for instance).
    ItemModel* playerModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getModel();
    if (mSourceModel != playerModel)
    {
        MWWorld::Ptr item = mSourceModel->moveItem(mItem, mDraggedCount, playerModel);

        playerModel->update();

        ItemModel::ModelIndex newIndex = -1;
        for (unsigned int i=0; i<playerModel->getItemCount(); ++i)
        {
            if (playerModel->getItem(i).mBase == item)
            {
                newIndex = i;
                break;
            }
        }
        mItem = playerModel->getItem(newIndex);
        mSourceModel = playerModel;

        SortFilterItemModel* playerFilterModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getSortFilterModel();
        mSourceSortModel = playerFilterModel;
    }

    std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
    MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);

    if (mSourceSortModel)
    {
        mSourceSortModel->clearDragItems();
        mSourceSortModel->addDragItem(mItem.mBase, count);
    }

    ItemWidget* baseWidget = MyGUI::Gui::getInstance().createWidget<ItemWidget>("MW_ItemIcon", 0, 0, 42, 42, MyGUI::Align::Default, "DragAndDrop");

    Controllers::ControllerFollowMouse* controller =
            MyGUI::ControllerManager::getInstance().createItem(Controllers::ControllerFollowMouse::getClassTypeName())
            ->castType<Controllers::ControllerFollowMouse>();
    MyGUI::ControllerManager::getInstance().addItem(baseWidget, controller);

    mDraggedWidget = baseWidget;
    baseWidget->setItem(mItem.mBase);
    baseWidget->setNeedMouseFocus(false);
    baseWidget->setCount(count);

    sourceView->update();

    MWBase::Environment::get().getWindowManager()->setDragDrop(true);
}
开发者ID:AAlderman,项目名称:openmw,代码行数:60,代码来源:draganddrop.cpp

示例3: QTreeWidgetItem

void Container::refreshView(QTreeWidget *treeView)
{
    QTreeWidgetItem *selectedItem=treeView->currentItem();
    if(this->getSelectedItem(treeView))
    {
        this->setSelectedItem(treeView,this->getSelectedItem(treeView));
    }
    treeView->clear();

    if(this->root->size()>0)
    {
        QTreeWidgetItem * treeWidgetItem = new QTreeWidgetItem(treeView);
        ItemWidget * myItem = new ItemWidget(
            this->root->getId(),
            QString( this->root->getTitle().c_str() ),
            QString( this->root->getDate().c_str() ),
            this->root->isDoneChecked(),
            -1);
        myItem->setState(false);
        treeView->setItemWidget(treeWidgetItem,0,myItem);
        this->addItemsFromList(this->root,treeView,treeWidgetItem);
    }
    if(!selectedItem&&treeView->itemAt(0,0))
    {
        this->setSelectedItem(treeView,this->root);
    }
    treeView->expandAll();
//    this->root->afficher();
//    std::cout<<std::endl;
}
开发者ID:Niiner,项目名称:PeaceTache,代码行数:30,代码来源:container.cpp

示例4: setEditorData

void ItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    ItemWidget *w = m_cache[index.row()];
    if ( w != NULL)
        w->setEditorData(editor, index);
    else
        editor->setProperty( "plainText", index.data(Qt::EditRole) );
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:8,代码来源:itemdelegate.cpp

示例5: currentIndex

void ClipboardBrowser::updateCurrentItem()
{
    const QModelIndex current = currentIndex();
    if ( current.isValid() && d.hasCache(current) ) {
        ItemWidget *item = d.cache(current);
        item->setCurrent(false);
        item->setCurrent( hasFocus() );
    }
}
开发者ID:se7entime,项目名称:CopyQ,代码行数:9,代码来源:clipboardbrowser.cpp

示例6: setModelData

void ItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                const QModelIndex &index) const
{
    ItemWidget *w = m_cache[index.row()];
    if ( w != NULL) {
        w->setModelData(editor, model, index);
    } else {
        QPlainTextEdit *textEdit = (qobject_cast<QPlainTextEdit*>(editor));
        model->setData(index, textEdit->toPlainText());
    }
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:11,代码来源:itemdelegate.cpp

示例7: onItemChanged

void ItemDelegate::onItemChanged(ItemWidget *item)
{
    for( int i = 0; i < m_cache.length(); ++i ) {
        ItemWidget *w = m_cache[i];
        if ( w != NULL && w == item ) {
            QSize oldSize = w->widget()->size();
            emit rowChanged(i, oldSize);
            return;
        }
    }
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:11,代码来源:itemdelegate.cpp

示例8: rowNumberWidth

void ItemDelegate::setItemSizes(const QSize &size, int idealWidth)
{
    const int margins = 2 * m_hMargin + rowNumberWidth();
    m_maxSize.setWidth(size.width() - margins);
    m_idealWidth = idealWidth - margins;

    for( int i = 0; i < m_cache.length(); ++i ) {
        ItemWidget *w = m_cache[i];
        if (w != NULL)
            w->updateSize(m_maxSize, m_idealWidth);
    }
}
开发者ID:GabLeRoux,项目名称:CopyQ,代码行数:12,代码来源:itemdelegate.cpp

示例9: Q_UNUSED

QWidget* UniversalItemDelegate::createEditor(
		QWidget* parent,
		const QStyleOptionViewItem& option,
		const QModelIndex& index) const {
	Q_UNUSED(option);

	editingRow = index.row();

	ItemWidget* newEditor = editor->clone(parent);
	newEditor->setIndex(index);
	return newEditor;
}
开发者ID:IgorStefanovic,项目名称:ProjekatDSP2,代码行数:12,代码来源:UniversalItemDelegate.cpp

示例10: assert

void ResolveRecipientsPage::ListWidget::addEntry( const QString& id, const QString& name, const Mailbox& mbox )
{
    assert( !widgets.contains( id ) && !items.contains( id ) );
    QListWidgetItem* item = new QListWidgetItem;
    item->setData( IdRole, id );
    ItemWidget* wid = new ItemWidget( id, name, mbox, this );
    connect( wid, SIGNAL(changed()), this, SIGNAL(completeChanged()) );
    wid->setProtocol( m_protocol );
    item->setSizeHint( wid->sizeHint() );
    m_listWidget->addItem( item );
    m_listWidget->setItemWidget( item, wid );
    widgets[id] = wid;
    items[id] = item;
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:14,代码来源:resolverecipientspage.cpp

示例11: while

void ItemView::update()
{
    while (mScrollView->getChildCount())
        MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0));

    if (!mModel)
        return;

    mModel->update();

    MyGUI::Widget* dragArea = mScrollView->createWidget<MyGUI::Widget>("",0,0,mScrollView->getWidth(),mScrollView->getHeight(),
                                                                       MyGUI::Align::Stretch);
    dragArea->setNeedMouseFocus(true);
    dragArea->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedBackground);
    dragArea->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);

    for (ItemModel::ModelIndex i=0; i<static_cast<int>(mModel->getItemCount()); ++i)
    {
        const ItemStack& item = mModel->getItem(i);

        ItemWidget* itemWidget = dragArea->createWidget<ItemWidget>("MW_ItemIcon",
            MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
        itemWidget->setUserString("ToolTipType", "ItemModelIndex");
        itemWidget->setUserData(std::make_pair(i, mModel));
        ItemWidget::ItemState state = ItemWidget::None;
        if (item.mType == ItemStack::Type_Barter)
            state = ItemWidget::Barter;
        if (item.mType == ItemStack::Type_Equipped)
            state = ItemWidget::Equip;
        itemWidget->setItem(item.mBase, state);

        itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
        itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);

        // text widget that shows item count
        // TODO: move to ItemWidget
        MyGUI::TextBox* text = itemWidget->createWidget<MyGUI::TextBox>("SandBrightText",
            MyGUI::IntCoord(5, 19, 32, 18), MyGUI::Align::Default, std::string("Label"));
        text->setTextAlign(MyGUI::Align::Right);
        text->setNeedMouseFocus(false);
        text->setTextShadow(true);
        text->setTextShadowColour(MyGUI::Colour(0,0,0));
        text->setCaption(getCountString(item.mCount));
    }

    layoutWidgets();
}
开发者ID:nthauvin,项目名称:openmw,代码行数:47,代码来源:itemview.cpp

示例12: paint

void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                         const QModelIndex &index) const
{
    int row = index.row();
    ItemWidget *w = m_cache[row];
    if (w == NULL)
        return;

    const QRect &rect = option.rect;

    bool isSelected = option.state & QStyle::State_Selected;

    /* render background (selected, alternate, ...) */
    QStyle *style = m_view->style();
    style->drawControl(QStyle::CE_ItemViewItem, &option, painter, m_view);

    /* render number */
    if (m_showRowNumber) {
        const QString num = QString::number(row);
        QPalette::ColorRole role = isSelected ? QPalette::HighlightedText : QPalette::Text;
        painter->save();
        painter->setFont(m_rowNumberFont);
        style->drawItemText(painter, rect.translated(m_hMargin / 2, m_vMargin), 0,
                            m_rowNumberPalette, true, num,
                            role);
        painter->restore();
    }

    /* highlight search string */
    w->setHighlight(m_re, m_foundFont, m_foundPalette);

    /* text color for selected/unselected item */
    QWidget *ww = w->widget();
    if ( ww->property(propertySelectedItem) != isSelected ) {
        ww->setProperty(propertySelectedItem, isSelected);
        if ( !ww->property("CopyQ_no_style").toBool() ) {
            ww->setStyle(style);
            foreach (QWidget *child, ww->findChildren<QWidget *>())
                child->setStyle(style);
            ww->update();
        }
    }
}
开发者ID:GabLeRoux,项目名称:CopyQ,代码行数:43,代码来源:itemdelegate.cpp

示例13: paint

void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                         const QModelIndex &index) const
{
    int row = index.row();

    ItemWidget *w = m_cache[row];
    if (w == NULL)
        return;

    const QRect &rect = option.rect;

    /* render background (selected, alternate, ...) */
    QStyle *style = m_parent->style();
    style->drawControl(QStyle::CE_ItemViewItem, &option, painter);
    QPalette::ColorRole role = option.state & QStyle::State_Selected ?
                QPalette::HighlightedText : QPalette::Text;

    /* render number */
    QRect numRect(0, 0, 0, 0);
    if (m_showNumber) {
        QString num = QString::number(row) + "  ";
        painter->save();
        painter->setFont(m_numberFont);
        style->drawItemText(painter, rect.translated(4, 4), 0,
                            m_numberPalette, true, num,
                            role);
        painter->restore();
        numRect = style->itemTextRect( QFontMetrics(m_numberFont), rect, 0,
                                       true, num );
    }

    /* highlight search string */
    w->setHighlight(m_re, m_foundFont, m_foundPalette);

    /* text color for selected/unselected item */
    QPalette palette = w->widget()->palette();
    palette.setColor( QPalette::Text, option.palette.color(role) );
    w->widget()->setPalette(palette);

    /* render widget */
    w->widget()->show();
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:42,代码来源:itemdelegate.cpp

示例14: QFontMetrics

void ItemDelegate::setItemMaximumSize(const QSize &size)
{
    int w = size.width() - 8;
    if (m_showNumber) {
        w -= QFontMetrics(m_numberFont).boundingRect( QString("0123") ).width();
    }

    if (m_maxSize.width() == w)
        return;

    m_maxSize.setWidth(w);

    for( int i = 0; i < m_cache.length(); ++i ) {
        ItemWidget *w = m_cache[i];
        if (w != NULL) {
            QSize oldSize = w->widget()->size();
            w->widget()->setMaximumSize(m_maxSize);
            w->updateSize();
            emit rowChanged(i, oldSize);
        }
    }
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:22,代码来源:itemdelegate.cpp

示例15: startDrag

    void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemModel* sourceModel, ItemView* sourceView, int count)
    {
        mItem = sourceModel->getItem(index);
        mDraggedCount = count;
        mSourceModel = sourceModel;
        mSourceView = sourceView;
        mSourceSortModel = sortModel;
        mIsOnDragAndDrop = true;
        mDragAndDropWidget->setVisible(true);

        std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
        MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);

        if (mSourceSortModel)
        {
            mSourceSortModel->clearDragItems();
            mSourceSortModel->addDragItem(mItem.mBase, count);
        }

        ItemWidget* baseWidget = mDragAndDropWidget->createWidget<ItemWidget>
                ("MW_ItemIcon", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
        mDraggedWidget = baseWidget;
        baseWidget->setItem(mItem.mBase);
        baseWidget->setNeedMouseFocus(false);

        // text widget that shows item count
        // TODO: move to ItemWidget
        MyGUI::TextBox* text = baseWidget->createWidget<MyGUI::TextBox>("SandBrightText",
            MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
        text->setTextAlign(MyGUI::Align::Right);
        text->setNeedMouseFocus(false);
        text->setTextShadow(true);
        text->setTextShadowColour(MyGUI::Colour(0,0,0));
        text->setCaption(ItemView::getCountString(count));

        sourceView->update();

        MWBase::Environment::get().getWindowManager()->setDragDrop(true);
    }
开发者ID:PotatoesMaster,项目名称:openmw,代码行数:39,代码来源:container.cpp


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