diff --git a/ui/annotationproxymodels.cpp b/ui/annotationproxymodels.cpp index d34d03983..eab99dc63 100644 --- a/ui/annotationproxymodels.cpp +++ b/ui/annotationproxymodels.cpp @@ -206,6 +206,7 @@ void PageGroupProxyModel::setSourceModel( QAbstractItemModel *model ) disconnect( sourceModel(), &QAbstractItemModel::modelReset, this, &PageGroupProxyModel::rebuildIndexes ); disconnect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &PageGroupProxyModel::rebuildIndexes ); disconnect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &PageGroupProxyModel::rebuildIndexes ); + disconnect( sourceModel(), &QAbstractItemModel::dataChanged, this, &PageGroupProxyModel::sourceDataChanged ); } QAbstractProxyModel::setSourceModel( model ); @@ -214,6 +215,7 @@ void PageGroupProxyModel::setSourceModel( QAbstractItemModel *model ) 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 +251,11 @@ void PageGroupProxyModel::rebuildIndexes() 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 +320,7 @@ class AuthorGroupItem int row() const { return ( mParent ? mParent->mChilds.indexOf( const_cast( this ) ) : 0 ); - } + } Type type() const { return mType; } QModelIndex index() const { return mIndex; } @@ -435,6 +442,7 @@ void AuthorGroupProxyModel::setSourceModel( QAbstractItemModel *model ) disconnect( sourceModel(), &QAbstractItemModel::modelReset, this, &AuthorGroupProxyModel::rebuildIndexes ); disconnect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &AuthorGroupProxyModel::rebuildIndexes ); disconnect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &AuthorGroupProxyModel::rebuildIndexes ); + disconnect( sourceModel(), &QAbstractItemModel::dataChanged, this, &AuthorGroupProxyModel::sourceDataChanged ); } QAbstractProxyModel::setSourceModel( model ); @@ -443,6 +451,7 @@ void AuthorGroupProxyModel::setSourceModel( QAbstractItemModel *model ) 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 +610,9 @@ void AuthorGroupProxyModel::rebuildIndexes() 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/annotationproxymodels.h b/ui/annotationproxymodels.h index 2a4534e48..8b914c25b 100644 --- a/ui/annotationproxymodels.h +++ b/ui/annotationproxymodels.h @@ -87,6 +87,7 @@ class PageGroupProxyModel : public QAbstractProxyModel private Q_SLOTS: void rebuildIndexes(); + void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); private: bool mGroupByPage; @@ -136,6 +137,7 @@ class AuthorGroupProxyModel : public QAbstractProxyModel private Q_SLOTS: void rebuildIndexes(); + void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); private: class Private; diff --git a/ui/guiutils.cpp b/ui/guiutils.cpp index 5308a9595..45656453b 100644 --- a/ui/guiutils.cpp +++ b/ui/guiutils.cpp @@ -64,6 +64,8 @@ QString captionForAnnotation( const Okular::Annotation * ann ) { Q_ASSERT( ann ); + const bool hasComment = !ann->contents().isEmpty(); + QString ret; switch( ann->subType() ) { @@ -75,35 +77,35 @@ QString captionForAnnotation( const Okular::Annotation * ann ) 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" );