📄 q3listbox.cpp
字号:
This signal is emitted when the right button is pressed. The \a item is the item that the button was pressed over (which could be 0 if no item was pressed over), and the \a point is where the press took place in global coordinates.*//*! \fn void Q3ListBox::contextMenuRequested(Q3ListBoxItem *item, const QPoint & pos) This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys, with \a item being the item under the mouse cursor or the current item, respectively. \a pos is the position for the context menu in the global coordinate system.*//*! \fn void Q3ListBox::selectionChanged() This signal is emitted when the selection set of a list box changes. This signal is emitted in each selection mode. If the user selects five items by drag-selecting, Q3ListBox tries to emit just one selectionChanged() signal so the signal can be connected to computationally expensive slots. \sa selected() currentItem()*//*! \fn void Q3ListBox::selectionChanged(Q3ListBoxItem *item) \overload This signal is emitted when the selection in a \l Single selection list box changes. \a item is the newly selected list box item. \sa selected() currentItem()*//*! \fn void Q3ListBox::currentChanged(Q3ListBoxItem *item) This signal is emitted when the user makes a new item the current item. \a item is the new current list box item. \sa setCurrentItem() currentItem()*//*! \fn void Q3ListBox::highlighted(int index) This signal is emitted when the user makes a new item the current item. \a index is the index of the new current item. \sa currentChanged() selected() currentItem() selectionChanged()*//*! \fn void Q3ListBox::highlighted(Q3ListBoxItem *item) \overload This signal is emitted when the user makes a new \a item the current \a item. \sa currentChanged() selected() currentItem() selectionChanged()*//*! \fn void Q3ListBox::highlighted(const QString & text) \overload This signal is emitted when the user makes a new item the current item and the item is (or has) as string. The argument is the new current item's \a text. \sa currentChanged() selected() currentItem() selectionChanged()*//*! \fn void Q3ListBox::selected(int index) This signal is emitted when the user double-clicks on an item or presses Enter on the current item. \a index is the index of the selected item. \sa currentChanged() highlighted() selectionChanged()*//*! \fn void Q3ListBox::selected(Q3ListBoxItem *item) \overload This signal is emitted when the user double-clicks on an \a item or presses Enter on the current \a item. \sa currentChanged() highlighted() selectionChanged()*//*! \fn void Q3ListBox::selected(const QString &text) \overload This signal is emitted when the user double-clicks on an item or presses Enter on the current item, and the item is (or has) a string. The argument is the \a text of the selected item. \sa currentChanged() highlighted() selectionChanged()*//*! \property Q3ListBox::count \brief the number of items in the list box*/uint Q3ListBox::count() const{ return d->count;}// ### fix before Qt 4.0#if 0/*! Inserts the string list \a list into the list at position \a index. If \a index is negative, \a list is inserted at the end of the list. If \a index is too large, the operation is ignored. \warning This function uses \c{const char *} rather than QString, so we recommend against using it. It is provided so that legacy code will continue to work, and so that programs that certainly will not need to handle code outside a single 8-bit locale can use it. See insertStringList() which uses real QStrings. \warning This function is never significantly faster than a loop around insertItem(). \sa insertItem(), insertStringList()*/void Q3ListBox::insertStrList(const QStrList *list, int index){ if (!list) { Q_ASSERT(list != 0); return; } insertStrList(*list, index);}#endif/*! Inserts the string list \a list into the list at position \a index. If \a index is negative, \a list is inserted at the end of the list. If \a index is too large, the operation is ignored. \warning This function is never significantly faster than a loop around insertItem(). \sa insertItem(), insertStrList()*/void Q3ListBox::insertStringList(const QStringList & list, int index){ if (index < 0) index = count(); for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) insertItem(new Q3ListBoxText(*it), index++);}// ### fix me#if 0/*! \overload Inserts the string list \a list into the list at position \a index. If \a index is negative, \a list is inserted at the end of the list. If \a index is too large, the operation is ignored. \warning This function uses \c{const char *} rather than QString, so we recommend against using it. It is provided so that legacy code will continue to work, and so that programs that certainly will not need to handle code outside a single 8-bit locale can use it. See insertStringList() which uses real QStrings. \warning This function is never significantly faster than a loop around insertItem(). \sa insertItem(), insertStringList()*/void Q3ListBox::insertStrList(const QStrList & list, int index){ QStrListIterator it(list); const char* txt; if (index < 0) index = count(); while ((txt=it.current())) { ++it; insertItem(new Q3ListBoxText(QString::fromLatin1(txt)), index++); } if (hasFocus() && !d->current) setCurrentItem(d->head);}#endif/*! Inserts the \a numStrings strings of the array \a strings into the list at position \a index. If \a index is negative, insertStrList() inserts \a strings at the end of the list. If \a index is too large, the operation is ignored. \warning This function uses \c{const char *} rather than QString, so we recommend against using it. It is provided so that legacy code will continue to work, and so that programs that certainly will not need to handle code outside a single 8-bit locale can use it. See insertStringList() which uses real QStrings. \warning This function is never significantly faster than a loop around insertItem(). \sa insertItem(), insertStringList()*/void Q3ListBox::insertStrList(const char **strings, int numStrings, int index){ if (!strings) { Q_ASSERT(strings != 0); return; } if (index < 0) index = count(); int i = 0; while ((numStrings<0 && strings[i]!=0) || i<numStrings) { insertItem(new Q3ListBoxText(QString::fromLatin1(strings[i])), index + i); i++; } if (hasFocus() && !d->current) setCurrentItem(d->head);}/*! Inserts the item \a lbi into the list at position \a index. If \a index is negative or larger than the number of items in the list box, \a lbi is inserted at the end of the list. \sa insertStrList()*/void Q3ListBox::insertItem(const Q3ListBoxItem *lbi, int index){ if (!lbi) return; if (index < 0) index = d->count; if (index >= d->count) { insertItem(lbi, d->last); return; } Q3ListBoxItem * item = (Q3ListBoxItem *)lbi; d->count++; d->cache = 0; item->lbox = this; if (!d->head || index == 0) { item->n = d->head; item->p = 0; d->head = item; item->dirty = true; if (item->n) item->n->p = item; } else { Q3ListBoxItem * i = d->head; while (i->n && index > 1) { i = i->n; index--; } if (i->n) { item->n = i->n; item->p = i; item->n->p = item; item->p->n = item; } else { i->n = item; item->p = i; item->n = 0; } } if (hasFocus() && !d->current) { d->current = d->head; updateItem(d->current); emit highlighted(d->current); emit highlighted(d->current->text()); emit highlighted(index); } triggerUpdate(true);}/*! \overload Inserts the item \a lbi into the list after the item \a after, or at the beginning if \a after is 0. \sa insertStrList()*/void Q3ListBox::insertItem(const Q3ListBoxItem *lbi, const Q3ListBoxItem *after){ if (!lbi) return; Q3ListBoxItem * item = (Q3ListBoxItem*)lbi; d->count++; d->cache = 0; item->lbox = this; if (!d->head || !after) { item->n = d->head; item->p = 0; d->head = item; item->dirty = true; if (item->n) item->n->p = item; } else { Q3ListBoxItem * i = (Q3ListBoxItem*) after; if (i) { item->n = i->n; item->p = i; if (item->n) item->n->p = item; if (item->p) item->p->n = item; } } if (after == d->last) d->last = (Q3ListBoxItem*) lbi; if (hasFocus() && !d->current) { d->current = d->head; updateItem(d->current); emit highlighted(d->current); emit highlighted(d->current->text()); emit highlighted(index(d->current)); } triggerUpdate(true);}/*! \overload Inserts a new list box text item with the text \a text into the list at position \a index. If \a index is negative, \a text is inserted at the end of the list. \sa insertStrList()*/void Q3ListBox::insertItem(const QString &text, int index){ insertItem(new Q3ListBoxText(text), index);}/*! \overload Inserts a new list box pixmap item with the pixmap \a pixmap into the list at position \a index. If \a index is negative, \a pixmap is inserted at the end of the list. \sa insertStrList()*/void Q3ListBox::insertItem(const QPixmap &pixmap, int index){ insertItem(new Q3ListBoxPixmap(pixmap), index);}/*! \overload Inserts a new list box pixmap item with the pixmap \a pixmap and the text \a text into the list at position \a index. If \a index is negative, \a pixmap is inserted at the end of the list. \sa insertStrList()*/void Q3ListBox::insertItem(const QPixmap &pixmap, const QString &text, int index){ insertItem(new Q3ListBoxPixmap(pixmap, text), index);}/*! Removes and deletes the item at position \a index. If \a index is equal to currentItem(), a new item becomes current and the currentChanged() and highlighted() signals are emitted. \sa insertItem(), clear()*/void Q3ListBox::removeItem(int index){ bool wasVisible = itemVisible(currentItem()); delete item(index); triggerUpdate(true); if (wasVisible) ensureCurrentVisible();}/*! Deletes all the items in the list. \sa removeItem()*/void Q3ListBox::clear(){ setContentsPos(0, 0); bool blocked = signalsBlocked(); blockSignals(true); d->clearing = true; d->current = 0; d->tmpCurrent = 0; Q3ListBoxItem * i = d->head; d->head = 0; while (i) { Q3ListBoxItem * n = i->n; i->n = i->p = 0; delete i; i = n; } d->count = 0; d->numRows = 1; d->numColumns = 1; d->currentRow = 0; d->currentColumn = 0; d->mousePressRow = -1; d->mousePressColumn = -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -