⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q3iconview.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        delete itemIcon;#ifndef QT_NO_PICTURE    delete itemPic;#endif    delete d;}int Q3IconViewItem::RTTI = 0;/*!    Returns 0.    Make your derived classes return their own values for rtti(), so    that you can distinguish between icon view item types. You should    use values greater than 1000, preferably a large random number, to    allow for extensions to this class.*/int Q3IconViewItem::rtti() const{    return RTTI;}/*!    Sets \a text as the text of the icon view item. This function    might be a no-op if you reimplement text().    \sa text()*/void Q3IconViewItem::setText(const QString &text){    if (text == itemText)        return;    wordWrapDirty = true;    itemText = text;    if (itemKey.isEmpty())        itemKey = itemText;    QRect oR = rect();    calcRect();    oR = oR.united(rect());    if (view) {        if (QRect(view->contentsX(), view->contentsY(),                    view->visibleWidth(), view->visibleHeight()).             intersects(oR))            view->repaintContents(oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2);    }}/*!    Sets \a k as the sort key of the icon view item. By default    text() is used for sorting.    \sa compare()*/void Q3IconViewItem::setKey(const QString &k){    if (k == itemKey)        return;    itemKey = k;}/*!    Sets \a icon as the item's icon in the icon view. This function    might be a no-op if you reimplement pixmap().    \sa pixmap()*/void Q3IconViewItem::setPixmap(const QPixmap &icon){    if (itemIcon && itemIcon == unknown_icon)        itemIcon = 0;    if (itemIcon)        *itemIcon = icon;    else        itemIcon = new QPixmap(icon);    QRect oR = rect();    calcRect();    oR = oR.united(rect());    if (view) {        if (QRect(view->contentsX(), view->contentsY(),                    view->visibleWidth(), view->visibleHeight()).             intersects(oR))            view->repaintContents(oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2);    }}/*!    Sets \a icon as the item's icon in the icon view. This function    might be a no-op if you reimplement picture().    \sa picture()*/#ifndef QT_NO_PICTUREvoid Q3IconViewItem::setPicture(const QPicture &icon){    // clear assigned pixmap if any    if (itemIcon) {        if (itemIcon == unknown_icon) {            itemIcon = 0;        } else {            delete itemIcon;            itemIcon = 0;        }    }    if (itemPic)        delete itemPic;    itemPic = new QPicture(icon);    QRect oR = rect();    calcRect();    oR = oR.united(rect());    if (view) {        if (QRect(view->contentsX(), view->contentsY(),                    view->visibleWidth(), view->visibleHeight()).             intersects(oR))            view->repaintContents(oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2);    }}#endif/*!    \overload    Sets \a text as the text of the icon view item. If \a recalc is    true, the icon view's layout is recalculated. If \a redraw is true    (the default), the icon view is repainted.    \sa text()*/void Q3IconViewItem::setText(const QString &text, bool recalc, bool redraw){    if (text == itemText)        return;    wordWrapDirty = true;    itemText = text;    if (recalc)        calcRect();    if (redraw)        repaint();}/*!    \overload    Sets \a icon as the item's icon in the icon view. If \a recalc is    true, the icon view's layout is recalculated. If \a redraw is true    (the default), the icon view is repainted.    \sa pixmap()*/void Q3IconViewItem::setPixmap(const QPixmap &icon, bool recalc, bool redraw){    if (itemIcon && itemIcon == unknown_icon)        itemIcon = 0;    if (itemIcon)        *itemIcon = icon;    else        itemIcon = new QPixmap(icon);    if (redraw) {        if (recalc) {            QRect oR = rect();            calcRect();            oR = oR.united(rect());            if (view) {                if (QRect(view->contentsX(), view->contentsY(),                            view->visibleWidth(), view->visibleHeight()).                     intersects(oR))                    view->repaintContents(oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2);            }        } else {            repaint();        }    } else if (recalc) {        calcRect();    }}/*!    If \a allow is true, the user can rename the icon view item by    clicking on the text (or pressing F2) while the item is selected    (in-place renaming). If \a allow is false, in-place renaming is    not possible.*/void Q3IconViewItem::setRenameEnabled(bool allow){    allow_rename = (uint)allow;}/*!    If \a allow is true, the icon view permits the user to drag the    icon view item either to another position within the icon view or    to somewhere outside of it. If \a allow is false, the item cannot    be dragged.*/void Q3IconViewItem::setDragEnabled(bool allow){    allow_drag = (uint)allow;}/*!    If \a allow is true, the icon view lets the user drop something on    this icon view item.*/void Q3IconViewItem::setDropEnabled(bool allow){    allow_drop = (uint)allow;}/*!    Returns the text of the icon view item. Normally you set the text    of the item with setText(), but sometimes it's inconvenient to    call setText() for every item; so you can subclass Q3IconViewItem,    reimplement this function, and return the text of the item. If you    do this, you must call calcRect() manually each time the text    (and therefore its size) changes.    \sa setText()*/QString Q3IconViewItem::text() const{    return itemText;}/*!    Returns the key of the icon view item or text() if no key has been    explicitly set.    \sa setKey(), compare()*/QString Q3IconViewItem::key() const{    return itemKey;}/*!    Returns the icon of the icon view item if it is a pixmap, or 0 if    it is a picture. In the latter case use picture() instead.    Normally you set the pixmap of the item with setPixmap(), but    sometimes it's inconvenient to call setPixmap() for every item. So    you can subclass Q3IconViewItem, reimplement this function and    return a pointer to the item's pixmap. If you do this, you \e must    call calcRect() manually each time the size of this pixmap    changes.    \sa setPixmap()*/QPixmap *Q3IconViewItem::pixmap() const{    return itemIcon;}/*!    Returns the icon of the icon view item if it is a picture, or 0 if    it is a pixmap. In the latter case use pixmap() instead. Normally    you set the picture of the item with setPicture(), but sometimes    it's inconvenient to call setPicture() for every item. So you can    subclass Q3IconViewItem, reimplement this function and return a    pointer to the item's picture. If you do this, you \e must call    calcRect() manually each time the size of this picture changes.    \sa setPicture()*/#ifndef QT_NO_PICTUREQPicture *Q3IconViewItem::picture() const{    return itemPic;}#endif/*!    Returns true if the item can be renamed by the user with in-place    renaming; otherwise returns false.    \sa setRenameEnabled()*/bool Q3IconViewItem::renameEnabled() const{    return (bool)allow_rename;}/*!    Returns true if the user is allowed to drag the icon view item;    otherwise returns false.    \sa setDragEnabled()*/bool Q3IconViewItem::dragEnabled() const{    return (bool)allow_drag;}/*!    Returns true if the user is allowed to drop something onto the    item; otherwise returns false.    \sa setDropEnabled()*/bool Q3IconViewItem::dropEnabled() const{    return (bool)allow_drop;}/*!    Returns a pointer to this item's icon view parent.*/Q3IconView *Q3IconViewItem::iconView() const{    return view;}/*!    Returns a pointer to the previous item, or 0 if this is the first    item in the icon view.    \sa nextItem() Q3IconView::firstItem()*/Q3IconViewItem *Q3IconViewItem::prevItem() const{    return prev;}/*!    Returns a pointer to the next item, or 0 if this is the last item    in the icon view.    To find the first item use Q3IconView::firstItem().    Example:    \code    Q3IconViewItem *item;    for (item = iconView->firstItem(); item; item = item->nextItem())        do_something_with(item);    \endcode    \sa prevItem()*/Q3IconViewItem *Q3IconViewItem::nextItem() const{    return next;}/*!    Returns the index of this item in the icon view, or -1 if an error    occurred.*/int Q3IconViewItem::index() const{    if (view)        return view->index(this);    return -1;}/*!    \overload    This variant is equivalent to calling the other variant with \e cb    set to false.*/void Q3IconViewItem::setSelected(bool s){    setSelected(s, false);}/*!    Selects or unselects the item, depending on \a s; it may also    unselect other items, depending on Q3IconView::selectionMode() and    \a cb.    If \a s is false, the item is unselected.    If \a s is true and Q3IconView::selectionMode() is    Q3IconView::Single, the item is selected and the item previously    selected is unselected.    If \a s is true and Q3IconView::selectionMode() is    Q3IconView::Extended, the item is selected. If \a cb is true, the    selection state of the other items is left unchanged. If \a cb is    false (the default) all other items are unselected.    If \a s is true and Q3IconView::selectionMode() is    Q3IconView::Multi, the item is selected.    Note that \a cb is used only if Q3IconView::selectionMode() is    Q3IconView::Extended; cb defaults to false.    All items whose selection status changes repaint themselves.*/void Q3IconViewItem::setSelected(bool s, bool cb){    if (!view)        return;    if (view->selectionMode() != Q3IconView::NoSelection &&         selectable && s != (bool)selected) {        if (view->d->selectionMode == Q3IconView::Single && this != view->d->currentItem) {            Q3IconViewItem *o = view->d->currentItem;            if (o && o->selected)                o->selected = false;            view->d->currentItem = this;            if (o)                o->repaint();            emit view->currentChanged(this);        }        if (!s) {            selected = false;        } else {            if (view->d->selectionMode == Q3IconView::Single && view->d->currentItem) {                view->d->currentItem->selected = false;            }            if ((view->d->selectionMode == Q3IconView::Extended && !cb) ||                 view->d->selectionMode == Q3IconView::Single) {                bool b = view->signalsBlocked();                view->blockSignals(true);                view->selectAll(false);                view->blockSignals(b);            }            selected = s;        }        repaint();        if (!view->signalsBlocked()) {            bool emitIt = view->d->selectionMode == Q3IconView::Single && s;            Q3IconView *v = view;            emit v->selectionChanged();            if (emitIt)                emit v->selectionChanged(this);        }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -