<class name="QAbstractListModel" doc="/** <p>The <a href="QAbstractListModel.html#QAbstractListModel(com.trolltech.qt.core.QObject)"><tt>QAbstractListModel</tt></a> class provides an abstract model that can be subclassed to create one-dimensional list models.</p> <p><a href="QAbstractListModel.html#QAbstractListModel(com.trolltech.qt.core.QObject)"><tt>QAbstractListModel</tt></a> provides a standard interface for models that represent their data as a simple non-hierarchical sequence of items. It is not used directly, but must be subclassed.</p> <p>Since the model provides a more specialized interface than <a href="QAbstractItemModel.html#QAbstractItemModel(com.trolltech.qt.core.QObject)"><tt>QAbstractItemModel</tt></a>, it is not suitable for use with tree views; you will need to subclass <a href="QAbstractItemModel.html#QAbstractItemModel(com.trolltech.qt.core.QObject)"><tt>QAbstractItemModel</tt></a> if you want to provide a model for that purpose. If you need to use a number of list models to manage data, it may be more appropriate to subclass <a href="%2E%2E/gui/QAbstractTableModel.html"><tt>QAbstractTableModel</tt></a> class instead.</p> <p>Simple models can be created by subclassing this class and implementing the minimum number of required functions. For example, we could implement a simple read-only <a href="%2E%2E/porting4.html#qstringlist"><tt>QStringList</tt></a>-based model that provides a list of strings to a <a href="%2E%2E/gui/QListView.html"><tt>QListView</tt></a> widget. In such a case, we only need to implement the <a href="QAbstractItemModel.html#rowCount(com.trolltech.qt.core.QModelIndex)"><tt>rowCount</tt></a> function to return the number of items in the list, and the <a href="QAbstractItemModel.html#data(com.trolltech.qt.core.QModelIndex, int)"><tt>data</tt></a> function to retrieve items from the list.</p> <p>Since the model represents a one-dimensional structure, the <a href="QAbstractItemModel.html#rowCount(com.trolltech.qt.core.QModelIndex)"><tt>rowCount</tt></a> function returns the total number of items in the model. The <a href="QAbstractListModel.html#columnCount(com.trolltech.qt.core.QModelIndex)"><tt>columnCount</tt></a> function is implemented for interoperability with all kinds of views, but by default informs views that the model contains only one column.</p> <a name="subclassing"></a> <h3>Subclassing</h3> <p><b>Note:</b> Some general guidelines for subclassing models are available in the <a href="%2E%2E/model-view-model-subclassing.html">Model Subclassing Reference</tt></a>.</p> <p>When subclassing <a href="QAbstractListModel.html#QAbstractListModel(com.trolltech.qt.core.QObject)"><tt>QAbstractListModel</tt></a>, you must provide implementations of the <a href="QAbstractItemModel.html#rowCount(com.trolltech.qt.core.QModelIndex)"><tt>rowCount</tt></a> and <a href="QAbstractItemModel.html#data(com.trolltech.qt.core.QModelIndex, int)"><tt>data</tt></a> functions. Well behaved models also provide a <a href="QAbstractItemModel.html#headerData(int, com.trolltech.qt.core.Qt.Orientation, int)"><tt>headerData</tt></a> implementation.</p> <p>For editable list models, you must also provide an implementation of <a href="QAbstractItemModel.html#setData(com.trolltech.qt.core.QModelIndex, java.lang.Object, int)"><tt>setData</tt></a>, implement the <a href="QAbstractItemModel.html#flags(com.trolltech.qt.core.QModelIndex)"><tt>flags</tt></a> function so that it returns a value containing Qt::ItemIsEditable.</p> <p>Note that <a href="QAbstractListModel.html#QAbstractListModel(com.trolltech.qt.core.QObject)"><tt>QAbstractListModel</tt></a> provides a default implementation of <a href="QAbstractListModel.html#columnCount(com.trolltech.qt.core.QModelIndex)"><tt>columnCount</tt></a> that informs views that there is only a single column of items in this model.</p> <p>Models that provide interfaces to resizable list-like data structures can provide implementations of <a href="QAbstractItemModel.html#insertRows(int, int, com.trolltech.qt.core.QModelIndex)"><tt>insertRows</tt></a> and <a href="QAbstractItemModel.html#removeRows(int, int, com.trolltech.qt.core.QModelIndex)"><tt>removeRows</tt></a>. When implementing these functions, it is important to call the appropriate functions so that all connected views are aware of any changes:</p> <ul> <li>An <a href="QAbstractItemModel.html#insertRows(int, int, com.trolltech.qt.core.QModelIndex)"><tt>insertRows</tt></a> implementation must call <a href="QAbstractItemModel.html#beginInsertRows(com.trolltech.qt.core.QModelIndex, int, int)"><tt>beginInsertRows</tt></a> <i>before</i> inserting new rows into the data structure, and it must call <a href="QAbstractItemModel.html#endInsertRows()"><tt>endInsertRows</tt></a> <i>immediately afterwards</i>.</li> <li>A <a href="QAbstractItemModel.html#removeRows(int, int, com.trolltech.qt.core.QModelIndex)"><tt>removeRows</tt></a> implementation must call <a href="QAbstractItemModel.html#beginRemoveRows(com.trolltech.qt.core.QModelIndex, int, int)"><tt>beginRemoveRows</tt></a> <i>before</i> the rows are removed from the data structure, and it must call <a href="QAbstractItemModel.html#endRemoveRows()"><tt>endRemoveRows</tt></a> <i>immediately afterwards</i>.</li> </ul> @see <a href="%2E%2E/model-view-model.html">Model Classes</tt></a> @see <a href="%2E%2E/model-view-model-subclassing.html">Model Subclassing Reference</tt></a> @see <a href="%2E%2E/gui/QAbstractItemView.html"><tt>QAbstractItemView</tt></a> @see <a href="%2E%2E/gui/QAbstractTableModel.html"><tt>QAbstractTableModel</tt></a> @see Item Views Puzzle Example</tt> */"> <signal name="protected final void dataChanged(com.trolltech.qt.core.QModelIndex topLeft, com.trolltech.qt.core.QModelIndex bottomRight)" doc="/** <p>This signal is emitted whenever the data in an existing item changes. The affected items are those between <tt>topLeft</tt> and <tt>bottomRight</tt> inclusive (of the same parent).</p> <p>Note that this signal must be emitted explicitly when reimplementing the <a href="QAbstractItemModel.html#setData(com.trolltech.qt.core.QModelIndex, java.lang.Object, int)"><tt>setData</tt></a> function.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(com.trolltech.qt.core.QModelIndex topLeft, com.trolltech.qt.core.QModelIndex bottomRight)</tt></dd> <dd><tt>void mySlot(com.trolltech.qt.core.QModelIndex topLeft)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QAbstractListModel.html#headerDataChanged(com.trolltech.qt.core.Qt.Orientation, int, int)"><tt>headerDataChanged</tt></a>, <a href="QAbstractItemModel.html#setData(com.trolltech.qt.core.QModelIndex, java.lang.Object, int)"><tt>setData</tt></a>, <a href="QAbstractListModel.html#layoutChanged()"><tt>layoutChanged</tt></a></dd> </dl> */"/> <signal name="protected final void headerDataChanged(com.trolltech.qt.core.Qt.Orientation orientation, int first, int last)" doc="/** <p>This signal is emitted whenever a header is changed. The <tt>orientation</tt> indicates whether the horizontal or vertical header has changed. The sections in the header from the <tt>first</tt> to the <tt>last</tt> need to be updated.</p> <p>Note that this signal must be emitted explicitly when reimplementing the <a href="QAbstractItemModel.html#setHeaderData(int, com.trolltech.qt.core.Qt.Orientation, java.lang.Object, int)"><tt>setHeaderData</tt></a> function.</p> <p>If you are changing the number of columns or rows you don't need to emit this signal, but use the begin/end functions.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(com.trolltech.qt.core.Qt.Orientation orientation, int first, int last)</tt></dd> <dd><tt>void mySlot(com.trolltech.qt.core.Qt.Orientation orientation, int first)</tt></dd> <dd><tt>void mySlot(com.trolltech.qt.core.Qt.Orientation orientation)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QAbstractItemModel.html#headerData(int, com.trolltech.qt.core.Qt.Orientation, int)"><tt>headerData</tt></a>, <a href="QAbstractItemModel.html#setHeaderData(int, com.trolltech.qt.core.Qt.Orientation, java.lang.Object, int)"><tt>setHeaderData</tt></a>, <a href="QAbstractListModel.html#dataChanged(com.trolltech.qt.core.QModelIndex, com.trolltech.qt.core.QModelIndex)"><tt>dataChanged</tt></a></dd> </dl> */"/> <signal name="protected final void layoutAboutToBeChanged()" doc="/** <p>This signal is emitted just before the layout of a model is changed. Components connected to this signal use it to adapt to changes in the model's layout.</p> <p>Subclasses should update any persistent model indexes after emitting <a href="QAbstractListModel.html#layoutAboutToBeChanged()"><tt>layoutAboutToBeChanged</tt></a>.</p> <dl> <dt><b>Compatible Slot Signature:</b></dt> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QAbstractListModel.html#layoutChanged()"><tt>layoutChanged</tt></a>, <a href="QAbstractItemModel.html#changePersistentIndex(com.trolltech.qt.core.QModelIndex, com.trolltech.qt.core.QModelIndex)"><tt>changePersistentIndex</tt></a></dd> </dl> */"/> <signal name="protected final void layoutChanged()" doc="/** <p>This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. When this signal is received by a view, it should update the layout of items to reflect this change.</p> <p>When subclassing <a href="QAbstractItemModel.html#QAbstractItemModel(com.trolltech.qt.core.QObject)"><tt>QAbstractItemModel</tt></a> or <a href="%2E%2E/gui/QAbstractProxyModel.html"><tt>QAbstractProxyModel</tt></a>, ensure that you emit <a href="QAbstractListModel.html#layoutAboutToBeChanged()"><tt>layoutAboutToBeChanged</tt></a> before changing the order of items or altering the structure of the data you expose to views, and emit <a href="QAbstractListModel.html#layoutChanged()"><tt>layoutChanged</tt></a> after changing the layout.</p> <p>Subclasses should update any persistent model indexes before emitting <a href="QAbstractListModel.html#layoutChanged()"><tt>layoutChanged</tt></a>.</p> <dl> <dt><b>Compatible Slot Signature:</b></dt> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QAbstractListModel.html#layoutAboutToBeChanged()"><tt>layoutAboutToBeChanged</tt></a>, <a href="QAbstractListModel.html#dataChanged(com.trolltech.qt.core.QModelIndex, com.trolltech.qt.core.QModelIndex)"><tt>dataChanged</tt></a>, <a href="QAbstractListModel.html#headerDataChanged(com.trolltech.qt.core.Qt.Orientation, int, int)"><tt>headerDataChanged</tt></a>, <a href="QAbstractItemModel.html#reset()"><tt>reset</tt></a>, <a href="QAbstractItemModel.html#changePersistentIndex(com.trolltech.qt.core.QModelIndex, com.trolltech.qt.core.QModelIndex)"><tt>changePersistentIndex</tt></a></dd> </dl> */"/> <method name="public QAbstractListModel(com.trolltech.qt.core.QObject parent)" doc="/** <p>Constructs an abstract list model with the given <tt>parent</tt>.</p> */"/> <method name="public QAbstractListModel()" doc="/** <p>Equivalent to <a href="QAbstractListModel.html#QAbstractListModel(com.trolltech.qt.core.QObject)"><tt>QAbstractListModel</tt></a>(0). */"/> <method name="public @Deprecated public final int columnCount(com.trolltech.qt.core.QModelIndex parent)" doc="/** <p>This function is reimplemented for internal reasons.</p> @see <a href="QAbstractItemModel.html#rowCount(com.trolltech.qt.core.QModelIndex)"><tt>rowCount</tt></a> */"/> <method name="public @Deprecated public final boolean hasChildren(com.trolltech.qt.core.QModelIndex parent)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="public @Deprecated public final com.trolltech.qt.core.QModelIndex parent(com.trolltech.qt.core.QModelIndex child)" doc="/** <p>This function is reimplemented for internal reasons.</p> @see <a href="QAbstractListModel.html#index(int, int, com.trolltech.qt.core.QModelIndex)"><tt>index</tt></a> @see <a href="QAbstractListModel.html#hasChildren(com.trolltech.qt.core.QModelIndex)"><tt>hasChildren</tt></a> */"/> <method name="public boolean dropMimeData(com.trolltech.qt.gui.QMimeData data, com.trolltech.qt.core.Qt.DropAction action, int row, int column, com.trolltech.qt.core.QModelIndex parent)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="public com.trolltech.qt.core.QModelIndex index(int row, int column, com.trolltech.qt.core.QModelIndex parent)" doc="/** <p>Returns the index of the data in <tt>row</tt> and <tt>column</tt> with <tt>parent</tt>.</p> @see <a href="QAbstractListModel.html#parent(com.trolltech.qt.core.QModelIndex)"><tt>parent</tt></a> */"/> <method name="public final com.trolltech.qt.core.QModelIndex index(int row, int column)" doc="/** <p>Equivalent to <a href="QAbstractListModel.html#index(int, int, com.trolltech.qt.core.QModelIndex)">index</tt></a>(<tt>row</tt>, <tt>column</tt>, QModelIndex()). */"/> <method name="public final com.trolltech.qt.core.QModelIndex index(int row)" doc="/** <p>Equivalent to <a href="QAbstractListModel.html#index(int, int, com.trolltech.qt.core.QModelIndex)">index</tt></a>(<tt>row</tt>, 0, QModelIndex()). */"/> </class>