kpdf_part.h 4.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/***************************************************************************
 *   Copyright (C) 2002 by Wilco Greven <greven@kde.org>                   *
 *   Copyright (C) 2003-2004 by Christophe Devriese                        *
 *                         <Christophe.Devriese@student.kuleuven.ac.be>    *
 *   Copyright (C) 2003 by Laurent Montel <montel@kde.org>                 *
 *   Copyright (C) 2004 by Dominique Devriese <devriese@kde.org>           *
 *   Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es>            *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/

15
16
17
#ifndef _KPDF_PART_H_
#define _KPDF_PART_H_

18
#include <qmutex.h>
19
20
#include <qwidget.h>

Wilco Greven's avatar
Wilco Greven committed
21
#include <kparts/browserextension.h>
22
23
24
25
26
27
28
29
#include <kparts/part.h>

class QWidget;

class KAboutData;
class KAction;
class KURL;
class KToggleAction;
30
class KSelectAction;
31
32
33
34
35
36

class LinkAction;
class LinkDest;
class PDFDoc;
class XOutputDev;

Christophe Devriese's avatar
Christophe Devriese committed
37
class PDFPartView;
38
class KPrinter;
Christophe Devriese's avatar
Christophe Devriese committed
39

40
41
namespace KPDF
{
Wilco Greven's avatar
Wilco Greven committed
42
  class BrowserExtension;
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
  class PageWidget;

  /**
   * This is a "Part".  It that does all the real work in a KPart
   * application.
   *
   * @short Main Part
   * @author Wilco Greven <greven@kde.org>
   * @version 0.1
   */
  class Part : public KParts::ReadOnlyPart
  {
    Q_OBJECT

  public:
     // Do with these first. We can always add the other zoommodes which can
     // be specified in a Destination later.
     enum ZoomMode { FitInWindow, FitWidth, FitVisible, FixedFactor };

    /**
     * Default constructor
     */
    Part(QWidget* parentWidget, const char* widgetName,
         QObject* parent, const char* name, const QStringList& args);

    /**
     * Destructor
     */
    virtual ~Part();

    static KAboutData* createAboutData();

75
76
    bool closeURL();

Albert Astals Cid's avatar
Albert Astals Cid committed
77
      void displayPage(int pageNumber, float zoomFactor = 1.0);
78
      void displayDestination(LinkDest*);
Laurent Montel's avatar
Laurent Montel committed
79
      void updateActionPage();
80
      void setFullScreen( bool fs );
81
82
      PageWidget* pageWidget() const {return m_outputDev;}

83
84
85
86
  public slots:
    void print();


87
88
89
90
91
92
  protected:
    /**
     * This must be implemented by each part
     */
    virtual bool openFile();

93
94
    virtual bool openURL(const KURL &url);

Laurent Montel's avatar
Laurent Montel committed
95
96
97
      void update();
      void readSettings();
      void writeSettings();
98
99
      bool nextPage();
      bool previousPage();
Laurent Montel's avatar
Laurent Montel committed
100
      void updateAction();
Laurent Montel's avatar
Laurent Montel committed
101
      void goToPage( int page );
102
      void doPrint( KPrinter& printer );
Laurent Montel's avatar
Laurent Montel committed
103

104
  protected slots:
105
    void find();
Albert Astals Cid's avatar
Albert Astals Cid committed
106
    void findNext();
Christophe Devriese's avatar
Christophe Devriese committed
107
108
    void zoomIn()   { m_zoomFactor += 0.1; update(); };
    void zoomOut()  { m_zoomFactor -= 0.1; update(); };
109
110
    void back()     { /* stub */ };
    void forward()  { /* stub */ };
Albert Astals Cid's avatar
Albert Astals Cid committed
111
112
113
114
115
    void slotNextPage();
    void slotPreviousPage();
    void slotGotoEnd();
    void slotGotoStart();
    void slotGoToPage();
116
    void printPreview();
117

118
    void executeAction(LinkAction*);
119

120
121
      void showScrollBars( bool );
      void showMarkList( bool );
122
123
      void showTOC( bool );
      void hasTOC( bool );
124
125
      void slotReadUp();
      void slotReadDown();
Laurent Montel's avatar
Laurent Montel committed
126
      void slotOpenUrlDropped( const KURL & );
127
128
      void slotZoom( const QString& );

129
  private:
Albert Astals Cid's avatar
Albert Astals Cid committed
130
      void doFind(QString s, bool next);
131

Albert Astals Cid's avatar
Albert Astals Cid committed
132
133
      PDFDoc*     m_doc;
      PageWidget* m_outputDev;
134
      PDFPartView * pdfpartview;
Albert Astals Cid's avatar
Albert Astals Cid committed
135
136
137
138
      KAction* m_firstPage;
      KAction* m_lastPage;
      KAction* m_prevPage;
      KAction* m_nextPage;
Laurent Montel's avatar
Laurent Montel committed
139
      KAction *m_gotoPage;
Albert Astals Cid's avatar
Albert Astals Cid committed
140
141
      KToggleAction* m_showScrollBars;
      KToggleAction* m_showPageList;
142
      KToggleAction* m_showTOC;
143
      KSelectAction *m_zoomTo;
144
      KToggleAction* m_fitToWidth;
Albert Astals Cid's avatar
Albert Astals Cid committed
145
146
147
148
      KAction *m_find;
      KAction *m_findNext;

      QString m_findText;
149

Albert Astals Cid's avatar
Albert Astals Cid committed
150
    // first page is page 1
151
    int   m_currentPage;
152
    QMutex m_docMutex;
153
154
155
156

    ZoomMode m_zoomMode;
    float    m_zoomFactor;

157
158
    static unsigned int m_count;

159
  private slots:
Albert Astals Cid's avatar
Albert Astals Cid committed
160
		void slotFitToWidthToggled();
Christophe Devriese's avatar
Christophe Devriese committed
161
		void redrawPage();
Albert Astals Cid's avatar
Albert Astals Cid committed
162
		void pageClicked ( int );
163
    void fileSaveAs();
164
  };
Wilco Greven's avatar
Wilco Greven committed
165
166
167
168

  class BrowserExtension : public KParts::BrowserExtension
  {
    Q_OBJECT
169

Wilco Greven's avatar
Wilco Greven committed
170
171
172
173
174
175
176
  public:
    BrowserExtension(Part*);

  public slots:
    // Automatically detected by the host.
    void print();
  };
177

178
179
180
181
182
}

#endif

// vim:ts=2:sw=2:tw=78:et