filemanager/src/filemanager/src/components/fmviewdetailsitem.cpp
changeset 25 b7bfdea70ca2
parent 14 1957042d8c7e
child 33 328cf6fbe40c
equal deleted inserted replaced
16:ada7962b4308 25:b7bfdea70ca2
    24 #include <hblabel.h>
    24 #include <hblabel.h>
    25 
    25 
    26 FmViewDetailsItem::FmViewDetailsItem( QGraphicsItem *parent )
    26 FmViewDetailsItem::FmViewDetailsItem( QGraphicsItem *parent )
    27     : HbListViewItem( parent ),
    27     : HbListViewItem( parent ),
    28       mDetailsContentLabel( 0 ),
    28       mDetailsContentLabel( 0 ),
    29       mDetailsLabel( 0 )
    29       mDetailsLabel( 0 ),
       
    30       mLayout( 0 )
    30 
    31 
    31 {
    32 {
    32     init();
       
    33 }
    33 }
    34 
    34 
    35 FmViewDetailsItem::~FmViewDetailsItem()
    35 FmViewDetailsItem::~FmViewDetailsItem()
    36 {
    36 {
    37 }
    37 }
    38 
    38 
    39 HbAbstractViewItem *FmViewDetailsItem::createItem()
    39 HbAbstractViewItem *FmViewDetailsItem::createItem()
    40 {
    40 {
    41     return new FmViewDetailsItem( parentItem() );
    41     return new FmViewDetailsItem( *this );
    42 }
    42 }
    43 
    43 
    44 bool FmViewDetailsItem::canSetModelIndex( const QModelIndex &index ) const
    44 bool FmViewDetailsItem::canSetModelIndex( const QModelIndex &index ) const
    45 {
    45 {
    46     Q_UNUSED( index );
    46     Q_UNUSED( index );
    52     Q_UNUSED(params);
    52     Q_UNUSED(params);
    53 }
    53 }
    54 
    54 
    55 void FmViewDetailsItem::updateChildItems()
    55 void FmViewDetailsItem::updateChildItems()
    56 {
    56 {
       
    57     if( !mLayout ) {
       
    58         init();
       
    59     }
    57     QString string = modelIndex().data( Qt::DisplayRole ).toString();   
    60     QString string = modelIndex().data( Qt::DisplayRole ).toString();   
    58     
    61     
    59     mDetailsContentLabel->setPlainText( string );
    62     mDetailsContentLabel->setPlainText( string );
    60     
    63     
    61     string = modelIndex().data( Qt::UserRole ).toString();  
    64     string = modelIndex().data( Qt::UserRole ).toString();  
    64 
    67 
    65 }
    68 }
    66 
    69 
    67 void FmViewDetailsItem::init()
    70 void FmViewDetailsItem::init()
    68 {
    71 {
    69     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
    72     mLayout = new QGraphicsLinearLayout();
    70     
    73     
    71     if( FmViewManager::viewManager()->orientation() == Qt::Vertical ){
    74     if( FmViewManager::viewManager()->orientation() == Qt::Vertical ){
    72         layout->setOrientation( Qt::Vertical );
    75         mLayout->setOrientation( Qt::Vertical );
    73     }
    76     }
    74     else{
    77     else{
    75         layout->setOrientation( Qt::Horizontal );   
    78         mLayout->setOrientation( Qt::Horizontal );   
    76     }
    79     }
    77 
    80 
    78 
    81 
    79     mDetailsContentLabel = new HbLabel("");
    82     mDetailsContentLabel = new HbLabel("");
    80     mDetailsContentLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
    83     mDetailsContentLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
    81     layout->addItem( mDetailsContentLabel );
    84     mLayout->addItem( mDetailsContentLabel );
    82     layout->setAlignment( mDetailsContentLabel, Qt::AlignLeft );
    85     mLayout->setAlignment( mDetailsContentLabel, Qt::AlignLeft );
    83 
    86 
    84     mDetailsLabel = new HbLabel("");
    87     mDetailsLabel = new HbLabel("");
    85     mDetailsLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) );
    88     mDetailsLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) );
    86     layout->addItem( mDetailsLabel );
    89     mLayout->addItem( mDetailsLabel );
    87     layout->setAlignment( mDetailsLabel, Qt::AlignLeft );
    90     mLayout->setAlignment( mDetailsLabel, Qt::AlignLeft );
    88 
    91 
    89     setLayout( layout );
    92     setLayout( mLayout );
    90 }
    93 }