From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kviewshell/marklist.h | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 kviewshell/marklist.h (limited to 'kviewshell/marklist.h') diff --git a/kviewshell/marklist.h b/kviewshell/marklist.h new file mode 100644 index 00000000..01458db3 --- /dev/null +++ b/kviewshell/marklist.h @@ -0,0 +1,186 @@ +// -*- C++ -*- +/* This file is part of the KDE project + Copyright (C) 2004 Wilfried Huss + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef MARKLIST_H +#define MARKLIST_H + +#include "pageNumber.h" + +#include +#include +#include + +class QCheckBox; +class QLabel; +class KPopupMenu; + +class DocumentPageCache; + +class MarkList; +class MarkListWidget; + + +/****** ThumbnailWidget ******/ + + +class ThumbnailWidget : public QWidget +{ + Q_OBJECT + +public: + ThumbnailWidget(MarkListWidget* parent_, const PageNumber& _pageNumber, DocumentPageCache*); + +private: + virtual void paintEvent(QPaintEvent*); + virtual void resizeEvent(QResizeEvent*); + +private slots: + void setThumbnail(); + +private: + PageNumber pageNumber; + + bool needsUpdating; + + DocumentPageCache* pageCache; + + MarkListWidget* parent; + + QPixmap thumbnail; +}; + + +/****** MarkListWidget ******/ + + +class MarkListWidget : public QWidget +{ + Q_OBJECT + +public: + MarkListWidget(QWidget* _parent, MarkList*, const PageNumber& _pageNumber, DocumentPageCache*, bool _showThumbnail = true); + + bool isChecked() const; + + bool isVisible(); + +public slots: + void toggle(); + void setChecked( bool checked ); + + void setSelected( bool selected ); + + int setNewWidth(int width); + +signals: + /** Emitted when the Page is selected in the ThumbnailView. */ + void selected(const PageNumber&); + + /** Emitted on right click. */ + void showPopupMenu(const PageNumber& pageNumber, const QPoint& position); + +protected: + virtual void mousePressEvent(QMouseEvent*); + +private: + + bool showThumbnail; + + ThumbnailWidget* thumbnailWidget; + QCheckBox* checkBox; + QLabel* pageLabel; + QColor _backgroundColor; + + const PageNumber pageNumber; + + DocumentPageCache* pageCache; + + static const int margin = 5; + + MarkList* markList; +}; + + +/****** MarkList ******/ + + +class MarkList: public QScrollView +{ + Q_OBJECT + +public: + MarkList(QWidget* parent = 0, const char* name = 0); + virtual ~MarkList(); + + void setPageCache(DocumentPageCache*); + + QValueList selectedPages() const; + + PageNumber currentPageNumber() { return currentPage; } + + PageNumber numberOfPages() { return widgetList.count(); } + + virtual QSize sizeHint() const { return QSize(); } + +public slots: + void setNumberOfPages(int numberOfPages, bool showThumbnails = true); + + void thumbnailSelected(const PageNumber& pageNumber); + void setCurrentPageNumber(const PageNumber& pageNumber); + + void clear(); + + void slotShowThumbnails(bool); + void repaintThumbnails(); + + void updateWidgetSize(const PageNumber&); + +protected: + virtual void viewportResizeEvent(QResizeEvent*); + + virtual void mousePressEvent(QMouseEvent*); + +signals: + void selected(const PageNumber&); + +private slots: + void showPopupMenu(const PageNumber& pageNumber, const QPoint& position); + + void selectAll(); + void selectEven(); + void selectOdd(); + void toggleSelection(); + void removeSelection(); + +private: + QPtrVector widgetList; + + PageNumber currentPage; + + PageNumber clickedThumbnail; + + DocumentPageCache* pageCache; + + bool showThumbnails; + + KPopupMenu* contextMenu; +}; + +#endif -- cgit v1.2.1