src/hbwidgets/widgets/hbcombobox_p.h
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 7 923ff622b8b9
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    64 
    64 
    65 public:
    65 public:
    66     HbComboBoxPrivate( );
    66     HbComboBoxPrivate( );
    67     ~HbComboBoxPrivate( );
    67     ~HbComboBoxPrivate( );
    68     void init( );
    68     void init( );
    69     void createPrimitives();
    69     void createPrimitives( );
    70     void setModel( QAbstractItemModel * model );
    70     void setModel( QAbstractItemModel * model );
    71     void positionDropDown( );
    71     void positionDropDown( );
    72     void setCompletion( bool completion );
    72     void setCompletion( bool completion );
    73     void setEditable(  bool editable );
    73     void setEditable(  bool editable );
    74     QString itemText( const QModelIndex &index ) const;
    74     QString itemText( const QModelIndex &index ) const;
    86     void _q_textChanged( const QString & aString );
    86     void _q_textChanged( const QString & aString );
    87     void currentIndexChanged( const QModelIndex &index );
    87     void currentIndexChanged( const QModelIndex &index );
    88     QModelIndex findData( const QVariant &data ) const;
    88     QModelIndex findData( const QVariant &data ) const;
    89     void showPopup( QAbstractItemModel* aModel, QModelIndex aIndex = QModelIndex( ) );
    89     void showPopup( QAbstractItemModel* aModel, QModelIndex aIndex = QModelIndex( ) );
    90     void createDropDown( );
    90     void createDropDown( );
    91     void calculateListItemHeight();
    91     void calculateListItemHeight( );
    92 
    92 
    93 public:    
    93 public:
    94     HbCustomLineEdit* mLineEdit;
    94     HbCustomLineEdit* mLineEdit;
    95     QGraphicsItem* mTextItem;
    95     QGraphicsItem* mTextItem;
    96     QGraphicsItem *mButton;
    96     QGraphicsItem *mButton;
    97     HbComboDropDown* mDropDown;
    97     HbComboDropDown* mDropDown;
    98     QAbstractItemModel* mModel;
    98     QAbstractItemModel* mModel;
   116 
   116 
   117 class HbComboListViewItem : public HbListViewItem
   117 class HbComboListViewItem : public HbListViewItem
   118 {
   118 {
   119     Q_OBJECT
   119     Q_OBJECT
   120 public:
   120 public:
   121     explicit HbComboListViewItem ( QGraphicsItem *parent = 0 ) : HbListViewItem( parent )
   121     explicit HbComboListViewItem ( QGraphicsItem *parent = 0 ) : HbListViewItem( parent ) {
   122     {
       
   123     }
   122     }
   124 
   123 
   125     HbAbstractViewItem *createItem()
   124     HbAbstractViewItem *createItem( ) {
   126     {
   125         return new HbComboListViewItem( *this );
   127         return new HbComboListViewItem(*this);
   126     }
   128     }   
       
   129 };
   127 };
   130 
   128 
   131 class HbCustomLineEdit : public HbLineEdit
   129 class HbCustomLineEdit : public HbLineEdit
   132 {
   130 {
   133 
   131 
   134     Q_OBJECT
   132     Q_OBJECT
   135 public:
   133 public:
   136     HbCustomLineEdit( QGraphicsWidget *parent, HbComboBoxPrivate *comboPriv )
   134     HbCustomLineEdit( QGraphicsWidget *parent, HbComboBoxPrivate *comboPriv ) :
   137         :HbLineEdit( *new HbLineEditPrivate, parent ),
   135         HbLineEdit( *new HbLineEditPrivate, parent ),
   138         comboBoxPrivate( comboPriv ),
   136         comboBoxPrivate( comboPriv ),
   139         VkbLaunched( false )
   137         VkbLaunched( false ) {
   140     {
       
   141         
       
   142     }
   138     }
   143 void setLongPressEnabled( bool enable = true ) 
   139 
   144      {
   140     ~HbCustomLineEdit() {
   145          if( enable ) {
   141         HbEditorInterface editorInterface( this );
   146              scrollArea( )->setLongPressEnabled( true );
   142         HbVkbHost *host = editorInterface.vkbHost( );
   147          } else {
   143         if( host ) {
   148              scrollArea( )->setLongPressEnabled( false );
   144             host->disconnect();
   149          }
   145         }
   150      }
   146     }
       
   147 
       
   148     void setLongPressEnabled( bool enable = true ) {
       
   149         if( enable ) {
       
   150             scrollArea( )->setLongPressEnabled( true );
       
   151         } else {
       
   152             scrollArea( )->setLongPressEnabled( false );
       
   153         }
       
   154     }
       
   155 
   151 protected:
   156 protected:
   152     void focusInEvent( QFocusEvent *event )
   157     void focusInEvent( QFocusEvent *event ) {
   153     {
   158         HbEditorInterface editorInterface( this );
   154             HbEditorInterface editorInterface(this);
   159         HbVkbHost *host = editorInterface.vkbHost( );
   155             HbVkbHost *host = editorInterface.vkbHost();
   160         if ( host && !VkbLaunched ) {
   156             if ( host && !VkbLaunched ) {
   161             VkbLaunched = true;
   157                VkbLaunched = true;
   162             connect( host, SIGNAL( keypadClosed (  ) ), comboBoxPrivate->mDropDown,
   158                connect( host, SIGNAL( keypadClosed (  ) ), comboBoxPrivate->mDropDown,
   163                 SLOT( keypadClosed(  ) ) );
   159                        SLOT( keypadClosed(  ) ) );
   164             connect( host, SIGNAL( keypadOpened (  ) ), comboBoxPrivate->mDropDown,
   160                connect( host, SIGNAL( keypadOpened (  ) ), comboBoxPrivate->mDropDown,
   165                 SLOT( keypadOpened(  ) ) );
   161                        SLOT( keypadOpened(  ) ) );
   166         }
   162             }
   167         HbLineEdit::focusInEvent( event );
   163             HbLineEdit::focusInEvent(event);
       
   164     }
   168     }
   165 private:
   169 private:
   166     HbComboBoxPrivate *comboBoxPrivate;
   170     HbComboBoxPrivate *comboBoxPrivate;
   167     bool VkbLaunched;
   171     bool VkbLaunched;
   168 };
   172 };