src/hbwidgets/itemviews/hblistviewitem_p.h
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #ifndef HBLISTVIEWITEMPRIVATE_H
       
    27 #define HBLISTVIEWITEMPRIVATE_H
       
    28 
       
    29 #include <hbmainwindow.h>
       
    30 
       
    31 #include "hblistviewitem.h"
       
    32 #include "hbabstractviewitem_p.h"
       
    33 #include "hbabstractitemview.h"
       
    34 
       
    35 class HbStyleOptionListViewItem;
       
    36 
       
    37 class QGraphicsItem;
       
    38 
       
    39 class HbListViewItemShared : public HbAbstractViewItemShared
       
    40 {
       
    41     public:
       
    42 
       
    43         HbListViewItemShared() :
       
    44             HbAbstractViewItemShared(),
       
    45             mTextFormat(Qt::PlainText),
       
    46             mStretchingStyle(HbListViewItem::NoStretching),
       
    47             mGraphicsSize(HbListViewItem::MediumIcon),
       
    48             mMinimumSecondaryTextRowCount(1),
       
    49             mMaximumSecondaryTextRowCount(1)
       
    50         {
       
    51         }
       
    52 
       
    53         Qt::TextFormat    mTextFormat;
       
    54         HbListViewItem::StretchingStyle mStretchingStyle;
       
    55         HbListViewItem::GraphicsSize mGraphicsSize;
       
    56         int mMinimumSecondaryTextRowCount;
       
    57         int mMaximumSecondaryTextRowCount;
       
    58 };
       
    59 
       
    60 class HbListViewItemPrivate : public HbAbstractViewItemPrivate
       
    61 {
       
    62     Q_DECLARE_PUBLIC(HbListViewItem)
       
    63 
       
    64 public:
       
    65 
       
    66     HbListViewItemPrivate(HbListViewItem *prototype);
       
    67     
       
    68     HbListViewItemPrivate(const HbListViewItemPrivate &source);
       
    69     
       
    70     HbListViewItemPrivate &operator=(const HbListViewItemPrivate &source);
       
    71 
       
    72     virtual ~HbListViewItemPrivate();
       
    73 
       
    74     void init();
       
    75 
       
    76     void setDecorationRole(const QVariant &value,
       
    77                            const int index);
       
    78     void setDisplayRole(const QString &value,
       
    79                         const int index);
       
    80 
       
    81     inline HbStyle::Primitive displayPrimitive() const {
       
    82         HbStyle::Primitive primitive = HbStyle::P_ListViewItem_text;
       
    83         const HbListViewItemShared *sd = static_cast<const HbListViewItemShared *>(mSharedData.constData());
       
    84 
       
    85         if (sd->mTextFormat != Qt::PlainText) {
       
    86             primitive = HbStyle::P_ListViewItem_richtext;
       
    87         }
       
    88         return primitive;
       
    89     }
       
    90 
       
    91     inline bool isLandscape() const {
       
    92         Q_Q( const HbListViewItem );
       
    93         HbAbstractItemView *view = q->itemView();
       
    94         if (    view
       
    95             &&  view->mainWindow()) {
       
    96             return (view->mainWindow()->orientation() == Qt::Horizontal);
       
    97         }
       
    98         return false;
       
    99     }
       
   100 
       
   101     inline bool isStretching() const {
       
   102         if (    isLandscape()
       
   103             &&  static_cast<const HbListViewItemShared*>(mSharedData.constData())->mStretchingStyle == HbListViewItem::StretchLandscape) {
       
   104             return true;
       
   105         }
       
   106         return false;
       
   107     }
       
   108 
       
   109     inline bool isMultilineSupported() const {
       
   110         return !(   static_cast<const HbListViewItemShared*>(mSharedData.constData())->mGraphicsSize == HbListViewItem::Thumbnail
       
   111                 ||  isStretching()); 
       
   112     }
       
   113 
       
   114     inline HbStyle::Primitive decorationPrimitive(const QVariant& decoration) {
       
   115         HbStyle::Primitive primitive = HbStyle::P_None;
       
   116 
       
   117         if (decoration.isValid()) {
       
   118             if (decoration.canConvert<HbIcon>() || decoration.canConvert<QIcon>()) {
       
   119                 primitive = HbStyle::P_ListViewItem_icon;
       
   120             }
       
   121         }
       
   122         return primitive;
       
   123     }
       
   124 
       
   125     QList<QGraphicsItem *> mDisplayRoleTextItems;
       
   126     QList<QGraphicsItem *> mDecorationRoleItems;
       
   127 
       
   128     QStringList     mStringList;
       
   129     QVariantList    mDecorationList;
       
   130 };
       
   131 
       
   132 #endif // HBLISTVIEWITEMPRIVATE_H