[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kviewshell
From: Wilfried Huss <Wilfried.Huss () gmx ! at>
Date: 2006-07-13 8:57:34
Message-ID: 1152781054.274281.32659.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 561776 by whuss:
port of commits 559496 and 559501:
Since we don't hold program state in the DocumentPageCache anymore,
move the current resolution into the DataModel.
M +2 -2 plugins/pdf/pdfWidget.cpp
M +12 -1 shell/dataModel.cpp
M +17 -0 shell/dataModel.h
M +6 -12 shell/documentPageCache.cpp
M +0 -13 shell/documentPageCache.h
M +1 -1 shell/documentWidget.cpp
M +2 -2 shell/kviewpart.cpp
M +3 -3 shell/presentationwidget.cpp
--- trunk/KDE/kdegraphics/kviewshell/plugins/pdf/pdfWidget.cpp #561775:561776
@@ -50,7 +50,7 @@
// with Control+Left Mousebutton
if (e->button() == Qt::MidButton || (e->button() == Qt::LeftButton && \
(e->modifiers() & Qt::ControlModifier))) {
- emit inverseSearch(pageNumber, inverseMap(e->pos()) * \
documentCache->getResolution(), true); + emit inverseSearch(pageNumber, \
inverseMap(e->pos()) * dataModel->resolution(), true); e->accept();
}
@@ -76,7 +76,7 @@
if ( e->modifiers() == Qt::NoModifier )
{
clearStatusBarTimer.stop();
- emit inverseSearch(pageNumber, inverseMap(e->pos()) / \
documentCache->getResolution(), false); + emit inverseSearch(pageNumber, \
inverseMap(e->pos()) / dataModel->resolution(), false);
if (!clearStatusBarTimer.isActive())
{
--- trunk/KDE/kdegraphics/kviewshell/shell/dataModel.cpp #561775:561776
@@ -38,7 +38,8 @@
DataModel::DataModel(QObject* parent)
: QObject(parent),
- _numberOfPages(0),
+ _numberOfPages(0),
+ resolutionInDPI(0.0),
_useCustomPageSize(false)
{
prefs = new KVSPrefs();
@@ -103,6 +104,16 @@
}
+void DataModel::setResolution(double resolution)
+{
+ if (resolution != resolutionInDPI)
+ {
+ resolutionInDPI = resolution;
+ emit resolutionChanged();
+ }
+}
+
+
void DataModel::deletePages(const PageNumber& from, const PageNumber& to)
{
// Paranoid safety checks
--- trunk/KDE/kdegraphics/kviewshell/shell/dataModel.h #561775:561776
@@ -55,6 +55,20 @@
unsigned int numberOfPages();
void setNumberOfPages(unsigned int);
+ /** @brief get the resolution currently used for drawing.
+
+ @returns the resolution of the display device. In
+ principle. In fact, kviewshell implements zooming by calling the
+ setResolution()-method with values that are not exactly the
+ resolution of the display, but multiplied with the zoom
+ factor. Bottom line: the documentRenderer should act as if this
+ field indeed contains resolution of the display device. When a
+ documentRenderer is constructed, this field is set to the actual
+ resolution to give a reasonable default value.
+ */
+ double resolution() const { return resolutionInDPI; }
+ void setResolution(double resolution);
+
/** @brief delete pages from the document
This method should be called whenever pages have been removed from
@@ -163,6 +177,7 @@
void currentPageNumberChanged();
void gotoCurrentPage();
void numberOfPagesChanged();
+ void resolutionChanged();
/** This signal es emitted whenever the selected text changes.
The argument is false if no text is selected, true otherwise.
@@ -202,6 +217,8 @@
PageNumber _currentPageNumber;
unsigned int _numberOfPages;
+ double resolutionInDPI;
+
QMap<PageNumber, QString> userBookmarks;
// A sorted list of the currently selected pages.
--- trunk/KDE/kdegraphics/kviewshell/shell/documentPageCache.cpp #561775:561776
@@ -33,8 +33,6 @@
renderQueue = new RenderQueue(this);
renderThread = new RenderThread(renderQueue);
- resolutionInDPI = 0.0;
-
renderThread->start();
}
@@ -98,10 +96,6 @@
return s;
}
-void DocumentPageCache::setResolution(double res)
-{
- resolutionInDPI = res;
-}
QSize DocumentPageCache::sizeOfPageInPixel(const PageNumber& pg) const
{
@@ -117,8 +111,8 @@
SimplePageSize ps = sizeOfPage(pg);
if (ps.isValid())
- return ps.sizeInPixel(resolutionInDPI);
- return dataModel->userPreferredPageSize().sizeInPixel(resolutionInDPI);
+ return ps.sizeInPixel(dataModel->resolution());
+ return dataModel->userPreferredPageSize().sizeInPixel(dataModel->resolution());
}
@@ -200,7 +194,7 @@
return;
}
- JobId id(pageNumber, resolutionInDPI, dataModel->preferences()->rotation(), \
false); + JobId id(pageNumber, dataModel->resolution(), \
dataModel->preferences()->rotation(), false); QString key = id.key();
if (!LRUCache[key])
{
@@ -258,7 +252,7 @@
return false;
}
- JobId id(pageNumber, resolutionInDPI, dataModel->preferences()->rotation(), \
false); + JobId id(pageNumber, dataModel->resolution(), \
dataModel->preferences()->rotation(), false);
// Check if the page that we are looking for is in the cache.
RenderedDocumentPagePixmap* page = LRUCache[id.key()];
@@ -291,7 +285,7 @@
return 0;
}
- JobId id(pageNr, resolutionInDPI, dataModel->preferences()->rotation(), false);
+ JobId id(pageNr, dataModel->resolution(), dataModel->preferences()->rotation(), \
false);
// First check if the page that we are looking for is in the cache
RenderedDocumentPagePixmap* page = LRUCache[id.key()];
@@ -300,7 +294,7 @@
return page;
// The page was not found in the cache, so we have render the page
- if (resolutionInDPI > 0.0)
+ if (dataModel->resolution() > 0.0)
{
if (async)
{
--- trunk/KDE/kdegraphics/kviewshell/shell/documentPageCache.h #561775:561776
@@ -59,9 +59,6 @@
deleted, or another renderer has been set. */
void setRenderer(DocumentRenderer*);
- void setResolution(double res);
- double getResolution() const {return resolutionInDPI;}
-
/** Returns the size of page 'page'. If the document does not
specify a size (which happens, e.g., for some DVI-files), then
the userPreferredSize is returned. */
@@ -127,16 +124,6 @@
TODO: make this configurable, or detact an appropriate value at startup. */
quint32 maxMemory;
- /** This field contains resolution of the display device. In
- principle. In fact, kviewshell implements zooming by calling the
- setResolution()-method with values that are not exactly the
- resolution of the display, but multiplied with the zoom
- factor. Bottom line: the documentRenderer should act as if this
- field indeed contains resolution of the display device. When a
- documentRenderer is constructed, this field is set to the actual
- resolution to give a reasonable default value. */
- double resolutionInDPI;
-
/** This list holds the cache. */
QCache<QString, RenderedDocumentPagePixmap> LRUCache;
--- trunk/KDE/kdegraphics/kviewshell/shell/documentWidget.cpp #561775:561776
@@ -982,7 +982,7 @@
QString DocumentWidget::printLength(int l) const
{
- double res = documentCache->getResolution();
+ double res = dataModel->resolution();
Length px;
px.setLength_in_pixel(l, res);
--- trunk/KDE/kdegraphics/kviewshell/shell/kviewpart.cpp #561775:561776
@@ -1851,7 +1851,7 @@
(multiPage->getRenderer().isNull()) )
return;
- pageView()->gotoPage(a.page, \
(int)(a.distance_from_top.getLength_in_inch()*pageCache.getResolution() + 0.5), \
true); + pageView()->gotoPage(a.page, (int)(a.distance_from_top.getLength_in_inch() \
* dataModel->resolution() + 0.5), true); }
@@ -1930,7 +1930,7 @@
if (zoom > ZoomLimits::MaxZoom/1000.0)
zoom = ZoomLimits::MaxZoom/1000.0;
- pageCache.setResolution(mainWidget->logicalDpiX()*zoom);
+ dataModel->setResolution(mainWidget->logicalDpiX()*zoom);
emit zoomChanged();
return zoom;
}
--- trunk/KDE/kdegraphics/kviewshell/shell/presentationwidget.cpp #561775:561776
@@ -59,7 +59,7 @@
m_width = -1;
- oldResolution = m_cache->getResolution();
+ oldResolution = dataModel->resolution();
// show widget and take control
showMaximized();
@@ -77,7 +77,7 @@
for ( ; fIt != fEnd; ++fIt )
delete *fIt;
- m_cache->setResolution(oldResolution);
+ dataModel->setResolution(oldResolution);
}
@@ -473,7 +473,7 @@
double zoomHeight = pageSize.zoomForHeight(m_height, *this);
double zoom = qMin(zoomWidth, zoomHeight);
- m_cache->setResolution(logicalDpiX()*zoom);
+ dataModel->setResolution(logicalDpiX()*zoom);
RenderedDocumentPagePixmap* pageData = m_cache->getPage(frame->page, false);
// Prerender the previous and next pages in the rendering thread.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic