phoneplugins/infowidgetplugin/infowidget/inc/infowidget.h
changeset 45 6b911d05207e
child 46 bc5a64e5bc3c
equal deleted inserted replaced
37:ba76fc04e6c2 45:6b911d05207e
       
     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 INFOWIDGET_H
       
    19 #define INFOWIDGET_H
       
    20 
       
    21 #include <hbwidget.h>
       
    22 #include <QList>
       
    23 #include <QFlags>
       
    24 #include "infowidgetlayoutmanager.h"
       
    25 #include "infowidgetengine.h"
       
    26 #include "infowidgetpreferences.h"
       
    27 
       
    28 // Forward declarations 
       
    29 class QGraphicsSceneMouseEvent;
       
    30 class QGraphicsLinearLayout;
       
    31 class QTranslator; 
       
    32 class HbDialog;
       
    33 class HbIconItem; 
       
    34 class HbMarqueeItem;
       
    35 class HbLabel; 
       
    36 class HbCheckBox; 
       
    37 class HbPushButton;
       
    38 class HbFrameItem;
       
    39 class HbAction; 
       
    40 class InfoWidgetEngine; 
       
    41 class InfoWidgetPreferences;
       
    42  
       
    43 // Class declaration
       
    44 class InfoWidget : public HbWidget
       
    45 {
       
    46     Q_OBJECT
       
    47 
       
    48 public: 
       
    49 
       
    50     // State for animation
       
    51     enum AnimationState {
       
    52         AnimationIdle, 
       
    53         AnimationStarting,
       
    54         AnimationOngoing
       
    55     } m_animationState; 
       
    56     
       
    57     // Delay for animation start
       
    58     enum AnimationStartDelay {
       
    59         StartNoDelay, 
       
    60         StartDelayed
       
    61     }; 
       
    62     
       
    63 public:    
       
    64     InfoWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
       
    65     ~InfoWidget();
       
    66 
       
    67 public: // From QGraphicsItem.
       
    68     QRectF boundingRect() const;
       
    69     QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const;  
       
    70     QSizePolicy sizePolicy () const;  
       
    71 
       
    72 public: // Property definitions
       
    73     Q_PROPERTY(QString homeZoneDisplay READ homeZoneDisplay WRITE setHomeZoneDisplay)
       
    74     Q_PROPERTY(QString mcnDisplay READ mcnDisplay WRITE setMcnDisplay)
       
    75     Q_PROPERTY(QString activeLineDisplay READ activeLineDisplay WRITE setActiveLineDisplay)
       
    76     Q_PROPERTY(QString satDisplay READ satDisplay WRITE setSatDisplay)
       
    77     Q_PROPERTY(QString spnDisplay READ spnDisplay WRITE setSpnDisplay)
       
    78     QString homeZoneDisplay();
       
    79     void setHomeZoneDisplay(QString value);
       
    80     QString mcnDisplay();
       
    81     void setMcnDisplay(QString value);
       
    82     QString activeLineDisplay();
       
    83     void setActiveLineDisplay(QString value);
       
    84     QString satDisplay();
       
    85     void setSatDisplay(QString value);
       
    86     QString spnDisplay();
       
    87     void setSpnDisplay(QString value);
       
    88     
       
    89 protected:
       
    90     void mousePressEvent(QGraphicsSceneMouseEvent *event);
       
    91     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 
       
    92     void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 
       
    93     void changeEvent(QEvent *event);
       
    94     void timerEvent(QTimerEvent *event);
       
    95     
       
    96     void updateInfoDisplay();
       
    97     bool readPersistentPreferences();
       
    98     void initializeCheckBoxStates(); 
       
    99     bool installTranslator(QString translationFile); 
       
   100     void removeTranslators(); 
       
   101      
       
   102 private: 
       
   103     void updateItemsVisibility();
       
   104     void layoutInfoDisplay(); 
       
   105     void updateInfoDisplayItem(
       
   106             InfoWidgetLayoutManager::LayoutItemRole itemRole, 
       
   107             QString text); 
       
   108     void layoutSettingsDialog();
       
   109     void initializeSettingsDialogItems();
       
   110     void startChanges(); 
       
   111     void endChanges(); 
       
   112 
       
   113 public slots: 
       
   114     // Slots for Homescreen FW callbacks
       
   115     void onInitialize();
       
   116     void onUninitialize();
       
   117     void onShow();
       
   118     void onHide();
       
   119 
       
   120     // Info widget specific slots 
       
   121     void readModel(); 
       
   122     void handleModelError(int operation,int errorCode);  
       
   123     void spnDisplaySettingChanged(int state);
       
   124     void mcnDisplaySettingChanged(int state);
       
   125     void satDisplaySettingChanged(int state);
       
   126 
       
   127     void settingsEditingFinished();
       
   128     void settingsEditingCancelled();
       
   129     void settingsValidationFailed(); 
       
   130     void settingsDialogClosed(HbAction* action); 
       
   131     
       
   132     bool startMarquees(AnimationStartDelay delay = StartNoDelay);
       
   133     void stopMarquees(); 
       
   134     void marqueeNext(); 
       
   135     
       
   136 signals: 
       
   137     void setPreferences(const QStringList &names);
       
   138 
       
   139 private:
       
   140     Q_DISABLE_COPY(InfoWidget)
       
   141     
       
   142     // Engine for widget, owned
       
   143     QScopedPointer<InfoWidgetEngine> m_engine;
       
   144     
       
   145     // Widget preference store, owned   
       
   146     QScopedPointer<InfoWidgetPreferences> m_preferences;
       
   147 
       
   148     // Layout manager for widget, owned 
       
   149     QScopedPointer<InfoWidgetLayoutManager> m_layoutManager;
       
   150     
       
   151     // Translators, owned
       
   152     QList<QTranslator *> m_translators;
       
   153 
       
   154     // Current widget layout, not owned 
       
   155     QGraphicsLinearLayout *m_layout;
       
   156     
       
   157     // Currently animating item(s), not owned 
       
   158     HbMarqueeItem *m_animatingItem; 
       
   159     QList<HbMarqueeItem *> m_animatingItems; 
       
   160     
       
   161     // Background frame drawer, not owned
       
   162     HbFrameItem *m_backgroundFrameItem;
       
   163     
       
   164     // Id of active timer 
       
   165     int m_timerId; 
       
   166     
       
   167     // Flags 
       
   168     bool m_layoutChanging;
       
   169     bool m_dragEvent; 
       
   170     bool m_initialized;
       
   171 
       
   172 };
       
   173 
       
   174 
       
   175 #endif // INFOWIDGET_H
       
   176