/src/qt3support/itemviews/q3listbox.cpp
https://bitbucket.org/ultra_iter/qt-vtl · C++ · 4687 lines · 2611 code · 575 blank · 1501 comment · 854 complexity · f544e93302cca8e745ac1e355f7324e9 MD5 · raw file
Large files are truncated click here to view the full file
- /****************************************************************************
- **
- ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the Qt3Support module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- ** GNU Lesser General Public License Usage
- ** This file may be used under the terms of the GNU Lesser General Public
- ** License version 2.1 as published by the Free Software Foundation and
- ** appearing in the file LICENSE.LGPL included in the packaging of this
- ** file. Please review the following information to ensure the GNU Lesser
- ** General Public License version 2.1 requirements will be met:
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, Nokia gives you certain additional
- ** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU General
- ** Public License version 3.0 as published by the Free Software Foundation
- ** and appearing in the file LICENSE.GPL included in the packaging of this
- ** file. Please review the following information to ensure the GNU General
- ** Public License version 3.0 requirements will be met:
- ** http://www.gnu.org/copyleft/gpl.html.
- **
- ** Other Usage
- ** Alternatively, this file may be used in accordance with the terms and
- ** conditions contained in a signed written agreement between you and Nokia.
- **
- **
- **
- **
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- #include "qglobal.h"
- #if defined(Q_CC_BOR)
- // needed for qsort() because of a std namespace problem on Borland
- #include "qplatformdefs.h"
- #endif
- #include "q3listbox.h"
- #ifndef QT_NO_LISTBOX
- #include "qapplication.h"
- #include "qevent.h"
- #include "qfontmetrics.h"
- #include "qpainter.h"
- #include "qpixmap.h"
- #include "qstringlist.h"
- #include "qstyle.h"
- #include "qstyleoption.h"
- #include "qtimer.h"
- #include "qvector.h"
- #include "qpointer.h"
- #ifndef QT_NO_ACCESSIBILITY
- #include "qaccessible.h"
- #endif
- #include <stdlib.h>
- QT_BEGIN_NAMESPACE
- class Q3ListBoxPrivate
- {
- public:
- Q3ListBoxPrivate(Q3ListBox *lb):
- head(0), last(0), cache(0), cacheIndex(-1), current(0),
- highlighted(0), tmpCurrent(0), columnPos(1), rowPos(1), rowPosCache(0),
- columnPosOne(0), rowMode(Q3ListBox::FixedNumber),
- columnMode(Q3ListBox::FixedNumber), numRows(1), numColumns(1),
- currentRow(0), currentColumn(0),
- mousePressRow(-1), mousePressColumn(-1),
- mouseMoveRow(-1), mouseMoveColumn(-1), mouseInternalPress(false),
- scrollTimer(0), updateTimer(0), visibleTimer(0),
- selectionMode(Q3ListBox::Single),
- count(0),
- listBox(lb), currInputString(QString()),
- rowModeWins(false),
- ignoreMoves(false),
- layoutDirty(true),
- mustPaintAll(true),
- dragging(false),
- dirtyDrag (false),
- variableHeight(true /* !!! ### false */),
- variableWidth(false),
- inMenuMode(false)
- {}
- int findItemByName(int item, const QString &text);
- ~Q3ListBoxPrivate();
- Q3ListBoxItem * head, *last, *cache;
- int cacheIndex;
- Q3ListBoxItem * current, *highlighted, *tmpCurrent;
- QVector<int> columnPos;
- QVector<int> rowPos;
- int rowPosCache;
- int columnPosOne;
- Q3ListBox::LayoutMode rowMode;
- Q3ListBox::LayoutMode columnMode;
- int numRows;
- int numColumns;
- int currentRow;
- int currentColumn;
- int mousePressRow;
- int mousePressColumn;
- int mouseMoveRow;
- int mouseMoveColumn;
- bool mouseInternalPress;
- QTimer * scrollTimer;
- QTimer * updateTimer;
- QTimer * visibleTimer;
- QTimer * resizeTimer;
- QPoint scrollPos;
- Q3ListBox::SelectionMode selectionMode;
- int count;
- Q3ListBox *listBox;
- QString currInputString;
- QTimer *inputTimer;
- Q3ListBoxItem *pressedItem, *selectAnchor;
- uint select :1;
- uint pressedSelected :1;
- uint rowModeWins :1;
- uint ignoreMoves :1;
- uint clearing :1;
- uint layoutDirty :1;
- uint mustPaintAll :1;
- uint dragging :1;
- uint dirtyDrag :1;
- uint variableHeight :1;
- uint variableWidth :1;
- uint inMenuMode :1;
- QRect *rubber;
- struct SortableItem {
- Q3ListBoxItem *item;
- };
- };
- Q3ListBoxPrivate::~Q3ListBoxPrivate()
- {
- Q_ASSERT(!head);
- }
- /*!
- \class Q3ListBoxItem
- \brief The Q3ListBoxItem class is the base class of all list box items.
- \compat
- This class is an abstract base class used for all list box items.
- If you need to insert customized items into a Q3ListBox you must
- inherit this class and reimplement paint(), height() and width().
- \sa Q3ListBox
- */
- /*!
- Constructs an empty list box item in the list box \a listbox.
- */
- Q3ListBoxItem::Q3ListBoxItem(Q3ListBox* listbox)
- {
- lbox = listbox;
- s = false;
- dirty = true;
- custom_highlight = false;
- selectable = true;
- p = n = 0;
- if (listbox)
- listbox->insertItem(this);
- }
- /*!
- Constructs an empty list box item in the list box \a listbox and
- inserts it after the item \a after or at the beginning if \a after
- is 0.
- */
- Q3ListBoxItem::Q3ListBoxItem(Q3ListBox* listbox, Q3ListBoxItem *after)
- {
- lbox = listbox;
- s = false;
- dirty = true;
- custom_highlight = false;
- selectable = true;
- p = n = 0;
- if (listbox)
- listbox->insertItem(this, after);
- }
- /*!
- Destroys the list box item.
- */
- Q3ListBoxItem::~Q3ListBoxItem()
- {
- if (lbox)
- lbox->takeItem(this);
- }
- /*!
- Defines whether the list box item is responsible for drawing
- itself in a highlighted state when being selected.
- If \a b is false (the default), the list box will draw some
- default highlight indicator before calling paint().
- \sa isSelected(), paint()
- */
- void Q3ListBoxItem::setCustomHighlighting(bool b)
- {
- custom_highlight = b;
- }
- /*!
- \fn void Q3ListBoxItem::paint(QPainter *p)
- Implement this function to draw your item. The painter, \a p, is
- already open for painting.
- \sa height(), width()
- */
- /*!
- \fn int Q3ListBoxItem::width(const Q3ListBox* lb) const
- Reimplement this function to return the width of your item. The \a
- lb parameter is the same as listBox() and is provided for
- convenience and compatibility.
- The default implementation returns
- \l{QApplication::globalStrut()}'s width.
- \sa paint(), height()
- */
- int Q3ListBoxItem::width(const Q3ListBox*) const
- {
- return QApplication::globalStrut().width();
- }
- /*!
- \fn int Q3ListBoxItem::height(const Q3ListBox* lb) const
- Implement this function to return the height of your item. The \a
- lb parameter is the same as listBox() and is provided for
- convenience and compatibility.
- The default implementation returns
- \l{QApplication::globalStrut()}'s height.
- \sa paint(), width()
- */
- int Q3ListBoxItem::height(const Q3ListBox*) const
- {
- return QApplication::globalStrut().height();
- }
- /*!
- Returns the text of the item. This text is also used for sorting.
- \sa setText()
- */
- QString Q3ListBoxItem::text() const
- {
- return txt;
- }
- /*!
- Returns the pixmap associated with the item, or 0 if there isn't
- one.
- The default implementation returns 0.
- */
- const QPixmap *Q3ListBoxItem::pixmap() const
- {
- return 0;
- }
- /*! \fn void Q3ListBoxItem::setSelectable(bool b)
- If \a b is true (the default) then this item can be selected by
- the user; otherwise this item cannot be selected by the user.
- \sa isSelectable()
- */
- /*! \fn bool Q3ListBoxItem::isSelectable() const
- Returns true if this item is selectable (the default); otherwise
- returns false.
- \sa setSelectable()
- */
- /*!
- \fn void Q3ListBoxItem::setText(const QString &text)
- Sets the text of the Q3ListBoxItem to \a text. This \a text is also
- used for sorting. The text is not shown unless explicitly drawn in
- paint().
- \sa text()
- */
- /*!
- \class Q3ListBoxText
- \brief The Q3ListBoxText class provides list box items that display text.
- \compat
- The text is drawn in the widget's current font. If you need
- several different fonts, you must implement your own subclass of
- Q3ListBoxItem.
- \sa Q3ListBox, Q3ListBoxItem
- */
- /*!
- Constructs a list box item in list box \a listbox showing the text
- \a text.
- */
- Q3ListBoxText::Q3ListBoxText(Q3ListBox *listbox, const QString &text)
- :Q3ListBoxItem(listbox)
- {
- setText(text);
- }
- /*!
- Constructs a list box item showing the text \a text.
- */
- Q3ListBoxText::Q3ListBoxText(const QString &text)
- :Q3ListBoxItem()
- {
- setText(text);
- }
- /*!
- Constructs a list box item in list box \a listbox showing the text
- \a text. The item is inserted after the item \a after, or at the
- beginning if \a after is 0.
- */
- Q3ListBoxText::Q3ListBoxText(Q3ListBox* listbox, const QString &text, Q3ListBoxItem *after)
- : Q3ListBoxItem(listbox, after)
- {
- setText(text);
- }
- /*!
- Destroys the item.
- */
- Q3ListBoxText::~Q3ListBoxText()
- {
- }
- /*!
- Draws the text using \a painter.
- */
- void Q3ListBoxText::paint(QPainter *painter)
- {
- int itemHeight = height(listBox());
- QFontMetrics fm = painter->fontMetrics();
- int yPos = ((itemHeight - fm.height()) / 2) + fm.ascent();
- painter->drawText(3, yPos, text());
- }
- /*!
- Returns the height of a line of text in list box \a lb.
- \sa paint(), width()
- */
- int Q3ListBoxText::height(const Q3ListBox* lb) const
- {
- int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0;
- return qMax(h, QApplication::globalStrut().height());
- }
- /*!
- Returns the width of this line in list box \a lb.
- \sa paint(), height()
- */
- int Q3ListBoxText::width(const Q3ListBox* lb) const
- {
- int w = lb ? lb->fontMetrics().width(text()) + 6 : 0;
- return qMax(w, QApplication::globalStrut().width());
- }
- /*!
- \fn int Q3ListBoxText::rtti() const
- \reimp
- Returns 1.
- Make your derived classes return their own values for rtti(), and
- you can distinguish between listbox items. You should use values
- greater than 1000 preferably a large random number, to allow for
- extensions to this class.
- */
- int Q3ListBoxText::rtti() const
- {
- return RTTI;
- }
- /*!
- \class Q3ListBoxPixmap
- \brief The Q3ListBoxPixmap class provides list box items with a
- pixmap and optional text.
- \compat
- Items of this class are drawn with the pixmap on the left with the
- optional text to the right of the pixmap.
- \sa Q3ListBox, Q3ListBoxItem
- */
- /*!
- Constructs a new list box item in list box \a listbox showing the
- pixmap \a pixmap.
- */
- Q3ListBoxPixmap::Q3ListBoxPixmap(Q3ListBox* listbox, const QPixmap &pixmap)
- : Q3ListBoxItem(listbox)
- {
- pm = pixmap;
- }
- /*!
- Constructs a new list box item showing the pixmap \a pixmap.
- */
- Q3ListBoxPixmap::Q3ListBoxPixmap(const QPixmap &pixmap)
- : Q3ListBoxItem()
- {
- pm = pixmap;
- }
- /*!
- Constructs a new list box item in list box \a listbox showing the
- pixmap \a pixmap. The item gets inserted after the item \a after,
- or at the beginning if \a after is 0.
- */
- Q3ListBoxPixmap::Q3ListBoxPixmap(Q3ListBox* listbox, const QPixmap &pixmap, Q3ListBoxItem *after)
- : Q3ListBoxItem(listbox, after)
- {
- pm = pixmap;
- }
- /*!
- Destroys the item.
- */
- Q3ListBoxPixmap::~Q3ListBoxPixmap()
- {
- }
- /*!
- Constructs a new list box item in list box \a listbox showing the
- pixmap \a pix and the text \a text.
- */
- Q3ListBoxPixmap::Q3ListBoxPixmap(Q3ListBox* listbox, const QPixmap &pix, const QString& text)
- : Q3ListBoxItem(listbox)
- {
- pm = pix;
- setText(text);
- }
- /*!
- Constructs a new list box item showing the pixmap \a pix and the
- text to \a text.
- */
- Q3ListBoxPixmap::Q3ListBoxPixmap(const QPixmap & pix, const QString& text)
- : Q3ListBoxItem()
- {
- pm = pix;
- setText(text);
- }
- /*!
- Constructs a new list box item in list box \a listbox showing the
- pixmap \a pix and the string \a text. The item gets inserted after
- the item \a after, or at the beginning if \a after is 0.
- */
- Q3ListBoxPixmap::Q3ListBoxPixmap(Q3ListBox* listbox, const QPixmap & pix, const QString& text,
- Q3ListBoxItem *after)
- : Q3ListBoxItem(listbox, after)
- {
- pm = pix;
- setText(text);
- }
- /*!
- \fn const QPixmap *Q3ListBoxPixmap::pixmap() const
- Returns the pixmap associated with the item.
- */
- /*!
- Draws the pixmap using \a painter.
- */
- void Q3ListBoxPixmap::paint(QPainter *painter)
- {
- int itemHeight = height(listBox());
- int yPos;
- const QPixmap *pm = pixmap();
- if (pm && ! pm->isNull()) {
- yPos = (itemHeight - pm->height()) / 2;
- painter->drawPixmap(3, yPos, *pm);
- }
- if (!text().isEmpty()) {
- QFontMetrics fm = painter->fontMetrics();
- yPos = ((itemHeight - fm.height()) / 2) + fm.ascent();
- painter->drawText(pm->width() + 5, yPos, text());
- }
- }
- /*!
- Returns the height of the pixmap in list box \a lb.
- \sa paint(), width()
- */
- int Q3ListBoxPixmap::height(const Q3ListBox* lb) const
- {
- int h;
- if (text().isEmpty())
- h = pm.height();
- else
- h = qMax(pm.height(), lb->fontMetrics().lineSpacing() + 2);
- return qMax(h, QApplication::globalStrut().height());
- }
- /*!
- Returns the width of the pixmap plus some margin in list box \a lb.
- \sa paint(), height()
- */
- int Q3ListBoxPixmap::width(const Q3ListBox* lb) const
- {
- if (text().isEmpty())
- return qMax(pm.width() + 6, QApplication::globalStrut().width());
- return qMax(pm.width() + lb->fontMetrics().width(text()) + 6,
- QApplication::globalStrut().width());
- }
- /*!
- \fn int Q3ListBoxPixmap::rtti() const
- \reimp
- Returns 2.
- Make your derived classes return their own values for rtti(), and
- you can distinguish between listbox items. You should use values
- greater than 1000 preferably a large random number, to allow for
- extensions to this class.
- */
- int Q3ListBoxPixmap::rtti() const
- {
- return RTTI;
- }
- /*!
- \class Q3ListBox
- \brief The Q3ListBox widget provides a list of selectable, read-only items.
- \compat
- This is typically a single-column list in which either no item or
- one item is selected, but it can also be used in many other ways.
- Q3ListBox will add scroll bars as necessary, but it isn't intended
- for \e really big lists. If you want more than a few thousand
- items, it's probably better to use a different widget mainly
- because the scroll bars won't provide very good navigation, but
- also because Q3ListBox may become slow with huge lists. (See
- Q3ListView and Q3Table for possible alternatives.)
- There are a variety of selection modes described in the
- Q3ListBox::SelectionMode documentation. The default is \l Single
- selection mode, but you can change it using setSelectionMode().
- (setMultiSelection() is still provided for compatibility with Qt
- 1.x. We recommend using setSelectionMode() in all code.)
- Because Q3ListBox offers multiple selection it must display
- keyboard focus and selection state separately. Therefore there are
- functions both to set the selection state of an item, i.e.
- setSelected(), and to set which item displays keyboard focus, i.e.
- setCurrentItem().
- The list box normally arranges its items in a single column and
- adds a vertical scroll bar if required. It is possible to have a
- different fixed number of columns (setColumnMode()), or as many
- columns as will fit in the list box's assigned screen space
- (setColumnMode(FitToWidth)), or to have a fixed number of rows
- (setRowMode()) or as many rows as will fit in the list box's
- assigned screen space (setRowMode(FitToHeight)). In all these
- cases Q3ListBox will add scroll bars, as appropriate, in at least
- one direction.
- If multiple rows are used, each row can be as high as necessary
- (the normal setting), or you can request that all items will have
- the same height by calling setVariableHeight(false). The same
- applies to a column's width, see setVariableWidth().
- The Q3ListBox's items are Q3ListBoxItem objects. Q3ListBox provides
- methods to insert new items as strings, as pixmaps, and as
- Q3ListBoxItem * (insertItem() with various arguments), and to
- replace an existing item with a new string, pixmap or Q3ListBoxItem
- (changeItem() with various arguments). You can also remove items
- singly with removeItem() or clear() the entire list box. Note that
- if you create a Q3ListBoxItem yourself and insert it, Q3ListBox
- takes ownership of the item.
- You can also create a Q3ListBoxItem, such as Q3ListBoxText or
- Q3ListBoxPixmap, with the list box as first parameter. The item
- will then append itself. When you delete an item it is
- automatically removed from the list box.
- The list of items can be arbitrarily large; Q3ListBox will add
- scroll bars if necessary. Q3ListBox can display a single-column
- (the common case) or multiple-columns, and offers both single and
- multiple selection. Q3ListBox does not support multiple-column
- items (but Q3ListView and Q3Table do), or tree hierarchies (but
- Q3ListView does).
- The list box items can be accessed both as Q3ListBoxItem objects
- (recommended) and using integer indexes (the original Q3ListBox
- implementation used an array of strings internally, and the API
- still supports this mode of operation). Everything can be done
- using the new objects, and most things can be done using indexes.
- Each item in a Q3ListBox contains a Q3ListBoxItem. One of the items
- can be the current item. The currentChanged() signal and the
- highlighted() signal are emitted when a new item becomes current,
- e.g. because the user clicks on it or Q3ListBox::setCurrentItem()
- is called. The selected() signal is emitted when the user
- double-clicks on an item or presses Enter on the current item.
- If the user does not select anything, no signals are emitted and
- currentItem() returns -1.
- A list box has Qt::WheelFocus as a default focusPolicy(), i.e. it
- can get keyboard focus by tabbing, clicking and through the use of
- the mouse wheel.
- New items can be inserted using insertItem(), insertStrList() or
- insertStringList().
- By default, vertical and horizontal scroll bars are added and
- removed as necessary. setHScrollBarMode() and setVScrollBarMode()
- can be used to change this policy.
- If you need to insert types other than strings and pixmaps, you
- must define new classes which inherit Q3ListBoxItem.
- \warning The list box assumes ownership of all list box items and
- will delete them when it does not need them any more.
- \inlineimage qlistbox-m.png Screenshot in Motif style
- \inlineimage qlistbox-w.png Screenshot in Windows style
- \sa Q3ListView, QComboBox, QButtonGroup
- */
- /*!
- \enum Q3ListBox::SelectionMode
- This enumerated type is used by Q3ListBox to indicate how it reacts
- to selection by the user.
- \value Single When the user selects an item, any already-selected
- item becomes unselected and the user cannot unselect the selected
- item. This means that the user can never clear the selection, even
- though the selection may be cleared by the application programmer
- using Q3ListBox::clearSelection().
- \value Multi When the user selects an item the selection status
- of that item is toggled and the other items are left alone.
- \value Extended When the user selects an item the selection is
- cleared and the new item selected. However, if the user presses
- the Ctrl key when clicking on an item, the clicked item gets
- toggled and all other items are left untouched. And if the user
- presses the Shift key while clicking on an item, all items between
- the current item and the clicked item get selected or unselected,
- depending on the state of the clicked item. Also, multiple items
- can be selected by dragging the mouse while the left mouse button
- is kept pressed.
- \value NoSelection Items cannot be selected.
- In other words, \c Single is a real single-selection list box, \c
- Multi is a real multi-selection list box, \c Extended is a list
- box in which users can select multiple items but usually want to
- select either just one or a range of contiguous items, and \c
- NoSelection is for a list box where the user can look but not
- touch.
- */
- /*!
- \enum Q3ListBox::LayoutMode
- This enum type is used to specify how Q3ListBox lays out its rows
- and columns.
- \value FixedNumber There is a fixed number of rows (or columns).
- \value FitToWidth There are as many columns as will fit
- on-screen.
- \value FitToHeight There are as many rows as will fit on-screen.
- \value Variable There are as many rows as are required by the
- column mode. (Or as many columns as required by the row mode.)
- Example: When you call setRowMode(FitToHeight), columnMode()
- automatically becomes \c Variable to accommodate the row mode
- you've set.
- */
- /*!
- \fn void Q3ListBox::onItem(Q3ListBoxItem *i)
- This signal is emitted when the user moves the mouse cursor onto
- an item, similar to the QWidget::enterEvent() function. \a i is
- the Q3ListBoxItem that the mouse has moved on.
- */
- // ### bug here too? enter/leave event may noit considered. move the
- // mouse out of the window and back in, to the same item - does it
- // work?
- /*!
- \fn void Q3ListBox::onViewport()
- This signal is emitted when the user moves the mouse cursor from
- an item to an empty part of the list box.
- */
- /*!
- Constructs a new empty list box called \a name and with parent \a
- parent and widget attributes \a f.
- This constructor sets the Qt::WA_StaticContent and the
- Qt::WA_NoBackground attributes to boost performance when drawing
- Q3ListBoxItems. This may be unsuitable for custom Q3ListBoxItem
- classes, in which case Qt::WA_StaticContents and Qt::WA_NoBackground
- should be cleared on the viewport() after construction.
- */
- Q3ListBox::Q3ListBox(QWidget *parent, const char *name, Qt::WindowFlags f)
- : Q3ScrollView(parent, name, f | Qt::WStaticContents | Qt::WNoAutoErase)
- {
- d = new Q3ListBoxPrivate(this);
- d->updateTimer = new QTimer(this, "listbox update timer");
- d->visibleTimer = new QTimer(this, "listbox visible timer");
- d->inputTimer = new QTimer(this, "listbox input timer");
- d->resizeTimer = new QTimer(this, "listbox resize timer");
- d->clearing = false;
- d->pressedItem = 0;
- d->selectAnchor = 0;
- d->select = false;
- d->rubber = 0;
- setMouseTracking(true);
- viewport()->setMouseTracking(true);
- connect(d->updateTimer, SIGNAL(timeout()),
- this, SLOT(refreshSlot()));
- connect(d->visibleTimer, SIGNAL(timeout()),
- this, SLOT(ensureCurrentVisible()));
- connect(d->resizeTimer, SIGNAL(timeout()),
- this, SLOT(adjustItems()));
- viewport()->setBackgroundRole(QPalette::Base);
- viewport()->setFocusProxy(this);
- viewport()->setFocusPolicy(Qt::WheelFocus);
- setFocusPolicy(Qt::WheelFocus);
- setAttribute(Qt::WA_MacShowFocusRect);
- }
- Q3ListBox * Q3ListBox::changedListBox = 0;
- /*!
- Destroys the list box. Deletes all list box items.
- */
- Q3ListBox::~Q3ListBox()
- {
- if (changedListBox == this)
- changedListBox = 0;
- clear();
- delete d;
- d = 0;
- }
- /*!
- \fn void Q3ListBox::pressed(Q3ListBoxItem *item)
- This signal is emitted when the user presses any mouse button. If
- \a item is not 0, the cursor is on \a item. If \a item is 0, the
- mouse cursor isn't on any item.
- Note that you must not delete any Q3ListBoxItem objects in slots
- connected to this signal.
- */
- /*!
- \fn void Q3ListBox::pressed(Q3ListBoxItem *item, const QPoint &pnt)
- \overload
- This signal is emitted when the user presses any mouse button. If
- \a item is not 0, the cursor is on \a item. If \a item is 0, the
- mouse cursor isn't on any item.
- \a pnt is the position of the mouse cursor in the global
- coordinate system (QMouseEvent::globalPos()).
- Note that you must not delete any Q3ListBoxItem objects in slots
- connected to this signal.
- \sa mouseButtonPressed() rightButtonPressed() clicked()
- */
- /*!
- \fn void Q3ListBox::clicked(Q3ListBoxItem *item)
- This signal is emitted when the user clicks any mouse button. If
- \a item is not 0, the cursor is on \a item. If \a item is 0, the
- mouse cursor isn't on any item.
- Note that you must not delete any Q3ListBoxItem objects in slots
- connected to this signal.
- */
- /*!
- \fn void Q3ListBox::clicked(Q3ListBoxItem *item, const QPoint &pnt)
- \overload
- This signal is emitted when the user clicks any mouse button. If
- \a item is not 0, the cursor is on \a item. If \a item is 0, the
- mouse cursor isn't on any item.
- \a pnt is the position of the mouse cursor in the global
- coordinate system (QMouseEvent::globalPos()). (If the click's
- press and release differs by a pixel or two, \a pnt is the
- position at release time.)
- Note that you must not delete any Q3ListBoxItem objects in slots
- connected to this signal.
- */
- /*!
- \fn void Q3ListBox::mouseButtonClicked (int button, Q3ListBoxItem * item, const QPoint & pos)
- This signal is emitted when the user clicks mouse button \a
- button. If \a item is not 0, the cursor is on \a item. If \a item
- is 0, the mouse cursor isn't on any item.
- \a pos is the position of the mouse cursor in the global
- coordinate system (QMouseEvent::globalPos()). (If the click's
- press and release differs by a pixel or two, \a pos is the
- position at release time.)
- Note that you must not delete any Q3ListBoxItem objects in slots
- connected to this signal.
- */
- /*!
- \fn void Q3ListBox::mouseButtonPressed (int button, Q3ListBoxItem * item, const QPoint & pos)
- This signal is emitted when the user presses mouse button \a
- button. If \a item is not 0, the cursor is on \a item. If \a item
- is 0, the mouse cursor isn't on any item.
- \a pos is the position of the mouse cursor in the global
- coordinate system (QMouseEvent::globalPos()).
- Note that you must not delete any Q3ListBoxItem objects in slots
- connected to this signal.
- */
- /*!
- \fn void Q3ListBox::doubleClicked(Q3ListBoxItem *item)
- This signal is emitted whenever an item is double-clicked. It's
- emitted on the second button press, not the second button release.
- If \a item is not 0, the cursor is on \a item. If \a item is 0,
- the mouse cursor isn't on any item.
- */
- /*!
- \fn void Q3ListBox::returnPressed(Q3ListBoxItem *item)
- This signal is emitted when Enter or Return is pressed. The
- \a item passed in the argument is currentItem().
- */
- /*!
- \fn void Q3ListBox::rightButtonClicked(Q3ListBoxItem *item, const QPoint& point)
- This signal is emitted when the right button is clicked. The \a
- item is the item that the button was clicked on (which could be
- 0 if no item was clicked on), and the \a point is where the
- click took place in global coordinates.
- */
- /*!
- \fn void Q3ListBox::rightButtonPressed (Q3ListBoxItem *item, const QPoint &point)
- 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;
- }
- #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++);
- }
- #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;
- d->mouseMoveRow = -1;
- d->mouseMoveColumn = -1;
- clearSelection();
- d->selectAnchor = 0;
- blockSignals(blocked);
- triggerUpdate(true);
- d->last = 0;
- d->clearing = false;
- }
- /*!
- Returns the text at position \a index, or an empty string if there
- is no text at that position.
- \sa pixmap()
- */
- QString Q3ListBox::text(int index) const
- {
- Q3ListBoxItem * i = item(index);
- if (i)
- return i->text();
- return QString();
- }
- /*!
- Returns a pointer to the pixmap at position \a index, or 0 if
- there is no pixmap there.
- \sa text()
- */
- const QPixmap *Q3ListBox::pixmap(int index) const
- {
- Q3ListBoxItem * i = item(index);
- if (i)
- return i->pixmap();
- return 0;
- }
- /*!
- \overload
- Replaces the item at position \a index with a new list box text
- item with text \a text.
- The operation is ignored if \a index is out of range.
- \sa insertItem(), removeItem()
- */
- void Q3ListBox::changeItem(const QString &text, int index)
- {
- if(index >= 0 && index < (int)count())
- changeItem(new Q3ListBoxText(text), index);
- }
- /*!
- \overload
- Replaces the item at position \a index with a new list box pixmap
- item with pixmap \a pixmap.
- The operation is ignored if \a index is out of range.
- \sa insertItem(), removeItem()
- */
- void Q3ListBox::changeItem(const QPixmap &pixmap, int index)
- {
- if(index >= 0 && index < (int)count())
- changeItem(new Q3ListBoxPixmap(pixmap), index);
- }
- /*!
- \overload
- Replaces the item at position \a index with a new list box pixmap
- item with pixmap \a pixmap and text \a text.
- The operation is ignored if \a index is out of range.
- \sa insertItem(), removeItem()
- */
- void Q3ListBox::changeItem(const QPixmap &pixmap, const QString &text, int index)
- {
- if(index >= 0 && index < (int)count())
- changeItem(new Q3ListBoxPixmap(pixmap, text), index);
- }
- /*!
- Replaces the item at position \a index with \a lbi. If \a index is
- negative or too large, changeItem() does nothing.
- The item that has been changed will become selected.
- \sa insertItem(), removeItem()
- */
- void Q3ListBox::changeItem(const Q3ListBoxItem *lbi, int index)
- {
- if (!lbi || index < 0 || index >= (int)count())
- return;
- removeItem(index);
- insertItem(lbi, index);
- setCurrentItem(index);
- }
- /*!
- \property Q3ListBox::numItemsVisible
- \brief the number of visible items.
- Both partially and entirely visible items are counted.
- */
- int Q3ListBox::numItemsVisible() const
- {
- doLayout();
- int columns = 0;
- int x = contentsX();
- int i=0;
- while (i < (int)d->columnPos.size()-1 &&
- d->columnPos[i] < x)
- i++;
- if (i < (int)d->columnPos.size()-1 &&
- d->columnPos[i] > x)
- columns++;
- x += visibleWidth();
- while (i < (int)d->columnPos.size()-1 &&
- d->columnPos[i] < x) {
- i++;
- columns++;
- }
- int y = contentsY();
- int rows = 0;
- while (i < (int)d->rowPos.size()-1 &&
- d->rowPos[i] < y)
- i++;
- if (i < (int)d->rowPos.size()-1 &&
- d->rowPos[i] > y)
- rows++;
- y += visibleHeight();
- while (i < (int)d->rowPos.size()-1 &&
- d->rowPos[i] < y) {
- i++;
- rows++;
- }
- return rows*columns;
- }
- int Q3ListBox::currentItem() const
- {
- if (!d->current || !d->head)
- return -1;
- return index(d->current);
- }
- /*!
- \property Q3ListBox::currentText
- \brief the text of the current item.
- This is equivalent to text(currentItem()).
- */
- /*!
- \property Q3ListBox::currentItem
- \brief the current highlighted item
- When setting this property, the highlighting is moved to the item
- and the list box scrolled as necessary.
- If no item is current, currentItem() returns -1.
- */
- void Q3ListBox::setCurrentItem(int index)
- {
- setCurrentItem(item(index));
- }
- /*!
- \reimp
- */
- QVariant Q3ListBox::inputMethodQuery(Qt::InputMethodQuery query) const
- {
- if (query == Qt::ImMicroFocus)
- return d->current ? itemRect(d->current) : QRect();
- return QWidget::inputMethodQuery(query);
- }
- /*!
- \overload
- Sets the current item to the Q3ListBoxItem \a i.
- */
- void Q3ListBox::setCurrentItem(Q3ListBoxItem * i)
- {
- if (!i || d->current == i)
- return;
- Q3ListBoxItem * o = d->current;
- d->current = i;
- int ind = index(i);
- if (i && selectionMode() == Single) {
- bool changed = false;
- if (o && o->s) {
- changed = true;
- o->s = false;
- }
- if (i && !i->s && d->selectionMode != NoSelection && i->isSelectable()) {
- i->s = true;
- changed = true;
- emit selectionChanged(i);
- #ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(viewport(), ind+1, QAccessible::StateChanged);
- #endif
- }
- if (changed) {
- emit selectionChanged();
- #ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(viewport(), 0, QAccessible::Selection);
- #endif
- }
- }
- d->currentColumn = ind / numRows();
- d->currentRow = ind % numRows();
- if (o)
- updateItem(o);
- if (i)
- updateItem(i);
- // scroll after the items are redrawn
- d->visibleTimer->start(1, true);
- QString tmp;
- if (i)
- tmp = i->text();
- emit highlighted(i);
- if (!tmp.isNull())
- emit highlighted(tmp);
- emit highlighted(ind);
- emit currentChanged(i);
- #ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(viewport(), ind+1, QAccessible::Focus);
- #endif
- }
- /*!
- Returns a pointer to the item at position \a index, or 0 if \a
- index is out of bounds.
- \sa index()
- */
- Q3ListBoxItem *Q3ListBox::item(int index) const
- {
- if (index < 0 || index > d->count -1)
- return 0;
- Q3ListBoxItem * i = d->head;
- if (d->cache && index > 0) {
- i = d->cache;
- int idx = d->cacheIndex;
- while (i && idx < index) {
- idx++;
- i = i->n;
- }
- while (i && idx > index) {
- idx--;
- i = i->p;
- }
- } else {
- int idx = index;
- while (i && idx > 0) {
- idx--;
- i = i->n;
- }
- }
- if (index > 0) {
- d->cache = i;
- d->cacheIndex = index;
- }
- return i;
- }
- /*!
- Returns the index of \a lbi, or -1 if the item is not in this list
- box or \a lbi is 0.
- \sa item()
- */
- int Q3ListBox::index(const Q3ListBoxItem * lbi) const
- {
- if (!lbi)
- return -1;
- Q3ListBoxItem * i_n = d->head;
- int c_n = 0;
- if (d->cache) {
- i_n = d->cache;
- c_n = d->cacheIndex;
- }
- Q3ListBoxItem* i_p = i_n;
- int c_p = c_n;
- while ((i_n != 0 || i_p != 0) && i_n != lbi && i_p != lbi) {
- if (i_n) {
- c_n++;
- i_n = i_n->n;
- }
- if (i_p) {
- c_p--;
- i_p = i_p->p;
- }
- }
- if (i_p == lbi)
- return c_p;
- if (i_n == lbi)
- return c_n;
- return -1;
- }
- /*!
- Returns true if the item at position \a index is at least partly
- visible; otherwise returns false.
- */
- bool Q3ListBox::itemVisible(int index)
- {
- Q3ListBoxItem * i = item(index);
- return i ? itemVisible(i) : false;
- }
- /*!
- \overload
- Returns true if \a item is at least partly visible; otherwise
- returns false.
- */
- bool Q3ListBox::itemVisible(const Q3ListBoxItem * item)
- {
- if (d->layoutDirty)
- doLayout();
- int i = index(item);
- int col = i / numRows();
- int row = i % numRows();
- return (d->columnPos[col] < contentsX()+visibleWidth() &&
- d->rowPos[row] < contentsY()+visibleHeight() &&
- d->columnPos[col+1] > contentsX() &&
- d->rowPos[row+1] > contentsY());
- }
- /*! \reimp */
- void Q3ListBox::mousePressEvent(QMouseEvent *e)
- {
- mousePressEventEx(e);
- }
- void Q3ListBox::mousePressEventEx(QMouseEvent *e)
- {
- d->mouseInternalPress = true;
- Q3ListBoxItem * i = itemAt(e->pos());
- if (!i && !d->current && d->head) {
- d->current = d->head;
- updateItem(d->head);
- }
- if (!i && (d->selectionMode != Single || e->button() == Qt::RightButton)
- && !(e->state() & Qt::ControlButton))
- clearSelection();
- d->select = d->selectionMode == Multi ? (i ? !i->isSelected() : false) : true;
- d->pressedSelected = i && i->s;
- if (i)
- d->selectAnchor = i;
- if (i) {
- switch(selectionMode()) {
- default:
- case Single:
- if (!i->s || i != d->current) {
- if (i->isSelectable())
- setSelected(i, true);
- else
- setCurrentItem(i);
- }
- break;
- case Extended:
- if (i) {
- bool shouldBlock = false;
- if (!(e->state() & Qt::ShiftButton) &&
- !(e->state() & Qt::ControlButton)) {
- if (!i->isSelected()) {
- bool b = signalsBlocked();
- blockSignals(true);
- clearSelection();
- blockSignals(b);
- }
- setSelected(i, true);
- d->dragging = true; // always assume dragging
- shouldBlock = true;
- } else if (e->state() & Qt::ShiftButton) {
- d->pressedSelected = false;
- Q3ListBoxItem *oldCurrent = item(currentItem());
- bool down = index(oldCurrent) < index(i);
- Q3ListBoxItem *lit = down ? oldCurrent : i;
- bool select = d->select;
- bool blocked = signalsBlocked();
- blockSignals(true);
- for (;; lit = lit->n) {
- if (!lit) {
- triggerUpdate(false);
- break;
- }
- if (down && lit == i) {
- setSelected(i, select);
- triggerUpdate(false);
- break;
- }
- if (!down && lit == oldCurrent) {
- setSelected(oldCurrent, select);
- triggerUpdate(false);
- break;
- }
- setSelected(lit, select);
- }
- blockSignals(blocked);
- emit selectionChanged();
- } else if (e->state() & Qt::ControlButton) {
- setSelected(i, !i->isSelected()…