Diggory i think there was a misunderstanding in our discussion

The patch is unfinished (not goot to commit with a TODO)
and needs to be improved (need to find a way to not break ABI, QSize param should be const &) please
open a reviewrequest and we can discuss/finalize it there.

CCMAIL: diggory.hardy@unibas.ch
remotes/origin/Applications/14.12
Albert Astals Cid 12 years ago
parent e96dabc467
commit f76184cb55
  1. 12
      core/generator.h
  2. 4
      generators/epub/converter.cpp
  3. 9
      generators/epub/epubdocument.cpp
  4. 2
      generators/epub/epubdocument.h

@ -430,12 +430,6 @@ class OKULAR_EXPORT Generator : public QObject
*/ */
void setDPI(const QSizeF &dpi); void setDPI(const QSizeF &dpi);
/**
* Returns DPI, previously set via setDPI()
* @since 0.19 (KDE 4.13)
*/
QSizeF dpi() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
* This signal should be emitted whenever an error occurred in the generator. * This signal should be emitted whenever an error occurred in the generator.
@ -528,6 +522,12 @@ class OKULAR_EXPORT Generator : public QObject
*/ */
void updatePageBoundingBox( int page, const NormalizedRect & boundingBox ); void updatePageBoundingBox( int page, const NormalizedRect & boundingBox );
/**
* Returns DPI, previously set via setDPI()
* @since 0.19 (KDE 4.13)
*/
QSizeF dpi() const;
protected Q_SLOTS: protected Q_SLOTS:
/** /**
* Gets the font data for the given font * Gets the font data for the given font

@ -158,7 +158,6 @@ static QPoint calculateXYPosition( QTextDocument *document, int startPosition )
double x = startBoundingRect.x() ; double x = startBoundingRect.x() ;
double y = startBoundingRect.y() + startLine.y(); double y = startBoundingRect.y() + startLine.y();
//TODO: should this 800 be modified as in
y = (int)y % 800; y = (int)y % 800;
return QPoint(x,y); return QPoint(x,y);
@ -166,8 +165,7 @@ static QPoint calculateXYPosition( QTextDocument *document, int startPosition )
QTextDocument* Converter::convert( const QString &fileName ) QTextDocument* Converter::convert( const QString &fileName )
{ {
EpubDocument *newDocument = EpubDocument *newDocument = new EpubDocument(fileName);
new EpubDocument(fileName, generator()->dpi());
if (!newDocument->isValid()) { if (!newDocument->isValid()) {
emit error(i18n("Error while opening the EPub document."), -1); emit error(i18n("Error while opening the EPub document."), -1);
delete newDocument; delete newDocument;

@ -29,17 +29,12 @@ QString resourceUrl(const KUrl &baseUrl, const QString &u)
} }
EpubDocument::EpubDocument(const QString &fileName, QSizeF dpi) : EpubDocument::EpubDocument(const QString &fileName) : QTextDocument(),
QTextDocument(),
padding(20) padding(20)
{ {
mEpub = epub_open(qPrintable(fileName), 3); mEpub = epub_open(qPrintable(fileName), 3);
//NOTE: the 600, 800 values may or may not be a good base. Scaling by DPI setPageSize(QSizeF(600, 800));
// seems to produce reasonable results.
// Assume 96 is the base DPI
QSizeF size(600 * dpi.width() / 96.0f, 800 * dpi.height() / 96.0f);
setPageSize(size);
} }
bool EpubDocument::isValid() bool EpubDocument::isValid()

@ -22,7 +22,7 @@ namespace Epub {
class EpubDocument : public QTextDocument { class EpubDocument : public QTextDocument {
public: public:
EpubDocument(const QString &fileName, QSizeF dpi); EpubDocument(const QString &fileName);
bool isValid(); bool isValid();
~EpubDocument(); ~EpubDocument();
struct epub *getEpub(); struct epub *getEpub();

Loading…
Cancel
Save