[poppler] poppler/qt: test-poppler-qt.cpp,1.5,1.6
Albert Astals Cid
aacid at freedesktop.org
Fri Jul 22 20:45:21 EST 2005
Update of /cvs/poppler/poppler/qt
In directory gabe:/tmp/cvs-serv19476/qt
Modified Files:
test-poppler-qt.cpp
Log Message:
Make it possible to browse pages in test-poppler-qt
Index: test-poppler-qt.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt/test-poppler-qt.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- test-poppler-qt.cpp 7 Jun 2005 20:25:48 -0000 1.5
+++ test-poppler-qt.cpp 22 Jul 2005 10:45:19 -0000 1.6
@@ -16,7 +16,11 @@
~PDFDisplay();
protected:
void paintEvent( QPaintEvent * );
+ void keyPressEvent( QKeyEvent * );
private:
+ void display();
+
+ int currentPage;
QPixmap *pixmap;
Poppler::Document *doc;
};
@@ -24,15 +28,8 @@
PDFDisplay::PDFDisplay( Poppler::Document *d )
{
doc = d;
- if (doc) {
- Poppler::Page *page = doc->getPage(0);
- if (page) {
- page->renderToPixmap(&pixmap, -1, -1, -1, -1);
- delete page;
- }
- } else {
- printf("doc not loaded\n");
- }
+ currentPage = 0;
+ display();
}
PDFDisplay::~PDFDisplay()
@@ -48,6 +45,40 @@
paint.drawPixmap(0, 0, *pixmap);
}
+void PDFDisplay::keyPressEvent( QKeyEvent *e )
+{
+ if (e->key() == Qt::Key_Down)
+ {
+ if (currentPage + 1 < doc->getNumPages())
+ {
+ currentPage++;
+ display();
+ }
+ }
+ else if (e->key() == Qt::Key_Up)
+ {
+ if (currentPage > 0)
+ {
+ currentPage--;
+ display();
+ }
+ }
+}
+
+void PDFDisplay::display()
+{
+ if (doc) {
+ Poppler::Page *page = doc->getPage(currentPage);
+ if (page) {
+ page->renderToPixmap(&pixmap, -1, -1, -1, -1);
+ delete page;
+ update();
+ }
+ } else {
+ printf("doc not loaded\n");
+ }
+}
+
int main( int argc, char **argv )
{
QApplication a( argc, argv ); // QApplication required!
More information about the poppler
mailing list