okular/kpdf/thumbnaillist.h
Enrico Ros 16908b2f0c Changed pixmap requesting methods. Now each request is packed into a
PixmapRequest class. When requesting pixmaps, one or multiple requests are
sent to the Document that (frees memory as in current policy) and send each
PixmapRequest to the current Generator. Added a signal in generators to
notify the Document when a pixmap generation has finished.

PageView, ThumbnailsList, PreviewWidget have been unbroken after the memory
management commit. (mem management seems in pretty good shape..it's smart.)
Added 'visible widgets' list to those classes to speed up searching and
processing on visible widgets only.

Note: asyncronous pixmap requests can now be queued and we're getting very
close to the threaded generator.

Note2: Leakfixes and memory improvements.

Final NOTE: head merging is possible now, as all remaining work can be
considered bugfixes.. API is getting final. It will only change in xpdf
dep stuff, the already undefined Viewport object and some bits in
Generators.

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=372787
2004-12-22 18:21:36 +00:00

91 lines
3 KiB
C++

/***************************************************************************
* 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 THUMBNAILLIST_H
#define THUMBNAILLIST_H
#include <qscrollview.h>
#include <qvaluevector.h>
#include <qvbox.h>
#include "document.h"
class QTimer;
class KActionCollection;
class ThumbnailWidget;
/**
* @short A scrollview that displays pages pixmaps previews (aka thumbnails).
*
* ...
*/
class ThumbnailList : public QScrollView, public KPDFDocumentObserver
{
Q_OBJECT
public:
ThumbnailList(QWidget *parent, KPDFDocument *document);
// inherited: return thumbnails observer id
uint observerId() const { return THUMBNAILS_ID; }
// inherited: create thumbnails ( inherited as a DocumentObserver )
void pageSetup( const QValueVector<KPDFPage*> & pages, bool documentChanged );
// inherited: hilihght current thumbnail ( inherited as DocumentObserver )
void pageSetCurrent( int pageNumber, const QRect & viewport );
// inherited: tell if pixmap is hidden and can be unloaded
bool canUnloadPixmap( int pageNumber );
// inherited: redraw thumbnail ( inherited as DocumentObserver )
void notifyPixmapChanged( int pageNumber );
// inherited: request all visible pixmap (due to a global shange or so..)
void notifyPixmapsCleared();
// redraw visible widgets (useful for refreshing contents...)
void updateWidgets();
protected:
// scroll up/down the view
void keyPressEvent( QKeyEvent * e );
// select a thumbnail by clicking on it
void contentsMousePressEvent( QMouseEvent * );
// resize thumbnails to fit the width
void viewportResizeEvent( QResizeEvent * );
// file drop related events (an url may be dropped even here)
void dragEnterEvent( QDragEnterEvent* );
void dropEvent( QDropEvent* );
signals:
void urlDropped( const KURL& );
public slots:
// make requests for generating pixmaps for visible thumbnails
void slotRequestPixmaps( int newContentsX = -1, int newContentsY = -1 );
private:
void requestPixmaps( int delayMs = 0 );
KPDFDocument *m_document;
ThumbnailWidget *m_selected;
QTimer *m_delayTimer;
QValueVector<ThumbnailWidget *> m_thumbnails;
QValueList<ThumbnailWidget *> m_visibleThumbnails;
int m_vectorIndex;
};
/**
* @short A vertical boxed container with zero size hint (for insertion on left toolbox)
*/
class ThumbnailsBox : public QVBox
{
public:
ThumbnailsBox( QWidget * parent ) : QVBox( parent ) {};
QSize sizeHint() const { return QSize(); }
};
#endif