915 changes: 915 additions & 0 deletions images/themes/gis/mIconDeselected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
915 changes: 915 additions & 0 deletions images/themes/gis/mIconSelected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsfeaturelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void QgsFeatureListView::mousePressEvent( QMouseEvent *event )
{
QPoint pos = event->pos();

if ( QgsFeatureListViewDelegate::EditButtonElement == mItemDelegate->positionToElement( event->pos() ) )
if ( QgsFeatureListViewDelegate::EditElement == mItemDelegate->positionToElement( event->pos() ) )
{
mEditSelectionDrag = true;
QModelIndex index = mModel->mapToMaster( indexAt( pos ) );
Expand Down
44 changes: 23 additions & 21 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ QgsFeatureListViewDelegate::QgsFeatureListViewDelegate( QgsFeatureListModel *lis

QgsFeatureListViewDelegate::Element QgsFeatureListViewDelegate::positionToElement( const QPoint &pos )
{
if ( pos.x() < sIconSize )
if ( pos.x() > sIconSize )
{
return EditButtonElement;
return EditElement;
}
else
{
return TextElement;
return SelectionElement;
}
}

Expand All @@ -45,46 +45,48 @@ void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionVie
{
QString text = index.model()->data( index, Qt::EditRole ).toString();
QgsFeatureListModel::FeatureInfo featInfo = index.model()->data( index, Qt::UserRole ).value<QgsFeatureListModel::FeatureInfo>();
bool isEdited = mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );

// Edit button state
bool checked = mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );
// Icon layout options
QStyleOptionViewItem iconOption;

QStyleOptionButton pbn1Opts;
QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );

pbn1Opts.iconSize = QSize( sIconSize, sIconSize );
QPixmap icon;

pbn1Opts.state |= QStyle::State_Enabled;
if ( checked )
if ( option.state.testFlag( QStyle::State_Selected ) )
{
pbn1Opts.icon = QgsApplication::getThemeIcon( "/mIconEditableEdits.png" );
pbn1Opts.state |= QStyle::State_On;
// Item is selected
icon = QgsApplication::getThemePixmap( "/mIconSelected.svg" );
}
else
{
pbn1Opts.icon = QgsApplication::getThemeIcon( "/mIconEditable.png" );
pbn1Opts.state |= QStyle::State_Off;
icon = QgsApplication::getThemePixmap( "/mIconDeselected.svg" );
}

QRect pbn1Rect( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
pbn1Opts.rect = pbn1Rect;
// Text layout options
QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );

QApplication::style()->drawControl( QStyle::CE_PushButton, &pbn1Opts, painter );

QRect textLayoutBounds( pbn1Rect.x() + pbn1Rect.width(), option.rect.y(), option.rect.width() - ( pbn1Rect.x() + pbn1Rect.width() ), option.rect.height() );

QStyleOptionViewItem textOption = option;
QStyleOptionViewItem textOption;
textOption.state |= QStyle::State_Enabled;
if ( isEdited )
{
textOption.state |= QStyle::State_Selected;
}

if ( featInfo.isNew )
{
textOption.font.setStyle( QFont::StyleItalic );
textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
}
else if ( featInfo.isEdited || checked )
else if ( featInfo.isEdited || isEdited )
{
textOption.font.setStyle( QFont::StyleItalic );
textOption.palette.setColor( QPalette::Text, Qt::red );
textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
}

drawDisplay( painter, textOption, textLayoutBounds, text );
drawDecoration( painter, iconOption, iconLayoutBounds, icon );
}
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class QgsFeatureListViewDelegate : public QItemDelegate

enum Element
{
EditButtonElement,
TextElement
EditElement,
SelectionElement
};

explicit QgsFeatureListViewDelegate( QgsFeatureListModel* listModel, QObject *parent = 0 );
Expand Down