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" );
148 if ( role == Qt::DisplayRole )
155 return column->
width();
166 if ( !mComposerTable )
171 if ( role == Qt::DisplayRole )
173 if ( orientation == Qt::Vertical )
206 if ( !index.
isValid() || role != Qt::EditRole || !mComposerTable )
239 column->
setHAlignment( Qt::AlignmentFlag( value.
toInt() & Qt::AlignHorizontal_Mask ) );
260 return flags | Qt::ItemIsEditable;
272 int maxRow = qMin( row + count - 1, mComposerTable->
columns()->
length() - 1 );
275 for (
int i = maxRow; i >= row; --i )
277 delete( *mComposerTable->
columns() )[i];
289 for (
int i = row; i < row + count; ++i )
300 if (( direction ==
ShiftUp && row <= 0 ) ||
308 int swapWithRow = direction ==
ShiftUp ? row - 1 : row + 1;
338 if ( !mComposerTable )
356 if ( !column || !mComposerTable )
364 for ( ; columnIt != mComposerTable->
columns()->
constEnd(); ++columnIt )
366 highestRank = qMax( highestRank, ( *columnIt )->sortByRank() );
378 if ( !mComposerTable || !column )
395 if ( !mComposerTable || !column )
412 sortedColumns.
append( currentColumn );
416 int columnPos = sortedColumns.
indexOf( column );
418 if (( columnPos == 0 && direction ==
ShiftUp )
419 || (( columnPos == sortedColumns.
length() - 1 ) && direction ==
ShiftDown ) )
426 sortedColumns[ columnPos - 1]
427 : sortedColumns[ columnPos + 1];
448 , mComposerTable( composerTable )
449 , mFilterType( filterType )
520 if (( role != Qt::DisplayRole && role != Qt::EditRole ) || !index.
isValid() )
536 if ( role == Qt::DisplayRole )
540 case Qt::DescendingOrder:
541 return tr(
"Descending" );
542 case Qt::AscendingOrder:
544 return tr(
"Ascending" );
560 if ( !mComposerTable )
565 if ( role == Qt::DisplayRole )
567 if ( orientation == Qt::Vertical )
596 if ( index.
column() == 1 )
599 flags |= Qt::ItemIsEditable;
607 if ( !index.
isValid() || role != Qt::EditRole )
610 if ( !mComposerTable )
621 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
QgsComposerTableColumn * columnFromRow(int row)
Returns the QgsComposerTableColumn corresponding to a row in the proxy model.
void setAttribute(const QString &attribute)
Sets the attribute name or expression used for the column's values.
bool moveColumnInSortRank(QgsComposerTableColumn *column, ShiftDirection direction)
Moves a column up or down in the sort rank for the QgsComposerAttributeTable.
ShiftDirection
Controls whether a row/column is shifted up or down.
virtual QVariant data(const QModelIndex &index, int role) const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const=0
void setColumnAsUnsorted(QgsComposerTableColumn *column)
Sets a specified column as an unsorted column in the QgsComposerAttributeTable.
Qt::AlignmentFlag hAlignment() const
Returns the horizontal alignment for a column, which controls the alignment used for drawing column v...
Qt::AlignmentFlag vAlignment() const
Returns the vertical alignment for a column, which controls the alignment used for drawing column val...
int columnCount(const QModelIndex &parent=QModelIndex()) const override
static bool columnsBySortRank(QgsComposerTableColumn *a, QgsComposerTableColumn *b)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setHAlignment(Qt::AlignmentFlag alignment)
Sets the horizontal alignment for a column, which controls the alignment used for drawing column valu...
QString tr(const char *sourceText, const char *disambiguation, int n)
A table that displays attributes from a vector layer.
int indexOf(const T &value, int from) const
void append(const T &value)
void resetToLayer()
Resets the attribute table's columns to match the source layer's fields.
int toInt(bool *ok) const
QModelIndex indexFromColumn(QgsComposerTableColumn *column)
Returns a QModelIndex corresponding to a QgsComposerTableColumn in the model.
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...
int sortByRank() const
Returns the sort rank for the column.
void setColumnAsSorted(QgsComposerTableColumn *column, Qt::SortOrder order)
Sets a specified column as a sorted column in the QgsComposerAttributeTable.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
void setDynamicSortFilter(bool enable)
void * internalPointer() const
virtual QVariant data(const QModelIndex &index, int role) const=0
Stores properties of a column in a QgsComposerTable.
double width() const
Returns the width for a column.
virtual ~QgsComposerTableSortColumnsProxyModelV2()
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
QModelIndex createIndex(int row, int column, void *ptr) const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) 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)
Qt::ItemFlags flags(const QModelIndex &index) const override
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
bool moveRow(int row, ShiftDirection direction)
Moves the specified row up or down in the model.
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the proxy model.
ColumnFilterType
Controls whether the proxy model shows sorted or unsorted columns.
QgsComposerTableColumn * columnFromSourceIndex(const QModelIndex &sourceIndex) const
Returns the QgsComposerTableColumn corresponding to an index from the source QgsComposerAttributeTabl...
QAbstractItemModel * sourceModel() const
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void resetColumns()
Resets the attribute table's columns to match the vector layer's fields.
QgsComposerAttributeTableColumnModelV2(QgsComposerAttributeTableV2 *composerTable, QObject *parent=nullptr)
Constructor for QgsComposerAttributeTableColumnModel.
QgsComposerTableSortColumnsProxyModelV2(QgsComposerAttributeTableV2 *composerTable, ColumnFilterType filterType, QObject *parent=nullptr)
Constructor for QgsComposerTableSortColumnsProxyModel.
void insert(int i, const T &value)
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.
QgsComposerTableColumns * columns()
Returns a pointer to the list of QgsComposerTableColumns shown in the table.
virtual ~QgsComposerAttributeTableColumnModelV2()
virtual Qt::ItemFlags flags(const QModelIndex &index) const
double toDouble(bool *ok) const
void setWidth(const double width)
Sets the width for a column.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Qt::ItemFlags flags(const QModelIndex &index) const override
const_iterator constEnd() const
const_iterator constBegin() const
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void resetFilter()
Invalidates the current filter used by the proxy model.
Qt::SortOrder sortOrder() const
Returns the sort order for the column.
void setSortByRank(int sortByRank)
Sets the sort rank for the column.
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the model.
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
virtual QVariant data(const QModelIndex &index, int role) const override