Warning, file /office/calligra/libs/main/KoView.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 0003 Copyright (C) 2007 Thomas Zander <zander@kde.org> 0004 Copyright (C) 2010 Benjamin Port <port.benjamin@gmail.com> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 Boston, MA 02110-1301, USA. 0020 */ 0021 #ifndef __koView_h__ 0022 #define __koView_h__ 0023 0024 #include <QWidget> 0025 #include <kxmlguiclient.h> 0026 #include "komain_export.h" 0027 0028 class KoPart; 0029 class KoDocument; 0030 class KoMainWindow; 0031 class KoPrintJob; 0032 class KoViewPrivate; 0033 class KoZoomController; 0034 struct KoPageLayout; 0035 0036 // Qt classes 0037 class QStatusBar; 0038 class QDragEnterEvent; 0039 class QDropEvent; 0040 class QPrintDialog; 0041 0042 /** 0043 * This class is used to display a KoDocument. 0044 * 0045 * Multiple views can be attached to one document at a time. 0046 */ 0047 class KOMAIN_EXPORT KoView : public QWidget, public KXMLGUIClient 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 /** 0053 * Creates a new view for the document. Usually you don't create views yourself 0054 * since the Calligra components come with their own view classes which inherit 0055 * KoView. 0056 * 0057 * The standard way to retrieve a KoView is to call KoPart::createView. 0058 * 0059 * @param part is the KoPart for the document. 0060 * @param document is the document which should be displayed in this view. This pointer 0061 * must not be zero. 0062 * @param parent parent widget for this view. 0063 */ 0064 KoView(KoPart *part, KoDocument *document, QWidget *parent = 0); 0065 0066 /** 0067 * Destroys the view and unregisters at the document. 0068 */ 0069 ~KoView() override; 0070 0071 // QWidget overrides 0072 protected: 0073 0074 void dragEnterEvent(QDragEnterEvent * event) override; 0075 0076 /** 0077 * dropEvent by default calls addImages. Your KoView subclass might 0078 * override dropEvent and if your app can also handle images, call this 0079 * method. 0080 */ 0081 void dropEvent(QDropEvent * event) override; 0082 0083 // KoView api 0084 0085 /** 0086 * Adds the given list of QImages as imageshapes to the view's document. 0087 * 0088 * @param imageList a list of QImages that can be inserted 0089 * @param insertAt the position in screen pixels where the images 0090 * can be inserted. 0091 */ 0092 virtual void addImages(const QVector<QImage> &imageList, const QPoint &insertAt); 0093 0094 public: 0095 0096 /** 0097 * Retrieves the document object of this view. 0098 */ 0099 KoDocument *koDocument() const; 0100 0101 /** 0102 * Tells this view that its document has got deleted (called internally) 0103 */ 0104 void setDocumentDeleted(); 0105 0106 /** 0107 * In order to print the document represented by this view a new print job should 0108 * be constructed that is capable of doing the printing. 0109 * The default implementation returns 0, which silently cancels printing. 0110 */ 0111 virtual KoPrintJob * createPrintJob(); 0112 0113 /** 0114 * In order to export the document represented by this view a new print job should 0115 * be constructed that is capable of doing the printing. 0116 * The default implementation call createPrintJob. 0117 */ 0118 virtual KoPrintJob * createPdfPrintJob(); 0119 0120 /** 0121 * @return the page layout to be used for printing. 0122 * Default is the documents layout. 0123 * Reimplement if your application needs to use a different layout. 0124 */ 0125 virtual KoPageLayout pageLayout() const; 0126 0127 /** 0128 * Create a QPrintDialog based on the @p printJob 0129 */ 0130 virtual QPrintDialog *createPrintDialog(KoPrintJob *printJob, QWidget *parent); 0131 0132 /** 0133 * @return the KoMainWindow in which this view is currently. 0134 */ 0135 KoMainWindow * mainWindow() const; 0136 0137 /** 0138 * @return the statusbar of the KoMainWindow in which this view is currently. 0139 */ 0140 QStatusBar * statusBar() const; 0141 0142 /** 0143 * This adds a widget to the statusbar for this view. 0144 * If you use this method instead of using statusBar() directly, 0145 * KoView will take care of removing the items when the view GUI is deactivated 0146 * and readding them when it is reactivated. 0147 * The parameters are the same as QStatusBar::addWidget(). 0148 * 0149 * Note that you can't use KStatusBar methods (inserting text items by id). 0150 * But you can create a KStatusBarLabel with a dummy id instead, and use 0151 * it directly, to get the same look and feel. 0152 */ 0153 void addStatusBarItem(QWidget * widget, int stretch = 0, bool permanent = false); 0154 0155 /** 0156 * Remove a widget from the statusbar for this view. 0157 */ 0158 void removeStatusBarItem(QWidget * widget); 0159 0160 /** 0161 * You have to implement this method and disable/enable certain functionality (actions for example) in 0162 * your view to allow/disallow editing of the document. 0163 */ 0164 virtual void updateReadWrite(bool readwrite) = 0; 0165 0166 /** 0167 * Return the zoomController for this view. 0168 */ 0169 virtual KoZoomController *zoomController() const = 0; 0170 0171 /// create a list of actions that when activated will change the unit on the document. 0172 QList<QAction*> createChangeUnitActions(bool addPixelUnit = false); 0173 0174 /** 0175 * @brief guiActivateEvent is called when the window activates a view. Reimplement this for any special behaviour. 0176 */ 0177 virtual void guiActivateEvent(bool activated); 0178 0179 public Q_SLOTS: 0180 0181 /** 0182 * Display a message in the status bar (calls QStatusBar::message()) 0183 * @todo rename to something more generic 0184 */ 0185 void slotActionStatusText(const QString &text); 0186 0187 /** 0188 * End of the message in the status bar (calls QStatusBar::clear()) 0189 * @todo rename to something more generic 0190 */ 0191 void slotClearStatusText(); 0192 0193 /** 0194 * Updates the author profile actions from configuration. 0195 */ 0196 void slotUpdateAuthorProfileActions(); 0197 0198 protected: 0199 0200 /** 0201 * Generate a name for this view. 0202 */ 0203 QString newObjectName(); 0204 0205 protected Q_SLOTS: 0206 0207 virtual void changeAuthorProfile(const QString &profileName); 0208 0209 private: 0210 virtual void setupGlobalActions(void); 0211 KoViewPrivate * const d; 0212 }; 0213 0214 #endif