Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 871422ce authored by Albert Astals Cid's avatar Albert Astals Cid

Merge kpdf_part and part

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=344835
parent b8c2ee05
......@@ -29,7 +29,7 @@ all virtuals from the interface and draws text/image into an inner pixmap.
the rendering of a page is finished (and some other features such as collection
of per-page text that permits to implement search).
- Kpdf's QOutputDevPixmap returns a image containing a single redered page.
- Kpdf's QOutputDev returns a image containing a single redered page.
*** Architecture:
......@@ -47,13 +47,6 @@ area on the right), some XMLgui functionalities (zoom actions, search actions,
more...) and some background logic (thumbnail generation, page changes,
loading/saving settings and more).
Architecture::Part:CentralWidget: (part.cpp/.h)
The centralWidget (namely PDFPartView) holds a 'ThumbnailList' (a QTable
composed of 'Thumbnails') and a 'PageWidget'. The central widget has few
accessors to the list of thumbnails, whereas the page widget is accessed
publicly by the core of the Part (this may change soon!).
Architecture::Part:CentralWidget:PageWidget (kpdf_pagewidget.cc/.h)
Displays current page pixmap (holds a QOutputDevPixmap inside). Handles mouse,
......@@ -68,6 +61,8 @@ document using the ThumbnailCreator class.
*** Last Revisions to this document:
2004-09-08 : 0.3 - Albert Astals Cid <tsdgeos@terra.es>
- Bye bye part.cpp/.h
2004-09-04 : 0.2 - Albert Astals Cid <tsdgeos@terra.es>
- ThumbnailList creates the thumbnails itself
2004-09-04 : 0.1 - Enrico Ros <eros.kde@email.it>
......
......@@ -24,7 +24,6 @@ bin_PROGRAMS = kpdf
kpdf_SOURCES = main.cpp kpdf_shell.cpp
kpdf_LDFLAGS = $(KDE_RPATH) $(all_libraries)
kpdf_LDADD = $(LIB_KPARTS)
kpdf_COMPILE_FIRST = part.h
EXTRA_DIST = kpdf.desktop
xdg_apps_DATA = kpdf.desktop
......@@ -39,7 +38,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES = libkpdfpart.la
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevKPrinter.cpp kpdf_part.cpp kpdf_pagewidget.cc part.cpp thumbnail.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp
libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevKPrinter.cpp kpdf_part.cpp kpdf_pagewidget.cc thumbnail.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) $(LIB_KUTILS) -lm
......
......@@ -25,9 +25,9 @@
#include <math.h>
#include <qwidget.h>
#include <qlistbox.h>
#include <qfile.h>
#include <qhbox.h>
#include <qpainter.h>
#include <qtimer.h>
......@@ -46,7 +46,6 @@
#include <kio/netaccess.h>
#include "kpdf_error.h"
#include "part.h"
#include "GString.h"
......@@ -55,6 +54,7 @@
#include "TextOutputDev.h"
#include "QOutputDevKPrinter.h"
#include "thumbnaillist.h"
#include "kpdf_pagewidget.h"
typedef KParts::GenericFactory<KPDF::Part> KPDFPartFactory;
......@@ -80,14 +80,25 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
// we need an instance
setInstance(KPDFPartFactory::instance());
pdfpartview = new PDFPartView(parentWidget, widgetName, &m_docMutex);
connect(pdfpartview, SIGNAL( clicked ( int ) ), this, SLOT( pageClicked ( int ) ));
m_outputDev = pdfpartview->outputdev;
QHBox *widget = new QHBox(parentWidget, widgetName);
widget->setSpacing(3);
widget->setMargin(3);
m_thumbnailList = new ThumbnailList(widget, &m_docMutex);
m_thumbnailList->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)7, 0, 0, m_thumbnailList->sizePolicy().hasHeightForWidth() ) );
m_thumbnailList->setMaximumSize( QSize( 75, 32767 ) );
m_thumbnailList->setColumnWidth(0, 75);
m_outputDev = new KPDF::PageWidget( widget, "outputdev", &m_docMutex );
// is this really necessaty??
widget->resize( QSize(623, 381).expandedTo(widget->minimumSizeHint()) );
connect(m_thumbnailList, SIGNAL(clicked(int)), this, SLOT(pageClicked(int)));
connect(m_outputDev, SIGNAL(rightClick()), this, SIGNAL(rightClick()));
m_outputDev->setAcceptDrops( true );
setWidget(pdfpartview);
setWidget(widget);
m_showScrollBars = new KToggleAction( i18n( "Show &Scrollbars" ), 0,
actionCollection(), "show_scrollbars" );
......@@ -185,7 +196,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
Part::~Part()
{
m_count--;
pdfpartview->stopThumbnailGeneration();
m_thumbnailList->stopThumbnailGeneration();
writeSettings();
if (m_count == 0) delete globalParams;
delete m_doc;
......@@ -223,7 +234,7 @@ void Part::goToPage( int page )
if (page != m_currentPage)
{
m_currentPage = page;
pdfpartview->setCurrentThumbnail(m_currentPage);
m_thumbnailList->setCurrentThumbnail(m_currentPage);
m_outputDev->setPage(m_currentPage);
updateActionPage();
}
......@@ -234,12 +245,6 @@ void Part::slotOpenUrlDropped( const KURL &url )
openURL(url);
}
void Part::setFullScreen( bool fs )
{
pdfpartview->showPageList(!fs);
}
void Part::updateActionPage()
{
if ( m_doc )
......@@ -304,7 +309,8 @@ void Part::showScrollBars( bool show )
void Part::showMarkList( bool show )
{
pdfpartview->showPageList(show);
if (show) m_thumbnailList->show();
else m_thumbnailList->hide();
}
void Part::slotGotoEnd()
......@@ -364,7 +370,7 @@ Part::createAboutData()
bool
Part::closeURL()
{
pdfpartview->stopThumbnailGeneration();
m_thumbnailList->stopThumbnailGeneration();
delete m_doc;
m_doc = 0;
......@@ -394,9 +400,9 @@ Part::openFile()
if (m_doc->getNumPages() > 0)
{
// TODO use a qvaluelist<int> to pass aspect ratio?
// TODO move it to inside pdfpartview or even the thumbnail list itself?
pdfpartview->setPages(m_doc->getNumPages(), m_doc->getPageHeight(1)/m_doc->getPageWidth(1));
pdfpartview->generateThumbnails(m_doc);
// TODO move it the thumbnail list?
m_thumbnailList->setPages(m_doc->getNumPages(), m_doc->getPageHeight(1)/m_doc->getPageWidth(1));
m_thumbnailList->generateThumbnails(m_doc);
m_outputDev->setPDFDocument(m_doc);
goToPage(1);
......@@ -751,7 +757,7 @@ void Part::doPrint( KPrinter& printer )
void Part::find()
{
KFindDialog dlg(pdfpartview);
KFindDialog dlg(widget());
if (dlg.exec() != QDialog::Accepted) return;
doFind(dlg.pattern(), false);
......
......@@ -25,6 +25,7 @@ class QWidget;
class KAboutData;
class KAction;
class KPrinter;
class KURL;
class KToggleAction;
class KSelectAction;
......@@ -34,8 +35,8 @@ class LinkDest;
class PDFDoc;
class XOutputDev;
class ThumbnailList;
class PDFPartView;
class KPrinter;
namespace KPDF
{
......@@ -77,12 +78,14 @@ namespace KPDF
void displayPage(int pageNumber, float zoomFactor = 1.0);
/*void displayDestination(LinkDest*);*/
void updateActionPage();
void setFullScreen( bool fs );
PageWidget* pageWidget() const {return m_outputDev;}
public slots:
void print();
signals:
void rightClick();
protected:
/**
......@@ -124,10 +127,13 @@ namespace KPDF
private:
void doFind(QString s, bool next);
PDFDoc* m_doc;
ThumbnailList *m_thumbnailList;
// TODO rename to something else
PageWidget* m_outputDev;
PDFPartView * pdfpartview;
PDFDoc* m_doc;
KAction* m_firstPage;
KAction* m_lastPage;
KAction* m_prevPage;
......
......@@ -19,9 +19,6 @@
#include "kpdf_shell.h"
#include "kpdf_shell.moc"
#include "kpdf_part.h"
#include "part.h"
#include "kpdf_pagewidget.h"
#include <kaction.h>
#include <kapplication.h>
......@@ -79,8 +76,7 @@ Shell::Shell()
// next time we enter the event loop...
return;
}
PDFPartView * partView = static_cast<PDFPartView *>(m_part->widget());
connect( partView->outputdev, SIGNAL( rightClick() ),SLOT( slotRMBClick() ) );
connect( m_part, SIGNAL( rightClick() ),SLOT( slotRMBClick() ) );
readSettings();
}
......@@ -201,7 +197,6 @@ void Shell::slotUpdateFullScreen()
menuBar()->hide();
toolBar()->hide();
//todo fixme
//m_pdfpart->setFullScreen( true );
showFullScreen();
#if 0
kapp->installEventFilter( m_fsFilter );
......@@ -212,7 +207,6 @@ void Shell::slotUpdateFullScreen()
else
{
//kapp->removeEventFilter( m_fsFilter );
//m_pdfpart->setFullScreen( false );
menuBar()->show();
toolBar()->show();
showNormal();
......
/***************************************************************************
* 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. *
***************************************************************************/
#include "part.h"
#include <qlayout.h>
#include "kpdf_pagewidget.h"
#include "thumbnaillist.h"
/*
* Constructs a PDFPartView as a child of 'parent', with the
* name 'name'
*/
PDFPartView::PDFPartView(QWidget* parent, const char* name, QMutex *docMutex) : QWidget(parent, name)
{
PDFPartViewLayout = new QHBoxLayout( this, 3, 3, "PDFPartViewLayout");
pagesList = new ThumbnailList(this, docMutex);
pagesList->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)7, 0, 0, pagesList->sizePolicy().hasHeightForWidth() ) );
pagesList->setMaximumSize( QSize( 75, 32767 ) );
pagesList->setColumnWidth(0, 75);
PDFPartViewLayout->addWidget( pagesList );
outputdev = new KPDF::PageWidget( this, "outputdev", docMutex );
PDFPartViewLayout->addWidget( outputdev );
resize( QSize(623, 381).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
connect(pagesList, SIGNAL(clicked(int)), this, SIGNAL(clicked(int)));
}
/*
* Destroys the object and frees any allocated resources
*/
PDFPartView::~PDFPartView()
{
// no need to delete child widgets, Qt does it all for us
}
void PDFPartView::setCurrentThumbnail(int i)
{
pagesList->setCurrentItem(i);
}
void PDFPartView::setPages(int i, double ar)
{
pagesList->setPages(i, ar);
}
void PDFPartView::generateThumbnails(PDFDoc *doc)
{
pagesList->generateThumbnails(doc);
}
void PDFPartView::stopThumbnailGeneration()
{
pagesList->stopThumbnailGeneration();
}
void PDFPartView::showPageList(bool show)
{
if (show) pagesList->show();
else pagesList->hide();
}
#include "part.moc"
/***************************************************************************
* 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. *
***************************************************************************/
#ifndef PDFPARTVIEW_H
#define PDFPARTVIEW_H
#include <qwidget.h>
class QHBoxLayout;
class QMutex;
namespace KPDF {
class PageWidget;
}
class PDFDoc;
class ThumbnailList;
class PDFPartView : public QWidget
{
Q_OBJECT
public:
PDFPartView(QWidget* parent, const char* name, QMutex *docMutex);
~PDFPartView();
// first page is page 1
void setCurrentThumbnail(int i);
void setPages(int i, double ar);
void generateThumbnails(PDFDoc *doc);
void stopThumbnailGeneration();
void showPageList(bool show);
// TODO make private
KPDF::PageWidget* outputdev;
signals:
void clicked(int);
protected:
QHBoxLayout* PDFPartViewLayout;
private:
ThumbnailList* pagesList;
};
#endif // PDFPARTVIEW_H
......@@ -37,7 +37,7 @@ ThumbnailList::~ThumbnailList()
}
}
void ThumbnailList::setCurrentItem(int i)
void ThumbnailList::setCurrentThumbnail(int i)
{
setCurrentCell(i-1, 0);
changeSelected(i-1);
......
......@@ -25,7 +25,7 @@ Q_OBJECT
ThumbnailList(QWidget *parent, QMutex *docMutex);
~ThumbnailList();
void setCurrentItem(int i);
void setCurrentThumbnail(int i);
void setPages(int i, double ar);
void generateThumbnails(PDFDoc *doc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment