2 #ifndef __libquark_gui_AbstractTableModel_hxx 3 #define __libquark_gui_AbstractTableModel_hxx 10 #include <QStringList> 39 template<
class T,
class IS = QDataStream,
class OS = QDataStream>
51 virtual int rowCount(
const QModelIndex &
parent = QModelIndex())
const;
54 virtual QVariant
data(
const QModelIndex &
index,
int role = Qt::DisplayRole)
58 virtual bool setData(
const QModelIndex &index,
const QVariant &value,
59 int role = Qt::EditRole);
63 const QModelIndex &
parent = QModelIndex());
69 virtual QVariant
headerData(
int section, Qt::Orientation orientation,
70 int role = Qt::DisplayRole)
const;
73 virtual QModelIndex
index(
int row,
int column,
74 const QModelIndex &
parent = QModelIndex())
const;
77 virtual QModelIndex
parent(
const QModelIndex &index)
const;
80 virtual Qt::ItemFlags
flags(
const QModelIndex &index)
const;
86 virtual QMimeData *
mimeData(
const QModelIndexList &indexes)
const;
89 virtual bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
90 int row,
int column,
const QModelIndex &parent);
183 virtual int indexOf(
const T *item)
const = 0;
221 virtual QVariant
getFieldValue(
const T &item,
int field)
const = 0;
226 virtual QVariant
getSortValue(
const T &item,
int field)
const;
228 virtual bool write(OS &stream)
const;
229 virtual bool read(IS &stream);
242 virtual QIcon
getIcon(
const T &item)
const;
245 virtual QSize
getSize(
const T &item)
const;
251 virtual void setFieldValue(T *item,
int field,
const QVariant &value);
310 virtual T *
getAt(
int row)
const = 0;
313 virtual T *
takeAt(
int row) = 0;
319 virtual void insertAt(T *item,
int row) = 0;
345 Qt::DropAction action,
int row,
346 int column,
const QModelIndex &parent);
374 virtual void writeItem(
const T &item, OS &stream)
const;
414 #include <quark/AbstractTableModelImpl.h++> 419 #endif // __libquark_gui_AbstractTableModel_hxx void removeItem(T *item)
Removes and deletes the specified item from the model.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Specified by QAbstractItemModel.
virtual bool isDroppable(const T &item) const
Tests if a given item can be dropped onto.
virtual void itemAdded(const T *item)
Called when an item has been added to the model.
virtual QString itemMimeType() const
Returns the model's native MIME-type.
void insertItemAt(T *item, int row)
Inserts an item into the model at the given row position.
bool moveItemDownAt(int row)
Moves the given row down one position in the model.
virtual bool isFieldCheckable(const T &item, int field) const
Tests if a field of a given item is checkable.
virtual bool isFieldEditable(const T &item, int field) const
Tests if a field of a given item is editable.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Specified by QAbstractItemModel.
virtual T * getAt(int row) const =0
Returns the item at the given row.
virtual void setFieldChecked(T *item, int field, bool checked)
Sets the checked state of a checkable field.
void updateItem(T *item)
Notifies the model that the specified item in the model has changed in some way.
virtual void itemRemoved(const T &item)
Called when an item is about to be removed from the model.
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 ...
virtual int getSortIndex(const T &item) const
Calculates the row at which a new item should be inserted in a presumably sorted model.
AbstractTableModel(Options options=0, QObject *parent=NULL)
Constructs an AbstractTableModel with the specified options.
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...
int indexOfItemEqualTo(const T &item) const
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
void updateItemAt(int row)
Notifies the model that the item in the given row has changed in some way.
virtual ~AbstractTableModel()
Destructor.
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...
virtual void insertAt(T *item, int row)=0
Inserts an item at the given row, or at the end if the row is negative.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
bool containsItemEqualTo(const T &item) const
A non-parameterized abstract base class for Quark table models.
Definition: AbstractTableModelBase.h++:20
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Specified by QAbstractItemModel.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Specified by QAbstractItemModel.
Definition: BarChartView.h++:6
virtual bool 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 QString getRowName(int row) const
Returns the name of the given row.
virtual bool isFieldChecked(const T &item, int field) const
Tests if a field of a given item is currently checked.
bool moveItemUpAt(int row)
Moves the given row up one position in the model.
An abstract base class for table data models, i.e., models in which every row represents an instance ...
Definition: AbstractTableModel.h++:40
virtual void itemUpdated(const T &item)
Called when an item has been updated in the model.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Specified by QAbstractItemModel.
virtual void writeItem(const T &item, OS &stream) const
Serializes an item that is being dragged out of the model.
virtual QModelIndex parent(const QModelIndex &index) const
Specified by QAbstractItemModel.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Specified by QAbstractItemModel.
virtual QSize getSize(const T &item) const
Returns the preferred display size of a given item, if any.
virtual void setFieldValue(T *item, int field, const QVariant &value)
Sets the value of an edited field.
virtual QVariant getFieldValueForRole(const T &item, int field, int role) const
void clear()
Removes all items from the model.
virtual bool read(IS &stream)
void addItem(T *item)
Adds an item to the model.
virtual bool write(OS &stream) const
virtual QStringList mimeTypes() const
Specified by QAbstractItemModel.
virtual T * readItem(IS &stream)
Deserializes an item that is being dropped into the model.
virtual QStringList otherMimeTypes() const
Returns a list of additional MIME-types that can be dropped onto the model.
virtual bool isRootDroppable() const
Tests if new item(s) can be dropped onto a non-existent rows in the model.
virtual int indexOf(const T *item) const =0
Returns the row position of the given item in the model.
void removeItemAt(int row)
Removes and deletes the item at the specified row.
T * getItemAt(int row) const
Returns the item in the specified row.
virtual QVariant getFieldValue(const T &item, int field) const =0
Returns the value of the given field of an object.
virtual T * takeAt(int row)=0
Removes and returns the item at the given row.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
T * takeItemAt(int row)
Removes and returns the item at the specified row.
virtual int itemCount() const =0
Returns the number of items in the model.
virtual Qt::AlignmentFlag getRowHeaderAlignment() const
Returns the preferred row (vertical) header label alignment.
virtual QVariant getSortValue(const T &item, int field) const
virtual bool readProlog(IS &stream)
Reads any necessary prolog (e.g., an XML open-tag) when deserializing items that are being dropped in...
virtual QIcon getIcon(const T &item) const
Returns the icon for a given item, if any.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Specified by QAbstractItemModel.
bool isEmpty() const
Tests if the model is empty.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Specified by QAbstractItemModel.
virtual void removeAll()=0
Removes all items from the model.