tools/designer/src/lib/shared/formwindowbase_p.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Designer of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 //
       
    43 //  W A R N I N G
       
    44 //  -------------
       
    45 //
       
    46 // This file is not part of the Qt API.  It exists for the convenience
       
    47 // of Qt Designer.  This header
       
    48 // file may change from version to version without notice, or even be removed.
       
    49 //
       
    50 // We mean it.
       
    51 //
       
    52 
       
    53 #ifndef FORMWINDOWBASE_H
       
    54 #define FORMWINDOWBASE_H
       
    55 
       
    56 #include "shared_global_p.h"
       
    57 
       
    58 #include <QtDesigner/QDesignerFormWindowInterface>
       
    59 
       
    60 #include <QtCore/QVariantMap>
       
    61 #include <QtCore/QList>
       
    62 
       
    63 QT_BEGIN_NAMESPACE
       
    64 
       
    65 class QDesignerDnDItemInterface;
       
    66 class QMenu;
       
    67 class QtResourceSet;
       
    68 class QDesignerPropertySheet;
       
    69 
       
    70 namespace qdesigner_internal {
       
    71 
       
    72 class QEditorFormBuilder;
       
    73 class DeviceProfile;
       
    74 class Grid;
       
    75 
       
    76 class DesignerPixmapCache;
       
    77 class DesignerIconCache;
       
    78 class FormWindowBasePrivate;
       
    79 
       
    80 class QDESIGNER_SHARED_EXPORT FormWindowBase: public QDesignerFormWindowInterface
       
    81 {
       
    82     Q_OBJECT
       
    83 public:
       
    84     enum HighlightMode  { Restore, Highlight };
       
    85     enum SaveResourcesBehaviour  { SaveAll, SaveOnlyUsedQrcFiles, DontSaveQrcFiles };
       
    86 
       
    87     explicit FormWindowBase(QDesignerFormEditorInterface *core, QWidget *parent = 0, Qt::WindowFlags flags = 0);
       
    88     virtual ~FormWindowBase();
       
    89 
       
    90     QVariantMap formData();
       
    91     void setFormData(const QVariantMap &vm);
       
    92 
       
    93     // Return contents without warnings. Should be 'contents(bool quiet)'
       
    94     QString fileContents() const;
       
    95 
       
    96     // Return the widget containing the form. This is used to
       
    97     // apply embedded design settings to that are inherited (for example font).
       
    98     // These are meant to be applied to the form only and not to the other editors
       
    99     // in the widget stack.
       
   100     virtual QWidget *formContainer() const = 0;
       
   101 
       
   102     // Deprecated
       
   103     virtual QPoint grid() const;
       
   104 
       
   105     // Deprecated
       
   106     virtual void setGrid(const QPoint &grid);
       
   107 
       
   108     virtual bool hasFeature(Feature f) const;
       
   109     virtual Feature features() const;
       
   110     virtual void setFeatures(Feature f);
       
   111 
       
   112     const Grid &designerGrid() const;
       
   113     void setDesignerGrid(const  Grid& grid);
       
   114 
       
   115     bool hasFormGrid() const;
       
   116     void setHasFormGrid(bool b);
       
   117 
       
   118     bool gridVisible() const;
       
   119 
       
   120     SaveResourcesBehaviour saveResourcesBehaviour() const;
       
   121     void setSaveResourcesBehaviour(SaveResourcesBehaviour behaviour);
       
   122 
       
   123     static const Grid &defaultDesignerGrid();
       
   124     static void setDefaultDesignerGrid(const Grid& grid);
       
   125 
       
   126     // Overwrite to initialize and return a full popup menu for a managed widget
       
   127     virtual QMenu *initializePopupMenu(QWidget *managedWidget);
       
   128     // Helper to create a basic popup menu from task menu extensions (internal/public)
       
   129     static QMenu *createExtensionTaskMenu(QDesignerFormWindowInterface *fw, QObject *o, bool trailingSeparator = true);
       
   130 
       
   131     virtual bool dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, QWidget *target,
       
   132                              const QPoint &global_mouse_pos) = 0;
       
   133 
       
   134     // Helper to find the widget at the mouse position with some flags.
       
   135     enum WidgetUnderMouseMode { FindSingleSelectionDropTarget, FindMultiSelectionDropTarget };
       
   136     QWidget *widgetUnderMouse(const QPoint &formPos, WidgetUnderMouseMode m);
       
   137 
       
   138     virtual QWidget *widgetAt(const QPoint &pos) = 0;
       
   139     virtual QWidget *findContainer(QWidget *w, bool excludeLayout) const = 0;
       
   140 
       
   141     void deleteWidgetList(const QWidgetList &widget_list);
       
   142 
       
   143     virtual void highlightWidget(QWidget *w, const QPoint &pos, HighlightMode mode = Highlight) = 0;
       
   144 
       
   145     enum PasteMode { PasteAll, PasteActionsOnly };
       
   146     virtual void paste(PasteMode pasteMode) = 0;
       
   147 
       
   148     // Factory method to create a form builder
       
   149     virtual QEditorFormBuilder *createFormBuilder() = 0;
       
   150 
       
   151     virtual bool blockSelectionChanged(bool blocked) = 0;
       
   152     virtual void emitSelectionChanged() = 0;
       
   153 
       
   154     DesignerPixmapCache *pixmapCache() const;
       
   155     DesignerIconCache *iconCache() const;
       
   156     QtResourceSet *resourceSet() const;
       
   157     void setResourceSet(QtResourceSet *resourceSet);
       
   158     void addReloadableProperty(QDesignerPropertySheet *sheet, int index);
       
   159     void removeReloadableProperty(QDesignerPropertySheet *sheet, int index);
       
   160     void addReloadablePropertySheet(QDesignerPropertySheet *sheet, QObject *object);
       
   161     void removeReloadablePropertySheet(QDesignerPropertySheet *sheet);
       
   162     void reloadProperties();
       
   163 
       
   164     void emitWidgetRemoved(QWidget *w);
       
   165     void emitObjectRemoved(QObject *o);
       
   166 
       
   167     DeviceProfile deviceProfile() const;
       
   168     QString styleName() const;
       
   169     QString deviceProfileName() const;
       
   170 
       
   171     enum LineTerminatorMode {
       
   172         LFLineTerminator,
       
   173         CRLFLineTerminator,
       
   174         NativeLineTerminator =
       
   175 #if defined (Q_OS_WIN)
       
   176             CRLFLineTerminator
       
   177 #else
       
   178             LFLineTerminator
       
   179 #endif
       
   180     };
       
   181 
       
   182     void setLineTerminatorMode(LineTerminatorMode mode);
       
   183     LineTerminatorMode lineTerminatorMode() const;
       
   184 
       
   185     // Connect the 'activated' (doubleclicked) signal of the form window to a
       
   186     // slot triggering the default action (of the task menu)
       
   187     static void setupDefaultAction(QDesignerFormWindowInterface *fw);
       
   188 
       
   189 public slots:
       
   190     void resourceSetActivated(QtResourceSet *resourceSet, bool resourceSetChanged);
       
   191 
       
   192 private slots:
       
   193     void triggerDefaultAction(QWidget *w);
       
   194 
       
   195 private:
       
   196     void syncGridFeature();
       
   197 
       
   198     FormWindowBasePrivate *m_d;    
       
   199 };
       
   200 
       
   201 }  // namespace qdesigner_internal
       
   202 
       
   203 QT_END_NAMESPACE
       
   204 
       
   205 #endif // FORMWINDOWBASE_H