28 m_sortOrdering(Qt::AscendingOrder),
31 Model *baseModel = dynamic_cast<Model *>(m);
36 connect(baseModel, SIGNAL(aboutToBeDeleted()),
47 if (!
m_model)
return QVariant();
48 if (role != Qt::EditRole && role != Qt::DisplayRole)
return QVariant();
49 if (!
index.isValid())
return QVariant();
57 if (!
index.isValid())
return false;
73 if (
parent.isValid())
return false;
75 emit beginInsertRows(
parent, row, row);
85 return (command ?
true :
false);
92 if (
parent.isValid())
return false;
94 emit beginRemoveRows(
parent, row, row);
102 emit endRemoveRows();
104 return (command ?
true :
false);
110 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsEditable |
111 Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsSelectable;
118 if (!
m_model)
return QVariant();
120 if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
123 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
132 return createIndex(row, column, (
void *)0);
138 return QModelIndex();
145 if (
parent.isValid())
return 0;
153 if (
parent.isValid())
return 0;
160 if (!
m_model)
return createIndex(0, 0);
162 return createIndex(
getSorted(row), 0, (
void *)0);
175 if (text ==
"")
return QModelIndex();
179 for (
int row = 1; row <= rows; ++row) {
180 int wrapped = (row + current) % rows;
181 for (
int col = 0; col < cols; ++col) {
186 Qt::DisplayRole).toString();
187 if (cell.contains(text, Qt::CaseInsensitive)) {
188 return createIndex(wrapped, col);
192 return QModelIndex();
207 if (current != prevCurrent) {
211 emit layoutChanged();
218 emit layoutChanged();
226 emit layoutChanged();
253 if (row >= 0 && row < (
int)
m_sort.size()) {
281 if (row >= 0 && row < (
int)
m_sort.size()) {
308 std::map<int, int> tmp;
312 for (
int i = 0; i < (int)
m_rsort.size(); ++i) {
318 for (std::map<int, int>::const_iterator i = tmp.begin(); i != tmp.end(); ++i) {
319 m_sort.push_back(i->second);
330 typedef std::multimap<double, int> MapType;
335 for (
int i = 0; i < rows; ++i) {
337 rowMap.insert(MapType::value_type(value.toDouble(), i));
340 for (MapType::iterator i = rowMap.begin(); i != rowMap.end(); ++i) {
353 typedef std::multimap<QString, int> MapType;
358 for (
int i = 0; i < rows; ++i) {
361 rowMap.insert(MapType::value_type(value.toString(), i));
364 for (MapType::iterator i = rowMap.begin(); i != rowMap.end(); ++i) {
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
virtual Command * getSetDataCommand(int, int, const QVariant &, int)
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
int getUnsorted(int row) const
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
virtual int getRowForFrame(long frame) const =0
int getSorted(int row) const
virtual int getRowCount() const =0
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Qt::ItemFlags flags(const QModelIndex &index) const
ModelDataTableModel(TabularModel *m)
virtual long getFrameForRow(int row) const =0
bool setData(const QModelIndex &index, const QVariant &value, int role)
QModelIndex getModelIndexForFrame(int frame) const
int getCurrentRow() const
int columnCount(const QModelIndex &parent=QModelIndex()) const
bool insertRow(int row, const QModelIndex &parent=QModelIndex())
virtual SortType getSortType(int col) const =0
void resortNumeric() const
Model is the base class for all data models that represent any sort of data on a time scale based on ...
TabularModel is an abstract base class for models that support direct access to data in a tabular for...
Qt::SortOrder m_sortOrdering
virtual QVariant getData(int row, int column, int role) const =0
virtual QString getHeading(int column) const =0
void setCurrentRow(int row)
int getFrameForModelIndex(const QModelIndex &) const
void resortAlphabetical() const
QVariant data(const QModelIndex &index, int role) const
QModelIndex findText(QString text) const
QModelIndex parent(const QModelIndex &index) const
virtual Command * getRemoveRowCommand(int)
virtual Command * getInsertRowCommand(int)
void modelChangedWithin(int, int)
void addCommand(Command *)
virtual int getColumnCount() const =0
void modelAboutToBeDeleted()
virtual ~ModelDataTableModel()
virtual bool isColumnTimeValue(int col) const =0
void currentChanged(const QModelIndex &)