src/hbwidgets/widgets/hbsearchpanel_p.cpp
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 //
       
    27 //  W A R N I N G
       
    28 //  -------------
       
    29 //
       
    30 // This file is not part of the Hb API.  It exists purely as an
       
    31 // implementation detail.  This file may change from version to
       
    32 // version without notice, or even be removed.
       
    33 //
       
    34 // We mean it.
       
    35 //
       
    36 
       
    37 #include "hbsearchpanel_p.h"
       
    38 
       
    39 #include <hblineedit.h>
       
    40 #include <hbpushbutton.h>
       
    41 
       
    42 const QString cancelIcon = QString("qtg_mono_exit");
       
    43 const QString searchOptionsIcon = QString("qtg_mono_options_menu");
       
    44 const QString progressIcon = QString("qtg_mono_go");
       
    45 
       
    46 HbSearchPanelPrivate::HbSearchPanelPrivate( ):
       
    47     HbWidgetPrivate (  ),
       
    48     mProgressive ( true ),
       
    49     mSearchOptions ( false ),
       
    50     mSearchOptionsButton(0),
       
    51     mLineEdit(0),
       
    52     mProgressButton(0),
       
    53     mCancelButton(0)
       
    54 {
       
    55 }
       
    56 
       
    57 HbSearchPanelPrivate::~HbSearchPanelPrivate( )
       
    58 {
       
    59 }
       
    60 
       
    61 void HbSearchPanelPrivate::init( )
       
    62 {
       
    63     Q_Q( HbSearchPanel );
       
    64     constructUi();
       
    65 
       
    66     //set default values
       
    67     q->setAttribute(Hb::InputMethodNeutral);
       
    68     q->setFlag(QGraphicsItem::ItemIsFocusable);
       
    69 
       
    70     // connect initial state signals
       
    71     QObject::connect(mCancelButton, SIGNAL(clicked()), q, SLOT(_q_hideClicked()));
       
    72     QObject::connect(mLineEdit, SIGNAL(textChanged(QString)), q, SIGNAL(criteriaChanged(QString)));
       
    73 
       
    74 }
       
    75 
       
    76 void HbSearchPanelPrivate::addSearchOptionsButton()
       
    77 {
       
    78     Q_Q( HbSearchPanel );
       
    79     mSearchOptions = true;
       
    80     mSearchOptionsButton = new HbPushButton(q);
       
    81     mSearchOptionsButton->setObjectName("optionsbutton");
       
    82 
       
    83     mSearchOptionsButton->setIcon(HbIcon(searchOptionsIcon));
       
    84     QObject::connect(mSearchOptionsButton, SIGNAL(clicked()), q, SLOT(_q_searchOptionsClicked()));
       
    85 
       
    86     HbStyle::setItemName( mSearchOptionsButton, "searchoptionsbutton" );
       
    87     q->repolish();
       
    88 }
       
    89 
       
    90 void HbSearchPanelPrivate::removeSearchOptionsButton()
       
    91 {
       
    92     Q_Q( HbSearchPanel );
       
    93     mSearchOptions = false;
       
    94     HbStyle::setItemName( mSearchOptionsButton, "" );
       
    95     QObject::disconnect(mSearchOptionsButton, SIGNAL(clicked()), q, SLOT(_q_searchOptionsClicked()));
       
    96     mSearchOptionsButton->deleteLater();
       
    97     mSearchOptionsButton = 0;
       
    98     q->repolish();
       
    99 }
       
   100 
       
   101 void HbSearchPanelPrivate::addProgressButton()
       
   102 {
       
   103     Q_Q( HbSearchPanel );
       
   104     mProgressive = false;
       
   105     mProgressButton = new HbPushButton(q);
       
   106     mProgressButton->setObjectName("progressbutton");
       
   107 
       
   108     mProgressButton->setIcon(HbIcon(progressIcon));
       
   109     QObject::connect(mProgressButton, SIGNAL(clicked()), q, SLOT(_q_criteriaChanged()));
       
   110     QObject::disconnect(mLineEdit,SIGNAL(textChanged(QString)),q, SIGNAL(criteriaChanged(QString)));
       
   111 
       
   112     HbStyle::setItemName( mProgressButton, "progressbutton" );
       
   113     q->repolish();
       
   114 }
       
   115 
       
   116 void HbSearchPanelPrivate::removeProgressButton()
       
   117 {
       
   118     Q_Q( HbSearchPanel );
       
   119     mProgressive = true;
       
   120     HbStyle::setItemName( mProgressButton, "" );
       
   121     QObject::disconnect(mProgressButton, SIGNAL(clicked()), q, SLOT(_q_criteriaChanged()));
       
   122     mProgressButton->deleteLater();
       
   123     mProgressButton = 0;
       
   124 
       
   125     // start to send events always when text is updated
       
   126     QObject::connect(mLineEdit, SIGNAL(textChanged(QString)), q, SIGNAL(criteriaChanged(QString)));
       
   127     q->repolish();
       
   128 }
       
   129 
       
   130 void HbSearchPanelPrivate::constructUi()
       
   131 {
       
   132     Q_Q( HbSearchPanel );
       
   133 
       
   134     //construct default ui.
       
   135     mLineEdit = new HbLineEdit(q);
       
   136     mLineEdit->setObjectName("lineedit");
       
   137     mLineEdit->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
       
   138     HbStyle::setItemName( mLineEdit, "lineedit" );
       
   139 	
       
   140     mCancelButton = new HbPushButton(q);
       
   141     mCancelButton->setObjectName("cancelbutton");
       
   142     mCancelButton->setIcon(cancelIcon);
       
   143 #if QT_VERSION >= 0x040600
       
   144     mCancelButton->setFlag(QGraphicsItem::ItemIsPanel, true);
       
   145     mCancelButton->setActive(false);
       
   146 #endif
       
   147     HbStyle::setItemName( mCancelButton, "cancelbutton" );
       
   148 }
       
   149 
       
   150 void HbSearchPanelPrivate::_q_hideClicked()
       
   151 {
       
   152     Q_Q( HbSearchPanel );
       
   153     emit q->exitClicked();
       
   154 }
       
   155 
       
   156 void HbSearchPanelPrivate::_q_criteriaChanged()
       
   157 {
       
   158     Q_Q( HbSearchPanel );
       
   159     emit q->criteriaChanged(mLineEdit->text());
       
   160 }
       
   161 
       
   162 void HbSearchPanelPrivate::_q_searchOptionsClicked( )
       
   163 {
       
   164     Q_Q( HbSearchPanel );
       
   165     emit q->searchOptionsClicked();
       
   166 }
       
   167 
       
   168 #include "moc_hbsearchpanel.cpp"