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:
111 return tr(
"Top center" );
112 case Qt::AlignBottom:
113 return tr(
"Bottom center" );
115 return tr(
"Middle center" );
121 return tr(
"Top right" );
122 case Qt::AlignBottom:
123 return tr(
"Bottom right" );
125 return tr(
"Middle right" );
132 return tr(
"Top left" );
133 case Qt::AlignBottom:
134 return tr(
"Bottom left" );
136 return tr(
"Middle left" );
155 if ( !mComposerTable )
160 if ( role == Qt::DisplayRole )
162 if ( orientation == Qt::Vertical )
192 if ( !index.
isValid() || role != Qt::EditRole || !mComposerTable )
225 column->
setHAlignment( Qt::AlignmentFlag( value.
toInt() & Qt::AlignHorizontal_Mask ) );
242 return flags | Qt::ItemIsEditable;
254 int maxRow = qMin( row + count - 1, mComposerTable->
columns()->
length() - 1 );
257 for (
int i = maxRow; i >= row; --i )
259 delete( *mComposerTable->
columns() )[i];
271 for (
int i = row; i < row + count; ++i )
282 if (( direction ==
ShiftUp && row <= 0 ) ||
290 int swapWithRow = direction ==
ShiftUp ? row - 1 : row + 1;
320 if ( !mComposerTable )
338 if ( !column || !mComposerTable )
346 for ( ; columnIt != mComposerTable->
columns()->
constEnd(); ++columnIt )
348 highestRank = qMax( highestRank, ( *columnIt )->sortByRank() );
360 if ( !mComposerTable || !column )
377 if ( !mComposerTable || !column )
394 sortedColumns.
append( currentColumn );
398 int columnPos = sortedColumns.
indexOf( column );
400 if (( columnPos == 0 && direction ==
ShiftUp )
401 || (( columnPos == sortedColumns.
length() - 1 ) && direction ==
ShiftDown ) )
408 sortedColumns[ columnPos - 1]
409 : sortedColumns[ columnPos + 1];
430 , mComposerTable( composerTable )
431 , mFilterType( filterType )
502 if (( role != Qt::DisplayRole && role != Qt::EditRole ) || !index.
isValid() )
518 if ( role == Qt::DisplayRole )
522 case Qt::DescendingOrder:
523 return tr(
"Descending" );
524 case Qt::AscendingOrder:
526 return tr(
"Ascending" );
542 if ( !mComposerTable )
547 if ( role == Qt::DisplayRole )
549 if ( orientation == Qt::Vertical )
578 if ( index.
column() == 1 )
581 flags |= Qt::ItemIsEditable;
589 if ( !index.
isValid() || role != Qt::EditRole )
592 if ( !mComposerTable )
603 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
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
virtual QVariant data(const QModelIndex &index, int role) const override
void setAttribute(const QString &attribute)
Sets the attribute name or expression used for the column's values.
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.
Qt::AlignmentFlag hAlignment() const
Returns the horizontal alignment for a column, which controls the alignment used for drawing column v...
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Qt::AlignmentFlag vAlignment() const
Returns the vertical alignment for a column, which controls the alignment used for drawing column val...
void setColumnAsSorted(QgsComposerTableColumn *column, Qt::SortOrder order)
Sets a specified column as a sorted column in the QgsComposerAttributeTable.
QList< QgsComposerTableColumn * > * columns()
Returns a pointer to the list of QgsComposerTableColumns shown in the table.
ShiftDirection
Controls whether a row/column is shifted up or down.
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)
int indexOf(const T &value, int from) const
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the model.
void append(const T &value)
int toInt(bool *ok) const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void setHeading(const QString &heading)
Sets the heading for a column, which is the value displayed in the columns header cell...
static bool columnsBySortRank(QgsComposerTableColumn *a, QgsComposerTableColumn *b)
QgsComposerAttributeTableColumnModel(QgsComposerAttributeTable *composerTable, QObject *parent=nullptr)
Constructor for QgsComposerAttributeTableColumnModel.
virtual ~QgsComposerAttributeTableColumnModel()
int sortByRank() const
Returns the sort rank for the column.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
void setDynamicSortFilter(bool enable)
void * internalPointer() const
QgsComposerTableColumn * columnFromSourceIndex(const QModelIndex &sourceIndex) const
Returns the QgsComposerTableColumn corresponding to an index from the source QgsComposerAttributeTabl...
virtual QVariant data(const QModelIndex &index, int role) const=0
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
QString heading() const
Returns the heading for a column, which is the value displayed in the columns header cell...
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.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void insert(int i, const T &value)
ColumnFilterType
Controls whether the proxy model shows sorted or unsorted columns.
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.
void setVAlignment(Qt::AlignmentFlag alignment)
Sets the vertical alignment for a column, which controls the alignment used for drawing column values...
QString attribute() const
Returns the attribute name or expression used for the column's values.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Qt::ItemFlags flags(const QModelIndex &index) const override
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
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QgsComposerTableSortColumnsProxyModel(QgsComposerAttributeTable *composerTable, ColumnFilterType filterType, QObject *parent=nullptr)
Constructor for QgsComposerTableSortColumnsProxyModel.
virtual ~QgsComposerTableSortColumnsProxyModel()
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the proxy model.
void setColumnAsUnsorted(QgsComposerTableColumn *column)
Sets a specified column as an unsorted column in the QgsComposerAttributeTable.
Qt::SortOrder sortOrder() const
Returns the sort order for the column.
void setSortByRank(int sortByRank)
Sets the sort rank for the column.
void resetFilter()
Invalidates the current filter used by the proxy model.