phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/inc/infowidgetlayoutmanager.h
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 40 bab96b7ed1a4
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef INFOWIDGETLAYOUTMANAGER_H
       
    19 #define INFOWIDGETLAYOUTMANAGER_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QList>
       
    23 #include <QSizeF>
       
    24 #include <QRectF>
       
    25 #include <QMap>
       
    26 #include <hbdocumentloader.h>
       
    27 
       
    28 class QGraphicsLayout; 
       
    29 class QGraphicsWidget;
       
    30 class HbLabel;
       
    31 class HbIconItem;
       
    32 class HbPushButton;
       
    33 class HbMarqueeItem;
       
    34 class HbCheckBox; 
       
    35 
       
    36 /*!
       
    37  */
       
    38 class InfoWidgetDocumentLoader : public HbDocumentLoader
       
    39 {
       
    40 public:
       
    41     InfoWidgetDocumentLoader();
       
    42     virtual QObject *createObject(const QString& type,
       
    43                                   const QString &name);
       
    44 };
       
    45 
       
    46 class InfoWidgetLayoutManager : public QObject
       
    47 {
       
    48     Q_OBJECT
       
    49     
       
    50 public: 
       
    51     
       
    52     enum LayoutItemRole {
       
    53         RoleUndefined = 0,
       
    54         // Content widget, the main widget from document 
       
    55         RoleContent,
       
    56         // Marquee items 
       
    57         RoleMcnMarqueeItem,
       
    58         RoleSatMarqueeItem,
       
    59         // Labels 
       
    60         RoleSpnLabel,
       
    61         RoleMcnLabel, 
       
    62         RoleSatTextLabel,
       
    63         // Icons
       
    64         RoleSpnIcon, 
       
    65         RoleMcnIcon, 
       
    66         RoleSatTextIcon, 
       
    67         // Check boxes 
       
    68         RoleSpnCheckBox,
       
    69         RoleMcnCheckBox, 
       
    70         RoleSatTextCheckBox,
       
    71         // Buttons 
       
    72         RoleOkButton,
       
    73         // Layout containers
       
    74         RoleContainer, 
       
    75         RoleSettingsContainer, 
       
    76         // Must be the last enumeration        
       
    77         RoleLastEnum
       
    78         }; 
       
    79     
       
    80     enum DisplayRole {
       
    81         InfoDisplay,
       
    82         SettingsDisplay
       
    83         }; 
       
    84     
       
    85     InfoWidgetLayoutManager(QObject *parent = 0);
       
    86     ~InfoWidgetLayoutManager();
       
    87     
       
    88     void destroyObjects(); 
       
    89     
       
    90     DisplayRole currentDisplayRole(); 
       
    91     QList<LayoutItemRole> currentWidgetRoles(); 
       
    92     
       
    93     int layoutRows() const; 
       
    94     void setLayoutRows(int rows);
       
    95     qreal rowHeight() const; 
       
    96     
       
    97     QGraphicsLayout* layoutInfoDisplay();
       
    98     QGraphicsLayout* layoutSettingsDisplay(); 
       
    99     
       
   100     const QList<InfoWidgetLayoutManager::LayoutItemRole> widgetRoles(
       
   101             DisplayRole displayRole) const; 
       
   102 
       
   103     bool loadWidgets(const DisplayRole displayRole, 
       
   104             const QList<LayoutItemRole> &displayWidgets,
       
   105             QMap<LayoutItemRole, QGraphicsWidget *> &widgetMap);
       
   106     bool reloadWidgets(const DisplayRole displayRole);
       
   107     
       
   108     QGraphicsWidget* loadWidget(InfoWidgetDocumentLoader &loader, 
       
   109             DisplayRole displayRole, 
       
   110             LayoutItemRole widgetRole);
       
   111     
       
   112     QGraphicsWidget* getWidget(LayoutItemRole itemRole);
       
   113     QGraphicsWidget* contentWidget();
       
   114     
       
   115     void removeWidget(LayoutItemRole itemRole);
       
   116     void hideWidget(LayoutItemRole itemRole);
       
   117     void hideAll();
       
   118     void showAll();
       
   119     
       
   120     
       
   121 private:
       
   122     QMap<LayoutItemRole, QGraphicsWidget *> m_widgets; 
       
   123     QMap<LayoutItemRole, QGraphicsWidget *> m_infoDisplayWidgets; 
       
   124     QMap<LayoutItemRole, QGraphicsWidget *> m_settingsDisplayWidgets; 
       
   125 
       
   126     InfoWidgetDocumentLoader *m_documentLoader;
       
   127     DisplayRole m_displayRole; 
       
   128     int m_layoutRows;
       
   129     
       
   130 };
       
   131 
       
   132 
       
   133 #endif // INFOWIDGETLAYOUTMANAGER_H
       
   134