--- a/locationpickerservice/src/locationpickercollectioncontent.cpp Fri Apr 16 14:54:12 2010 +0300
+++ b/locationpickerservice/src/locationpickercollectioncontent.cpp Mon May 03 12:27:22 2010 +0300
@@ -15,81 +15,45 @@
*
*/
-#include <HbListView>
#include <QStandardItemModel>
-#include <HbMenu>
-#include <HbListViewItem>
-#include <HbAction>
#include "locationpickerproxymodel.h"
#include "locationpickercollectioncontent.h"
#include "locationpickerdatamanager.h"
#include "locationpickertypes.h"
-#include "locationpickerappwindow.h"
// ======== MEMBER FUNCTIONS ========
// ----------------------------------------------------------------
// LocationPickerCollectionContent::LocationPickerCollectionContent()
// -----------------------------------------------------------------
-LocationPickerCollectionContent::LocationPickerCollectionContent(
- LocationPickerAppWindow *aWindow, quint32 aCollectionId, QGraphicsItem* aParent):
- HbView( aParent )
-
+LocationPickerCollectionContent::LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionId )
+ :mOrientation(aOrientation),
+ mProxyModel(NULL),
+ mModel(NULL),
+ mDataManager(NULL)
{
- // inditialize window
- mWindow = aWindow;
// Create a standard model for the view list
mModel = new QStandardItemModel( this );
- mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerCollectionContentView );
- mListView = new HbListView( this );
-
-
- if( mDataManager->populateModel( aCollectionId ) )
+ mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerCollectionContent );
+ if( mDataManager->populateModel( mOrientation , aCollectionId ) )
{
- // connect the activated signal of list view item
- connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &)));
- //Creation of List View
- //Set graphics size for the list items.
- HbListViewItem *hbListItem = new HbListViewItem();
- hbListItem->setGraphicsSize(HbListViewItem::Thumbnail);
-
// Create the proxy model.
- mProxyModel = new LocationPickerProxyModel();
+ mProxyModel = new LocationPickerProxyModel(mOrientation);
mProxyModel->setSourceModel(mModel);
-
- // set the model
- mListView->setModel( mProxyModel, hbListItem );
mProxyModel->setDynamicSortFilter(TRUE);
mProxyModel->setSortRole(Qt::DisplayRole);
mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
-
// sort
mProxyModel->sort(0, Qt::AscendingOrder);
-
- // construct menu for the view
- constructMenu();
}
-
else
{
// no locations to display.
QStandardItem *modelItem = new QStandardItem();
- modelItem->setData(QVariant(KNoLocations), Qt::DisplayRole);
+ modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole);
mModel->appendRow( modelItem );
- mListView->setModel(mModel);
- }
-
- setWidget(mListView);
-
-
- // create back action
- mSecondaryBackAction = new HbAction( Hb::BackAction, this );
- // add back key action
- setNavigationAction( mSecondaryBackAction );
- connect(mSecondaryBackAction, SIGNAL(triggered()), mWindow,
- SLOT(backButtonTriggered()));
-
+ }
}
// ----------------------------------------------------------------
@@ -97,50 +61,24 @@
// -----------------------------------------------------------------
LocationPickerCollectionContent::~LocationPickerCollectionContent()
{
- if( mDataManager )
- delete mDataManager;
+ delete mProxyModel;
+ delete mModel;
+ delete mDataManager;
}
// ----------------------------------------------------------------
-// LocationPickerCollectionContent::constructMenu()
+// LocationPickerCollectionContent::getProxyModel
// -----------------------------------------------------------------
-void LocationPickerCollectionContent::constructMenu()
-{
- HbMenu *menu = this->menu();
- HbMenu *subMenu = menu->addMenu(KSortBy);
- HbAction *act;
-
- act = new HbAction(QString(KAscend), this);
- subMenu->addAction(act);
- connect(act,SIGNAL(triggered()),this,SLOT(sortAscending()));
-
- act = subMenu->addAction( KDescend );
- connect(act, SIGNAL(triggered()), SLOT(sortDescending()));
-}
+LocationPickerProxyModel* LocationPickerCollectionContent::getProxyModel()
+ {
+ return mProxyModel;
+ }
// ----------------------------------------------------------------
-// LocationPickerCollectionContent::sortAscending()
-// -----------------------------------------------------------------
-void LocationPickerCollectionContent::sortAscending()
-{
- mProxyModel->sort(0, Qt::AscendingOrder);
-}
-// ----------------------------------------------------------------
-// LocationPickerCollectionContent::sortDescending()
+// LocationPickerCollectionContent::getDataManager
// -----------------------------------------------------------------
-void LocationPickerCollectionContent::sortDescending()
-{
- mProxyModel->sort(0, Qt::DescendingOrder);
-}
-
-// ----------------------------------------------------------------
-// LocationPickerCollectionContent::handleActivated()
-// -----------------------------------------------------------------
-void LocationPickerCollectionContent::handleActivated(const QModelIndex &aIndex)
-{
- QModelIndex index = mProxyModel->mapToSource(aIndex);
- quint32 lm = 0;
- mDataManager->getData( index.row(), lm );
- mWindow->itemSelected( lm );
-}
+LocationPickerDataManager* LocationPickerCollectionContent::getDataManager()
+ {
+ return mDataManager;
+ }