diff --git a/ui/annotationproxymodels.h b/ui/annotationproxymodels.h --- a/ui/annotationproxymodels.h +++ b/ui/annotationproxymodels.h @@ -87,6 +87,7 @@ private Q_SLOTS: void rebuildIndexes(); + void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); private: bool mGroupByPage; @@ -136,6 +137,7 @@ private Q_SLOTS: void rebuildIndexes(); + void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); private: class Private; diff --git a/ui/annotationproxymodels.cpp b/ui/annotationproxymodels.cpp --- a/ui/annotationproxymodels.cpp +++ b/ui/annotationproxymodels.cpp @@ -214,6 +214,7 @@ connect( sourceModel(), &QAbstractItemModel::modelReset, this, &PageGroupProxyModel::rebuildIndexes ); connect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &PageGroupProxyModel::rebuildIndexes ); connect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &PageGroupProxyModel::rebuildIndexes ); + connect( sourceModel(), &QAbstractItemModel::dataChanged, this, &PageGroupProxyModel::sourceDataChanged ); rebuildIndexes(); } @@ -249,6 +250,11 @@ endResetModel(); } +void PageGroupProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) +{ + emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles); +} + void PageGroupProxyModel::groupByPage( bool value ) { if ( mGroupByPage == value ) @@ -313,7 +319,7 @@ int row() const { return ( mParent ? mParent->mChilds.indexOf( const_cast( this ) ) : 0 ); - } + } Type type() const { return mType; } QModelIndex index() const { return mIndex; } @@ -443,6 +449,7 @@ connect( sourceModel(), &QAbstractItemModel::modelReset, this, &AuthorGroupProxyModel::rebuildIndexes ); connect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &AuthorGroupProxyModel::rebuildIndexes ); connect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &AuthorGroupProxyModel::rebuildIndexes ); + connect( sourceModel(), &QAbstractItemModel::dataChanged, this, &AuthorGroupProxyModel::sourceDataChanged ); rebuildIndexes(); } @@ -601,4 +608,9 @@ endResetModel(); } +void AuthorGroupProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) +{ + emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles); +} + #include "moc_annotationproxymodels.cpp" diff --git a/ui/guiutils.cpp b/ui/guiutils.cpp --- a/ui/guiutils.cpp +++ b/ui/guiutils.cpp @@ -64,6 +64,8 @@ { Q_ASSERT( ann ); + const bool hasComment = !ann->contents().isEmpty(); + QString ret; switch( ann->subType() ) { @@ -75,35 +77,35 @@ break; case Okular::Annotation::ALine: if( ( (Okular::LineAnnotation*)ann )->linePoints().count() == 2 ) - ret = i18n( "Straight Line" ); + ret = hasComment ? i18n( "Straight Line with Comment" ) : i18n( "Straight Line" ); else - ret = i18n( "Polygon" ); + ret = hasComment ? i18n( "Polygon with Comment" ) : i18n( "Polygon" ); break; case Okular::Annotation::AGeom: - ret = i18n( "Geometry" ); + ret = hasComment ? i18n( "Geometry with Comment" ) : i18n( "Geometry" ); break; case Okular::Annotation::AHighlight: switch ( ( (Okular::HighlightAnnotation*)ann )->highlightType() ) { case Okular::HighlightAnnotation::Highlight: - ret = i18n( "Highlight" ); + ret = hasComment ? i18n( "Highlight with Comment" ) : i18n( "Highlight" ); break; case Okular::HighlightAnnotation::Squiggly: - ret = i18n( "Squiggle" ); + ret = hasComment ? i18n( "Squiggle with Comment" ) : i18n( "Squiggle" ); break; case Okular::HighlightAnnotation::Underline: - ret = i18n( "Underline" ); + ret = hasComment ? i18n( "Underline with Comment" ) : i18n( "Underline" ); break; case Okular::HighlightAnnotation::StrikeOut: - ret = i18n( "Strike Out" ); + ret = hasComment ? i18n( "Strike Out with Comment" ) : i18n( "Strike Out" ); break; } break; case Okular::Annotation::AStamp: - ret = i18n( "Stamp" ); + ret = hasComment ? i18n( "Stamp with Comment" ) : i18n( "Stamp" ); break; case Okular::Annotation::AInk: - ret = i18n( "Freehand Line" ); + ret = hasComment ? i18n( "Freehand Line with Comment" ) : i18n( "Freehand Line" ); break; case Okular::Annotation::ACaret: ret = i18n( "Caret" );