27 , mComposerTable( composerTable )
39 if (
hasIndex( row, column, parent ) )
41 if (( *mComposerTable->
columns() )[row] )
72 ( role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::UserRole ) )
89 if ( role == Qt::UserRole )
92 return qVariantFromValue( qobject_cast<QObject *>( column ) );
103 if ( role == Qt::DisplayRole )
107 case Qt::AlignHCenter:
108 return tr(
"Center" );
110 return tr(
"Right" );
131 if ( !mComposerTable )
136 if ( role == Qt::DisplayRole )
138 if ( orientation == Qt::Vertical )
168 if ( !index.
isValid() || role != Qt::EditRole || !mComposerTable )
217 return flags | Qt::ItemIsEditable;
229 int maxRow = qMin( row + count - 1, mComposerTable->
columns()->
length() - 1 );
232 for (
int i = maxRow; i >= row; --i )
234 delete( *mComposerTable->
columns() )[i];
246 for (
int i = row; i < row + count; ++i )
257 if (( direction ==
ShiftUp && row <= 0 ) ||
265 int swapWithRow = direction ==
ShiftUp ? row - 1 : row + 1;
295 if ( !mComposerTable )
313 if ( !column || !mComposerTable )
321 for ( ; columnIt != mComposerTable->
columns()->
constEnd(); ++columnIt )
323 highestRank = qMax( highestRank, ( *columnIt )->sortByRank() );
335 if ( !mComposerTable || !column )
352 if ( !mComposerTable || !column )
366 for ( ; columnIt != mComposerTable->
columns()->
end(); ++columnIt )
368 if (( *columnIt )->sortByRank() > 0 )
370 sortedColumns.
append( *columnIt );
374 int columnPos = sortedColumns.
indexOf( column );
376 if (( columnPos == 0 && direction ==
ShiftUp )
377 || (( columnPos == sortedColumns.
length() - 1 ) && direction ==
ShiftDown ) )
384 sortedColumns[ columnPos - 1]
385 : sortedColumns[ columnPos + 1];
406 , mComposerTable( composerTable )
407 , mFilterType( filterType )
478 if (( role != Qt::DisplayRole && role != Qt::EditRole ) || !index.
isValid() )
494 if ( role == Qt::DisplayRole )
498 case Qt::DescendingOrder:
499 return tr(
"Descending" );
500 case Qt::AscendingOrder:
502 return tr(
"Ascending" );
518 if ( !mComposerTable )
523 if ( role == Qt::DisplayRole )
525 if ( orientation == Qt::Vertical )
554 if ( index.
column() == 1 )
557 flags |= Qt::ItemIsEditable;
565 if ( !index.
isValid() || role != Qt::EditRole )
568 if ( !mComposerTable )
579 if ( index.
column() == 1 )
bool hasIndex(int row, int column, const QModelIndex &parent) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
virtual QVariant data(const QModelIndex &index, int role) const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
QModelIndex index(int row, int column, const QModelIndex &parent) const override
QgsComposerTableColumn * columnFromRow(int row)
Returns the QgsComposerTableColumn corresponding to a row in the proxy model.
void setAttribute(QString attribute)
Sets the attribute name or expression used for the column's values.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int sortByRank() const
Returns the sort rank for the column.
QgsComposerAttributeTableColumnModel(QgsComposerAttributeTable *composerTable, QObject *parent=0)
Constructor for QgsComposerAttributeTableColumnModel.
void setColumnAsSorted(QgsComposerTableColumn *column, Qt::SortOrder order)
Sets a specified column as a sorted column in the QgsComposerAttributeTable.
Qt::SortOrder sortOrder() const
Returns the sort order for the column.
QList< QgsComposerTableColumn * > * columns()
Returns a pointer to the list of QgsComposerTableColumns shown in the table.
void setHeading(QString heading)
Sets the heading for a column, which is the value displayed in the columns header cell...
void setHAlignment(Qt::AlignmentFlag alignment)
Sets the horizontal alignment for a column, which controls the alignment used for drawing column valu...
bool moveRow(int row, ShiftDirection direction)
Moves the specified row up or down in the model.
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsComposerTableColumn * columnFromSourceIndex(const QModelIndex &sourceIndex) const
Returns the QgsComposerTableColumn corresponding to an index from the source QgsComposerAttributeTabl...
int indexOf(const T &value, int from) const
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
void append(const T &value)
int toInt(bool *ok) const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
static bool columnsBySortRank(QgsComposerTableColumn *a, QgsComposerTableColumn *b)
virtual ~QgsComposerAttributeTableColumnModel()
void beginRemoveRows(const QModelIndex &parent, int first, int last)
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the model.
void setDynamicSortFilter(bool enable)
void * internalPointer() const
virtual QVariant data(const QModelIndex &index, int role) const =0
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the proxy model.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Stores properties of a column in a QgsComposerTable.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
void resetColumns()
Resets the attribute table's columns to match the vector layer's fields.
QModelIndex createIndex(int row, int column, void *ptr) const
virtual QVariant data(const QModelIndex &index, int role) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
void beginInsertRows(const QModelIndex &parent, int first, int last)
void resetToLayer()
Resets the attribute table's columns to match the source layer's fields.
QModelIndex indexFromColumn(QgsComposerTableColumn *column)
Returns a QModelIndex corresponding to a QgsComposerTableColumn in the model.
QAbstractItemModel * sourceModel() const
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
A table class that displays a vector attribute table.
bool moveColumnInSortRank(QgsComposerTableColumn *column, ShiftDirection direction)
Moves a column up or down in the sort rank for the QgsComposerAttributeTable.
QString heading() const
Returns the heading for a column, which is the value displayed in the columns header cell...
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void insert(int i, const T &value)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void setSortOrder(Qt::SortOrder sortOrder)
Sets the sort order for the column.
Qt::AlignmentFlag hAlignment() const
Returns the horizontal alignment for a column, which controls the alignment used for drawing column v...
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Qt::ItemFlags flags(const QModelIndex &index) const override
QString attribute() const
Returns the attribute name or expression used for the column's values.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
const_iterator constEnd() const
const_iterator constBegin() const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
QgsComposerTableSortColumnsProxyModel(QgsComposerAttributeTable *composerTable, ColumnFilterType filterType, QObject *parent=0)
Constructor for QgsComposerTableSortColumnsProxyModel.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
virtual ~QgsComposerTableSortColumnsProxyModel()
void setColumnAsUnsorted(QgsComposerTableColumn *column)
Sets a specified column as an unsorted column in the QgsComposerAttributeTable.
void setSortByRank(int sortByRank)
Sets the sort rank for the column.
void resetFilter()
Invalidates the current filter used by the proxy model.