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" );
124 if ( role == Qt::DisplayRole )
131 return column->
width();
142 if ( !mComposerTable )
147 if ( role == Qt::DisplayRole )
149 if ( orientation == Qt::Vertical )
182 if ( !index.
isValid() || role != Qt::EditRole || !mComposerTable )
235 return flags | Qt::ItemIsEditable;
247 int maxRow = qMin( row + count - 1, mComposerTable->
columns()->
length() - 1 );
250 for (
int i = maxRow; i >= row; --i )
252 delete( *mComposerTable->
columns() )[i];
264 for (
int i = row; i < row + count; ++i )
275 if (( direction ==
ShiftUp && row <= 0 ) ||
283 int swapWithRow = direction ==
ShiftUp ? row - 1 : row + 1;
313 if ( !mComposerTable )
331 if ( !column || !mComposerTable )
339 for ( ; columnIt != mComposerTable->
columns()->
constEnd(); ++columnIt )
341 highestRank = qMax( highestRank, ( *columnIt )->sortByRank() );
353 if ( !mComposerTable || !column )
370 if ( !mComposerTable || !column )
384 for ( ; columnIt != mComposerTable->
columns()->
end(); ++columnIt )
386 if (( *columnIt )->sortByRank() > 0 )
388 sortedColumns.
append( *columnIt );
392 int columnPos = sortedColumns.
indexOf( column );
394 if (( columnPos == 0 && direction ==
ShiftUp )
395 || (( columnPos == sortedColumns.
length() - 1 ) && direction ==
ShiftDown ) )
402 sortedColumns[ columnPos - 1]
403 : sortedColumns[ columnPos + 1];
424 , mComposerTable( composerTable )
425 , mFilterType( filterType )
496 if (( role != Qt::DisplayRole && role != Qt::EditRole ) || !index.
isValid() )
512 if ( role == Qt::DisplayRole )
516 case Qt::DescendingOrder:
517 return tr(
"Descending" );
518 case Qt::AscendingOrder:
520 return tr(
"Ascending" );
536 if ( !mComposerTable )
541 if ( role == Qt::DisplayRole )
543 if ( orientation == Qt::Vertical )
572 if ( index.
column() == 1 )
575 flags |= Qt::ItemIsEditable;
583 if ( !index.
isValid() || role != Qt::EditRole )
586 if ( !mComposerTable )
597 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
QgsComposerTableColumn * columnFromRow(int row)
Returns the QgsComposerTableColumn corresponding to a row in the proxy model.
bool moveColumnInSortRank(QgsComposerTableColumn *column, ShiftDirection direction)
Moves a column up or down in the sort rank for the QgsComposerAttributeTable.
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.
void setAttribute(QString attribute)
Sets the attribute name or expression used for the column's values.
int sortByRank() const
Returns the sort rank for the column.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
static bool columnsBySortRank(QgsComposerTableColumn *a, QgsComposerTableColumn *b)
double width() const
Returns the width for a column.
Qt::SortOrder sortOrder() const
Returns the sort order for the column.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setHeading(QString heading)
Sets the heading for a column, which is the value displayed in the columns header cell...
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the model.
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)
QgsComposerTableSortColumnsProxyModelV2(QgsComposerAttributeTableV2 *composerTable, ColumnFilterType filterType, QObject *parent=0)
Constructor for QgsComposerTableSortColumnsProxyModel.
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 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)
QgsComposerTableColumn * columnFromIndex(const QModelIndex &index) const
Returns the QgsComposerTableColumn corresponding to an index in the proxy model.
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.
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
void beginInsertRows(const QModelIndex &parent, int first, int last)
QgsComposerAttributeTableColumnModelV2(QgsComposerAttributeTableV2 *composerTable, QObject *parent=0)
Constructor for QgsComposerAttributeTableColumnModel.
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.
QAbstractItemModel * sourceModel() const
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
QString heading() const
Returns the heading for a column, which is the value displayed in the columns header cell...
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.
void insert(int i, const T &value)
void setSortOrder(Qt::SortOrder sortOrder)
Sets the sort order for the column.
QgsComposerTableColumn * columnFromSourceIndex(const QModelIndex &sourceIndex) const
Returns the QgsComposerTableColumn corresponding to an index from the source QgsComposerAttributeTabl...
Qt::AlignmentFlag hAlignment() const
Returns the horizontal alignment for a column, which controls the alignment used for drawing column v...
QgsComposerTableColumns * columns()
Returns a pointer to the list of QgsComposerTableColumns shown in the table.
QString attribute() const
Returns the attribute name or expression used for the column's values.
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.
void setSortByRank(int sortByRank)
Sets the sort rank for the column.
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
virtual QVariant data(const QModelIndex &index, int role) const override