1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#ifndef PDFANNOTATION_H
#define PDFANNOTATION_H
#ifndef NO_POPPLER_PREVIEW
#include "poppler-annotation.h"
#include <QTableView>
class PDFDocument;
class QTableView;
/*** PDFAnnotation **********************************************************/
class PDFAnnotation: public QObject
{
Q_OBJECT
public:
PDFAnnotation(Poppler::Annotation *ann, int pageNum, QObject *parent = 0);
~PDFAnnotation();
const Poppler::Annotation *popplerAnnotation() const { return m_popplerAnnotation; }
QString subTypeText() const;
QString subTypeIconName() const;
int pageNum() const { return m_pageNum; }
static QString subTypeText(Poppler::Annotation::SubType subtype);
static QString subTypeIconName(Poppler::Annotation::SubType subtype);
private:
Poppler::Annotation *m_popplerAnnotation;
int m_pageNum;
};
typedef QList<PDFAnnotation *> PDFAnnotationList;
/*** PDFAnnotations *********************************************************/
class PDFAnnotationModel; // forward declaration
class PDFAnnotations: public QObject
{
Q_OBJECT
public:
friend class PDFAnnotationModel;
explicit PDFAnnotations(PDFDocument *doc);
const PDFAnnotationList &annotationsInPage(int page) const;
PDFAnnotationModel *createModel();
//const PDFAnnotation * annotation(int page, int number) const;
const PDFAnnotation *annotation(int absNumber) const;
private:
void update();
PDFDocument *m_doc;
QList<PDFAnnotationList> m_annotationsInPage;
PDFAnnotationList m_annotations;
};
/*** PDFAnnotationModel *****************************************************/
class PDFAnnotationModel: public QAbstractTableModel
{
Q_OBJECT
public:
explicit PDFAnnotationModel(PDFAnnotations *parent = 0);
enum ColType {CT_AUTHOR, CT_CONTENTS, CT_TYPE, CT_MODIFICATON_DATE, CT_CREATION_DATE, CT_PAGE};
int rowCount ( const QModelIndex &parent = QModelIndex() ) const;
int columnCount ( const QModelIndex &parent = QModelIndex() ) const;
QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const;
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
const PDFAnnotation *itemForIndex( const QModelIndex &index ) const;
private:
QString colTypeText(ColType colType) const;
QList<ColType> columnTypes;
PDFAnnotations *m_annotations;
};
/*** PDFAnnotationTableView *************************************************/
class PDFAnnotationTableView: public QTableView
{
Q_OBJECT
public:
explicit PDFAnnotationTableView(QWidget *parent = 0);
public slots:
signals:
void annotationClicked(const PDFAnnotation *ann);
private slots:
void onClick(const QModelIndex &index);
private:
};
#endif
#endif // PDFANNOTATION_H
|