ui/views/detailsview/src/glxdetailsview.cpp
changeset 50 a0f57508af73
parent 45 863223ea6961
child 52 a3a4c0de738e
equal deleted inserted replaced
45:863223ea6961 50:a0f57508af73
    98 //--------------------------------------------------------------------------------------------------------------------------------------------
    98 //--------------------------------------------------------------------------------------------------------------------------------------------
    99 void GlxDetailsView::activate()
    99 void GlxDetailsView::activate()
   100     {
   100     {
   101     OstTraceFunctionEntry0( GLXDETAILSVIEW_ACTIVATE_ENTRY );
   101     OstTraceFunctionEntry0( GLXDETAILSVIEW_ACTIVATE_ENTRY );
   102     //create and set the Favourite Model
   102     //create and set the Favourite Model
   103     setFavModel();
   103     if(getSubState() != IMAGEVIEWER_DETAIL_S) {
       
   104        setFavModel();
       
   105     }
   104     
   106     
   105     //fill the data
   107     //fill the data
   106     FillDetails();
   108     FillDetails();
   107     
   109     
   108     //Initialze the Model
   110     //Initialze the Model
   118     }
   120     }
   119 
   121 
   120 //--------------------------------------------------------------------------------------------------------------------------------------------
   122 //--------------------------------------------------------------------------------------------------------------------------------------------
   121 //initializeView
   123 //initializeView
   122 //--------------------------------------------------------------------------------------------------------------------------------------------
   124 //--------------------------------------------------------------------------------------------------------------------------------------------
   123 void GlxDetailsView::initializeView(QAbstractItemModel *model)
   125 void GlxDetailsView::initializeView( QAbstractItemModel *model, GlxView *preView)
   124     {
   126 {
       
   127     Q_UNUSED( preView )
   125     OstTraceFunctionEntry0( GLXDETAILSVIEW_INITIALIZEVIEW_ENTRY );
   128     OstTraceFunctionEntry0( GLXDETAILSVIEW_INITIALIZEVIEW_ENTRY );
   126     bool loaded = false;
   129     bool loaded = false;
   127     
   130 
   128     if(!mDocLoader)
   131     if(!mDocLoader)
   129         {
   132         {
   130          mDocLoader = new GlxDetailsViewDocLoader();
   133          mDocLoader = new GlxDetailsViewDocLoader();
   131         }
   134         }
   132     
   135 
   133     //Load the docml
   136     //Load the docml
   134     mDocLoader->load(GLX_DETAILSVIEW_DOCMLPATH, &loaded);     
   137     mDocLoader->load(GLX_DETAILSVIEW_DOCMLPATH, &loaded);     
   135     
   138 
   136     HbView *mView = static_cast<HbView*> (mDocLoader->findWidget(
   139     HbView *mView = static_cast<HbView*> (mDocLoader->findWidget(
   137             GLX_DETAILSVIEW_VIEW));
   140             GLX_DETAILSVIEW_VIEW));
   138     
   141     
   139     HbWidget *mwidget = static_cast<HbWidget*> (mDocLoader->findWidget(
   142     HbWidget *mwidget = static_cast<HbWidget*> (mDocLoader->findWidget(
   140             "MainWidget"));
   143             "MainWidget"));
   142     mDetailsIcon = static_cast<HbLabel*> (mDocLoader->findWidget(
   145     mDetailsIcon = static_cast<HbLabel*> (mDocLoader->findWidget(
   143             GLX_DETAILSVIEW_IMAGE));
   146             GLX_DETAILSVIEW_IMAGE));
   144     mFavIcon = static_cast<HbPushButton*> (mDocLoader->findWidget(
   147     mFavIcon = static_cast<HbPushButton*> (mDocLoader->findWidget(
   145             GLX_DETAILSVIEW_FAVICON));
   148             GLX_DETAILSVIEW_FAVICON));
   146 
   149 
       
   150 
   147     mDescriptions = static_cast<GlxDetailsDescriptionEdit*> (mDocLoader->findWidget(
   151     mDescriptions = static_cast<GlxDetailsDescriptionEdit*> (mDocLoader->findWidget(
   148             GLX_DETAILSVIEW_DESCRPTIONTEXT));
   152             GLX_DETAILSVIEW_DESCRPTIONTEXT));
   149     
   153     
   150     mImageName = static_cast<GlxDetailsNameLabel*> (mDocLoader->findWidget(
   154     mImageName = static_cast<GlxDetailsNameLabel*> (mDocLoader->findWidget(
   151             GLX_DETAILSVIEW_IMGNAME));
   155             GLX_DETAILSVIEW_IMGNAME));
   157             GLX_DETAILSVIEW_TIMETEXT));
   161             GLX_DETAILSVIEW_TIMETEXT));
   158     
   162     
   159     mSizeLabel = static_cast<HbLabel*> (mDocLoader->findWidget(
   163     mSizeLabel = static_cast<HbLabel*> (mDocLoader->findWidget(
   160             GLX_DETAILSVIEW_SIZETEXT));
   164             GLX_DETAILSVIEW_SIZETEXT));
   161 
   165 
   162     //set the frame graphics to the background of the fav icon
   166     
   163     HbFrameItem* frame = new HbFrameItem(this);
   167         //Set the Model
   164     frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   165     frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
   166     frame->graphicsItem()->setOpacity(0.2);
       
   167     mFavIcon->setBackgroundItem(frame->graphicsItem(), -1);
       
   168     mFavIcon->setBackground(HbIcon("qtg_fr_multimedia_trans"));
       
   169     mFavIcon->setIcon(HbIcon(GLXICON_REMOVE_FAV));
       
   170     
       
   171     setWidget(mView);
       
   172 
       
   173     //Set the Model
       
   174     mModel = model;  
   168     mModel = model;  
   175 
   169    if(getSubState() == IMAGEVIEWER_DETAIL_S) {
       
   170        mFavIcon->hide();
       
   171     }
       
   172     else
       
   173     {
       
   174         //set the frame graphics to the background of the fav icon
       
   175         HbFrameItem* frame = new HbFrameItem(this);
       
   176         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   177         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
   178         frame->graphicsItem()->setOpacity(0.2);
       
   179         mFavIcon->setBackgroundItem(frame->graphicsItem(), -1);
       
   180         mFavIcon->setBackground(HbIcon("qtg_fr_multimedia_trans"));
       
   181         mFavIcon->setIcon(HbIcon(GLXICON_REMOVE_FAV));
       
   182      }	
       
   183 	 
       
   184 	setWidget(mView);
       
   185 	
   176     //Set the Layout Correspondingly.
   186     //Set the Layout Correspondingly.
   177     updateLayout(mWindow->orientation());
   187     updateLayout(mWindow->orientation());
   178 
   188 
   179     //Shows the Image 
   189     //Shows the Image 
   180     showImage();
   190     showImage();
   209 //--------------------------------------------------------------------------------------------------------------------------------------------
   219 //--------------------------------------------------------------------------------------------------------------------------------------------
   210 //cleanUp
   220 //cleanUp
   211 //--------------------------------------------------------------------------------------------------------------------------------------------
   221 //--------------------------------------------------------------------------------------------------------------------------------------------
   212 void GlxDetailsView::cleanUp()
   222 void GlxDetailsView::cleanUp()
   213     {
   223     {
       
   224     qDebug("GlxDetailsView::cleanUp Enter");
       
   225 	//clear the connections
       
   226     clearConnections();   
       
   227     
   214     clearCurrentModel();
   228     clearCurrentModel();
   215 
       
   216     //clear the connections
       
   217     clearConnections();   
       
   218 
   229 
   219     delete mFavModel;
   230     delete mFavModel;
   220     mFavModel = NULL;
   231     mFavModel = NULL;
   221 
   232 
   222     delete mFavIcon;
   233     delete mFavIcon;
   294 //--------------------------------------------------------------------------------------------------------------------------------------------
   305 //--------------------------------------------------------------------------------------------------------------------------------------------
   295 void GlxDetailsView::setConnections()
   306 void GlxDetailsView::setConnections()
   296     {
   307     {
   297     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this,
   308     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this,
   298             SLOT(updateLayout(Qt::Orientation)));
   309             SLOT(updateLayout(Qt::Orientation)));
       
   310     
       
   311     
       
   312     if(getSubState() != IMAGEVIEWER_DETAIL_S) {    
   299     connect(mFavIcon, SIGNAL(clicked()), this, SLOT(updateFavourites()));
   313     connect(mFavIcon, SIGNAL(clicked()), this, SLOT(updateFavourites()));
   300     
   314     
   301     connect(mDescriptions, SIGNAL(labelPressed()), this,
   315     connect(mDescriptions, SIGNAL(labelPressed()), this,
   302             SLOT(UpdateDescription()));
   316             SLOT(UpdateDescription()));
   303     
   317     
       
   318     connect(mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ),
       
   319                    this, SLOT( dataChanged(QModelIndex,QModelIndex) ));
       
   320     }
       
   321     
   304     connect(mModel, SIGNAL( updateDetailsView() ), this, SLOT( FillDetails() ));
   322     connect(mModel, SIGNAL( updateDetailsView() ), this, SLOT( FillDetails() ));
   305     
   323     
   306     connect(mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ),
   324         
   307                this, SLOT( dataChanged(QModelIndex,QModelIndex) ));    
       
   308     }
   325     }
   309 
   326 
   310 //--------------------------------------------------------------------------------------------------------------------------------------------
   327 //--------------------------------------------------------------------------------------------------------------------------------------------
   311 //clearConnections
   328 //clearConnections
   312 //--------------------------------------------------------------------------------------------------------------------------------------------
   329 //--------------------------------------------------------------------------------------------------------------------------------------------
   313 void GlxDetailsView::clearConnections()
   330 void GlxDetailsView::clearConnections()
   314     {
   331     {
       
   332     
       
   333     qDebug("GlxDetailsView:: clearConnections");
   315     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this,
   334     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this,
   316             SLOT(updateLayout(Qt::Orientation)));
   335             SLOT(updateLayout(Qt::Orientation)));
   317     
   336            
       
   337     if(mModel && getSubState() != IMAGEVIEWER_DETAIL_S) {
   318     disconnect(mFavIcon, SIGNAL(clicked()), this, SLOT(updateFavourites()));
   338     disconnect(mFavIcon, SIGNAL(clicked()), this, SLOT(updateFavourites()));
   319     
       
   320     disconnect(mDescriptions, SIGNAL(labelPressed()), this,
   339     disconnect(mDescriptions, SIGNAL(labelPressed()), this,
   321             SLOT(UpdateDescription()));
   340             SLOT(UpdateDescription()));
       
   341     disconnect(mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ),
       
   342                     this, SLOT( dataChanged(QModelIndex,QModelIndex) ));
       
   343     }
   322     
   344     
   323     disconnect(mModel, SIGNAL( updateDetailsView() ), this, SLOT( FillDetails() ));
   345     disconnect(mModel, SIGNAL( updateDetailsView() ), this, SLOT( FillDetails() ));
   324     
   346     
   325     disconnect(mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ),
   347     
   326                 this, SLOT( dataChanged(QModelIndex,QModelIndex) ));
       
   327     }
   348     }
   328 
   349 
   329 //--------------------------------------------------------------------------------------------------------------------------------------------
   350 //--------------------------------------------------------------------------------------------------------------------------------------------
   330 //getAnimationItem
   351 //getAnimationItem
   331 //--------------------------------------------------------------------------------------------------------------------------------------------
   352 //--------------------------------------------------------------------------------------------------------------------------------------------
   612         sizeString.setNum(size);
   633         sizeString.setNum(size);
   613         sizeString.append("Bytes");
   634         sizeString.append("Bytes");
   614         }
   635         }
   615     return sizeString;
   636     return sizeString;
   616     }
   637     }
       
   638 
       
   639 //--------------------------------------------------------------------------------------------------------------------------------------------
       
   640 //getSubState
       
   641 //--------------------------------------------------------------------------------------------------------------------------------------------
       
   642 int GlxDetailsView::getSubState()
       
   643   {
       
   644     int substate = NO_DETAIL_S;
       
   645 
       
   646     if (mModel) {
       
   647       QVariant variant = mModel->data(mModel->index(0, 0), GlxSubStateRole);
       
   648 
       
   649       if (variant.isValid() && variant.canConvert<int> ()) {
       
   650            substate = variant.value<int> ();
       
   651       }
       
   652     } 
       
   653     return substate;
       
   654  }