diff -r ba76fc04e6c2 -r 6b911d05207e phoneplugins/infowidgetplugin/infowidget/inc/infowidgetlayoutmanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phoneplugins/infowidgetplugin/infowidget/inc/infowidgetlayoutmanager.h Wed Jun 23 18:12:20 2010 +0300 @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +#ifndef INFOWIDGETLAYOUTMANAGER_H +#define INFOWIDGETLAYOUTMANAGER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class QGraphicsLayout; +class QGraphicsWidget; +class HbLabel; +class HbIconItem; +class HbPushButton; +class HbMarqueeItem; +class HbCheckBox; + +// Class declaration +class InfoWidgetDocumentLoader : public HbDocumentLoader +{ +public: + InfoWidgetDocumentLoader(); + virtual QObject *createObject(const QString& type, + const QString &name); +}; + +// Class declaration +class InfoWidgetLayoutManager : public QObject +{ + Q_OBJECT + +public: + + enum LayoutItemRole { + RoleUndefined = 0, + // Content widget, the main widget from document + RoleContent, + // Marquee items + RoleSpnMarqueeItem, + RoleMcnMarqueeItem, + RoleSatMarqueeItem, + // Icons + RoleSpnIcon, + RoleMcnIcon, + RoleSatTextIcon, + // Check boxes + RoleSpnCheckBox, + RoleMcnCheckBox, + RoleSatTextCheckBox, + // Dialogs + RoleSettingsDialog, + // Actions + RoleOkAction, + RoleCancelAction, + // List widgets + RoleSettingsList, + // Layout containers + RoleContainer, + RoleSettingsContainer, + // Must be the last enumeration, + RoleLastEnum + }; + + enum DisplayRole { + InfoDisplay, + SettingsDialog + }; + + InfoWidgetLayoutManager(QObject *parent = 0); + ~InfoWidgetLayoutManager(); + + DisplayRole currentDisplayRole(); + QList currentWidgetRoles(); + + QGraphicsLayout* layoutInfoDisplay(); + QGraphicsLayout* layoutSettingsDialog(); + + const QList widgetRoles( + DisplayRole displayRole) const; + + bool loadWidgets(const DisplayRole displayRole, + const QList &displayWidgets, + QMap &widgetMap); + bool reloadWidgets(const DisplayRole displayRole); + + QGraphicsWidget* loadWidget(InfoWidgetDocumentLoader &loader, + DisplayRole displayRole, + LayoutItemRole widgetRole); + QGraphicsWidget* getWidget(LayoutItemRole itemRole); + + QObject* loadObject(InfoWidgetDocumentLoader &loader, + DisplayRole displayRole, + LayoutItemRole objectRole); + QObject* getObject(LayoutItemRole itemRole); + + QGraphicsWidget* contentWidget(); + QList marqueeItems(); + + void removeWidget(LayoutItemRole itemRole, + bool deleteLater = false); + void destroyWidgets(); + + int layoutRows() const; + void setLayoutRows(int rows); + + qreal layoutRowHeight() const; + bool textFitsToRect(QString text, QFont font, QRectF rect); + +private: + QMap m_widgets; + QMap m_infoDisplayWidgets; + QMap m_settingsDialogWidgets; + QMap m_objects; + + InfoWidgetDocumentLoader *m_documentLoader; + DisplayRole m_displayRole; + int m_layoutRows; + +}; + + +#endif // INFOWIDGETLAYOUTMANAGER_H +