File indexing completed on 2024-05-12 16:39:48

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
0003    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
0004    Copyright (C) 2004-2014 Jarosław Staniek <staniek@kde.org>
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 
0022 #ifndef KFORMDESIGNERFORM_P_H
0023 #define KFORMDESIGNERFORM_P_H
0024 
0025 #include <kundo2stack.h>
0026 #include <KActionCollection>
0027 
0028 #include <config-kexi.h>
0029 #include "resizehandle.h"
0030 #include "commands.h"
0031 #include "form.h"
0032 
0033 //! @todo pixmapcollection
0034 #ifdef KEXI_PIXMAP_COLLECTIONS_SUPPORT
0035 #include "pixmapcollection.h"
0036 #endif
0037 
0038 #include <KPropertySet>
0039 #include <KProperty>
0040 
0041 #include <QProxyStyle>
0042 
0043 class QStyleOption;
0044 
0045 namespace KFormDesigner
0046 {
0047 
0048 class ObjectTree;
0049 
0050 //! Used to alter the widget's style at design time
0051 class DesignModeStyle : public QProxyStyle
0052 {
0053     Q_OBJECT
0054 public:
0055     explicit DesignModeStyle(const QString &baseStyleName);
0056 
0057     //! Reimplemented to remove handling of the State_MouseOver state.
0058     virtual void drawControl(ControlElement element, const QStyleOption *option,
0059                              QPainter *p, const QWidget *w = 0) const override;
0060 
0061 private:
0062     QStyleOption* alterOption(ControlElement element, const QStyleOption *option) const;
0063 };
0064 
0065 //--------------
0066 
0067 //! @internal
0068 class FormPrivate
0069 {
0070 public:
0071     FormPrivate(Form *form, WidgetLibrary *library, Form::Mode mode, KActionCollection &col,
0072                 KFormDesigner::ActionGroup &group);
0073     ~FormPrivate();
0074 
0075     void enableAction(const char* name, bool enable);
0076 
0077     void initPropertiesDescription();
0078 
0079     QString propertyCaption(const QByteArray &name);
0080 
0081     QString valueCaption(const QByteArray &name);
0082 
0083     void addPropertyCaption(const QByteArray &property, const QString &caption);
0084 
0085     void addValueCaption(const QByteArray &value, const QString &caption);
0086 
0087     KPropertyListData* createValueList(WidgetInfo *winfo, const QStringList &list);
0088 
0089     //! Sets color of selected widget(s) to value of @a p.
0090     //! @a roleMethod can be backgroundColor or foregroundColor.
0091     //! Makes background inherited if @a roleMethod if background and value is null.
0092     void setColorProperty(KProperty& p,
0093                           QPalette::ColorRole (QWidget::*roleMethod)() const,
0094                           const QVariant& value);
0095 
0096     Form::Mode mode;
0097     Form::State state;
0098     Form::Features features;
0099     QPoint insertionPoint;
0100     QPointer<Container>  toplevel;
0101     ObjectTree *topTree;
0102     QPointer<QWidget> widget;
0103     KPropertySet propertySet;
0104     QWidgetList selected;
0105     ResizeHandleSet::Hash resizeHandles;
0106     QByteArray selectedClass;
0107     bool modified;
0108     bool interactive;
0109     bool isUndoing;
0110     bool isRedoing;
0111     bool snapToGrid;
0112     int gridSize;
0113     QString  filename;
0114     KUndo2Stack undoStack;
0115     KActionCollection internalCollection;
0116     KActionCollection *collection;
0117     QPointer<KFormDesigner::ActionGroup> widgetActionGroup;
0118 
0119     ObjectTreeList  tabstops;
0120     bool autoTabstops;
0121 
0122 #ifdef KEXI_PIXMAP_COLLECTIONS_SUPPORT
0123     PixmapCollection  *pixcollection;
0124 #endif
0125 
0126     //! This map is used to store cursor shapes before inserting (so we can restore them later)
0127     QHash<QObject*, QCursor> cursors;
0128 
0129     FormWidget *formWidget;
0130 
0131     //! A set of head properties to be stored in a .ui file.
0132     //! This includes KFD format version.
0133     QHash<QByteArray, QString> headerProperties;
0134 
0135     //! Format version, set by FormIO or on creating a new form.
0136     QString formatVersion;
0137     //! Format version, set by FormIO's loader or on creating a new form.
0138     QString originalFormatVersion;
0139 
0140 #ifdef KFD_SIGSLOTS
0141     ConnectionBuffer  *connBuffer;
0142 
0143     //! This string list is used to store the widgets which hasMouseTracking() == true (eg lineedits)
0144     QStringList *mouseTrackers;
0145 
0146     //! true if slot connection is curently being painted
0147     Connection *connection;
0148 #endif
0149 
0150     //! used to update command's value when undoing
0151     PropertyCommand  *lastCommand;
0152     PropertyCommandGroup  *lastCommandGroup;
0153     int idOfPropertyCommand;
0154 
0155     bool slotPropertyChangedEnabled;
0156     bool slotPropertyChanged_addCommandEnabled;
0157     bool insideAddPropertyCommand;
0158     bool selectWidgetEnabled;
0159 
0160     // i18n stuff
0161     QMap<QByteArray, QString> propCaption;
0162     QMap<QByteArray, QString> propValCaption;
0163 
0164     QStyle *designModeStyle;
0165 
0166     QPointer<QWidget> inlineEditor;
0167     QPointer<Container> inlineEditorContainer;
0168     QByteArray editedWidgetClass;
0169     QString originalInlineText;
0170     bool pixmapsStoredInline;
0171 
0172     WidgetLibrary * const library;
0173 
0174 private:
0175     Form *q;
0176 };
0177 }
0178 
0179 #endif