src/hbcore/gui/hbview.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    41 #include <QPointer>
    41 #include <QPointer>
    42 
    42 
    43 /*!
    43 /*!
    44     @stable
    44     @stable
    45     @hbcore
    45     @hbcore
    46 	\class HbView
    46     \class HbView
    47 	\brief The HbView class defines one screen of user interface content.
    47     \brief The HbView class defines one screen of user interface content.
    48     
    48 
    49     The screen area of a mobile device is small, so an application's user interface is often composed of a set of separate screens of content or "views". Each view can contain a number of widgets. A view can also contain a title, an icon (not used at present), a menu and a toolbar. These additional components are called decorators and together they make up the "chrome" of the interface.
    49     The screen area of a mobile device is small, so an application's user interface is often composed of a set of separate screens of content or "views". Each view can contain a number of widgets. A view can also contain a title, an icon (not used at present), a menu and a toolbar. These additional components are called decorators and together they make up the "chrome" of the interface.
    50     
    50 
    51     An application will have a number of views to present different kinds of information to the user. You can add multiple views to the \link HbMainWindow main window \endlink of your application and then manage them through the main window object. When a view is activated, the main window handles the updating of the view contents, i.e. the title, icon, menu and toolbar. The view object itself handles the visibility of the toolbar, but the main window will repaint it whenever the view is activated.
    51     An application will have a number of views to present different kinds of information to the user. You can add multiple views to the \link HbMainWindow main window \endlink of your application and then manage them through the main window object. When a view is activated, the main window handles the updating of the view contents, i.e. the title, icon, menu and toolbar. The view object itself handles the visibility of the toolbar, but the main window will repaint it whenever the view is activated.
    52 
    52 
    53     \image html hbview_wireframes.png "Wireframes of two different views in a messaging application"
    53     \image html hbview_wireframes.png "Wireframes of two different views in a messaging application"
    54 
    54 
    55    
    55 
    56     \section _usecases_hbview Using the HbView class
    56     \section _usecases_hbview Using the HbView class
    57     In general, the actual widgets, menu and toolbar that make up the content of a view will be designed with a UI layout tool. This means you do not need to use code to place each widget into the layout but instead load the layout from a file with HbDocumentLoader. Once the view is populated with widgets, you can manipulate them and connect their signals to methods in your application.
    57     In general, the actual widgets, menu and toolbar that make up the content of a view will be designed with a UI layout tool. This means you do not need to use code to place each widget into the layout but instead load the layout from a file with HbDocumentLoader. Once the view is populated with widgets, you can manipulate them and connect their signals to methods in your application.
    58 
    58 
    59     See the HbMainWindow class for information about switching between different views.
    59     See the HbMainWindow class for information about switching between different views.
    60 
    60 
    61     \subsection _uc_001_hbview Hiding and showing the chrome 
    61     \subsection _uc_001_hbview Hiding and showing the chrome
    62     The chrome, (i.e. title, menu and toolbar of the view) can be hidden to allow your application to fill the whole screen. Also, individual components of the chrome can be hidden if desired.
    62     The chrome, (i.e. title, menu and toolbar of the view) can be hidden to allow your application to fill the whole screen. Also, individual components of the chrome can be hidden if desired.
    63 
    63 
    64     \code 
    64     \code
    65     // Hide all the chrome items
    65     // Hide all the chrome items
    66     myView.setContentFullScreen(true)
    66     myView.setContentFullScreen(true)
    67 
    67 
    68     // Show all the chrome items
    68     // Show all the chrome items
    69     myView.setContentFullScreen(false)
    69     myView.setContentFullScreen(false)
   116 /*!
   116 /*!
   117     \enum HbView::HbViewFlag
   117     \enum HbView::HbViewFlag
   118     Defines policy for showing the HbTitleBar in the current HbView.
   118     Defines policy for showing the HbTitleBar in the current HbView.
   119 */
   119 */
   120 /*!
   120 /*!
   121     \var HbView::ViewFlagNone 
   121     \var HbView::ViewFlagNone
   122     Titlebar and statusbar is shown with the default attributes.
   122     Titlebar and statusbar is shown with the default attributes.
   123 */
   123 */
   124 /*!
   124 /*!
   125     \var HbView::ViewTitleBarMinimizable
   125     \var HbView::ViewTitleBarMinimizable
   126     When this flag is set, there will be an indication in the titlebar showing the possibility to minimize the titlebar, e.g. swipe it off the screen.
   126     When this flag is set, there will be an indication in the titlebar showing the possibility to
       
   127     minimize the titlebar, e.g. swipe it off the screen.
   127 */
   128 */
   128 /*!
   129 /*!
   129     \var HbView::ViewTitleBarMinimized
   130     \var HbView::ViewTitleBarMinimized
   130     Show the title bar in minimized state.
   131     Show the title bar in minimized state.
   131 */
   132 */
   132 /*!
   133 /*!
   133     \var HbView::ViewTitleBarHidden
   134     \var HbView::ViewTitleBarHidden
   134     Do not show the title bar at all. The title bar handle is not shown and it is not possible to maximize the title bar.
   135     Do not show the title bar at all.
       
   136     The title bar handle is not shown and it is not possible to maximize the title bar.
   135 */
   137 */
   136 /*!
   138 /*!
   137     \var HbView::ViewTitleBarTransparent
   139     \var HbView::ViewTitleBarTransparent
   138     Show normal style title bar but make it transparent. This flag is normally used in combination with TitleBarFloating flag.
   140     Show normal style title bar but make it transparent.
       
   141     This flag is normally used in combination with TitleBarFloating flag.
   139 */
   142 */
   140 /*!
   143 /*!
   141     \var HbView::ViewTitleBarFloating
   144     \var HbView::ViewTitleBarFloating
   142     Show the title bar floating on top of the underlying content. Setting this flag also make the application area start from the top of the screen. This flag is normally used in combination with TitleBarTransparent flag.
   145     Show the title bar floating on top of the underlying content.
       
   146     Setting this flag also make the application area start from the top of the screen.
       
   147     This flag is normally used in combination with TitleBarTransparent flag.
   143 */
   148 */
   144 /*!
   149 /*!
   145     \var HbView::ViewStatusBarHidden
   150     \var HbView::ViewStatusBarHidden
   146     Do not show the statusbar at all. This flag is normally used in combination with the ViewTitleBarHidden flag.
   151     Do not show the statusbar at all.
       
   152     This flag is normally used in combination with the ViewTitleBarHidden flag.
   147 */
   153 */
   148 /*!
   154 /*!
   149     \var HbView::ViewStatusBarTransparent
   155     \var HbView::ViewStatusBarTransparent
   150     Show the statusbar with normal content but transparent. This flag is normally used in combination with ViewStatusBarFloating flag.
   156     Show the statusbar with normal content but transparent.
       
   157     This flag is normally used in combination with ViewStatusBarFloating flag.
   151 */
   158 */
   152 /*!
   159 /*!
   153     \var HbView::ViewStatusBarFloating
   160     \var HbView::ViewStatusBarFloating
   154     Show the statusbar on top of the underlying content. Setting this flag also changes the application area to start from the top of the screen. This flag is normally used in combination with the ViewStatusBarTransparent flag.
   161     Show the statusbar on top of the underlying content.
       
   162     Setting this flag also changes the application area to start from the top of the screen.
       
   163     This flag is normally used in combination with the ViewStatusBarTransparent flag.
       
   164 */
       
   165 /*!
       
   166     \var HbView::ViewDisableRelayout
       
   167     This flag disables relayoting of the view when hiding the title and/or status bar.
       
   168     This flag is normally used in combination with ViewTitleBarHidden and/or ViewStatusBarHiddenflag.
   155 */
   169 */
   156 
   170 
   157 /*!
   171 /*!
   158     \enum HbView::ActionContainer
   172     \enum HbView::ActionContainer
   159     Defines the default container when you add actions to a view.
   173     Defines the default container when you add actions to a view.
   160     
   174 
   161     \sa navigationAction()
   175     \sa navigationAction()
   162 */
   176 */
   163 /*!
   177 /*!
   164     \var HbView::NotSpecified
   178     \var HbView::NotSpecified
   165     Indicate that no particular action container is preferred.
   179     Indicate that no particular action container is preferred.
   175 
   189 
   176 /*!
   190 /*!
   177     \fn void HbView::titleChanged(const QString &title)
   191     \fn void HbView::titleChanged(const QString &title)
   178 
   192 
   179     This signal is emitted when the title is replaced by a different title.
   193     This signal is emitted when the title is replaced by a different title.
   180     
   194 
   181     \sa setTitle()
   195     \sa setTitle()
   182  */
   196  */
   183 
   197 
   184 /*!
   198 /*!
   185     \fn void HbView::iconChanged(const HbIcon &icon)
   199     \fn void HbView::iconChanged(const HbIcon &icon)
   186 
   200 
   187     This signal is emitted when the icon is replaced by a different icon.
   201     This signal is emitted when the icon is replaced by a different icon.
   188     
   202 
   189     \sa setIcon()
   203     \sa setIcon()
   190  */
   204  */
   191 
   205 
   192 /*!
   206 /*!
   193     \fn void HbView::toolBarChanged()
   207     \fn void HbView::toolBarChanged()
   194 
   208 
   195     This signal is emitted when toolbar is replaced by a different toolbar.
   209     This signal is emitted when toolbar is replaced by a different toolbar.
   196     
   210 
   197     \sa setToolBar()
   211     \sa setToolBar()
   198  */
   212  */
   199 
   213 
   200 /*!
   214 /*!
   201    \fn void HbView::visibleItemsChanged()
   215    \fn void HbView::visibleItemsChanged()
   202  
   216 
   203    This signal is emitted when items in the chrome (e.g. toolbar, menu) are made visible or hidden.
   217    This signal is emitted when items in the chrome (e.g. toolbar, menu) are made visible or hidden.
   204    
   218 
   205    \sa visibleItems()
   219    \sa visibleItems()
   206 */
   220 */
   207 
   221 
   208 /*!
   222 /*!
   209    \fn void HbView::contentFullScreenChanged()
   223    \fn void HbView::contentFullScreenChanged()
   210  
   224 
   211    This signal is emitted when the view is set to occupy the whole screen.
   225    This signal is emitted when the view is set to occupy the whole screen.
   212    
   226 
   213    \sa setContentFullScreen()
   227    \sa setContentFullScreen()
   214 */
   228 */
   215 
   229 
   216 /*!
   230 /*!
   217    \fn void HbView::dockWidgetChanged()
   231    \fn void HbView::dockWidgetChanged()
   218  
   232 
   219    This signal is emitted when the dock widget is replaced by a different dock widget.
   233    This signal is emitted when the dock widget is replaced by a different dock widget.
   220    
   234 
   221    \sa setDockWidget()
   235    \sa setDockWidget()
   222 */
   236 */
   223 
   237 
   224 /*!
   238 /*!
   225     \fn int HbView::type() const
   239     \fn int HbView::type() const
   227 
   241 
   228 /*!
   242 /*!
   229     \internal
   243     \internal
   230  */
   244  */
   231 HbViewPrivate::HbViewPrivate()
   245 HbViewPrivate::HbViewPrivate()
   232     : mLayout(0), 
   246     : mLayout(0),
   233       menu(0), 
   247       menu(0),
   234       toolBar(0), 
   248       toolBar(0),
   235       dockWidget(0),
   249       dockWidget(0),
   236       widget(0),
   250       widget(0),
   237       mVisibleItems(Hb::AllItems),
   251       mVisibleItems(Hb::AllItems),
   238       mVisibleItemsSet(false),
   252       mVisibleItemsSet(false),
   239       mFullscreen(false),
   253       mFullscreen(false),
   264 }
   278 }
   265 
   279 
   266 /*!
   280 /*!
   267     \internal
   281     \internal
   268  */
   282  */
   269 HbView::HbView( HbViewPrivate &dd, QGraphicsItem *parent ):
   283 HbView::HbView(HbViewPrivate &dd, QGraphicsItem *parent):
   270     HbWidget(dd, parent)
   284     HbWidget(dd, parent)
   271 {
   285 {
   272     Q_D(HbView);
   286     Q_D(HbView);
   273     d->q_ptr = this; 
   287     d->q_ptr = this;
   274 }
   288 }
   275 
   289 
   276 /*!
   290 /*!
   277     Destructor.
   291     Destructor.
   278 */
   292 */
   369 */
   383 */
   370 void HbView::setMenu(HbMenu *menu)
   384 void HbView::setMenu(HbMenu *menu)
   371 {
   385 {
   372     Q_D(HbView);
   386     Q_D(HbView);
   373     if (d->menu != menu) {
   387     if (d->menu != menu) {
   374         if(d->menu) {
   388         if (d->menu) {
   375             d->menu->deleteLater();
   389             d->menu->deleteLater();
   376         }
   390         }
   377         d->menu = menu;
   391         d->menu = menu;
   378         if (d->menu) {
   392         if (d->menu) {
   379             HbMenuPrivate::d_ptr(d->menu)->changeToOptionsMenu();
   393             HbMenuPrivate::d_ptr(d->menu)->changeToOptionsMenu();
   387         }
   401         }
   388     }
   402     }
   389 }
   403 }
   390 
   404 
   391 /*!
   405 /*!
   392     Returns the toolbar for the view. If the view does not already have a toolbar, an 
   406     Returns the toolbar for the view. If the view does not already have a toolbar, an
   393 	empty toolbar is created and returned to the caller but the toolBarChanged() 
   407     empty toolbar is created and returned to the caller but the toolBarChanged()
   394 	signal is not emitted.
   408     signal is not emitted.
   395 
   409 
   396     Ownership is not transferred.
   410     Ownership is not transferred.
   397 
   411 
   398     \sa HbToolBar setToolBar()
   412     \sa HbToolBar setToolBar()
   399 */
   413 */
   428 
   442 
   429 /*!
   443 /*!
   430 Removes the toolbar from the view and returns it to the caller.
   444 Removes the toolbar from the view and returns it to the caller.
   431 Ownership of the toolbar is transferred to the caller.
   445 Ownership of the toolbar is transferred to the caller.
   432 
   446 
   433 \note This function is particularly useful if you want to switch to a 
   447 \note This function is particularly useful if you want to switch to a
   434 different view and keep the same toolbar.
   448 different view and keep the same toolbar.
   435 
   449 
   436     \sa setToolBar()
   450     \sa setToolBar()
   437 */
   451 */
   438 HbToolBar* HbView::takeToolBar()
   452 HbToolBar *HbView::takeToolBar()
   439 {
   453 {
   440     Q_D(HbView);
   454     Q_D(HbView);
   441     HbToolBar* toolBar = d->toolBar;
   455     HbToolBar *toolBar = d->toolBar;
   442     d->toolBar = 0;
   456     d->toolBar = 0;
   443 
   457 
   444     // Reset the ownership
   458     // Reset the ownership
   445     if (toolBar) {
   459     if (toolBar) {
   446         toolBar->setParentItem(0);
   460         toolBar->setParentItem(0);
   510     Q_D(HbView);
   524     Q_D(HbView);
   511     if (d->widget != widget) {
   525     if (d->widget != widget) {
   512         if (widget) {
   526         if (widget) {
   513             if (!d->mLayout) {
   527             if (!d->mLayout) {
   514                 d->mLayout = new HbStackedLayout;
   528                 d->mLayout = new HbStackedLayout;
   515                 d->mLayout->setContentsMargins( 0.0, 0.0, 0.0, 0.0 );
   529                 d->mLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
   516                 d->mLayout->setMinimumSize( 0.0, 0.0 );
   530                 d->mLayout->setMinimumSize(0.0, 0.0);
   517                 setLayout( d->mLayout );
   531                 setLayout(d->mLayout);
   518             } else {
   532             } else {
   519                 Q_ASSERT(d->mLayout->count() == 1);
   533                 Q_ASSERT(d->mLayout->count() == 1);
   520                 d->mLayout->removeAt( 0 );
   534                 d->mLayout->removeAt(0);
   521             }
   535             }
   522             d->mLayout->addItem( widget );
   536             d->mLayout->addItem(widget);
   523         } else {
   537         } else {
   524             if (d->mLayout) {
   538             if (d->mLayout) {
   525                 // "setLayout( 0 )" deletes the existing layout.
   539                 // "setLayout( 0 )" deletes the existing layout.
   526                 setLayout( 0 );
   540                 setLayout(0);
   527                 d->mLayout = 0;
   541                 d->mLayout = 0;
   528             }
   542             }
   529         }
   543         }
   530         delete d->widget;
   544         delete d->widget;
   531         d->widget = widget;            
   545         d->widget = widget;
   532     }
   546     }
   533 }
   547 }
   534 
   548 
   535 /*!
   549 /*!
   536 Removes the widget that makes up the view and returns the widget to the caller.
   550 Removes the widget that makes up the view and returns the widget to the caller.
   537 Ownership of the widget is transferred to the caller.
   551 Ownership of the widget is transferred to the caller.
   538 
   552 
   539 \note This function is particularly useful if you want to use 
   553 \note This function is particularly useful if you want to use
   540 different widgets in a view without deleting them.
   554 different widgets in a view without deleting them.
   541 
   555 
       
   556 \note The widget is not removed from the scene.
       
   557 
   542 \sa widget() setWidget()
   558 \sa widget() setWidget()
   543 */
   559 */
   544 QGraphicsWidget *HbView::takeWidget()
   560 QGraphicsWidget *HbView::takeWidget()
   545 {
   561 {
   546     Q_D(HbView);
   562     Q_D(HbView);
   547     QGraphicsWidget *widget = d->widget;
   563     QGraphicsWidget *widget = d->widget;
   548     if ( d->mLayout ) {
   564     if (d->mLayout) {
   549         d->mLayout->removeAt( 0 );
   565         d->mLayout->removeAt(0);
   550         // "setLayout( 0 )" deletes the existing layout.
   566         // "setLayout( 0 )" deletes the existing layout.
   551         setLayout( 0 );
   567         setLayout(0);
   552         d->mLayout = 0;
   568         d->mLayout = 0;
   553     }
   569     }
   554     d->widget = 0;
   570     d->widget = 0;
   555     // Reset the ownership
   571     // Reset the ownership
   556     if (widget) {
   572     if (widget) {
   561 
   577 
   562 /*!
   578 /*!
   563     Makes the given scene items visible in this view. Changes are visible
   579     Makes the given scene items visible in this view. Changes are visible
   564     instantly if the view is active, otherwise they will be shown the next time the
   580     instantly if the view is active, otherwise they will be shown the next time the
   565     view is activated.
   581     view is activated.
   566     
   582 
   567     The flag values in \a items override the corresponding settings in HbMainWindow.
   583     The flag values in \a items override the corresponding settings in HbMainWindow.
   568     
   584 
   569     \sa hideItems() setItemVisible() isItemVisible() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   585     \sa hideItems() setItemVisible() isItemVisible() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   570 */
   586 */
   571 void HbView::showItems(Hb::SceneItems items)
   587 void HbView::showItems(Hb::SceneItems items)
   572 {
   588 {
   573     Q_D(HbView);
   589     Q_D(HbView);
   588     Hides the given scene items in this view. Changes are visible
   604     Hides the given scene items in this view. Changes are visible
   589     instantly if the view is active, otherwise they will be shown the next time the
   605     instantly if the view is active, otherwise they will be shown the next time the
   590     view is activated.
   606     view is activated.
   591 
   607 
   592     The flag values in \a items override the corresponding settings in HbMainWindow.
   608     The flag values in \a items override the corresponding settings in HbMainWindow.
   593     
   609 
   594         
   610 
   595     \sa showItems() setItemVisible() isItemVisible() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   611     \sa showItems() setItemVisible() isItemVisible() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   596 */
   612 */
   597 void HbView::hideItems(Hb::SceneItems items)
   613 void HbView::hideItems(Hb::SceneItems items)
   598 {
   614 {
   599     Q_D(HbView);
   615     Q_D(HbView);
   612 
   628 
   613 /*!
   629 /*!
   614     Returns the scene items that are visible in this view.
   630     Returns the scene items that are visible in this view.
   615 
   631 
   616     \sa isItemVisible() setItemVisible() hideItems() showItems() unsetVisibleItems() isContentFullScreen() setContentFullScreen()
   632     \sa isItemVisible() setItemVisible() hideItems() showItems() unsetVisibleItems() isContentFullScreen() setContentFullScreen()
   617     
   633 
   618 */
   634 */
   619 Hb::SceneItems HbView::visibleItems() const
   635 Hb::SceneItems HbView::visibleItems() const
   620 {
   636 {
   621     Q_D(const HbView);
   637     Q_D(const HbView);
   622     if (d->mVisibleItemsSet) {
   638     if (d->mVisibleItemsSet) {
   628 
   644 
   629 /*!
   645 /*!
   630     Returns \c true if \a item is set to be visible, otherwise returns \c false.
   646     Returns \c true if \a item is set to be visible, otherwise returns \c false.
   631 
   647 
   632     \sa setItemVisible() hideItems() showItems() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   648     \sa setItemVisible() hideItems() showItems() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   633     
   649 
   634 */
   650 */
   635 bool HbView::isItemVisible(Hb::SceneItem item) const
   651 bool HbView::isItemVisible(Hb::SceneItem item) const
   636 {
   652 {
   637     Q_D(const HbView);
   653     Q_D(const HbView);
   638     return d->mVisibleItems & item;
   654     return d->mVisibleItems & item;
   640 
   656 
   641 /*!
   657 /*!
   642     Shows or hides the given scene item for the view. If \a visible is \c true,
   658     Shows or hides the given scene item for the view. If \a visible is \c true,
   643     then the given \a item is shown. If \a visible is \c false, then
   659     then the given \a item is shown. If \a visible is \c false, then
   644     the given \a item is hidden.
   660     the given \a item is hidden.
   645 	Changes are visible instantly if the view is active, otherwise they will be shown the next time the
   661     Changes are visible instantly if the view is active, otherwise they will be shown the next time the
   646     view is activated.    
   662     view is activated.
   647 
   663 
   648     This overrides the corresponding scene item settings in HbMainWindow.
   664     This overrides the corresponding scene item settings in HbMainWindow.
   649            
   665 
   650     \sa isItemVisible() hideItems() showItems() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   666     \sa isItemVisible() hideItems() showItems() unsetVisibleItems() visibleItems() isContentFullScreen() setContentFullScreen()
   651 */
   667 */
   652 void HbView::setItemVisible(Hb::SceneItem item, bool visible)
   668 void HbView::setItemVisible(Hb::SceneItem item, bool visible)
   653 {
   669 {
   654     Q_D(HbView);
   670     Q_D(HbView);
   668     Q_D(const HbView);
   684     Q_D(const HbView);
   669     return d->mFullscreen;
   685     return d->mFullscreen;
   670 }
   686 }
   671 
   687 
   672 /*!
   688 /*!
   673     Makes the view content fill the whole screen area. The decorators that make up the chrome (such as 
   689     Makes the view content fill the whole screen area. The decorators that make up the chrome (such as
   674     signal bar, title pane etc.) can still be shown on top of view content.
   690     signal bar, title pane etc.) can still be shown on top of view content.
   675 	Changes are visible instantly if the view is active, otherwise they will
   691     Changes are visible instantly if the view is active, otherwise they will
   676 	be shown the next time the view is activated.    
   692     be shown the next time the view is activated.
   677 
   693 
   678     \sa isContentFullScreen() setItemVisible() isItemVisible() hideItems() showItems() visibleItems()
   694     \sa isContentFullScreen() setItemVisible() isItemVisible() hideItems() showItems() visibleItems()
   679 */
   695 */
   680 void HbView::setContentFullScreen(bool enable)
   696 void HbView::setContentFullScreen(bool enable)
   681 {
   697 {
   761         if (d->toolBar) {
   777         if (d->toolBar) {
   762             d->toolBar->updatePrimitives();
   778             d->toolBar->updatePrimitives();
   763         }
   779         }
   764 
   780 
   765         // Statusbar-visibility
   781         // Statusbar-visibility
   766         if ( statusBar->isVisible() ){
   782         if (d->mViewFlags & HbView::ViewStatusBarHidden) {
       
   783             d->mVisibleItems &= ~Hb::StatusBarItem;
       
   784             d->mVisibleItemsSet = true;
       
   785         } else {
   767             d->mVisibleItems |= Hb::StatusBarItem;
   786             d->mVisibleItems |= Hb::StatusBarItem;
   768             d->mVisibleItemsSet = true;
   787             d->mVisibleItemsSet = true;
       
   788         }
       
   789 
       
   790         // Titlebar-visibility
       
   791         if (d->mViewFlags & HbView::ViewTitleBarHidden) {
       
   792             d->mVisibleItems &= ~Hb::TitleBarItem;
       
   793             d->mVisibleItemsSet = true;
   769         } else {
   794         } else {
   770             d->mVisibleItems &= ~Hb::StatusBarItem;
       
   771             d->mVisibleItemsSet = true;
       
   772         }
       
   773 
       
   774         // Titlebar-visibility
       
   775         if (titleBar->isVisible()){
       
   776             d->mVisibleItems |= Hb::TitleBarItem;
   795             d->mVisibleItems |= Hb::TitleBarItem;
   777             d->mVisibleItemsSet = true;
   796             d->mVisibleItemsSet = true;
   778         }else{
       
   779             d->mVisibleItems &= ~Hb::TitleBarItem;
       
   780             d->mVisibleItemsSet = true;
       
   781         }
   797         }
   782 
   798 
   783         // Repolish the screen if needed
   799         // Repolish the screen if needed
   784         int visibilityFlags = HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating 
   800         int visibilityFlags = HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating
   785             | HbView::ViewTitleBarMinimizable | HbView::ViewStatusBarHidden | HbView::ViewStatusBarFloating;
   801                               | HbView::ViewTitleBarMinimizable | HbView::ViewStatusBarHidden | HbView::ViewStatusBarFloating
       
   802                               | HbView::ViewTitleBarHidden | HbView::ViewDisableRelayout;
   786         if ((d->mViewFlags & visibilityFlags) != (originalFlags & visibilityFlags)) {
   803         if ((d->mViewFlags & visibilityFlags) != (originalFlags & visibilityFlags)) {
   787             HbMainWindowPrivate::d_ptr(mainWindow())->mClippingItem->decoratorVisibilityChanged();
   804             HbMainWindowPrivate::d_ptr(mainWindow())->mClippingItem->decoratorVisibilityChanged();
   788         }
   805         }
   789     }
   806     }
   790 }
   807 }
   802     Q_D(HbView);
   819     Q_D(HbView);
   803     if (visible) {
   820     if (visible) {
   804         setViewFlags(d->mViewFlags &~ HbView::ViewTitleBarHidden);
   821         setViewFlags(d->mViewFlags &~ HbView::ViewTitleBarHidden);
   805     } else {
   822     } else {
   806         setViewFlags(d->mViewFlags | HbView::ViewTitleBarHidden);
   823         setViewFlags(d->mViewFlags | HbView::ViewTitleBarHidden);
   807     }  
   824     }
   808 }
   825 }
   809 
   826 
   810 /*!
   827 /*!
   811     Changes the statusbar's visibility and uses the pre-defined effect.
   828     Changes the statusbar's visibility and uses the pre-defined effect.
   812 
   829 
   827 
   844 
   828 /*!
   845 /*!
   829     \overload
   846     \overload
   830 
   847 
   831 
   848 
   832     This adds the \a action to the list of actions in the view. You specify a preferred container 
   849     This adds the \a action to the list of actions in the view. You specify a preferred container
   833     in the UI where you would like the action to be added, e.g. the options menu or the toolbar. 
   850     in the UI where you would like the action to be added, e.g. the options menu or the toolbar.
   834     However, if you choose the toolbar as the preferred container but no more buttons can fit in the 
   851     However, if you choose the toolbar as the preferred container but no more buttons can fit in the
   835     the toolbar, then the action might be moved to the options menu or it might displace another item in the toolbar. 
   852     the toolbar, then the action might be moved to the options menu or it might displace another item in the toolbar.
   836     The result depends on the prioties of the actions already in the toolbar compared with the priority of 
   853     The result depends on the prioties of the actions already in the toolbar compared with the priority of
   837     the action you are adding.
   854     the action you are adding.
   838     
   855 
   839     Ownership of the \a action is not transferred.
   856     Ownership of the \a action is not transferred.
   840 */
   857 */
   841 void HbView::addAction(HbAction *action, ActionContainer preferredActionContainer)
   858 void HbView::addAction(HbAction *action, ActionContainer preferredActionContainer)
   842 {
   859 {
   843     Q_D(HbView);
   860     Q_D(HbView);
   856             d->actionManager = new HbViewActionManager(this);
   873             d->actionManager = new HbViewActionManager(this);
   857         }
   874         }
   858         QActionEvent *actionEvent = static_cast<QActionEvent *>(event);
   875         QActionEvent *actionEvent = static_cast<QActionEvent *>(event);
   859         HbAction *hbAction = qobject_cast<HbAction *>(actionEvent->action());
   876         HbAction *hbAction = qobject_cast<HbAction *>(actionEvent->action());
   860         // Forward command to action manager
   877         // Forward command to action manager
   861         d->actionManager->removeAction(hbAction); 
   878         d->actionManager->removeAction(hbAction);
   862         return true;
   879         return true;
   863     }
   880     } else if (event->type() == QEvent::ActionAdded) {
   864     else if (event->type() == QEvent::ActionAdded) {
       
   865         // Create action manager if needed
   881         // Create action manager if needed
   866         if (!d->actionManager) {
   882         if (!d->actionManager) {
   867             d->actionManager = new HbViewActionManager(this);
   883             d->actionManager = new HbViewActionManager(this);
   868         }
   884         }
   869         QActionEvent *actionEvent = static_cast<QActionEvent *>(event);
   885         QActionEvent *actionEvent = static_cast<QActionEvent *>(event);
   870         HbAction *hbAction = qobject_cast<HbAction *>(actionEvent->action());
   886         HbAction *hbAction = qobject_cast<HbAction *>(actionEvent->action());
   871         // Forward command to action manager
   887         // Forward command to action manager
   872         d->actionManager->addAction(hbAction, d->preferredActionContainer); 
   888         d->actionManager->addAction(hbAction, d->preferredActionContainer);
   873         // Clear the variable after used
   889         // Clear the variable after used
   874         d->preferredActionContainer = HbView::NotSpecified;
   890         d->preferredActionContainer = HbView::NotSpecified;
   875         return true;
   891         return true;
   876     }
   892     }
   877     return HbWidget::event(event);
   893     return HbWidget::event(event);
   878 }
   894 }
   879 
   895 
   880 /*!
   896 /*!
   881     \reimp
   897     \reimp
   882  */
   898  */
   883 void HbView::changeEvent(QEvent *event){
   899 void HbView::changeEvent(QEvent *event)
   884     
   900 {
       
   901 
   885     // We're listening for layout direction changes, because the screen needs to be
   902     // We're listening for layout direction changes, because the screen needs to be
   886     // repolished, if the layout direction changes and the titlebar is minimizable.
   903     // repolished, if the layout direction changes and the titlebar is minimizable.
   887     // We have to listen to the event here(and not in the titlebar), cause the layout
   904     // We have to listen to the event here(and not in the titlebar), cause the layout
   888     // direction change event is delivered to the titlebar (cause it does not mirror)
   905     // direction change event is delivered to the titlebar (cause it does not mirror)
   889     if (event->type() == QEvent::LayoutDirectionChange
   906     if (event->type() == QEvent::LayoutDirectionChange
   890         && isVisible()
   907             && isVisible()
   891         && (viewFlags() & ViewTitleBarMinimizable)){
   908             && (viewFlags() & ViewTitleBarMinimizable)) {
   892         HbMainWindow *mw = mainWindow();        
   909         HbMainWindow *mw = mainWindow();
   893         if (mw && mw->currentView() == this){
   910         if (mw && mw->currentView() == this) {
   894             HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged();
   911             HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged();
   895         }
   912         }
   896     }
   913     }
   897 
   914 
   898     HbWidget::changeEvent( event );
   915     HbWidget::changeEvent(event);
   899 }
   916 }
   900 
   917 
   901 /*!
   918 /*!
   902 Removes the menu from the view and returns it to the caller.
   919 Removes the menu from the view and returns it to the caller.
   903 Ownership of the menu is transferred to the caller.
   920 Ownership of the menu is transferred to the caller.
   905 \note This function is particularly useful if you want to switch between
   922 \note This function is particularly useful if you want to switch between
   906 different views without deleting the menu.
   923 different views without deleting the menu.
   907 
   924 
   908     \sa setMenu()
   925     \sa setMenu()
   909 */
   926 */
   910 HbMenu* HbView::takeMenu()
   927 HbMenu *HbView::takeMenu()
   911 {
   928 {
   912     Q_D(HbView);
   929     Q_D(HbView);
   913     HbMenu* menu = d->menu;
   930     HbMenu *menu = d->menu;
   914     d->menu = 0;
   931     d->menu = 0;
   915 
   932 
   916     // Reset the ownership
   933     // Reset the ownership
   917     if (menu) {
   934     if (menu) {
   918         menu->setParentItem(0);
   935         menu->setParentItem(0);
   926     return menu;
   943     return menu;
   927 }
   944 }
   928 
   945 
   929 #ifdef HB_EFFECTS
   946 #ifdef HB_EFFECTS
   930 /*
   947 /*
   931     Handles effect finished event for title bar animation    
   948     Handles effect finished event for title bar animation
   932  */
   949  */
   933 void HbView::titleBarEffectFinished(const HbEffect::EffectStatus &status)
   950 void HbView::titleBarEffectFinished(const HbEffect::EffectStatus &status)
   934 {   
   951 {
   935     Q_D(HbView);
   952     Q_D(HbView);
   936 
   953 
   937     HbMainWindow *mw = mainWindow();
   954     HbMainWindow *mw = mainWindow();
   938 
   955 
   939     if (d->mNavigationActionSet) {
   956     if (d->mNavigationActionSet) {
   947     if (mw) {
   964     if (mw) {
   948         HbTitleBar *titleBar = HbMainWindowPrivate::d_ptr(mw)->mTitleBar;
   965         HbTitleBar *titleBar = HbMainWindowPrivate::d_ptr(mw)->mTitleBar;
   949         if (titleBar) {
   966         if (titleBar) {
   950             if (status.effectEvent == "disappear") {
   967             if (status.effectEvent == "disappear") {
   951                 titleBar->setVisible(false);
   968                 titleBar->setVisible(false);
       
   969                 titleBar->resetTransform();
   952             } else {
   970             } else {
   953                 titleBar->setVisible(true);
   971                 titleBar->setVisible(true);
   954             }
   972             }
   955         }
   973         }
   956     }
   974     }
   957 }
   975 }
   958 
   976 
   959 /*
   977 /*
   960     Handles the effect finished event for title bar animation    
   978     Handles the effect finished event for title bar animation
   961  */
   979  */
   962 void HbView::statusBarEffectFinished(const HbEffect::EffectStatus &status)
   980 void HbView::statusBarEffectFinished(const HbEffect::EffectStatus &status)
   963 {   
   981 {
   964     HbMainWindow *mw = mainWindow();
   982     HbMainWindow *mw = mainWindow();
   965 
   983 
   966     HbStatusBar *statusBar = HbMainWindowPrivate::d_ptr(mw)->mStatusBar;
   984     HbStatusBar *statusBar = HbMainWindowPrivate::d_ptr(mw)->mStatusBar;
   967     if (!statusBar) {
   985     if (!statusBar) {
   968         return;
   986         return;
   969     }
   987     }
   970 
   988 
   971     statusBar->propertiesChanged();
   989     statusBar->propertiesChanged();
   972     HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged();
   990     HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged();
   973 
   991 
   974     if (mw) {    
   992     if (mw) {
   975         if (status.effectEvent == "disappear") {
   993         if (status.effectEvent == "disappear") {
   976             statusBar->setVisible(false);
   994             statusBar->setVisible(false);
       
   995             statusBar->resetTransform();
   977         } else {
   996         } else {
   978             statusBar->setVisible(true);
   997             statusBar->setVisible(true);
   979         }
   998         }
   980     }
   999     }
   981 }
  1000 }
   985   Returns the current navigation action. If no navigation action has been set, then
  1004   Returns the current navigation action. If no navigation action has been set, then
   986   0 is returned.
  1005   0 is returned.
   987 
  1006 
   988   If setNavigationAction() has not been called for this view, then the
  1007   If setNavigationAction() has not been called for this view, then the
   989   default action will be returned.
  1008   default action will be returned.
   990   
  1009 
   991   \sa setNavigationAction()
  1010   \sa setNavigationAction()
   992  */
  1011  */
   993 HbAction *HbView::navigationAction() const
  1012 HbAction *HbView::navigationAction() const
   994 {
  1013 {
   995     Q_D(const HbView);
  1014     Q_D(const HbView);