homescreen/widgetplugins/hsbookmarkwidgetplugin/inc/hsbookmarkwidget.h
changeset 12 afcd8e6d025b
child 16 3c88a81ff781
equal deleted inserted replaced
11:786160610b4d 12:afcd8e6d025b
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Homescreen bookmark widget
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef HSBOOKMARKWIDGET_H
       
    19 #define HSBOOKMARKWIDGET_H
       
    20 
       
    21 #include <HbWidget>
       
    22 
       
    23 class HbFrameItem;    
       
    24 class HbIconItem;
       
    25 class HbTextItem;
       
    26 class HbTouchArea;
       
    27 
       
    28 class HsBookmarkWidget : public HbWidget
       
    29 {
       
    30     Q_OBJECT
       
    31     
       
    32     Q_PROPERTY(QString rootPath READ rootPath WRITE setRootPath)
       
    33     
       
    34     // Persistent property of the homescreen bookmark widget. They are stored in homescreen
       
    35     // WidgetProperty of homescreen.db.
       
    36     Q_PROPERTY(QString bookmarkTitle READ bookmarkTitle WRITE setBookmarkTitle)
       
    37     Q_PROPERTY(QString bookmarkUrl READ bookmarkUrl WRITE setBookmarkUrl)
       
    38     Q_PROPERTY(QString faviconFileName READ faviconFileName WRITE setFaviconFileName)
       
    39     Q_PROPERTY(QString faviconPath READ faviconPath WRITE setFaviconPath)
       
    40 
       
    41 public:
       
    42     HsBookmarkWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
       
    43     ~HsBookmarkWidget();
       
    44     
       
    45     enum {
       
    46         maxDisplayLen = 6
       
    47     };
       
    48     
       
    49     enum {
       
    50         faviconPoint = 37
       
    51     };
       
    52     
       
    53     enum {
       
    54         faviconSize = 35
       
    55     };
       
    56     
       
    57     void setRootPath(const QString &rootPath);
       
    58     QString rootPath()const;
       
    59     
       
    60     void setBookmarkTitle(const QString &bookmarkTitle);
       
    61     QString bookmarkTitle() const;
       
    62     void setBookmarkUrl(const QString &bookmarkUrl);
       
    63     QString bookmarkUrl() const;
       
    64     void setFaviconFileName(const QString &faviconFileName);
       
    65     QString faviconFileName() const;
       
    66     void setFaviconPath(const QString &faviconPath);
       
    67     QString faviconPath() const;
       
    68     
       
    69     bool eventFilter(QObject *watched, QEvent *event);
       
    70 
       
    71 public slots:
       
    72 
       
    73     void onInitialize();
       
    74     void onShow();
       
    75     void onHide();
       
    76 
       
    77 private:
       
    78     
       
    79     void handleMousePressEvent(QGraphicsSceneMouseEvent *event);
       
    80     void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event);
       
    81     void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
       
    82             
       
    83     void createPrimitives();
       
    84 
       
    85     void setBackgroundToNormal();
       
    86     void setBackgroundToPressed();
       
    87     
       
    88     void updateContent(const QString title, const HbIcon& icon);
       
    89     
       
    90     QImage createImageWithOverlay(const QImage& baseImage, const QPoint& point, const QImage& overlayImage);
       
    91     HbIcon createIconWithOverlay(HbIcon& baseIcon, const QPoint& point, HbIcon& overlayIcon);
       
    92     
       
    93     void removeFavicon();
       
    94     
       
    95 private:
       
    96     Q_DISABLE_COPY(HsBookmarkWidget)
       
    97 	  
       
    98     HbFrameItem *mBackground;
       
    99     HbIconItem *mIcon;
       
   100     HbTextItem *mText;
       
   101     HbTouchArea *mTouchArea;
       
   102     
       
   103     QString mRootPath;
       
   104     QString mBookmarkTitle;
       
   105     QString mBookmarkUrl;
       
   106     QString mFaviconFileName;
       
   107     QString mFaviconPath;
       
   108 };
       
   109 
       
   110 #endif // HSBOOKMARKWIDGET_H