Change annotation type name when an annotation is associated to non-empty popup

Summary:
Mark the annotations that contain a non-empty popup. Especially useful to identify annotations that are not meant to contain an annotation as shapes or highlights.

BUG: 389836

Reviewers: #okular, aacid

Reviewed By: #okular, aacid

Subscribers: rkflx, aacid, ngraham

Tags: #okular

Differential Revision: https://phabricator.kde.org/D10797
remotes/offline-stg/wilder
Simone Gaiarin 8 years ago committed by Albert Astals Cid
parent 50b01e1e78
commit cbc6f671e3
  1. 16
      ui/annotationproxymodels.cpp
  2. 2
      ui/annotationproxymodels.h
  3. 20
      ui/guiutils.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<int> &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<AuthorGroupItem*>( 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<int> &roles)
{
emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles);
}
#include "moc_annotationproxymodels.cpp"

@ -87,6 +87,7 @@ class PageGroupProxyModel : public QAbstractProxyModel
private Q_SLOTS:
void rebuildIndexes();
void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &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<int> &roles);
private:
class Private;

@ -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" );

Loading…
Cancel
Save