File indexing completed on 2024-04-14 04:36:57

0001 /* This file is part of the KDE project
0002    Copyright (C) 2015 by Adam Pigg <adam@piggz.co.uk>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2.1 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KREPORTDESIGNERWIDGET_H
0021 #define KREPORTDESIGNERWIDGET_H
0022 
0023 #include <QDockWidget>
0024 #include <QPointer>
0025 #include <QScrollArea>
0026 #include <QToolBar>
0027 
0028 #include <KPropertyEditorView>
0029 #include <KPropertySet>
0030 
0031 class KReportDesigner;
0032 class QDomElement;
0033 class QMainWindow;
0034 class QScrollArea;
0035 
0036 //! KReportExample designer widget
0037 class ReportDesignerWidget : public QScrollArea
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     ReportDesignerWidget(QWidget *parent = nullptr);
0043     ~ReportDesignerWidget() override;
0044 
0045     //! Creates main toolbar for main window @a mainWindow
0046     //! @a mainWindow is required. To be called once.
0047     QToolBar* createMainToolBar(QMainWindow *mainWindow);
0048 
0049     //! Creates items toolbar for main window @a mainWindow
0050     //! @a mainWindow is required. To be called once.
0051     QToolBar* createItemsToolBar(QMainWindow *mainWindow);
0052 
0053     //! Creates a property editor dock widget for the main window @a mainWindow.
0054     //! The widget is added to the area @a area is it is not Qt::NoDockWidgetArea.
0055     //! @a mainWindow is required. To be called once.
0056     QDockWidget* createPropertyEditorDockWidget(QMainWindow *mainWindow,
0057                                                 Qt::DockWidgetArea area = Qt::NoDockWidgetArea);
0058 
0059     //! @return current document
0060     QDomElement document() const;
0061 
0062 Q_SIGNALS:
0063     void designChanged(const QDomElement&);
0064 
0065 private Q_SLOTS:
0066     void slotItemInserted(const QString &itemId);
0067     void slotDesignerPropertySetChanged();
0068     void designDirty();
0069 
0070 private:
0071     KReportDesigner *m_reportDesigner;
0072 
0073     QPointer<QToolBar> m_mainToolBar;
0074     QPointer<QToolBar> m_itemToolBar;
0075 
0076     QPointer<QDockWidget> m_propertyDock;
0077     QPointer<KPropertyEditorView> m_propertyEditor;
0078 };
0079 
0080 #endif // KREPORTDESIGNERWIDGET_H