kpresenter

KPrSideBar.h

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef SIDEBAR_H
00022 #define SIDEBAR_H
00023 
00024 #include <qrect.h>
00025 #include <qstringlist.h>
00026 #include <qtabwidget.h>
00027 #include <qvalidator.h>
00028 
00029 #include <kiconview.h>
00030 #include <klistview.h>
00031 
00032 class QListViewItem;
00033 class KPrDocument;
00034 class KPrView;
00035 class QDropEvent;
00036 class QPopupMenu;
00037 class KPrOutline;
00038 class OutlineSlideItem;
00039 class KPrThumbBar;
00040 class ThumbToolTip;
00041 class KPrPage;
00042 
00043 
00044 class KPrRenamePageValidator : public QValidator
00045 {
00046   public:
00047     KPrRenamePageValidator( const QStringList & list=QStringList() )
00048         : QValidator( 0, 0 ), mStringList( list ) {}
00049     virtual State validate( QString & input, int & pos ) const;
00050 
00051   protected:
00052     QStringList mStringList;
00053 };
00054 
00055 class KPrSideBarBase
00056 {
00057 public:
00058     KPrSideBarBase(KPrDocument *_doc, KPrView *_view);
00059     void setViewMasterPage( bool _b );
00060 protected:
00061     KPrDocument *m_doc;
00062     KPrView *m_view;
00063     bool m_viewMasterPage;
00064 };
00065 
00066 class KPrThumbBar : public KIconView, public KPrSideBarBase
00067 {
00068     Q_OBJECT
00069 
00070 public:
00071     KPrThumbBar(QWidget *parent, KPrDocument *d, KPrView *v);
00072     ~KPrThumbBar();
00073     void setCurrentPage( int pg );
00074     void updateItem( int pagenr, bool sticky = false );
00075     void addItem( int pos );
00076     void moveItem( int oldPos, int newPos );
00077     void removeItem( int pos );
00078     void refreshItems ( bool offset = false );
00079     QRect tip(const QPoint &pos, QString &title);
00080 
00081     bool uptodate;
00082 
00083 signals:
00084     void showPage( int i );
00085 
00086 public slots:
00087     void rebuildItems();
00088 
00089 private slots:
00090     void itemClicked(QIconViewItem *i);
00091     void slotContentsMoving(int x, int y);
00092     void slotRefreshItems();
00093 
00094 private:
00095     QPixmap getSlideThumb(int slideNr) const;
00096 
00097     ThumbToolTip *m_thumbTip;
00098     int m_offsetX;
00099     int m_offsetY;
00100 };
00101 
00102 class KPrOutline: public KListView, public KPrSideBarBase
00103 {
00104     Q_OBJECT
00105 
00106 public:
00107     KPrOutline( QWidget *parent, KPrDocument *d, KPrView *v );
00108     ~KPrOutline();
00109     void setCurrentPage( int pg );
00110     QSize sizeHint() const { return QSize( 145, KListView::sizeHint().height() ); }
00111     void updateItem( int pagenr, bool sticky = false);
00112     void addItem( int pos );
00113     void moveItem( int oldPos, int newPos );
00114     void removeItem( int pos );
00115 
00116 protected:
00117     void contentsDropEvent( QDropEvent *e );
00118     void moveItem( QListViewItem *i, QListViewItem *firstAfter, QListViewItem *newAfter );
00119     OutlineSlideItem* slideItem( int pageNumber );
00120     bool acceptDrag( QDropEvent* e ) const;
00121 
00122     virtual QDragObject* dragObject();
00123 
00124 signals: // all page numbers 0-based
00125     void showPage( int i );
00126     void movePage( int from, int to );
00127     void selectPage( int i, bool );
00128 
00129 public slots:
00130     void rebuildItems();
00131     void renamePageTitle();
00132 
00133 private slots:
00134     void itemClicked( QListViewItem *i );
00135     void slotDropped( QDropEvent *e, QListViewItem *parent, QListViewItem *target );
00136     void rightButtonPressed( QListViewItem *i, const QPoint &pnt, int c );
00137     void slotContextMenu( KListView*, QListViewItem *item, const QPoint &p );
00138 
00139 private:
00140     QListViewItem *m_movedItem, *m_movedAfter;
00141 };
00142 
00143 class KPrSideBar: public QTabWidget
00144 {
00145     Q_OBJECT
00146 
00147 public:
00148     KPrSideBar(QWidget *parent, KPrDocument *d, KPrView *v);
00149     void setCurrentPage( int pg ) {
00150         m_outline->setCurrentPage(pg);
00151         m_thb->setCurrentPage(pg);
00152     };
00153     void setOn( int , bool ) { };
00154     //QSize sizeHint() const { return QSize( 120, QTabWidget::sizeHint().height() ); };
00155     void updateItem( KPrPage *page );
00156     void addItem( int pos );
00157     void moveItem( int oldPos, int newPos );
00158     void removeItem( int pos );
00159 
00160     KPrOutline *outline() const { return m_outline; };
00161     KPrThumbBar *thumbBar() const { return m_thb; };
00162 
00163     void setViewMasterPage( bool _masterPage );
00164 signals: // all page numbers 0-based
00165     void showPage( int i );
00166     void movePage( int from, int to );
00167     void selectPage( int i, bool );
00168 
00169 public slots:
00170     //void rebuildItems() { m_outline->rebuildItems(); m_thb->rebuildItems();};
00171     void renamePageTitle() { m_outline->renamePageTitle(); };
00172     void currentChanged(QWidget *tab);
00173 
00174 private:
00175     KPrOutline *m_outline;
00176     KPrThumbBar *m_thb;
00177 
00178     KPrDocument *m_doc;
00179     KPrView *m_view;
00180 };
00181 
00182 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys