2 #ifndef __libquark_gui_AbstractGridModel_hxx 3 #define __libquark_gui_AbstractGridModel_hxx 5 #include <QAbstractItemModel> 31 template<
class T,
class IS = QDataStream,
class OS = QDataStream>
43 virtual int rowCount(
const QModelIndex &
parent = QModelIndex())
const;
46 virtual QVariant
data(
const QModelIndex &
index,
int role = Qt::DisplayRole)
50 virtual bool setData(
const QModelIndex &index,
const QVariant &value,
51 int role = Qt::EditRole);
57 virtual QVariant
headerData(
int section, Qt::Orientation orientation,
58 int role = Qt::DisplayRole)
const;
61 virtual QModelIndex
index(
int row,
int column,
62 const QModelIndex &
parent = QModelIndex())
const;
65 virtual QModelIndex
parent(
const QModelIndex &index)
const;
68 virtual Qt::ItemFlags
flags(
const QModelIndex &index)
const;
74 virtual QMimeData *
mimeData(
const QModelIndexList &indexes)
const;
77 virtual bool dropMimeData(
const QMimeData *mimeData, Qt::DropAction action,
78 int row,
int column,
const QModelIndex &parent);
123 void setItemAt(T *item,
int row,
int column);
182 virtual QPoint
positionOf(
const T *item)
const = 0;
201 virtual QVariant
getValue(
const T &item)
const = 0;
227 virtual QIcon
getIcon(
const T &item)
const;
230 virtual QSize
getSize(
const T &item)
const;
242 virtual void setValue(T *item,
const QVariant &value);
245 virtual void setChecked(T *item,
bool checked);
254 virtual bool isChecked(
const T &item)
const;
284 virtual T *
getAt(
int row,
int column)
const = 0;
287 virtual T *
takeAt(
int row,
int column) = 0;
290 virtual void setAt(T *item,
int row,
int column) = 0;
296 virtual void resizeData(
int rows,
int columns) = 0;
312 Qt::DropAction action,
int row,
313 int column,
const QModelIndex &parent);
341 virtual void writeItem(
const T &item, OS &stream)
const;
387 #include <quark/AbstractGridModelImpl.h++> 392 #endif // __libquark_gui_AbstractGridModel_hxx bool isEditable() const
Tests the editability of the model.
int columns() const
Returns the number of columns in the model.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Specified by QAbstractItemModel.
virtual void readProlog(IS &stream)
Reads any necessary prolog (e.g., an XML open-tag) when deserializing items that are being dropped in...
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Specified by QAbstractItemModel.
virtual Qt::AlignmentFlag getColumnHeaderAlignment() const
Returns the preferred column (horizontal) header label alignment.
virtual void writeEpilog(OS &stream) const
Writes any necessary epilog (e.g., an XML close-tag) when serializing items to be dragged out of the ...
int rows() const
Returns the number of rows in the model.
virtual QModelIndex parent(const QModelIndex &index) const
Specified by QAbstractItemModel.
virtual void itemAdded(const T *item)
Called when an item has been added to the model.
virtual QSize getSize(const T &item) const
Returns the preferred display size of a given item, if any.
T * takeItemAt(int row, int column)
Removes and returns the item at the specified row and column.
virtual void writeProlog(OS &stream) const
Writes any necessary prolog (e.g., an XML open-tag) when serializing items to be dragged out of the m...
void removeItemAt(int row, int column)
Removes and deletes the item at the specified row and column.
virtual QString itemMimeType() const =0
Returns the model's native MIME-type.
bool setItems(QList< T *> items)
Populates the model with items from a QList.
virtual void writeItem(const T &item, OS &stream) const
Serializes an item that is being dragged out of the model.
T * getItemAt(int row, int column) const
Returns the item at the specified row and column.
virtual bool isChecked(const T &item) const
Tests if a given item is currently checked.
virtual QPoint positionOf(const T *item) const =0
Returns the row and column position of the given item in the model.
virtual void readEpilog(IS &stream)
Reads any necessary epilog (e.g., an XML close-tag) when deserializing items that are being dropped i...
virtual bool isDraggable(const T &item) const
Tests if a given item can be dragged.
virtual T * readItem(IS &stream)
Deserializes an item that is being dropped into the model.
virtual T * takeAt(int row, int column)=0
Removes and returns the item at the given row and column.
void resize(int rows, int columns)
Resizes the model.
AbstractGridModel(QObject *parent=NULL)
Constructor.
virtual ~AbstractGridModel()
Destructor.
virtual bool dropOtherMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Handles the dropping of MIME data with a MIME-type that is supported by (but not native to) this mode...
virtual void setChecked(T *item, bool checked)
Sets the checked state of a checkable item.
virtual void setAt(T *item, int row, int column)=0
Sets the item at the given row and column.
virtual void itemUpdated(const T &item)
Called when an item has been updated in the model.
virtual bool isDroppable(const T &item) const
Tests if a given item can be dropped onto.
virtual void itemRemoved(const T &item)
Called when an item is about to be removed from the model.
Definition: BarChartView.h++:6
virtual T * getAt(int row, int column) const =0
Returns the item at the given row and column.
virtual void resizeData(int rows, int columns)=0
Resizes the model.
virtual QStringList otherMimeTypes() const
Returns a list of additional MIME-types that can be dropped onto the model.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Specified by QAbstractItemModel.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
void updateItemAt(int row, int column)
Notifies the model that the item at the given position has changed in some way.
void updateItem(T *item)
Notifies the model that the given item has changed in some way.
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
void setEditable(bool editable)
Sets the editability of the model.
int itemCount() const
Returns the number of items in the model.
virtual Qt::AlignmentFlag getRowHeaderAlignment() const
Returns the preferred row (vertical) header label alignment.
bool isCellEmpty(int row, int column) const
Tests if the given cell of the model is empty.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Specified by QAbstractItemModel.
void setItemAt(T *item, int row, int column)
Sets an item at the specified row and column.
virtual Qt::AlignmentFlag getValueAlignment(const T &item) const
Returns the preferred alignment of a given item.
virtual QString getColumnName(int column) const
Returns the name of the given column.
virtual bool isEmptyDroppable() const
Tests if an empty cell can be dropped onto.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Specified by QAbstractItemModel.
void clear()
Removes all items from the model.
virtual QStringList mimeTypes() const
Specified by QAbstractItemModel.
virtual void setValue(T *item, const QVariant &value)
Sets the value of an edited item.
virtual bool isCheckable(const T &item) const
Tests if a given item is checkable.
virtual QVariant getValue(const T &item) const =0
Returns the display object for the given item.
virtual void removeAll()=0
Removes all items from the model.
virtual QIcon getIcon(const T &item) const
Returns the icon for a given item, if any.
bool isEmpty() const
Tests if the model is empty.
virtual bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Specified by QAbstractItemModel.
virtual QString getRowName(int row) const
Returns the name of the given row.
An abstract base class for grid data models, i.e., models in which every cell contains the same type ...
Definition: AbstractGridModel.h++:32
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.