src/hbwidgets/dataform/hbdataformviewitem_p.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    27 #include "hbdataformviewitem_p.h"
    27 #include "hbdataformviewitem_p.h"
    28 #include "hbdataformmodel.h"
    28 #include "hbdataformmodel.h"
    29 #include "hbdataform_p.h"
    29 #include "hbdataform_p.h"
    30 #include "hbdataformheadingwidget_p.h"
    30 #include "hbdataformheadingwidget_p.h"
    31 #include "hbdatagroup_p.h"
    31 #include "hbdatagroup_p.h"
       
    32 #include "hbdataformmodelitem_p.h"
    32 #include "hbdatagroup_p_p.h"
    33 #include "hbdatagroup_p_p.h"
    33 
    34 
    34 #include <hbslider.h>
    35 #include <hbslider.h>
    35 #include <hbcheckbox.h>
    36 #include <hbcheckbox.h>
       
    37 #include <hblistwidget.h>
    36 #include <hblabel.h>
    38 #include <hblabel.h>
    37 #include <hblineedit.h>
    39 #include <hblineedit.h>
    38 #include <hbradiobuttonlist.h>
    40 #include <hbradiobuttonlist.h>
    39 #include <hbcombobox.h>
    41 #include <hbcombobox.h>
    40 #include <hbstyleoptiondataformviewitem.h>
    42 #include <hbstyleoptiondataformviewitem.h>
    41 #include <hblistdialog.h>
    43 #include <hbselectiondialog.h>
    42 #include <hbpushbutton.h>
    44 #include <hbpushbutton.h>
    43 #include <hbaction.h>
    45 #include <hbaction.h>
    44 
    46 
    45 #include <QGraphicsLinearLayout>
    47 #include <QGraphicsLinearLayout>
    46 #include <QCoreApplication>
    48 #include <QCoreApplication>
       
    49 
       
    50 #ifdef HB_GESTURE_FW
       
    51 #include <hbtapgesture.h>
       
    52 #endif
       
    53 #define MAX_INLINE_ITEM_COUNT 3
    47 
    54 
    48 HbToggleItem::HbToggleItem( QGraphicsItem* parent ): HbWidget( parent )
    55 HbToggleItem::HbToggleItem( QGraphicsItem* parent ): HbWidget( parent )
    49 {
    56 {
    50     // Toggle item uses button as the content widget and toggles the text when item is clicked
    57     // Toggle item uses button as the content widget and toggles the text when item is clicked
    51     mViewItem = static_cast<HbDataFormViewItem*>( parent );
    58     mViewItem = static_cast<HbDataFormViewItem*>( parent );
   118     HbToggleItem holds a HbLabel and an HbRadioButtonList internally and toggles these 
   125     HbToggleItem holds a HbLabel and an HbRadioButtonList internally and toggles these 
   119     widget as the contentwidget when user clicks the contentwidget area .
   126     widget as the contentwidget when user clicks the contentwidget area .
   120  */
   127  */
   121 HbRadioItem::HbRadioItem( QGraphicsItem* parent ):
   128 HbRadioItem::HbRadioItem( QGraphicsItem* parent ):
   122     HbWidget( parent ),
   129     HbWidget( parent ),
   123     mRadioButton( 0 )
   130     mRadioButtonList( 0 ),
   124 {
   131     mButton(0), 
   125     // Create label by default . RadioButtonList is created created at runtime 
   132     mDialog(0),
   126     // when clicked on the item
   133     layout(0),
       
   134     mSelected(-1)
       
   135 {
       
   136 
   127     mViewItem = static_cast<HbDataFormViewItem*>( parent );
   137     mViewItem = static_cast<HbDataFormViewItem*>( parent );
   128 
       
   129     mButton = new HbPushButton();
       
   130     QObject::connect(mButton, SIGNAL(released()), this, SLOT(buttonClicked()));
       
   131     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout( Qt::Vertical );
       
   132     layout->addItem( mButton );
       
   133     setLayout( layout );
       
   134     
       
   135     mButtonVisible = true;
       
   136     mSelected = 0;
       
   137     mModel = static_cast<HbDataFormModel*>(
   138     mModel = static_cast<HbDataFormModel*>(
   138             HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView->model());
   139             HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView->model());
   139     mModelItem = static_cast<HbDataFormModelItem*>(
   140     mModelItem = static_cast<HbDataFormModelItem*>(
   140             mModel->itemFromIndex(mViewItem->modelIndex()));
   141             mModel->itemFromIndex(mViewItem->modelIndex()));
       
   142     QString displayMode = mModelItem->contentWidgetData(QString("displayMode")).toString();
       
   143      
       
   144     // set displayMode to automatic if not already set by application
       
   145     if(displayMode.isEmpty()) {
       
   146         mModelItem->setContentWidgetData(QString("displayMode"), "automatic");
       
   147     }
   141     QObject::connect(this,SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),mViewItem, 
   148     QObject::connect(this,SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),mViewItem, 
   142         SIGNAL(itemModified(QPersistentModelIndex, QVariant)));
   149         SIGNAL(itemModified(QPersistentModelIndex, QVariant)));
       
   150     if(!layout) {
       
   151         layout = new QGraphicsLinearLayout( Qt::Vertical );
       
   152     }
       
   153     setLayout( layout );
   143 }
   154 }
   144 
   155 
   145 HbRadioItem::~HbRadioItem()
   156 HbRadioItem::~HbRadioItem()
   146 {
   157 {
   147     // delete the widget which is not currently visible. The visible will be deleted by layout hierarchy
   158 }
   148     if( mButtonVisible ) {
   159 
   149         if( mRadioButton ) {
   160 HbWidget* HbRadioItem::createRadioButton()
   150             delete mRadioButton;
       
   151         }
       
   152     } else {
       
   153         delete mButton;
       
   154     }
       
   155 }
       
   156 
       
   157 HbWidget* HbRadioItem::contentWidget()
       
   158 {
   161 {
   159     // If not created create and set properties and return the widget
   162     // If not created create and set properties and return the widget
   160     if(!mRadioButton) {
   163     if(!mRadioButtonList) {
   161         mRadioButton = new HbRadioButtonList();        
   164         mRadioButtonList = new HbRadioButtonList();      
   162         mRadioButton->setItems( mItems );        
   165         mRadioButtonList->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));
   163         mRadioButton->setVisible(false);
   166         //mRadioButtonList->setClampingStyle(HbScrollArea::StrictClamping);
   164         mRadioButton->setSelected(mSelected);
   167         mRadioButtonList->setItems( mItems );
   165 
   168         if( mSelected != -1 ) {
   166         QObject::connect( mRadioButton, SIGNAL(itemSelected(int)), this, SLOT(itemSelected(int)) );
   169             mRadioButtonList->setSelected( mSelected );
       
   170         }
       
   171         // model need to be updated when selection changes
       
   172         // in popup case this connection will be removed since model will be updated 
       
   173         // only when dialog closed
       
   174         QObject::connect( mRadioButtonList, SIGNAL(itemSelected(int)), 
       
   175             this, SLOT(updateModel(int)) );
   167         
   176         
   168     }
   177     }
   169     return mRadioButton;
   178     return mRadioButtonList;
   170 }
   179 }
   171 
   180 
   172 /*  This function is evoked when Dynamic property is set on HbRadioItem , then 
   181 /*  This function is evoked when Dynamic property is set on HbRadioItem , then 
   173     corresponding property will be set on  HbRadioButtonList
   182     corresponding property will be set on  HbRadioButtonList
   174 */
   183 */
   175 bool HbRadioItem::event( QEvent * e )
   184 bool HbRadioItem::event( QEvent * e )
   176 {
   185 {
   177     switch( e->type() ){
   186     switch( e->type() ){
   178         case QEvent::DynamicPropertyChange: {
   187         case QEvent::DynamicPropertyChange: {
   179                 QDynamicPropertyChangeEvent *changeEvent = static_cast<QDynamicPropertyChangeEvent*>( e );
   188                 QDynamicPropertyChangeEvent *changeEvent = 
   180                 QString name = changeEvent->propertyName().data();
   189                     static_cast<QDynamicPropertyChangeEvent*>( e );
   181                 if( mRadioButton ) {
   190                 QString dynamicPropertyName = changeEvent->propertyName().data();
   182                     mRadioButton->setProperty( 
   191                 if( mRadioButtonList ) {
   183                         changeEvent->propertyName().data() ,property( changeEvent->propertyName().data()) );
   192                     //Set the property on radiobutton list if already created 
       
   193                     mRadioButtonList->setProperty( 
       
   194                         changeEvent->propertyName().data() ,
       
   195                         property( changeEvent->propertyName().data()) );
   184                 }
   196                 }
   185                 if( name == "items" ) {
   197                 if( dynamicPropertyName == "items" || dynamicPropertyName == "displayMode" ) {
       
   198                     // store the items locally
   186                     mItems = property("items").toStringList();
   199                     mItems = property("items").toStringList();
   187                 } else if( name == "selected" ) {
   200                     // in case of automatic, displayMode (embedded, automatic or popup) will change 
   188                     mItems = property("items").toStringList();
   201                     // if new items are populated or mode should be changed if mode is set
       
   202                     //  explicitly by application at runtime
       
   203                     changeMode();
       
   204                 } else if(dynamicPropertyName == "selected") {
       
   205                     // store the new selection 
   189                     mSelected = property("selected").toInt();
   206                     mSelected = property("selected").toInt();
   190                     mButton->setText(mItems.at(mSelected));
   207                     // fine tune the new selection if it goes beyond range. This happens when new
   191                     mButton->setTextAlignment(Qt::AlignLeft);
   208                     // items are populated or selection index is changed by application in to the model
       
   209                     // which can be out of range
       
   210                     resetSelection();
       
   211                     selectItem();
   192                 }
   212                 }
   193                 break;
   213                 break;
   194             }
   214             }
   195         default:
   215         default:
   196             break;
   216             break;
   197     }
   217     }
   198 
       
   199     HbWidget::event(e);
   218     HbWidget::event(e);
   200     return false;
   219     return false;
   201 }
   220 }
   202 
   221 
       
   222 void HbRadioItem::makeEmbedded()
       
   223 {
       
   224     // button need to be deleted when mode is changed from popup to embedded
       
   225     if(mButton) {
       
   226         layout->removeItem(mButton);
       
   227         delete mButton;
       
   228         mButton = 0;
       
   229     }
       
   230     createRadioButton();
       
   231     layout->addItem(mRadioButtonList);
       
   232     mRadioButtonList->setScrollDirections(0);
       
   233 }
       
   234 
       
   235 void HbRadioItem::makePopup()
       
   236 {
       
   237     if(mRadioButtonList) {
       
   238         layout->removeItem(mRadioButtonList);
       
   239         // RadioButton will not be shown unless button is clicked so delete it
       
   240         delete mRadioButtonList;
       
   241         mRadioButtonList = 0;
       
   242     }
       
   243     initilizeButton();
       
   244 }
       
   245 
       
   246 
       
   247 void HbRadioItem::resetSelection()
       
   248 {
       
   249     if((mItems.count() > 0 && mSelected == -1) || 
       
   250         (mItems.count() > 0 && (mItems.count() <= mSelected ))) {
       
   251         // if selection is beyond range then set it to 0. 
       
   252         // This happens when new items are populated and 
       
   253         // application does not set selection explicitly
       
   254         mSelected = 0;
       
   255     } else if(mItems.count() == 0) {
       
   256         mSelected = -1;
       
   257     }
       
   258 }
       
   259 
       
   260 /*
       
   261 changeMode() will change the mode of visualization( embedded, automatic and popup) depending
       
   262 on the number of items in case of automatic mode or change it to correspoding if not automatic.
       
   263 In popup the selected item will be displayed as the text of the button otherwise RadioButtonList
       
   264 is placed inline.
       
   265 */
       
   266 void HbRadioItem::changeMode()
       
   267 {
       
   268     QString displayMode = mModelItem->contentWidgetData(QString("displayMode")).toString();
       
   269     
       
   270     if(displayMode == "embedded") {
       
   271         makeEmbedded();
       
   272     } else if(displayMode == "popup") {
       
   273         makePopup();
       
   274     }
       
   275     else if(displayMode == "automatic") {
       
   276         if(mItems.count() <= MAX_INLINE_ITEM_COUNT  && mItems.count() > 0  ) {
       
   277             makeEmbedded();
       
   278         } else if(mItems.count() >= MAX_INLINE_ITEM_COUNT){
       
   279             makePopup();
       
   280         }
       
   281     }
       
   282     resetSelection();
       
   283     selectItem();
       
   284 }
       
   285 
       
   286 void HbRadioItem::selectItem()
       
   287 {
       
   288     //Set Text if button is valid
       
   289     if(mSelected != -1) {
       
   290         if(mButton ) {
       
   291             mButton->setText(mItems.at(mSelected));
       
   292         } 
       
   293         // change selection of radiobutton list
       
   294         if(mRadioButtonList && mRadioButtonList->selected() != mSelected) {
       
   295             mRadioButtonList->setSelected(mSelected);
       
   296         }
       
   297     } else if( mButton ) {
       
   298         // clear the text on the button if items are cleared 
       
   299         mButton->setText(QString(""));
       
   300     }
       
   301 }
       
   302 
       
   303 void HbRadioItem::initilizeButton()
       
   304 {
       
   305     if(!mButton) {
       
   306         mButton = new HbPushButton();
       
   307         mButton->setTextAlignment(Qt::AlignLeft);
       
   308         QObject::connect(mButton, SIGNAL(clicked()), this, SLOT(buttonClicked()));
       
   309         layout->addItem( mButton ); 
       
   310     }
       
   311 }
   203 
   312 
   204 void HbRadioItem::buttonClicked()
   313 void HbRadioItem::buttonClicked()
   205 {
   314 {
   206     // launch popup only if number of items are more than 5
   315     if(mItems.count() > 0) {
   207     if(!mRadioButton) {
   316         if(!mRadioButtonList) {
   208             contentWidget();
   317             createRadioButton();
   209         } 
   318         } 
   210     
   319         mRadioButtonList->setScrollDirections(Qt::Vertical);
   211     
   320         QObject::disconnect( mRadioButtonList, SIGNAL(itemSelected(int)), 
   212         
   321             this, SLOT(updateModel(int)) );
   213         mButton->setVisible( false );  
   322         selectItem();
   214         static_cast<QGraphicsLinearLayout*>( layout() )->addItem( mRadioButton );   
   323         mDialog = new HbDialog();
   215         mRadioButton->setVisible( true );
   324         mDialog->setTimeout(HbPopup::NoTimeout);    
   216         mButtonVisible = false;
   325         mDialog->setAttribute(Qt::WA_DeleteOnClose);
   217         layout()->removeAt( 0 );
   326         mDialog->setContentWidget(mRadioButtonList);    
   218         
   327         mDialog->addAction(new HbAction(QString("Ok")));
   219 
   328         mDialog->addAction(new HbAction(QString("Cancel")));
   220 }
   329         mDialog->open(this,SLOT(dialogClosed(HbAction*)));  
   221 
   330         mRadioButtonList->setSelected(mSelected);
   222 
   331     }
   223 void HbRadioItem::itemSelected( int index )
   332 }
   224 {
   333 
   225     //update the label with the selected index text
   334 
   226     //mLabel->clear( );
   335 void HbRadioItem::updateModel( int index )
   227     mButton->setText( mRadioButton->items().at(index) );
   336 {
   228     emit valueChanged(mViewItem->modelIndex(), mRadioButton->items().at(index));
   337     mSelected = index;
   229     
   338     emit valueChanged(mViewItem->modelIndex(), mItems.at(index));
   230     
   339     // Disconnect modelchanged signal since visualization is already updated by user
   231     static_cast<QGraphicsLinearLayout*>( layout() )->addItem( mButton );
   340     // so if not disconnected , this will trigger visualization change again
   232 
       
   233     mRadioButton->setVisible( false );
       
   234     mButton->setVisible( true );
       
   235     mButtonVisible = true;
       
   236     layout()->removeAt( 0 );
       
   237     
       
   238     //update the model
       
   239     disconnect( mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
   341     disconnect( mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
   240                   HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   342                   HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   241                   SLOT( dataChanged(QModelIndex,QModelIndex)) );
   343                   SLOT( dataChanged(QModelIndex,QModelIndex)) );
   242     mModelItem->setContentWidgetData("selected", mRadioButton->property("selected"));
   344     //update the model
       
   345     mModelItem->setContentWidgetData("selected", mSelected);
       
   346     // establish the connection back
   243     connect( mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
   347     connect( mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
   244                   HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   348                   HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   245                   SLOT( dataChanged(QModelIndex,QModelIndex)) );
   349                   SLOT( dataChanged(QModelIndex,QModelIndex)) );
       
   350     // select the item . The selection is already stored in to the model above
       
   351     selectItem();
       
   352 }
       
   353 
       
   354 
       
   355 void HbRadioItem::dialogClosed(HbAction* action)
       
   356 {
       
   357     if(action->text() == "Ok") {
       
   358         // store the selected item to model
       
   359         updateModel(mRadioButtonList->selected());        
       
   360     }
       
   361     // dont change selection incase of "Cancel" button click .
       
   362     mRadioButtonList = 0;
       
   363     mDialog = 0;
   246 }
   364 }
   247 
   365 
   248 HbMultiSelectionItem::HbMultiSelectionItem( QGraphicsItem* parent ):
   366 HbMultiSelectionItem::HbMultiSelectionItem( QGraphicsItem* parent ):
   249     HbWidget(parent),
   367     HbWidget(parent),
   250     mQuery(0)
   368     mSelectionDialog(0),
       
   369     mButton(0),
       
   370     mMultiListWidget(0)
   251 {
   371 {
   252     // Create label by default . RadioButtonList is created created at runtime 
   372     // Create label by default . RadioButtonList is created created at runtime 
   253     // when clicked on the item        
   373     // when clicked on the item        
   254     mViewItem = static_cast<HbDataFormViewItem*>(parent);
   374     mViewItem = static_cast<HbDataFormViewItem*>(parent);
   255 
   375     layout = new QGraphicsLinearLayout(Qt::Horizontal);
   256     mButton = new HbPushButton();
       
   257     QObject::connect(mButton, SIGNAL(released()), this, SLOT(launchMultiSelectionList()));
       
   258     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Horizontal);
       
   259     layout->addItem(mButton);
       
   260     setLayout(layout);
   376     setLayout(layout);
   261     
   377     
   262     mModel = static_cast<HbDataFormModel*>(
   378     mModel = static_cast<HbDataFormModel*>(
   263             HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView->model());
   379             HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView->model());
   264     mModelItem = static_cast<HbDataFormModelItem*>(
   380     mModelItem = static_cast<HbDataFormModelItem*>(
   265             mModel->itemFromIndex(mViewItem->modelIndex()));
   381             mModel->itemFromIndex(mViewItem->modelIndex()));    
   266     QObject::connect(this,SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),mViewItem, SIGNAL(itemModified(QPersistentModelIndex, QVariant)));
   382     // set displayMode to automatic if not already set by application
       
   383     QString displayMode = mModelItem->contentWidgetData(QString("displayMode")).toString();
       
   384     if(displayMode.isEmpty()) {
       
   385         mModelItem->setContentWidgetData(QString("displayMode"), "automatic");
       
   386     }
       
   387     QObject::connect(this,SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
       
   388         mViewItem, SIGNAL(itemModified(QPersistentModelIndex, QVariant)));
   267 }
   389 }
   268 
   390 
   269 HbMultiSelectionItem::~HbMultiSelectionItem()
   391 HbMultiSelectionItem::~HbMultiSelectionItem()
   270 {
   392 {
   271 }
   393 }
   272 
   394 
   273 HbWidget* HbMultiSelectionItem::contentWidget() const
   395 
   274 {
   396 void HbMultiSelectionItem::makeSelection()
   275     return mButton;
   397 {
       
   398     QItemSelectionModel *model = 0;
       
   399     if(mMultiListWidget) {// embedded case
       
   400         // get selection model
       
   401         model = mMultiListWidget->selectionModel();
       
   402         if(model) {
       
   403             // disconnect so that the visualization does not get changed when selction 
       
   404             // model changes
       
   405             QObject::disconnect(model, 
       
   406                 SIGNAL(selectionChanged( const QItemSelection , const QItemSelection  )), 
       
   407                 this, SLOT(updateModel( const QItemSelection , const QItemSelection  )));
       
   408             model->clearSelection();
       
   409             for( int i = 0; i < mSelectedItems.count() ; i++ ) {
       
   410                 model->select( model->model()->index(mSelectedItems.at( i ).toInt(),0),
       
   411                     QItemSelectionModel::Select);
       
   412             }
       
   413             QObject::connect(model, 
       
   414                 SIGNAL(selectionChanged( const QItemSelection , const QItemSelection  )), 
       
   415                 this, SLOT(updateModel( const QItemSelection , const QItemSelection  )));
       
   416         }
       
   417     } else if(mButton) { // update text on button
       
   418         QString newValue("");
       
   419         // create sting to be set on button
       
   420         for ( int i = 0; i < mSelectedItems.count() ; i++ ) {
       
   421             int selectionindex = mSelectedItems.at( i ).toInt();
       
   422             if( selectionindex< mItems.count()) {
       
   423                 if( i > 0) {// dont add ; in the starting of the string
       
   424                     newValue.append( ";" );
       
   425                 }
       
   426                 newValue.append( mItems.at( mSelectedItems.at( i ).toInt() ) );
       
   427             } 
       
   428         }
       
   429         mButton->setText( newValue );
       
   430     }
       
   431 }
       
   432 
       
   433 void HbMultiSelectionItem::makeEmbedded()
       
   434 {
       
   435     
       
   436     // delete button if displaymode change has happened at runtime 
       
   437     if(mButton){
       
   438         layout->removeItem(mButton);
       
   439         delete mButton;
       
   440         mButton = 0;
       
   441     }
       
   442     // create ListWidget if not yet created 
       
   443     if(!mMultiListWidget) {
       
   444         mMultiListWidget = new HbListWidget();
       
   445         layout->addItem(mMultiListWidget);
       
   446     }
       
   447     
       
   448     mMultiListWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
       
   449     
       
   450     mMultiListWidget->clear();
       
   451     // update the listwidget with new items
       
   452     for (int index = 0; index < mItems.count(); ++index) {
       
   453         mMultiListWidget->addItem(mItems.at(index));
       
   454     }
       
   455     mMultiListWidget->setScrollDirections(0);
       
   456 }
       
   457 
       
   458 void HbMultiSelectionItem::makePopup()
       
   459 {
       
   460     // Delete ListWidget if mode change happened at runtime from embedded to popup
       
   461     if(mMultiListWidget) {
       
   462         layout->removeItem(mMultiListWidget);
       
   463         delete mMultiListWidget;
       
   464         mMultiListWidget = 0;
       
   465     }
       
   466     // create button since we need to display selected item on button
       
   467     // and popup will be launched when button is clicked
       
   468     if(!mButton) {
       
   469         mButton = new HbPushButton();
       
   470         mButton->setTextAlignment(Qt::AlignLeft);
       
   471         layout->addItem(mButton);
       
   472     }
       
   473     QObject::connect(mButton, SIGNAL(released()), this, SLOT(launchMultiSelectionList()));
       
   474 }
       
   475 
       
   476 void HbMultiSelectionItem::changeMode()
       
   477 {
       
   478     QString displayMode = mModelItem->contentWidgetData(QString("displayMode")).toString();
       
   479     if((mItems.count() <= MAX_INLINE_ITEM_COUNT && displayMode == "automatic") || 
       
   480         displayMode == "embedded" ) {
       
   481         makeEmbedded();
       
   482     } else{
       
   483         makePopup();
       
   484     }
       
   485     makeSelection();
   276 }
   486 }
   277 
   487 
   278 bool HbMultiSelectionItem::event( QEvent * e )
   488 bool HbMultiSelectionItem::event( QEvent * e )
   279 {
   489 {
   280     switch( e->type() ) {
   490     switch( e->type() ) {
   281         case QEvent::DynamicPropertyChange: {
   491         case QEvent::DynamicPropertyChange: {
   282                 QDynamicPropertyChangeEvent *eve = static_cast<QDynamicPropertyChangeEvent*>( e );
   492                 QDynamicPropertyChangeEvent *eve = static_cast<QDynamicPropertyChangeEvent*>( e );
   283                 QString name = eve->propertyName( ).data( );
   493                 QString dynamicPropertyName = eve->propertyName( ).data( );                
   284                 
   494                 if ( dynamicPropertyName == "items" || dynamicPropertyName == "displayMode" ) {
   285                 if ( name == "text" ) {
   495                     int prevCount = mItems.count();
   286                     mButton->setProperty(
   496                     mItems.clear();
   287                         eve->propertyName().data(), property(eve->propertyName().data()) );
       
   288                 }
       
   289                 if ( name == "items" ) {
       
   290                     mItems = property("items").toStringList();
   497                     mItems = property("items").toStringList();
   291                 } else if ( name == "selectedItems" ) {
   498                     if ( mItems.count() != prevCount || dynamicPropertyName == "displayMode") {
   292                      mItems = property("items").toStringList();
   499                         changeMode();
   293                      QList<QVariant> selected = property("selectedItems").toList();
       
   294                      
       
   295                      for( int i = 0; i < selected.count() ; i++ ) {
       
   296                          if ( !mSelectedItems.contains( selected.at( i ).toInt( ) ) ) {
       
   297                             mSelectedItems.append( selected.at( i ).toInt( ) );
       
   298                          }
       
   299                      }
       
   300                 }
       
   301                 if ( mSelectedItems.count() > 0 && mItems.count() > 0 ) {
       
   302                     QString newValue("");
       
   303                     for ( int i = 0; i < mSelectedItems.count() ; i++ ) {
       
   304                         newValue.append( mItems.at( mSelectedItems.at( i ) ) );
       
   305                         newValue.append( ";" );
       
   306                     }
   500                     }
   307                     //mButton->clear( );
   501                     
   308                     mButton->setText( newValue );                    
   502                 } else if ( dynamicPropertyName == "selectedItems" ) {                    
   309                     mButton->setTextAlignment(Qt::AlignLeft);
   503                     mItems = property("items").toStringList();
       
   504                     mSelectedItems = property("selectedItems").toList();
       
   505                     makeSelection();
   310                 }
   506                 }
   311                 break;
   507                 break;
   312             }
   508             }
   313         default:
   509         default:
   314             break;
   510             break;
   317     HbWidget::event( e );
   513     HbWidget::event( e );
   318     return false;
   514     return false;
   319 }
   515 }
   320 
   516 
   321 
   517 
       
   518 void HbMultiSelectionItem::updateModel( const QItemSelection &selected, 
       
   519     const QItemSelection  &deselected)
       
   520 {
       
   521 
       
   522     // This function gets called when selection changes in HbListWidget model
       
   523     disconnect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
       
   524         HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
       
   525         SLOT( dataChanged(QModelIndex,QModelIndex)));
       
   526     QModelIndexList selectList = selected.indexes();    
       
   527     QModelIndexList deselectList = deselected.indexes();
       
   528     // Add newly selected item to selected list
       
   529     for(int i = 0;i<selectList.count(); i++) {
       
   530        if(!mSelectedItems.contains(selectList.at(i).row())) {
       
   531             mSelectedItems.append(selectList.at(i).row());
       
   532        }
       
   533     }
       
   534     // remove selection from selection list
       
   535     for(int i = 0;i<deselectList.count(); i++) {
       
   536         mSelectedItems.removeOne(deselectList.at(i).row());
       
   537     }
       
   538     //update the model with the selected items
       
   539     
       
   540     mModelItem->setContentWidgetData("selectedItems", mSelectedItems);
       
   541 
       
   542     connect(mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
       
   543                   HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
       
   544                   SLOT( dataChanged(QModelIndex,QModelIndex)));
       
   545 }
       
   546 
   322 void HbMultiSelectionItem::launchMultiSelectionList()
   547 void HbMultiSelectionItem::launchMultiSelectionList()
   323 {
   548 {
   324     mQuery = 0;
   549     if(!mSelectionDialog ) {
   325     mQuery = new HbListDialog();
   550         mSelectionDialog = new HbSelectionDialog();
   326     mQuery->setSelectionMode( HbAbstractItemView::MultiSelection );
   551         mSelectionDialog->setSelectionMode( HbAbstractItemView::MultiSelection );
   327     mQuery->setStringItems( mItems, mItems.count() + 1 );    
   552         mSelectionDialog->setStringItems( mItems, -1 ); 
   328     mQuery->setSelectedItems( mSelectedItems );
   553         mSelectionDialog->setSelectedItems( mSelectedItems );
   329     mQuery->setAttribute(Qt::WA_DeleteOnClose);
   554         mSelectionDialog->setAttribute(Qt::WA_DeleteOnClose);
   330 
   555         mSelectionDialog->open(this,SLOT(dialogClosed(HbAction*)));   
   331     mQuery->open(this,SLOT(dialogClosed(HbAction*)));   
   556     }
   332 }
   557 }
   333 
   558 
   334 void HbMultiSelectionItem::dialogClosed(HbAction* action)
   559 void HbMultiSelectionItem::dialogClosed(HbAction* action)
   335 {
   560 {
   336     if( action == mQuery->primaryAction( )) {
   561     if( action->text() == "Ok") {
   337         //fetch the selected items
   562         //fetch the selected items
   338         mSelectedItems = mQuery->selectedItems();
   563         mSelectedItems = mSelectionDialog->selectedItems();
   339         QString newValue("");
   564         QString newValue("");
   340 
   565         QList<int> selection;
   341         qSort( mSelectedItems.begin(), mSelectedItems.end( ) );
       
   342         for( int i = 0; i < mSelectedItems.count(); i++ ) {
   566         for( int i = 0; i < mSelectedItems.count(); i++ ) {
   343             newValue.append(mQuery->stringItems().at(mSelectedItems.at(i)));
   567             selection.append(mSelectedItems.at(i).toInt());
   344             if( i != mSelectedItems.count() - 1 ) {
   568         }
       
   569         qSort( selection.begin(), selection.end( ) );
       
   570         mSelectedItems.clear();
       
   571         for( int i = 0; i < selection.count(); i++ ) {
       
   572             mSelectedItems.append(selection.at(i));
       
   573             newValue.append(mSelectionDialog->stringItems().at(selection.at(i)));
       
   574             if( i != selection.count() - 1 ) {
   345                 newValue.append( ";" );
   575                 newValue.append( ";" );
   346             }
   576             }
   347         }
   577         }        
   348         
       
   349         mButton->setText( newValue );
   578         mButton->setText( newValue );
   350         emit valueChanged(mViewItem->modelIndex(), newValue);
   579         emit valueChanged(mViewItem->modelIndex(), newValue);
   351 
   580 
   352         disconnect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
   581         disconnect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
   353                       HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   582                       HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   354                       SLOT( dataChanged(QModelIndex,QModelIndex)));
   583                       SLOT( dataChanged(QModelIndex,QModelIndex)));
       
   584         if(mModelItem) {
       
   585             mModelItem->setContentWidgetData(QString("text"), newValue);
       
   586         }
   355         
   587         
   356         mModelItem->setContentWidgetData( "items", mItems );
   588         mModelItem->setContentWidgetData( "items", mItems );
   357 
   589 
   358         //update the model with the selected items
   590         //update the model with the selected items
   359         QList<QVariant> items;
   591         mModelItem->setContentWidgetData("selectedItems", mSelectedItems);
   360         for( int i = 0; i < mSelectedItems.count(); i++ ) {
       
   361             items.append( mSelectedItems.at( i ) );
       
   362         }
       
   363         mModelItem->setContentWidgetData("selectedItems", items);
       
   364 
   592 
   365         connect(mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
   593         connect(mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
   366                       HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   594                       HbDataFormViewItemPrivate::d_ptr(mViewItem)->mSharedData->mItemView, 
   367                       SLOT( dataChanged(QModelIndex,QModelIndex)));
   595                       SLOT( dataChanged(QModelIndex,QModelIndex)));
   368     }
   596     }
       
   597     mSelectionDialog = 0;
   369 }
   598 }
   370 
   599 
   371 
   600 
   372 HbDataFormViewItemPrivate::HbDataFormViewItemPrivate( HbDataFormViewItem *prototype ):
   601 HbDataFormViewItemPrivate::HbDataFormViewItemPrivate( HbDataFormViewItem *prototype ):
   373     HbAbstractViewItemPrivate( prototype ),
   602     HbAbstractViewItemPrivate( prototype ),
   429 
   658 
   430     if( !mLabel.isEmpty() ) {
   659     if( !mLabel.isEmpty() ) {
   431         if( !mLabelItem ) {
   660         if( !mLabelItem ) {
   432             mLabelItem = q->style()->createPrimitive( HbStyle::P_DataItem_label, q );
   661             mLabelItem = q->style()->createPrimitive( HbStyle::P_DataItem_label, q );
   433         }
   662         }
       
   663     } else {
       
   664         if( mLabelItem ) {
       
   665             HbStyle::setItemName( mLabelItem, NULL );
       
   666             delete mLabelItem;
       
   667             mLabelItem = 0;
       
   668 
       
   669         }
   434     }
   670     }
   435 
   671 
   436     if( !mIcon.isEmpty() ) {
   672     if( !mIcon.isEmpty() ) {
   437         q->setProperty( "hasIcon", true );
   673         q->setProperty( "hasIcon", true );
   438         if(!mIconItem) {
   674         if(!mIconItem) {
   439             mIconItem = q->style()->createPrimitive( HbStyle::P_DataItem_icon, q );
   675             mIconItem = q->style()->createPrimitive( HbStyle::P_DataItem_icon, q );
   440         }
   676         }
   441     } else {
   677     } else {
   442         q->setProperty( "hasIcon", false );
   678         q->setProperty( "hasIcon", false );
       
   679         if( mIconItem ) {
       
   680             HbStyle::setItemName( mIconItem, NULL );
       
   681             delete mIconItem;
       
   682             mIconItem = 0;
       
   683         }
   443     }
   684     }
   444 
   685 
   445     if(!mDescription.isEmpty()) {
   686     if(!mDescription.isEmpty()) {
   446         if(!mDescriptionItem) {
   687         if(!mDescriptionItem) {
   447             mDescriptionItem = q->style()->createPrimitive(HbStyle::P_DataItem_description, q);
   688             mDescriptionItem = q->style()->createPrimitive(HbStyle::P_DataItem_description, q);
       
   689         }
       
   690     } else {
       
   691         if( mDescriptionItem ) {
       
   692             HbStyle::setItemName( mDescriptionItem, NULL );
       
   693             delete mDescriptionItem;
       
   694             mDescriptionItem = 0;
       
   695 
   448         }
   696         }
   449     }
   697     }
   450 }
   698 }
   451 
   699 
   452 /*
   700 /*
   453     Sets the description for the data item.
   701     Sets the description for the data item.
   454 */
   702 */
   455 void HbDataFormViewItemPrivate::setDescription( const QString& description )
   703 void HbDataFormViewItemPrivate::setDescription( const QString& description )
   456 {
   704 {
   457     mDescription = description; 
   705     Q_Q( HbDataFormViewItem );
       
   706 
       
   707     if ( mDescription == description ) {
       
   708         return;
       
   709     }
       
   710     
       
   711     bool doRepolish = false;
       
   712 
       
   713     if ( ( mDescription.isEmpty() && !description.isEmpty() ) || 
       
   714         ( !mDescription.isEmpty() && description.isEmpty() )) {
       
   715             doRepolish = true;
       
   716     }
       
   717 
       
   718     mDescription = description;
   458     createPrimitives();
   719     createPrimitives();
       
   720     if ( doRepolish ) {
       
   721         q->repolish();
       
   722     }
   459     updatePrimitives();
   723     updatePrimitives();
       
   724     
   460 }
   725 }
   461 
   726 
   462 /*
   727 /*
   463     Returns the description of data item.
   728     Returns the description of data item.
   464 */
   729 */
   498     will not be created .
   763     will not be created .
   499     
   764     
   500 */
   765 */
   501 void HbDataFormViewItemPrivate::setLabel( const QString& label )
   766 void HbDataFormViewItemPrivate::setLabel( const QString& label )
   502 {
   767 {
       
   768     Q_Q( HbDataFormViewItem );
       
   769 
       
   770     if (  mLabel == label ) {
       
   771         return;
       
   772     }
       
   773 
       
   774     bool doRepolish = false;
       
   775 
       
   776     if ( ( mLabel.isEmpty() && !label.isEmpty() ) || 
       
   777         ( !mLabel.isEmpty() && label.isEmpty() )) {
       
   778             doRepolish = true;
       
   779     }
       
   780 
   503     mLabel = label; 
   781     mLabel = label; 
   504     createPrimitives();
   782     createPrimitives();
       
   783     if ( doRepolish ) {
       
   784         q->repolish();
       
   785     }
   505     updatePrimitives();
   786     updatePrimitives();
   506 }
   787 }
   507 void HbDataFormViewItemPrivate::updateLabel(const QString& label)
   788 
       
   789 void HbDataFormViewItemPrivate::updateData()
   508 {
   790 {
   509     Q_Q(HbDataFormViewItem);
   791     Q_Q(HbDataFormViewItem);
   510     
   792     
   511     HbDataFormModelItem::DataItemType type = static_cast< HbDataFormModelItem::DataItemType>(
   793     HbDataFormModelItem::DataItemType type = static_cast< HbDataFormModelItem::DataItemType>(
   512                 q->modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
   794                 q->modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
   513     HbDataFormModel* data_model = static_cast<HbDataFormModel*>(q->itemView()->model());
   795     HbDataFormModel* data_model = static_cast<HbDataFormModel*>(q->itemView()->model());
   514     HbDataFormModelItem *model_item = static_cast<HbDataFormModelItem*>(data_model->itemFromIndex(mIndex));   
   796     HbDataFormModelItem *model_item = static_cast<HbDataFormModelItem*>(data_model->itemFromIndex(mIndex));
   515     
   797     HbDataFormModelItemPrivate *modelItem_priv = HbDataFormModelItemPrivate::d_ptr(model_item);    
   516     
   798 
   517     if(type == HbDataFormModelItem::FormPageItem) {
   799     //update label
   518 
   800     if( modelItem_priv->dirtyProperty() == "LabelRole" ) {
   519         int index = data_model->invisibleRootItem()->indexOf(model_item);
   801         QString label = model_item->label();
   520         HbDataFormPrivate* form_priv = HbDataFormPrivate::d_ptr(
   802         if(type == HbDataFormModelItem::FormPageItem) {
   521                                     static_cast<HbDataForm*>(q->itemView()));        
   803 
   522         if(index >= 0) {
   804             int index = data_model->invisibleRootItem()->indexOf(model_item);
   523             form_priv->mHeadingWidget->updatePageName(index ,label);
   805             HbDataFormPrivate* form_priv = HbDataFormPrivate::d_ptr(
   524         }
   806                                         static_cast<HbDataForm*>(q->itemView()));        
   525 
   807             if(index >= 0) {
   526     } else if(type == HbDataFormModelItem::GroupItem) {
   808                 form_priv->mHeadingWidget->updatePageName(index ,label);
   527         
   809             }
   528         
   810 
   529         HbDataGroupPrivate::d_ptr(static_cast<HbDataGroup*>(q))->setHeading(label);            
   811         } else if(type == HbDataFormModelItem::GroupItem) {
   530 
   812 
   531     } else if(type == HbDataFormModelItem::GroupPageItem) {
   813             HbDataGroupPrivate::d_ptr(static_cast<HbDataGroup*>(q))->setHeading(label);
   532        
   814 
   533         QModelIndex groupIndex = data_model->parent(mIndex);
   815         } else if(type == HbDataFormModelItem::GroupPageItem) {
   534         int index = (data_model->itemFromIndex(groupIndex))->indexOf(model_item);       
   816            
   535         HbDataGroup* groupItem = static_cast<HbDataGroup*>(
   817             QModelIndex groupIndex = data_model->parent(mIndex);
   536                         q->itemView()->itemByIndex(groupIndex));
   818             int index = (data_model->itemFromIndex(groupIndex))->indexOf(model_item);       
   537         groupItem->updateGroupPageName(index,label);
   819             HbDataGroup* groupItem = static_cast<HbDataGroup*>(
   538 
   820                             q->itemView()->itemByIndex(groupIndex));
   539     } else if (type > HbDataFormModelItem::GroupPageItem ) {
   821             groupItem->updateGroupPageName(index,label);
   540         setLabel(label);        
   822 
   541     }
   823         } else if (type > HbDataFormModelItem::GroupPageItem ) {
   542     
   824             setLabel(label);        
       
   825         }
       
   826     } else if ( modelItem_priv->dirtyProperty() == "DescriptionRole" ) {
       
   827         //update description of either data item or data group
       
   828         QString description = model_item->description();
       
   829         if( type == HbDataFormModelItem::GroupItem ) {
       
   830             HbDataGroupPrivate::d_ptr(static_cast<HbDataGroup*>(q))->setDescription(description);
       
   831         } else if ( type > HbDataFormModelItem::GroupPageItem ) {
       
   832             setDescription(description);
       
   833         }
       
   834     } else if ( modelItem_priv->dirtyProperty() == "DecorationRole" ){
       
   835         //update data item icon
       
   836         if ( type > HbDataFormModelItem::GroupPageItem ) {
       
   837             setIcon(model_item->icon());
       
   838         }
       
   839     }
   543 }
   840 }
   544 
   841 
   545 void HbDataFormViewItemPrivate::setEnabled(bool enabled)
   842 void HbDataFormViewItemPrivate::setEnabled(bool enabled)
   546 {
   843 {
   547     Q_Q(HbDataFormViewItem);
   844     Q_Q(HbDataFormViewItem);
   548 
       
   549 
   845 
   550     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   846     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   551     Qt::ItemFlags indexFlags = mIndex.flags();
   847     Qt::ItemFlags indexFlags = mIndex.flags();
   552 
   848 
   553     if (indexFlags & Qt::ItemIsEnabled) {
   849     if (indexFlags & Qt::ItemIsEnabled) {
   554         if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
   850         if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
   555             itemFlags |= QGraphicsItem::ItemIsFocusable;
   851             itemFlags |= QGraphicsItem::ItemIsFocusable;
   556             q->setFocusPolicy(q->prototype()->focusPolicy());
   852             q->setFocusPolicy(q->prototype()->focusPolicy());
   557             q->setProperty("state", "normal");
   853             q->setProperty("state", "normal");
       
   854             q->grabGesture(Qt::TapGesture);
   558         }
   855         }
   559     } else {
   856     } else {
   560         if (itemFlags & QGraphicsItem::ItemIsFocusable) {
   857         if (itemFlags & QGraphicsItem::ItemIsFocusable) {
   561             itemFlags &= ~QGraphicsItem::ItemIsFocusable;
   858             itemFlags &= ~QGraphicsItem::ItemIsFocusable;
   562             q->setFocusPolicy(Qt::NoFocus);
   859             q->setFocusPolicy(Qt::NoFocus);
   563             q->setProperty("state", "disabled");
   860             q->setProperty("state", "disabled");
       
   861             q->ungrabGesture(Qt::TapGesture);
   564         }
   862         }
   565     }
   863     }
   566 
   864 
   567     if( mContentWidget ) {
   865     if( mContentWidget ) {
   568         mContentWidget->setEnabled(enabled);
   866         mContentWidget->setEnabled(enabled);
   581     Sets the icon for the setting item . If no icon is set icon will not be created.
   879     Sets the icon for the setting item . If no icon is set icon will not be created.
   582     
   880     
   583 */
   881 */
   584 void HbDataFormViewItemPrivate::setIcon( const QString& icon )
   882 void HbDataFormViewItemPrivate::setIcon( const QString& icon )
   585 {
   883 {
       
   884     Q_Q(HbDataFormViewItem);
       
   885     if ( mIcon == icon ) {
       
   886         return;
       
   887     }
       
   888 
       
   889     bool doRepolish = false;
       
   890 
       
   891     if ( ( mIcon.isEmpty() && !icon.isEmpty() ) || 
       
   892         ( !mIcon.isEmpty() && icon.isEmpty() )) {
       
   893             doRepolish = true;
       
   894     }
       
   895 
   586     mIcon = icon;
   896     mIcon = icon;
   587     createPrimitives();
   897     createPrimitives();
       
   898     if ( doRepolish ) {
       
   899         q->repolish();
       
   900     }
       
   901 
   588     updatePrimitives();
   902     updatePrimitives();
   589 }
   903 }
   590 
   904 
   591 /*
   905 /*
   592     Returns the heading / label of the setting item.
   906     Returns the heading / label of the setting item.
   608         // following are standard data item
   922         // following are standard data item
   609         case HbDataFormModelItem::SliderItem:
   923         case HbDataFormModelItem::SliderItem:
   610         case HbDataFormModelItem::VolumeSliderItem: {
   924         case HbDataFormModelItem::VolumeSliderItem: {
   611                 mContentWidget = new HbSlider( Qt::Horizontal, q );
   925                 mContentWidget = new HbSlider( Qt::Horizontal, q );
   612                 mProperty.append( "sliderPosition" );            
   926                 mProperty.append( "sliderPosition" );            
   613                 QObject::connect( mContentWidget, SIGNAL(sliderReleased()), q,SLOT(save()) );
   927                 QObject::connect( mContentWidget, SIGNAL(valueChanged(int)), q,SLOT(save()) );
   614                 HbStyle::setItemName( mContentWidget, "dataItem_ContentWidget" );                
   928                 HbStyle::setItemName( mContentWidget, "dataItem_ContentWidget" );                
   615             }
   929             }
   616             break;
   930             break;
   617         case HbDataFormModelItem::CheckBoxItem: {
   931         case HbDataFormModelItem::CheckBoxItem: {
   618                 mContentWidget = new HbCheckBox(q);
   932                 mContentWidget = new HbCheckBox(q);
   667                     HbStyle::setItemName(mContentWidget, "dataItem_ContentWidget");
   981                     HbStyle::setItemName(mContentWidget, "dataItem_ContentWidget");
   668                 }
   982                 }
   669             }
   983             }
   670             break;
   984             break;
   671     }
   985     }
       
   986     //background primitive should get created.
       
   987     createPrimitives();
       
   988     updatePrimitives();
   672     if ( mContentWidget ) {
   989     if ( mContentWidget ) {
   673         QEvent polishEvent( QEvent::Polish );
   990         QEvent polishEvent( QEvent::Polish );
   674         QCoreApplication::sendEvent( mContentWidget, &polishEvent );
   991         QCoreApplication::sendEvent( mContentWidget, &polishEvent );
   675     }
   992     }
   676 }
   993 }