|
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 HBCOMBOBOX_P_H |
|
27 #define HBCOMBOBOX_P_H |
|
28 |
|
29 #include "hbdialog_p.h" |
|
30 #include "hbcombodropdown_p.h" |
|
31 #include "hblineedit_p.h" |
|
32 #include "hbwidget_p.h" |
|
33 |
|
34 #include <hbcombobox.h> |
|
35 #include <hblineedit.h> |
|
36 #include <hbwidgetfeedback.h> |
|
37 #include <hbinputeditorinterface.h> |
|
38 #include <hbinputvkbhost.h> |
|
39 #include <hblistviewitem.h> |
|
40 |
|
41 // |
|
42 // W A R N I N G |
|
43 // ------------- |
|
44 // |
|
45 // This file is not part of the Qt API. It exists purely as an |
|
46 // implementation detail. This header file may change from version to |
|
47 // version without notice, or even be removed. |
|
48 // |
|
49 // We mean it. |
|
50 // |
|
51 class QGraphicsLayoutItem; |
|
52 class HbDialog; |
|
53 class HbComboDropDown; |
|
54 class QModelIndex; |
|
55 class QSortFilterProxyModel; |
|
56 class QCompleter; |
|
57 class HbCustomLineEdit; |
|
58 class QGraphicsItem; |
|
59 class HbTextItem; |
|
60 |
|
61 class HbComboBoxPrivate : public HbWidgetPrivate |
|
62 { |
|
63 Q_DECLARE_PUBLIC( HbComboBox ) |
|
64 |
|
65 public: |
|
66 HbComboBoxPrivate( ); |
|
67 ~HbComboBoxPrivate( ); |
|
68 void init( ); |
|
69 void createPrimitives(); |
|
70 void setModel( QAbstractItemModel * model ); |
|
71 void positionDropDown( ); |
|
72 void setCompletion( bool completion ); |
|
73 void setEditable( bool editable ); |
|
74 QString itemText( const QModelIndex &index ) const; |
|
75 QIcon itemIcon( const QModelIndex &index ) const; |
|
76 int itemRole( ) const; |
|
77 void addDropDownToScene( ); |
|
78 void setCurrentIndex( const QModelIndex &index ); |
|
79 void touchAreaPressEvent( ); |
|
80 void touchAreaReleaseEvent( ); |
|
81 void touchAreaClicked( ); |
|
82 void vkbOpened( ); |
|
83 void vkbClosed( ); |
|
84 void _q_textChanged( const QModelIndex & aIndex ); |
|
85 void _q_textCompleted( const QModelIndex & aIndex ); |
|
86 void _q_textChanged( const QString & aString ); |
|
87 void currentIndexChanged( const QModelIndex &index ); |
|
88 QModelIndex findData( const QVariant &data ) const; |
|
89 void showPopup( QAbstractItemModel* aModel, QModelIndex aIndex = QModelIndex( ) ); |
|
90 void createDropDown( ); |
|
91 void calculateListItemHeight(); |
|
92 |
|
93 public: |
|
94 HbCustomLineEdit* mLineEdit; |
|
95 QGraphicsItem* mTextItem; |
|
96 QGraphicsItem *mButton; |
|
97 HbComboDropDown* mDropDown; |
|
98 QAbstractItemModel* mModel; |
|
99 QSortFilterProxyModel* mProxyModel; |
|
100 QModelIndex mCurrentIndex; |
|
101 QCompleter* mCompleter; |
|
102 HbComboBox::InsertPolicy insertPolicy; |
|
103 QGraphicsItem *mBackgroundItem; |
|
104 QGraphicsItem *mButtonTouchAreaItem; |
|
105 bool mIsDown; |
|
106 bool mEditable; |
|
107 bool mIsDorpdownCreated; |
|
108 bool mIsDropwnToSceneAdded; |
|
109 bool mHasDownEffect; |
|
110 bool mHasUpEffect; |
|
111 QString mText; |
|
112 qreal mListItemHeight; |
|
113 }; |
|
114 |
|
115 class HbComboListViewItem : public HbListViewItem |
|
116 { |
|
117 Q_OBJECT |
|
118 public: |
|
119 explicit HbComboListViewItem ( QGraphicsItem *parent = 0 ) : HbListViewItem( parent ) |
|
120 { |
|
121 } |
|
122 |
|
123 HbAbstractViewItem *createItem() |
|
124 { |
|
125 return new HbComboListViewItem(*this); |
|
126 } |
|
127 }; |
|
128 |
|
129 class HbCustomLineEdit : public HbLineEdit |
|
130 { |
|
131 |
|
132 Q_OBJECT |
|
133 public: |
|
134 HbCustomLineEdit( QGraphicsWidget *parent, HbComboBoxPrivate *comboPriv ) |
|
135 :HbLineEdit( *new HbLineEditPrivate, parent ), |
|
136 comboBoxPrivate( comboPriv ), |
|
137 VkbLaunched( false ) |
|
138 { |
|
139 |
|
140 } |
|
141 void setLongPressEnabled( bool enable = true ) |
|
142 { |
|
143 if( enable ) { |
|
144 scrollArea( )->setLongPressEnabled( true ); |
|
145 } else { |
|
146 scrollArea( )->setLongPressEnabled( false ); |
|
147 } |
|
148 } |
|
149 protected: |
|
150 void focusInEvent( QFocusEvent *event ) |
|
151 { |
|
152 HbEditorInterface editorInterface(this); |
|
153 HbVkbHost *host = editorInterface.vkbHost(); |
|
154 if ( host && !VkbLaunched ) { |
|
155 VkbLaunched = true; |
|
156 connect( host, SIGNAL( keypadClosed ( ) ), comboBoxPrivate->mDropDown, |
|
157 SLOT( keypadClosed( ) ) ); |
|
158 connect( host, SIGNAL( keypadOpened ( ) ), comboBoxPrivate->mDropDown, |
|
159 SLOT( keypadOpened( ) ) ); |
|
160 } |
|
161 HbLineEdit::focusInEvent(event); |
|
162 } |
|
163 private: |
|
164 HbComboBoxPrivate *comboBoxPrivate; |
|
165 bool VkbLaunched; |
|
166 }; |
|
167 |
|
168 #endif // HBCOMBOBOX_P_H |
|
169 |