--- a/ui/views/gridview/src/glxgridview.cpp Fri May 14 15:52:22 2010 +0300
+++ b/ui/views/gridview/src/glxgridview.cpp Thu May 27 12:51:42 2010 +0300
@@ -26,13 +26,18 @@
#include <hbiconitem.h>
#include <hbicon.h>
#include <xqserviceutil.h>
+#include <hbcheckbox.h>
+#include <hblabel.h>
+#include <QString>
+#include <hbframeitem.h>
//User Includes
#include "glxviewids.h"
#include "glxgridview.h"
#include "glxmodelparm.h"
#include "glxcommandhandlers.hrh"
-
+#include "glxicondefs.h"
+#include "glxlocalisationstrings.h"
#include "OstTraceDefinitions.h"
#ifdef OST_TRACE_COMPILER_IN_USE
@@ -47,8 +52,15 @@
mSelectionModel(NULL),
mModelWrapper(NULL),
mUiOnButton(NULL),
+ mCameraButton(NULL),
mScrolling(FALSE),
- mIconItem(NULL)
+ mIconItem(NULL),
+ mMarkCheckBox(NULL),
+ mCountItem(NULL),
+ mMainLabel(NULL),
+ mCountLabel(NULL),
+ mZeroItemLabel(NULL),
+ mAlbumName(NULL)
{
OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY );
mModelWrapper = new GlxModelWrapper();
@@ -61,20 +73,31 @@
{
OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY );
if(mUiOnButton == NULL) {
- mUiOnButton = new HbPushButton("UI",this);
+ mUiOnButton = new HbPushButton(this);
connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
- mUiOnButton->setGeometry(QRectF(610,0,15,15));
+ mUiOnButton->setGeometry(QRectF(590,0,40,40));
mUiOnButton->setZValue(1);
+ mUiOnButton->setIcon(HbIcon(GLXICON_WALL_UI_ON));
mUiOnButton->hide();
}
loadGridView();
+ connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)),Qt::UniqueConnection);
+ if(mCountItem == NULL) {
+ mCountItem = new HbLabel(this);
+ HbFrameItem *frame = new HbFrameItem(this); //graphics for mCountItem
+ frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
+ frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
+ frame->graphicsItem()->setOpacity(1);
+ mCountItem->setBackgroundItem(frame->graphicsItem(),-1);
+ }
OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT );
}
void GlxGridView::deActivate()
{
OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY );
- if (mUiOnButton && mUiOnButton->isVisible())
+ mScrolling = FALSE;
+ if (mUiOnButton)
{
mUiOnButton->hide();
}
@@ -85,6 +108,23 @@
mIconItem->setOpacity(0);
mIconItem->setZValue(mIconItem->zValue()-20);
}
+ if (mCountItem)
+ {
+ mCountItem->hide();
+ }
+ if (mAlbumName)
+ {
+ mAlbumName->hide();
+ }
+ if(mZeroItemLabel)
+ {
+ mZeroItemLabel->hide();
+ }
+ if(mCameraButton)
+ {
+ mCameraButton->hide();
+ }
+ disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT );
}
@@ -94,12 +134,37 @@
setModel(model);
}
-void GlxGridView::setModel(QAbstractItemModel *model)
+void GlxGridView::clearCurrentModel()
+{
+ if ( mModel ) {
+ disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(showItemCount()));
+ disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(showItemCount()));
+ disconnect(mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel()));
+ disconnect(mModel, SIGNAL(albumTitleAvailable(QString)), this, SLOT(showAlbumTitle(QString)));
+ disconnect(mModel, SIGNAL(populated()), this, SLOT( populated()));
+ mModel = NULL ;
+ }
+}
+
+void GlxGridView::initializeNewModel()
+{
+ if ( mModel ) {
+ connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(showItemCount()));
+ connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(showItemCount()));
+ connect(mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel()));
+ connect(mModel, SIGNAL(albumTitleAvailable(QString)), this, SLOT(showAlbumTitle(QString)));
+ connect(mModel, SIGNAL(populated()), this, SLOT( populated()));
+ }
+}
+
+void GlxGridView::setModel(QAbstractItemModel *model)
{
OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY );
if(model)
{
- mModel = model;
+ clearCurrentModel();
+ mModel = model;
+ initializeNewModel();
QVariant variantimage = mModel->data(mModel->index(0,0),GlxDefaultImage);
if (mWidget && variantimage.isValid() && variantimage.canConvert<QImage> () )
{
@@ -114,6 +179,7 @@
mWidget->setSelectionModel(mSelectionModel);
}
scrolltofocus(); // Need to do it here ?
+ showItemCount();
}
OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT );
}
@@ -142,12 +208,212 @@
{
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" );
mWidget->setSelectionMode(HgWidget::MultiSelection);
+ if (mMainLabel == NULL) {
+ mMainLabel = new HbLabel("Select Photos", this);
+ HbFrameItem *frame1 = new HbFrameItem(this); //graphics for mMainLabel
+ frame1->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
+ frame1->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
+ frame1->graphicsItem()->setOpacity(1);
+ mMainLabel->setBackgroundItem(frame1->graphicsItem(),-1);
+ }
+ if (mMarkCheckBox == NULL) {
+ mMarkCheckBox = new HbCheckBox(GLX_OPTION_MARK_ALL, this);
+ HbFrameItem *frame2 = new HbFrameItem(this); //graphics for mMarkCheckBox
+ frame2->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
+ frame2->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
+ frame2->graphicsItem()->setOpacity(1);
+ mMarkCheckBox->setBackgroundItem(frame2->graphicsItem(),-1);
+ }
+ if (mCountLabel == NULL) {
+ mCountLabel = new HbLabel(this);
+ HbFrameItem *frame3 = new HbFrameItem(this); //graphics for mCountLabel
+ frame3->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
+ frame3->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
+ frame3->graphicsItem()->setOpacity(1);
+ mCountLabel->setBackgroundItem(frame3->graphicsItem(),-1);
+ }
+
+ hideorshowitems(mWindow->orientation());
+
+ connect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
+ connect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
+
}
void GlxGridView::disableMarking()
{
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" );
mWidget->setSelectionMode(HgWidget::NoSelection);
+ disconnect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
+ disconnect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
+ if (mMainLabel) {
+ mMainLabel->hide();
+ }
+ if (mMarkCheckBox) {
+ mMarkCheckBox->setCheckState(Qt::Unchecked);
+ mMarkCheckBox->hide();
+ }
+ if (mCountLabel) {
+ mCountLabel->hide();
+ }
+
+ hideorshowitems(mWindow->orientation());
+}
+
+void GlxGridView::stateChanged(int state)
+{
+ if(state)
+ handleUserAction(EGlxCmdMarkAll);
+ else
+ handleUserAction(EGlxCmdUnMarkAll);
+}
+
+void GlxGridView::showMarkedItemCount()
+{
+ int count = mModel->rowCount();
+ QModelIndexList indexList = mWidget->selectionModel()->selectedIndexes();
+ int markItemCount = indexList.count();
+
+ QString text= QString("%1 / %2").arg( markItemCount ).arg( count );
+ mCountLabel->setPlainText( text );
+}
+
+void GlxGridView::showItemCount()
+{
+ int count = 0;
+ if(mModel) {
+ count = mModel->rowCount();
+ QSize deviceSize = HbDeviceProfile::current().logicalSize();
+ QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
+ : QSize( deviceSize.height(), deviceSize.width() ) ;
+ if(count) {
+ if(mZeroItemLabel) {
+ mZeroItemLabel->hide();
+ }
+ if(mCameraButton) {
+ mCameraButton->hide();
+ }
+ if(isItemVisible(Hb::TitleBarItem)) {
+ QString text;
+ if (getSubState() == ALL_ITEM_S) {
+ if (mAlbumName) {
+ mAlbumName->hide();
+ }
+ mCountItem->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
+ text = QString("%1 Items").arg( count );
+ mCountItem->setPlainText( text );
+ mCountItem->setAlignment(Qt::AlignLeft);
+ mCountItem->show();
+ }
+ else if (getSubState() == ALBUM_ITEM_S) {
+ mCountItem->hide();
+ QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
+ if (variant.toString() != NULL) {
+ showAlbumTitle(variant.toString());
+ }
+ }
+ }
+ else {
+ if (mCountItem) {
+ mCountItem->hide();
+ }
+ if (mAlbumName) {
+ mAlbumName->hide();
+ }
+ }
+
+ }
+ else {
+ bool populated = FALSE;
+ QVariant variant = mModel->data(mModel->index(0,0),GlxPopulated);
+ if (variant.isValid() && variant.canConvert<bool>() )
+ {
+ populated = variant.value<bool>();
+ }
+ if(populated) {
+ if (mCountItem) {
+ mCountItem->hide();
+ }
+ if (mAlbumName) {
+ mAlbumName->hide();
+ }
+
+ showNoImageString();
+
+ if (getSubState() == ALBUM_ITEM_S) {
+ QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
+ if (variant.toString() != NULL) {
+ showAlbumTitle(variant.toString());
+ }
+ }
+ }
+ }
+ }
+}
+
+void GlxGridView::showAlbumTitle(QString aTitle)
+{
+ int count = mModel->rowCount();
+ QSize deviceSize = HbDeviceProfile::current().logicalSize();
+ QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
+ : QSize( deviceSize.height(), deviceSize.width() ) ;
+ if(mAlbumName == NULL) {
+ mAlbumName = new HbLabel(this);
+ HbFrameItem *frame = new HbFrameItem(this); //graphics for mAlbumName
+ frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
+ frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
+ frame->graphicsItem()->setOpacity(1);
+ mAlbumName->setBackgroundItem(frame->graphicsItem(),-1);
+ }
+
+ if(count && isItemVisible(Hb::TitleBarItem)) {
+ mAlbumName->setGeometry(QRectF(0,0,screenSize.width()/2,deviceSize.height()/24));
+ QString text = QString(aTitle);
+ mAlbumName->setPlainText( text );
+ mAlbumName->show();
+ mCountItem->setGeometry(QRectF(screenSize.width()/2,0,screenSize.width()/2,deviceSize.height()/24));
+ text = QString("(%1)").arg(count);
+ mCountItem->setPlainText( text );
+ mCountItem->setAlignment(Qt::AlignRight);
+ mCountItem->show();
+ }
+ else if((!count) && isItemVisible(Hb::TitleBarItem)) {
+ mAlbumName->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
+ QString text = QString(aTitle);
+ mAlbumName->setPlainText( text );
+ mAlbumName->show();
+ }
+}
+
+void GlxGridView::showNoImageString()
+{
+ qreal chromeHeight = 0.0;
+ QSize deviceSize = HbDeviceProfile::current().logicalSize();
+ QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
+ : QSize( deviceSize.height(), deviceSize.width() ) ;
+ qreal midHeight = screenSize.height()/2;
+ if (isItemVisible(Hb::TitleBarItem)) {
+ style()->parameter("hb-param-widget-chrome-height", chromeHeight);
+ midHeight -= chromeHeight;
+ }
+ if (mZeroItemLabel == NULL) {
+ mZeroItemLabel = new HbLabel("(No Images)\n To capture images Open", this);
+ }
+ mZeroItemLabel->setGeometry(QRectF(0, midHeight - deviceSize.height()/16, screenSize.width(), 3*deviceSize.height()/32));
+ mZeroItemLabel->setAlignment(Qt::AlignHCenter);
+ mZeroItemLabel->show();
+ if (mCameraButton == NULL) {
+ mCameraButton = new HbPushButton(this);
+ mCameraButton->setIcon(HbIcon(GLXICON_CAMERA));
+ connect(mCameraButton, SIGNAL(clicked(bool)), this, SLOT(cameraButtonClicked(bool)));
+ }
+ mCameraButton->setGeometry(QRectF(screenSize.width()/2 - 3*deviceSize.height()/64, midHeight + deviceSize.height()/32, deviceSize.height()/32, deviceSize.height()/32));
+ mCameraButton->show();
+}
+
+void GlxGridView::populated()
+{
+ showItemCount();
}
void GlxGridView::handleUserAction(qint32 commandId)
@@ -239,10 +505,9 @@
mWidget = new HgGrid(orient);
mWidget->setLongPressEnabled(true);
mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide);
- //mWidget->setItemSize(QSizeF(120,120));
setWidget( mWidget );
addViewConnection();
- //hideorshowitems(orient);
+ hideorshowitems(orient);
}
OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT );
}
@@ -253,22 +518,46 @@
}
void GlxGridView::hideorshowitems(Qt::Orientation orient)
{
- if(orient == Qt::Horizontal)
- {
- if (mUiOnButton)
+ if (mWidget->selectionMode() == HgWidget::NoSelection) {
+ if(orient == Qt::Horizontal)
{
- mUiOnButton->show();
+ setItemVisible(Hb::AllItems, FALSE) ;
+ setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
+ showItemCount();
+ if (mUiOnButton)
+ {
+ mUiOnButton->show();
+ }
}
- setItemVisible(Hb::AllItems, FALSE) ;
+ else
+ {
+ showHbItems();
+ }
+ }
+
+ if (mWidget->selectionMode() == HgWidget::MultiSelection) {
+ setItemVisible(Hb::TitleBarItem, FALSE) ;
+ if (mUiOnButton) {
+ mUiOnButton->hide();
}
- else
- {
- if (mUiOnButton)
- {
- mUiOnButton->hide();
- }
- setItemVisible(Hb::AllItems, TRUE) ;
+ if (mCountItem) {
+ mCountItem->hide();
+ }
+ if (mAlbumName) {
+ mAlbumName->hide();
}
+ QSize deviceSize = HbDeviceProfile::current().logicalSize();
+ QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
+ : QSize( deviceSize.height(), deviceSize.width() ) ;
+ mMainLabel->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
+ mMarkCheckBox->setGeometry(QRectF(0,deviceSize.height()/24,screenSize.width()/2,deviceSize.height()/72));
+ mCountLabel->setGeometry(QRectF(screenSize.width()/2,deviceSize.height()/24,screenSize.width()/2,deviceSize.height()/12 - 3));
+ mCountLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ mMainLabel->show();
+ mMarkCheckBox->show();
+ mCountLabel->show();
+ showMarkedItemCount();
+ }
}
void GlxGridView::scrolltofocus()
@@ -298,7 +587,6 @@
void GlxGridView::addViewConnection()
{
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" );
- connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
//connect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
connect(mWidget, SIGNAL(activated(const QModelIndex &)), SLOT( itemSelected(const QModelIndex &)));
@@ -312,7 +600,6 @@
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" );
if(mWidget)
{
- disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
//disconnect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
disconnect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT( itemSelected(const QModelIndex &)));
@@ -346,16 +633,32 @@
void GlxGridView::scrollingStarted()
{
- if ((mWindow->orientation() == Qt::Horizontal))
+ if ((mWindow->orientation() == Qt::Horizontal) && mWidget->selectionMode() == HgWidget::NoSelection)
{
setItemVisible(Hb::AllItems, FALSE) ;
- }
+ setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
+ if (mUiOnButton)
+ {
+ mUiOnButton->hide();
+ }
+ if (mCountItem) {
+ mCountItem->hide();
+ }
+ if (mAlbumName) {
+ mAlbumName->hide();
+ }
+ }
+
mScrolling = TRUE;
}
void GlxGridView::scrollingEnded()
{
mScrolling = FALSE;
+ if (mUiOnButton && (mWindow->orientation() == Qt::Horizontal))
+ {
+ mUiOnButton->show();
+ }
QList<QModelIndex> visibleIndex = mWidget->getVisibleItemIndices();
if (visibleIndex.count() <= 0)
{
@@ -369,6 +672,7 @@
if(mModel)
{
mModel->setData( index, index.row(), GlxVisualWindowIndex);
+ mModel->setData( index, index.row(), GlxFocusIndexRole );
}
}
@@ -387,7 +691,17 @@
disconnect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
delete mUiOnButton;
}
+ if(mCameraButton) {
+ disconnect(mCameraButton, SIGNAL(clicked()), this, SLOT(cameraButtonClicked()));
+ delete mCameraButton;
+ }
delete mIconItem;
+ delete mCountItem;
+ delete mAlbumName;
+ delete mMainLabel;
+ delete mMarkCheckBox;
+ delete mCountLabel;
+ delete mZeroItemLabel;
OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT );
}
@@ -408,13 +722,34 @@
void GlxGridView::uiButtonClicked(bool /*checked*/)
{
- if (isItemVisible(Hb::TitleBarItem)) // W16 All item is Not Working , So Temp Fix
+ showHbItems();
+}
+
+void GlxGridView::showHbItems()
+{
+ setItemVisible(Hb::AllItems, TRUE) ;
+ setViewFlags(viewFlags() &~ HbView::ViewTitleBarHidden &~ HbView::ViewStatusBarHidden);
+ showItemCount();
+ toolBar()->resetTransform(); // Temp, this is for HbToolbar issue to get fixed
+ toolBar()->show();
+ if (mUiOnButton)
{
- setItemVisible(Hb::AllItems, FALSE) ;
- }
- else
- {
- setItemVisible(Hb::AllItems, TRUE) ;
+ mUiOnButton->hide();
}
}
+void GlxGridView::cameraButtonClicked(bool /*checked*/)
+{
+ emit actionTriggered(EGlxCmdCameraOpen);
+}
+
+int GlxGridView::getSubState()
+{
+ int substate = NO_GRID_S;
+ QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );
+ if ( variant.isValid() && variant.canConvert<int> () ) {
+ substate = variant.value<int>();
+ }
+ return substate;
+}
+