messagingapp/shareui/src/shareuiprivate.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 38 4e4b6adb1024
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
    67 /**
    67 /**
    68  * Destructor.
    68  * Destructor.
    69  */
    69  */
    70 ShareUiPrivate::~ShareUiPrivate()
    70 ShareUiPrivate::~ShareUiPrivate()
    71     {
    71     {
    72     reset();
       
    73     }
    72     }
    74 
    73 
    75 /**
    74 /**
    76  * Clear the internal data structures
    75  * Clear the internal data structures
    77  */
    76  */
    78 void ShareUiPrivate::reset()
    77 void ShareUiPrivate::reset()
    79     {
    78     {
    80     mFileList.clear();
    79     mFileList.clear();
    81     
    80 
    82     mIndexActionMap.clear(); // TODO Is there MEM leak.
    81     mIndexActionMap.clear();
    83     mAiwRequestList.clear(); // TODO Is there MEM leak.
    82     foreach(XQAiwRequest* request,mAiwRequestList)
    84     
    83     {
    85     if ( mContentItemModel )
    84         delete request;
    86         {
    85     }
    87         delete mContentItemModel;
    86     mAiwRequestList.clear();
    88         mContentItemModel = 0;
    87 
    89         }
       
    90     
       
    91     if ( mContentListView )
       
    92         {
       
    93         delete mContentListView;
       
    94         mContentListView = 0;
       
    95         }
       
    96     
       
    97     if ( mSharePopup )
       
    98         {
       
    99         delete mSharePopup;
       
   100         mSharePopup = 0;
       
   101         }
       
   102     }
    88     }
   103 
    89 
   104 /**
    90 /**
   105  * Initialize and start the dialog
    91  * Initialize and start the dialog
   106  * 
    92  * 
   109  * 
    95  * 
   110  */
    96  */
   111 bool ShareUiPrivate::init(QStringList& fileList, bool embedded)
    97 bool ShareUiPrivate::init(QStringList& fileList, bool embedded)
   112     {    
    98     {    
   113     reset();
    99     reset();
   114     
   100     mIsEmbedded = embedded;
   115     // No input files
   101     // No input files
   116     if ( fileList.count() == 0 )
   102     if ( fileList.count() == 0 )
   117         {
   103         {
   118         showNote(LOC_NO_FILES);
   104         showNote(LOC_NO_FILES);
   119         return true;       
   105         return true;       
   140     
   126     
   141     // Some protected content
   127     // Some protected content
   142     if ( fileList.count() != filteredFileList.count() )
   128     if ( fileList.count() != filteredFileList.count() )
   143         {
   129         {
   144         showNote(LOC_PROTECTED_CONTENT);      
   130         showNote(LOC_PROTECTED_CONTENT);      
       
   131         return true;
   145         }
   132         }
   146     
   133     
   147     // Only protected content
   134     // Only protected content
   148     if ( filteredFileList.count() == 0 )
   135     if ( filteredFileList.count() == 0 )
   149         {
   136         {
   199             {
   186             {
   200             showNote(LOC_NO_SERVICES);
   187             showNote(LOC_NO_SERVICES);
   201             return true;
   188             return true;
   202             }
   189             }
   203 
   190 
   204         mSharePopup->exec();
   191         mSharePopup->show();
   205         }
   192         }
   206     else
   193     else
   207         {
   194         {
   208         showNote(LOC_NO_SERVICES);
   195         showNote(LOC_NO_SERVICES);
   209         }
   196         }
   216   */
   203   */
   217 void ShareUiPrivate::initializeUi()
   204 void ShareUiPrivate::initializeUi()
   218     {
   205     {
   219     // Dialog
   206     // Dialog
   220     mSharePopup = new HbDialog();
   207     mSharePopup = new HbDialog();
   221     
   208     // make it delete itself on close
       
   209     mSharePopup->setAttribute( Qt::WA_DeleteOnClose, true );
   222     HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup);
   210     HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup);
   223     heading->setAlignment(Qt::AlignCenter);
   211     heading->setAlignment(Qt::AlignCenter);
       
   212     mSharePopup->setDismissPolicy(HbDialog::NoDismiss);
   224     mSharePopup->setHeadingWidget(heading);
   213     mSharePopup->setHeadingWidget(heading);
   225     mSharePopup->setTimeout(HbDialog::NoTimeout);  
       
   226     mSharePopup->setFrameType(HbDialog::Strong);
   214     mSharePopup->setFrameType(HbDialog::Strong);
   227     mSharePopup->setPrimaryAction(new HbAction(LOC_BUTTON_CANCEL, mSharePopup));
   215     connect(mSharePopup, SIGNAL(aboutToClose()), this, SLOT(reset()));
   228         
   216         
   229     // Content widget
   217     // Content widget
   230     mContentListView = new HbListView(mSharePopup);
   218     mContentListView = new HbListView(mSharePopup);
   231     ShareListItem *prototype = new ShareListItem(mSharePopup);
   219     ShareListItem *prototype = new ShareListItem(mSharePopup);
   232     mContentListView->setItemPrototype(prototype);
   220     mContentListView->setItemPrototype(prototype);
   235     mContentListView->setModel(mContentItemModel); 
   223     mContentListView->setModel(mContentItemModel); 
   236     mContentListView->setUniformItemSizes(true);
   224     mContentListView->setUniformItemSizes(true);
   237     mSharePopup->setContentWidget(mContentListView);
   225     mSharePopup->setContentWidget(mContentListView);
   238     connect(mContentListView, SIGNAL(activated(QModelIndex)),
   226     connect(mContentListView, SIGNAL(activated(QModelIndex)),
   239             this, SLOT(itemActivated(QModelIndex)));  
   227             this, SLOT(itemActivated(QModelIndex)));  
       
   228     
       
   229     HbAction* cancelAction = new HbAction(LOC_BUTTON_CANCEL,mSharePopup);
       
   230     mSharePopup->addAction(cancelAction);
   240     }
   231     }
   241 
   232 
   242 /**
   233 /**
   243  * fetchServiceAction fetches the action associated with a specified interface descriptor.
   234  * fetchServiceAction fetches the action associated with a specified interface descriptor.
   244  * This is used after the fetchServiceDescriptors is called, and 
   235  * This is used after the fetchServiceDescriptors is called, and 
   287     if(request)
   278     if(request)
   288         {
   279         {
   289         QList<QVariant> args;
   280         QList<QVariant> args;
   290         QVariant fileList(mFileList);
   281         QVariant fileList(mFileList);
   291         args << fileList;
   282         args << fileList;
       
   283         request->setEmbedded(mIsEmbedded);
   292         request->setArguments(args);
   284         request->setArguments(args);
   293         }
   285         }
   294     }
   286     }
   295 
   287 
   296 /**
   288 /**
   327     if ( action )
   319     if ( action )
   328         {
   320         {
   329         action->setEnabled(true);
   321         action->setEnabled(true);
   330         action->activate(HbAction::Trigger);
   322         action->activate(HbAction::Trigger);
   331         }    
   323         }    
   332     mSharePopup->close();
       
   333     }
   324     }
   334 
   325 
   335 
   326 
   336 /**
   327 /**
   337  * Convert a qaction to hbaction.
   328  * Convert a qaction to hbaction.