tools/designer/src/lib/shared/qdesigner_toolbox_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 QDESIGNER_TOOLBOX_H
       
    54 #define QDESIGNER_TOOLBOX_H
       
    55 
       
    56 #include "shared_global_p.h"
       
    57 #include "qdesigner_propertysheet_p.h"
       
    58 #include "qdesigner_utils_p.h"
       
    59 #include <QtGui/QPalette>
       
    60 
       
    61 QT_BEGIN_NAMESPACE
       
    62 
       
    63 namespace qdesigner_internal {
       
    64     class PromotionTaskMenu;
       
    65 }
       
    66 
       
    67 class QToolBox;
       
    68 
       
    69 class QAction;
       
    70 class QMenu;
       
    71 
       
    72 class QDESIGNER_SHARED_EXPORT QToolBoxHelper : public QObject
       
    73 {
       
    74     Q_OBJECT
       
    75 
       
    76     explicit QToolBoxHelper(QToolBox *toolbox);
       
    77 public:
       
    78     // Install helper on QToolBox
       
    79     static void install(QToolBox *toolbox);
       
    80     static QToolBoxHelper *helperOf(const QToolBox *toolbox);
       
    81     // Convenience to add a menu on a toolbox
       
    82     static QMenu *addToolBoxContextMenuActions(const QToolBox *toolbox, QMenu *popup);
       
    83 
       
    84     QPalette::ColorRole currentItemBackgroundRole() const;
       
    85     void setCurrentItemBackgroundRole(QPalette::ColorRole role);
       
    86 
       
    87     bool eventFilter(QObject *watched, QEvent *event);
       
    88     // Add context menu and return page submenu or 0.
       
    89 
       
    90     QMenu *addContextMenuActions(QMenu *popup) const;
       
    91 
       
    92 private slots:
       
    93     void removeCurrentPage();
       
    94     void addPage();
       
    95     void addPageAfter();
       
    96     void changeOrder();
       
    97 
       
    98 private:
       
    99     QToolBox *m_toolbox;
       
   100     QAction *m_actionDeletePage;
       
   101     QAction *m_actionInsertPage;
       
   102     QAction *m_actionInsertPageAfter;
       
   103     QAction *m_actionChangePageOrder;
       
   104     qdesigner_internal::PromotionTaskMenu* m_pagePromotionTaskMenu;
       
   105 };
       
   106 
       
   107 // PropertySheet to handle the page properties
       
   108 class QDESIGNER_SHARED_EXPORT QToolBoxWidgetPropertySheet : public QDesignerPropertySheet {
       
   109 public:
       
   110     explicit QToolBoxWidgetPropertySheet(QToolBox *object, QObject *parent = 0);
       
   111 
       
   112     virtual void setProperty(int index, const QVariant &value);
       
   113     virtual QVariant property(int index) const;
       
   114     virtual bool reset(int index);
       
   115     virtual bool isEnabled(int index) const;
       
   116 
       
   117     // Check whether the property is to be saved. Returns false for the page
       
   118     // properties (as the property sheet has no concept of 'stored')
       
   119     static bool checkProperty(const QString &propertyName);
       
   120 
       
   121 private:
       
   122     enum ToolBoxProperty { PropertyCurrentItemText, PropertyCurrentItemName, PropertyCurrentItemIcon,
       
   123                            PropertyCurrentItemToolTip,  PropertyTabSpacing, PropertyToolBoxNone };
       
   124 
       
   125     static ToolBoxProperty toolBoxPropertyFromName(const QString &name);
       
   126     QToolBox *m_toolBox;
       
   127     struct PageData
       
   128         {
       
   129         qdesigner_internal::PropertySheetStringValue text;
       
   130         qdesigner_internal::PropertySheetStringValue tooltip;
       
   131         qdesigner_internal::PropertySheetIconValue icon;
       
   132         };
       
   133     QMap<QWidget *, PageData> m_pageToData;
       
   134 };
       
   135 
       
   136 typedef QDesignerPropertySheetFactory<QToolBox, QToolBoxWidgetPropertySheet> QToolBoxWidgetPropertySheetFactory;
       
   137 
       
   138 QT_END_NAMESPACE
       
   139 
       
   140 #endif // QDESIGNER_TOOLBOX_H