annotationpopup.h 2.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/***************************************************************************
 *   Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org>                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef ANNOTATIONPOPUP_H
#define ANNOTATIONPOPUP_H

Yuri Chornoivan's avatar
Yuri Chornoivan committed
13 14 15 16
#include <QObject>
#include <QList>
#include <QPair>
#include <QPoint>
17 18 19 20 21 22 23 24 25 26 27

namespace Okular {
class Annotation;
class Document;
}

class AnnotationPopup : public QObject
{
    Q_OBJECT

    public:
28 29 30 31 32 33 34 35 36
        /**
         * Describes the structure of the popup menu.
         */
        enum MenuMode
        {
            SingleAnnotationMode, ///< The menu shows only entries to manipulate a single annotation, or multiple annotations as a group.
            MultiAnnotationMode   ///< The menu shows entries to manipulate multiple annotations.
        };

Albert Astals Cid's avatar
Albert Astals Cid committed
37
        AnnotationPopup( Okular::Document *document, MenuMode mode, QWidget *parent = nullptr );
38

39
        void addAnnotation( Okular::Annotation* annotation, int pageNumber );
40 41 42 43

        void exec( const QPoint &point = QPoint() );

    Q_SIGNALS:
44
        void openAnnotationWindow( Okular::Annotation *annotation, int pageNumber );
45

46
    public:
47
        struct AnnotPagePair {
48
            AnnotPagePair() : annotation( nullptr ),  pageNumber( -1 )
49 50
            { }

51 52 53
            AnnotPagePair( Okular::Annotation *a, int pn ) : annotation( a ),  pageNumber( pn )
            { }
            
Albert Astals Cid's avatar
Albert Astals Cid committed
54 55 56
            ~AnnotPagePair() = default;
            AnnotPagePair( const AnnotPagePair & pair ) = default;
            AnnotPagePair &operator=( const AnnotPagePair & pair ) = default;
57 58 59 60 61 62 63
            
            bool operator==( const AnnotPagePair & pair ) const
            { return annotation == pair.annotation && pageNumber == pair.pageNumber; }
            
            Okular::Annotation* annotation;
            int pageNumber;
        };
64 65 66 67

    private:
        QWidget *mParent;

68
        QList< AnnotPagePair > mAnnotations;
69
        Okular::Document *mDocument;
70
        MenuMode mMenuMode;
71 72 73 74
};


#endif