ui/views/detailsview/src/glxdetailsviewitemprototype.cpp
changeset 71 27f2d7aec52a
parent 65 ccee5c4b0de4
equal deleted inserted replaced
69:45459746d5e8 71:27f2d7aec52a
    36     : HbListViewItem(parent),
    36     : HbListViewItem(parent),
    37       mImageNameEditor( NULL ),
    37       mImageNameEditor( NULL ),
    38       mDescriptionEditor( NULL ),
    38       mDescriptionEditor( NULL ),
    39       mDateLabel( NULL ),
    39       mDateLabel( NULL ),
    40       mTimeLabel( NULL ),
    40       mTimeLabel( NULL ),
    41       mSizeLabel( NULL )
    41       mSizeLabel( NULL ),
       
    42       mImgNameLabel( NULL )
    42 {
    43 {
    43 }
    44 }
    44 
    45 
    45 //--------------------------------------------------------------------------------------------------------------------------------------------
    46 //--------------------------------------------------------------------------------------------------------------------------------------------
    46 //~GlxDetailsViewItemProtoType
    47 //~GlxDetailsViewItemProtoType
    51     switch (widgetIndex) {
    52     switch (widgetIndex) {
    52 
    53 
    53     case widgetNameIndex:
    54     case widgetNameIndex:
    54     {
    55     {
    55         delete mImageNameEditor;
    56         delete mImageNameEditor;
    56         mImageNameEditor = NULL;
    57         delete mImgNameLabel;
    57         break;
    58         break;
    58     }
    59     }
    59 
    60 
    60     case widgetDateIndex:
    61     case widgetDateIndex:
    61     {
    62     {
   107 
   108 
   108     switch (modelIndex().row()) {
   109     switch (modelIndex().row()) {
   109 
   110 
   110     case widgetNameIndex:
   111     case widgetNameIndex:
   111     {
   112     {
   112         //create the editor
   113         int substate = modelIndex().data(GlxSubStateRole).toInt();
   113         mImageNameEditor = new GlxDetailsTextEdit(this);        
   114         if(substate == IMAGEVIEWER_DETAIL_S)
   114         mImageNameEditor->setMaxRows(1);
   115             {
   115         
   116             mImgNameLabel = new HbLabel(this);
       
   117             }
       
   118         else
       
   119             {
       
   120             //create the editor
       
   121             mImageNameEditor = new GlxDetailsTextEdit(this);        
       
   122             mImageNameEditor->setMaxRows(1);
       
   123             }
   116         //retrieve the name from the model
   124         //retrieve the name from the model
   117         QString nameString(GLX_DETAILS_NAME);
   125         QString nameString(GLX_DETAILS_NAME);
   118         QVariant nameData = modelIndex().data(GlxUriRole).toString();
   126         QVariant nameData = modelIndex().data(GlxUriRole).toString();
   119         if (nameData.isValid()) {
   127         if (nameData.isValid()) {
   120             if (nameData.canConvert<QString> ()) {
   128             if (nameData.canConvert<QString> ()) {
   121                 nameString.append(nameData.toString());
   129                 nameString.append(nameData.toString());
   122             }
   130             }
   123         }
   131         }
   124         mImageNameEditor->setItemText(nameString);
   132         if(substate == IMAGEVIEWER_DETAIL_S)
       
   133             {
       
   134             mImgNameLabel->setPlainText(nameString);
       
   135             mImgNameLabel->setMinimumHeight(size().height() + 50);
       
   136             }
       
   137         else
       
   138             {
       
   139             mImageNameEditor->setItemText(nameString);
       
   140             }
   125 
   141 
   126         //Get the sub state of the details view
   142         //Get the sub state of the details view
   127         int substate = modelIndex().data(GlxSubStateRole).toInt();
       
   128         if (substate != IMAGEVIEWER_DETAIL_S) {
   143         if (substate != IMAGEVIEWER_DETAIL_S) {
   129             connect(mImageNameEditor, SIGNAL(editorTapped()), this, SLOT(forwardSignalsToView()));
   144             connect(mImageNameEditor, SIGNAL(editorTapped()), this, SLOT(forwardSignalsToView()));
   130         }
       
   131         else {
       
   132             mImageNameEditor->setTextItemReadOnly(TRUE);
       
   133         }
   145         }
   134 
   146 
   135         //Connect the Signals
   147         //Connect the Signals
   136         const QAbstractItemModel *model = (modelIndex().model());
   148         const QAbstractItemModel *model = (modelIndex().model());
   137         connect(model, SIGNAL(updateCustomWidgets()), this, SLOT(updateWidgetValues()));
   149         connect(model, SIGNAL(updateCustomWidgets()), this, SLOT(updateWidgetValues()));
   138 
   150 
   139         //Add the Layout
   151         //Add the Layout
   140         QGraphicsLinearLayout *widgetLayout = new QGraphicsLinearLayout(Qt::Horizontal, 0);
   152         QGraphicsLinearLayout *widgetLayout = new QGraphicsLinearLayout(Qt::Horizontal, 0);
   141         widgetLayout->setContentsMargins(CONTENTMARGINS,CONTENTMARGINS,CONTENTMARGINS,CONTENTMARGINS);
   153         widgetLayout->setContentsMargins(CONTENTMARGINS,CONTENTMARGINS,CONTENTMARGINS,CONTENTMARGINS);
   142         widgetLayout->addItem(mImageNameEditor);
   154         if(substate == IMAGEVIEWER_DETAIL_S)
       
   155             {
       
   156             widgetLayout->addItem(mImgNameLabel);
       
   157             }
       
   158         else
       
   159             {
       
   160             widgetLayout->addItem(mImageNameEditor);
       
   161             }
   143         setLayout(widgetLayout);
   162         setLayout(widgetLayout);
   144         break;
   163         break;
   145     }
   164     }
   146 
   165 
   147     case widgetDateIndex:
   166     case widgetDateIndex:
   276 void GlxDetailsViewItemProtoType::updateWidgetValues()
   295 void GlxDetailsViewItemProtoType::updateWidgetValues()
   277 {
   296 {
   278     int widgetIndex = modelIndex().row();
   297     int widgetIndex = modelIndex().row();
   279     if (widgetIndex == GlxDetailsViewItemProtoType::widgetNameIndex) {
   298     if (widgetIndex == GlxDetailsViewItemProtoType::widgetNameIndex) {
   280 
   299 
   281         QString nameString(GLX_DETAILS_NAME);
   300 		int substate = modelIndex().data(GlxSubStateRole).toInt();
       
   301 		QString nameString(GLX_DETAILS_NAME);
   282         QVariant nameData = modelIndex().data(GlxUriRole).toString();
   302         QVariant nameData = modelIndex().data(GlxUriRole).toString();
   283 
   303 
   284         if (nameData.isValid()) {
   304         if (nameData.isValid()) {
   285             if (nameData.canConvert<QString> ()) {
   305             if (nameData.canConvert<QString> ()) {
   286                 nameString.append(nameData.toString());
   306                 nameString.append(nameData.toString());
   287             }
   307             }
   288         }
   308         }
   289         mImageNameEditor->setItemText(nameString);
   309         if (substate == IMAGEVIEWER_DETAIL_S)
       
   310             {
       
   311             mImgNameLabel->setPlainText(nameString);
       
   312             }
       
   313         else
       
   314             {
       
   315             mImageNameEditor->setItemText(nameString);
       
   316             }
   290     }
   317     }
   291     else {
   318     else {
   292         QString descString(GLX_DETAILS_DESCRIPTION);
   319         QString descString(GLX_DETAILS_DESCRIPTION);
   293         QVariant descData = modelIndex().data(GlxDescRole).toString();
   320         QVariant descData = modelIndex().data(GlxDescRole).toString();
   294 
   321