videocollection/videocollectionview/inc/videolistselectiondialog.h
changeset 67 72c709219fcd
parent 58 d2b028fd1f7d
--- a/videocollection/videocollectionview/inc/videolistselectiondialog.h	Tue Oct 05 09:26:49 2010 +0300
+++ b/videocollection/videocollectionview/inc/videolistselectiondialog.h	Fri Oct 15 16:29:10 2010 +0300
@@ -18,24 +18,18 @@
 #ifndef VIDEOLISTSELECTIONDIALOG_H
 #define VIDEOLISTSELECTIONDIALOG_H
 
-#include <hbdialog.h>
+#include <hbselectiondialog.h>
 #include <qset.h>
-#include <qitemselectionmodel.h>
 #include <mpxitemid.h>
+#include <qpointer.h>
 
-class QGraphicItem;
-class QItemSelection;
-class HbWidget;
-class HbLabel;
-class HbCheckBox;
-class HbStackedWidget;
+class QGraphicsItem;
+class QTimer;
+class VideoProxyModelGeneric;
 class VideoCollectionUiLoader;
-class VideoCollectionWrapper;
-class VideoProxyModelGeneric;
-class VideoListWidget;
 
-class VideoListSelectionDialog: public HbDialog
-{     
+class VideoListSelectionDialog: public HbSelectionDialog
+{
     /**
      * definition required for emitting / connecting signals 
      */
@@ -51,6 +45,7 @@
     
     enum TSelectionFunction
     {
+        ENoFunction = -1,
         EDeleteVideos,
         EAddToCollection,        
         ERemoveFromCollection,
@@ -61,11 +56,10 @@
     /**
      * Constructor
      *
-     * @param uiLoader used to load UI components from docml
      * @param parent item's parent component
      */
-    VideoListSelectionDialog(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent=0);
-    
+    VideoListSelectionDialog(QGraphicsItem *parent=0);
+
     /**
      * Destructor
      */
@@ -80,8 +74,8 @@
      * @param type selection dialog function typy
      * @param activeItem id of item that the selection concerns
      */
-    void setupContent(int type, TMPXItemId activeItem = TMPXItemId::InvalidId());
-    
+    void setupContent(VideoListSelectionDialog::TSelectionFunction type, TMPXItemId activeItem = TMPXItemId::InvalidId());
+
 public slots:
 
     /**
@@ -98,35 +92,10 @@
 private slots:
     
     /**
-     * Slot connected to mCheckBox's stateChanged -signal. 
-     * Selects or deselects all items if mForcedCheck -flag is false.
-     * 
-     * If Forcedcehck is true, it indeicates that we want to change the checked state
-     * only, not slect or deselect anything. This is needed for example if after 
-     * all items are marked, user manually deselects item's. In that case all is not
-     * marked, so checked state needs to be changed. 
-     *
-     * @param state Qt::Checked everything should be set as selected.
+     * disables or enables popup's primary action in case selection changes
      */
-    void markAllStateChangedSlot(int state);
-    
-    /**
-     * disables or enables popup's primary action in case selection changes
-     *
-     * @param selected item selection list containing selected
-     * @param deselected item selection list containing  not selected (not used in this scope)
-     */
-    void selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected); 
-    
-    /**
-     * connected to list's activated -signal. Called when singel item is selected.
-     * If dialog's selection type is ESelectCollection, saves mpx id from provided index.
-     * and closes dialog by triggering primary action
-     *
-     * @param index of item selected
-     */
-    void singleItemSelectedSlot(const QModelIndex &index); 
-    
+    void selectionChangedSlot();
+
     /**
      * Handles model ready signal from model.
      */
@@ -138,12 +107,6 @@
     void albumListReadySlot();
     
     /**
-     * Changes the counter value. Sets the checkbutton state based on selection count.
-     *
-     */
-    void updateCounterSlot();
-    
-    /**
      * Primary action triggered signal slot.
      * 
      */
@@ -155,7 +118,42 @@
      * @param action causing the finished
      */
     void finishedSlot(HbAction *action);
-      
+
+    /**
+     * Signaled when view scrolling starts, pauses thumbnail creation.
+     *
+     */
+    void scrollingStartedSlot();
+
+    /**
+     * Signaled when view scrolling ends, initiates thumbnail fetching
+     * at index of first visible item and enables creation of thumbnails.
+     *
+     */
+    void scrollingEndedSlot();
+
+    /**
+     * Signaled when view scroll position changes, initiates timer to
+     * fetch thumbnails at index of first visible item.
+     *
+     * @param newPosition scroll position
+     *
+     */
+    void scrollPositionChangedSlot(const QPointF &newPosition);
+
+    /**
+     * Signaled when scroll position timer triggers. Starts fetching thumbnails
+     * for visible items.
+     *
+     */
+    void scrollPositionTimerSlot();
+
+    /**
+     * Fetches thumbnails for the visible items.
+     *
+     */
+    void fetchThumbnailsForVisibleItems();
+
 private:
     
     /**
@@ -165,12 +163,24 @@
      * @return bool true if inisializaion ok
      */
     bool initDialog();
-    
+
+    /**
+     * Method initializes list by setting the model
+     *
+     * @param model to be set
+     *
+     * @return bool true if inisializaion ok
+     */
+    bool initList(VideoProxyModelGeneric *model);
+
     /**
      * Method activated dialog based on value in mTypeOfSelection
+     *
+     * @param changeMode true if dialog mode is changed from multiselection to noselection while visible
+     *
      */
-    void activateSelection();
-    
+    void activateSelection(bool changeMode = false);
+
     /**
      * connects all required signals into appropriate slots 
      * for selection mode
@@ -197,20 +207,10 @@
 private:
    
     /**
-     * docml UI loader, not owned
-     */
-    VideoCollectionUiLoader *mUiLoader;
-    
-    /**
      * type for defining selection functionality
      */
-    int mTypeOfSelection;
-    
-    /**
-     * Selection 
-     */
-    QItemSelection mSelection;
-    
+    VideoListSelectionDialog::TSelectionFunction mTypeOfSelection;
+
     /**
      * Selected video items
      */
@@ -227,42 +227,6 @@
     QString mNewAlbumText;
     
     /**
-     * header label
-     */
-    HbLabel *mHeading;
-    
-    /**
-     * container widget for itemcount and checkbox;
-     */
-    HbWidget *mCheckboxContainer;
-    
-    /**
-     * counter label from docml
-     */
-    HbLabel *mItemCount;
-    
-    /**
-     * checkbox label from docml
-     */
-    HbLabel *mCheckBoxText;
-    
-    /**
-     * mark all checkbox
-     */
-    HbCheckBox *mCheckBox;
-    
-    /**
-     * videolist container in dialog
-     */
-    HbStackedWidget *mListContainer;
-    
-    /**
-     * flag indicating that we've changed check-btn state 
-     * explicitly and don't wanna handle selection based on that 
-     */
-    bool mForcedCheck;  
-    
-    /**
      * Video list model
      */
     VideoProxyModelGeneric *mModel;
@@ -276,21 +240,27 @@
      * Boolean to know if album list is ready or not.
      */
     bool mAlbumListReady;
-    
-    /** 
-     * List widget to show in selection
+
+    /**
+     * Boolean to know if listview has been initialised or not.
      */
-    VideoListWidget *mListWidget;
-    
+    bool mListInitialised;
+
     /**
      * Action to accept the selection dialog. 
      */
-    HbAction *mPrimaryAction;
-    
+    QPointer<HbAction> mPrimaryAction;
+
     /**
      * Action to cancel the selection dialog.
      */
-    HbAction *mSecondaryAction;
+    QPointer<HbAction> mSecondaryAction;
+
+    /**
+     * Timer used to report thumbnail fetches class index of
+     * first visible item when view is scrolling.
+     */
+    QPointer<QTimer> mScrollPositionTimer;
 };
 
 #endif  //VIDEOLISTSELECTIONDIALOG_H