Qt 4.8
Public Functions | Public Variables | List of all members
QItemSelectionModelPrivate Class Reference

#include <qitemselectionmodel_p.h>

Inheritance diagram for QItemSelectionModelPrivate:
QObjectPrivate QObjectData

Public Functions

void _q_columnsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 Split selection ranges if columns are about to be inserted in the middle. More...
 
void _q_columnsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void _q_layoutAboutToBeChanged ()
 Split selection into individual (persistent) indexes. More...
 
void _q_layoutChanged ()
 Merge the selected indexes into selection ranges again. More...
 
void _q_rowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 Split selection ranges if rows are about to be inserted in the middle. More...
 
void _q_rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
QItemSelection expandSelection (const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) const
 
void finalize ()
 
void initModel (QAbstractItemModel *model)
 
 QItemSelectionModelPrivate ()
 
void remove (QList< QItemSelectionRange > &r)
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QItemSelectionModel::SelectionFlags currentCommand
 
QPersistentModelIndex currentIndex
 
QItemSelection currentSelection
 
QPointer< QAbstractItemModelmodel
 
QItemSelection ranges
 
QList< QPersistentModelIndexsavedPersistentCurrentIndexes
 
QList< QPersistentModelIndexsavedPersistentIndexes
 
int tableColCount
 
QPersistentModelIndex tableParent
 
int tableRowCount
 
bool tableSelected
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 61 of file qitemselectionmodel_p.h.

Constructors and Destructors

◆ QItemSelectionModelPrivate()

QItemSelectionModelPrivate::QItemSelectionModelPrivate ( )
inline

Functions

◆ _q_columnsAboutToBeInserted()

void QItemSelectionModelPrivate::_q_columnsAboutToBeInserted ( const QModelIndex parent,
int  start,
int  end 
)

Split selection ranges if columns are about to be inserted in the middle.

Warning
This function is not part of the public interface.

Definition at line 794 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

796 {
797  Q_UNUSED(end);
798  finalize();
801  for (; it != ranges.end(); ) {
802  if ((*it).isValid() && (*it).parent() == parent
803  && (*it).left() < start && (*it).right() >= start) {
804  QModelIndex bottomMiddle = model->index((*it).bottom(), start - 1, (*it).parent());
805  QItemSelectionRange left((*it).topLeft(), bottomMiddle);
806  QModelIndex topMiddle = model->index((*it).top(), start, (*it).parent());
807  QItemSelectionRange right(topMiddle, (*it).bottomRight());
808  it = ranges.erase(it);
809  split.append(left);
810  split.append(right);
811  } else {
812  ++it;
813  }
814  }
815  ranges += split;
816 }
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
The QItemSelectionRange class manages information about a range of selected items in a model...
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPointer< QAbstractItemModel > model
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
static void split(QT_FT_Vector *b)
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
The QModelIndex class is used to locate data in a data model.
static const KeyPair *const end
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ _q_columnsAboutToBeRemoved()

void QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved ( const QModelIndex parent,
int  start,
int  end 
)
Warning
This function is not part of the public interface.

Definition at line 758 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

760 {
762 
763  // update current index
764  if (currentIndex.isValid() && parent == currentIndex.parent()
765  && currentIndex.column() >= start && currentIndex.column() <= end) {
767  if (start > 0) // there are columns to the left of the change
768  currentIndex = model->index(old.row(), start - 1, parent);
769  else if (model && end < model->columnCount() - 1) // there are columns to the right of the change
770  currentIndex = model->index(old.row(), end + 1, parent);
771  else // there are no columns left in the table
773  emit q->currentChanged(currentIndex, old);
774  if (currentIndex.row() != old.row())
775  emit q->currentRowChanged(currentIndex, old);
776  emit q->currentColumnChanged(currentIndex, old);
777  }
778 
779  // update selections
780  QModelIndex tl = model->index(0, start, parent);
781  QModelIndex br = model->index(model->rowCount(parent) - 1, end, parent);
782  q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect);
783  finalize();
784 }
int row() const
Returns the row this persistent model index refers to.
The QItemSelectionModel class keeps track of a view&#39;s selected items.
int column() const
Returns the column this persistent model index refers to.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
#define Q_Q(Class)
Definition: qglobal.h:2483
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPointer< QAbstractItemModel > model
int row() const
Returns the row this model index refers to.
#define emit
Definition: qobjectdefs.h:76
QModelIndex parent() const
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no pare...
The QItemSelection class manages information about selected items in a model.
QPersistentModelIndex currentIndex
The QModelIndex class is used to locate data in a data model.
QObject * parent
Definition: qobject.h:92
static const KeyPair *const end
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.

◆ _q_layoutAboutToBeChanged()

void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged ( )

Split selection into individual (persistent) indexes.

Warning
This function is not part of the public interface.

This is done in preparation for the layoutChanged() signal, where the indexes can be merged again.

Definition at line 860 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

861 {
864 
865  // optimization for when all indexes are selected
866  // (only if there is lots of items (1000) because this is not entirely correct)
867  if (ranges.isEmpty() && currentSelection.count() == 1) {
869  QModelIndex parent = range.parent();
870  tableRowCount = model->rowCount(parent);
871  tableColCount = model->columnCount(parent);
872  if (tableRowCount * tableColCount > 1000
873  && range.top() == 0
874  && range.left() == 0
875  && range.bottom() == tableRowCount - 1
876  && range.right() == tableColCount - 1) {
877  tableSelected = true;
879  return;
880  }
881  }
882  tableSelected = false;
883 
884  QModelIndexList indexes = ranges.indexes();
886  for (it = indexes.constBegin(); it != indexes.constEnd(); ++it)
888  indexes = currentSelection.indexes();
889  for (it = indexes.constBegin(); it != indexes.constEnd(); ++it)
891 }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
int left() const
Returns the column index corresponding to the leftmost selected column in the selection range...
#define it(className, varName)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
The QItemSelectionRange class manages information about a range of selected items in a model...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
int bottom() const
Returns the row index corresponding to the lowermost selected row in the selection range...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int right() const
Returns the column index corresponding to the rightmost selected column in the selection range...
QList< QPersistentModelIndex > savedPersistentIndexes
QModelIndex parent() const
Returns the parent model item index of the items in the selection range.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QPointer< QAbstractItemModel > model
friend class const_iterator
Definition: qlist.h:264
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QPersistentModelIndex > savedPersistentCurrentIndexes
void clear()
Removes all items from the list.
Definition: qlist.h:764
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
The QPersistentModelIndex class is used to locate data in a data model.
The QModelIndex class is used to locate data in a data model.
QObject * parent
Definition: qobject.h:92
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range...
QPersistentModelIndex tableParent
QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ _q_layoutChanged()

void QItemSelectionModelPrivate::_q_layoutChanged ( )

Merge the selected indexes into selection ranges again.

Warning
This function is not part of the public interface.

Definition at line 956 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

957 {
958  // special case for when all indexes are selected
961  ranges.clear();
963  int bottom = tableRowCount - 1;
964  int right = tableColCount - 1;
965  QModelIndex tl = model->index(0, 0, tableParent);
966  QModelIndex br = model->index(bottom, right, tableParent);
969  tableSelected = false;
970  return;
971  }
972 
974  // either the selection was actually empty, or we
975  // didn't get the layoutAboutToBeChanged() signal
976  return;
977  }
978  // clear the "old" selection
979  ranges.clear();
981 
982  // sort the "new" selection, as preparation for merging
985 
986  // update the selection by merging the individual indexes
989 
990  // release the persistent indexes
993 }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
static QItemSelection mergeIndexes(const QList< QPersistentModelIndex > &indexes)
Merges indexes into an item selection made up of ranges.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
The QItemSelectionRange class manages information about a range of selected items in a model...
QList< QPersistentModelIndex > savedPersistentIndexes
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPointer< QAbstractItemModel > model
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
QList< QPersistentModelIndex > savedPersistentCurrentIndexes
void clear()
Removes all items from the list.
Definition: qlist.h:764
void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:202
The QModelIndex class is used to locate data in a data model.
QPersistentModelIndex tableParent

◆ _q_rowsAboutToBeInserted()

void QItemSelectionModelPrivate::_q_rowsAboutToBeInserted ( const QModelIndex parent,
int  start,
int  end 
)

Split selection ranges if rows are about to be inserted in the middle.

Warning
This function is not part of the public interface.

Definition at line 826 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

828 {
829  Q_UNUSED(end);
830  finalize();
833  for (; it != ranges.end(); ) {
834  if ((*it).isValid() && (*it).parent() == parent
835  && (*it).top() < start && (*it).bottom() >= start) {
836  QModelIndex middleRight = model->index(start - 1, (*it).right(), (*it).parent());
837  QItemSelectionRange top((*it).topLeft(), middleRight);
838  QModelIndex middleLeft = model->index(start, (*it).left(), (*it).parent());
839  QItemSelectionRange bottom(middleLeft, (*it).bottomRight());
840  it = ranges.erase(it);
841  split.append(top);
842  split.append(bottom);
843  } else {
844  ++it;
845  }
846  }
847  ranges += split;
848 }
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
The QItemSelectionRange class manages information about a range of selected items in a model...
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPointer< QAbstractItemModel > model
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
static void split(QT_FT_Vector *b)
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
The QModelIndex class is used to locate data in a data model.
static const KeyPair *const end
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ _q_rowsAboutToBeRemoved()

void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved ( const QModelIndex parent,
int  start,
int  end 
)
Warning
This function is not part of the public interface.

Definition at line 687 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

689 {
691  finalize();
692 
693  // update current index
694  if (currentIndex.isValid() && parent == currentIndex.parent()
695  && currentIndex.row() >= start && currentIndex.row() <= end) {
697  if (start > 0) // there are rows left above the change
698  currentIndex = model->index(start - 1, old.column(), parent);
699  else if (model && end < model->rowCount(parent) - 1) // there are rows left below the change
700  currentIndex = model->index(end + 1, old.column(), parent);
701  else // there are no rows left in the table
703  emit q->currentChanged(currentIndex, old);
704  emit q->currentRowChanged(currentIndex, old);
705  if (currentIndex.column() != old.column())
706  emit q->currentColumnChanged(currentIndex, old);
707  }
708 
709  QItemSelection deselected;
710  QItemSelection newParts;
712  while (it != ranges.end()) {
713  if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range
714  QModelIndex itParent = it->topLeft().parent();
715  while (itParent.isValid() && itParent.parent() != parent)
716  itParent = itParent.parent();
717 
718  if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) {
719  deselected.append(*it);
720  it = ranges.erase(it);
721  } else {
722  ++it;
723  }
724  } else if (start <= it->bottom() && it->bottom() <= end // Full inclusion
725  && start <= it->top() && it->top() <= end) {
726  deselected.append(*it);
727  it = ranges.erase(it);
728  } else if (start <= it->top() && it->top() <= end) { // Top intersection
729  deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent())));
730  *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight());
731  ++it;
732  } else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection
733  deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight()));
734  *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent()));
735  ++it;
736  } else if (it->top() < start && end < it->bottom()) { // Middle intersection
737  // If the parent contains (1, 2, 3, 4, 5, 6, 7, 8) and [3, 4, 5, 6] is selected,
738  // and [4, 5] is removed, we need to split [3, 4, 5, 6] into [3], [4, 5] and [6].
739  // [4, 5] is appended to deselected, and [3] and [6] remain part of the selection
740  // in ranges.
741  const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()),
742  model->index(end, it->left(), it->parent()));
743  deselected.append(removedRange);
744  QItemSelection::split(*it, removedRange, &newParts);
745  it = ranges.erase(it);
746  } else
747  ++it;
748  }
749  ranges.append(newParts);
750 
751  if (!deselected.isEmpty())
752  emit q->selectionChanged(QItemSelection(), deselected);
753 }
int row() const
Returns the row this persistent model index refers to.
The QItemSelectionModel class keeps track of a view&#39;s selected items.
#define it(className, varName)
int column() const
Returns the column this persistent model index refers to.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
The QItemSelectionRange class manages information about a range of selected items in a model...
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define Q_Q(Class)
Definition: qglobal.h:2483
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPointer< QAbstractItemModel > model
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
int row() const
Returns the row this model index refers to.
#define emit
Definition: qobjectdefs.h:76
QModelIndex parent() const
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no pare...
friend class iterator
Definition: qlist.h:226
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
The QItemSelection class manages information about selected items in a model.
QPersistentModelIndex currentIndex
The QModelIndex class is used to locate data in a data model.
QObject * parent
Definition: qobject.h:92
static void split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)
Splits the selection range using the selection other range.
static const KeyPair *const end
int column() const
Returns the column this model index refers to.
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.

◆ expandSelection()

QItemSelection QItemSelectionModelPrivate::expandSelection ( const QItemSelection selection,
QItemSelectionModel::SelectionFlags  command 
) const
Warning
This function is not part of the public interface.

returns a QItemSelection where all ranges have been expanded to: Rows: left: 0 and right: columnCount()-1 Columns: top: 0 and bottom: rowCount()-1

Definition at line 653 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModelPrivate().

655 {
656  if (selection.isEmpty() && !((command & QItemSelectionModel::Rows) ||
657  (command & QItemSelectionModel::Columns)))
658  return selection;
659 
660  QItemSelection expanded;
661  if (command & QItemSelectionModel::Rows) {
662  for (int i = 0; i < selection.count(); ++i) {
663  QModelIndex parent = selection.at(i).parent();
664  int colCount = model->columnCount(parent);
665  QModelIndex tl = model->index(selection.at(i).top(), 0, parent);
666  QModelIndex br = model->index(selection.at(i).bottom(), colCount - 1, parent);
667  //we need to merge because the same row could have already been inserted
669  }
670  }
671  if (command & QItemSelectionModel::Columns) {
672  for (int i = 0; i < selection.count(); ++i) {
673  QModelIndex parent = selection.at(i).parent();
674  int rowCount = model->rowCount(parent);
675  QModelIndex tl = model->index(0, selection.at(i).left(), parent);
676  QModelIndex br = model->index(rowCount - 1, selection.at(i).right(), parent);
677  //we need to merge because the same column could have already been inserted
679  }
680  }
681  return expanded;
682 }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)
Merges the other selection with this QItemSelection using the command given.
int left() const
Returns the column index corresponding to the leftmost selected column in the selection range...
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
int bottom() const
Returns the row index corresponding to the lowermost selected row in the selection range...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int right() const
Returns the column index corresponding to the rightmost selected column in the selection range...
QModelIndex parent() const
Returns the parent model item index of the items in the selection range.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPointer< QAbstractItemModel > model
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QItemSelection class manages information about selected items in a model.
The QModelIndex class is used to locate data in a data model.
QObject * parent
Definition: qobject.h:92
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range...

◆ finalize()

void QItemSelectionModelPrivate::finalize ( )
inline

Definition at line 89 of file qitemselectionmodel_p.h.

90  {
92  if (!currentSelection.isEmpty()) // ### perhaps this should be in QList
94  }
void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)
Merges the other selection with this QItemSelection using the command given.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QItemSelectionModel::SelectionFlags currentCommand
void clear()
Removes all items from the list.
Definition: qlist.h:764

◆ initModel()

void QItemSelectionModelPrivate::initModel ( QAbstractItemModel model)

Definition at line 625 of file qitemselectionmodel.cpp.

Referenced by QItemSelectionModel::QItemSelectionModel(), and QItemSelectionModelPrivate().

626 {
627  this->model = model;
628  if (model) {
630  QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
632  QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
634  QObject::connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
636  QObject::connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
638  QObject::connect(model, SIGNAL(layoutAboutToBeChanged()),
640  QObject::connect(model, SIGNAL(layoutChanged()),
641  q, SLOT(_q_layoutChanged()));
642  }
643 }
The QItemSelectionModel class keeps track of a view&#39;s selected items.
void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
#define SLOT(a)
Definition: qobjectdefs.h:226
void _q_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
Split selection ranges if columns are about to be inserted in the middle.
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointer< QAbstractItemModel > model
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void _q_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
Split selection ranges if rows are about to be inserted in the middle.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void _q_layoutChanged()
Merge the selected indexes into selection ranges again.
The QModelIndex class is used to locate data in a data model.
void _q_layoutAboutToBeChanged()
Split selection into individual (persistent) indexes.
void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)

◆ remove()

void QItemSelectionModelPrivate::remove ( QList< QItemSelectionRange > &  r)
inline

Definition at line 82 of file qitemselectionmodel_p.h.

83  {
85  for (; it != r.constEnd(); ++it)
86  ranges.removeAll(*it);
87  }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

Properties

◆ currentCommand

QItemSelectionModel::SelectionFlags QItemSelectionModelPrivate::currentCommand

Definition at line 100 of file qitemselectionmodel_p.h.

Referenced by finalize().

◆ currentIndex

QPersistentModelIndex QItemSelectionModelPrivate::currentIndex

Definition at line 99 of file qitemselectionmodel_p.h.

◆ currentSelection

QItemSelection QItemSelectionModelPrivate::currentSelection

Definition at line 98 of file qitemselectionmodel_p.h.

Referenced by finalize().

◆ model

QPointer<QAbstractItemModel> QItemSelectionModelPrivate::model

Definition at line 96 of file qitemselectionmodel_p.h.

Referenced by QItemSelectionModelPrivate().

◆ ranges

QItemSelection QItemSelectionModelPrivate::ranges

Definition at line 97 of file qitemselectionmodel_p.h.

Referenced by finalize(), and remove().

◆ savedPersistentCurrentIndexes

QList<QPersistentModelIndex> QItemSelectionModelPrivate::savedPersistentCurrentIndexes

Definition at line 102 of file qitemselectionmodel_p.h.

◆ savedPersistentIndexes

QList<QPersistentModelIndex> QItemSelectionModelPrivate::savedPersistentIndexes

Definition at line 101 of file qitemselectionmodel_p.h.

◆ tableColCount

int QItemSelectionModelPrivate::tableColCount

Definition at line 106 of file qitemselectionmodel_p.h.

◆ tableParent

QPersistentModelIndex QItemSelectionModelPrivate::tableParent

Definition at line 105 of file qitemselectionmodel_p.h.

◆ tableRowCount

int QItemSelectionModelPrivate::tableRowCount

Definition at line 106 of file qitemselectionmodel_p.h.

◆ tableSelected

bool QItemSelectionModelPrivate::tableSelected

Definition at line 104 of file qitemselectionmodel_p.h.


The documentation for this class was generated from the following files: