videocollection/videocollectionview/inc/videolistselectiondialog.h
changeset 67 72c709219fcd
parent 58 d2b028fd1f7d
equal deleted inserted replaced
66:adb51f74b890 67:72c709219fcd
    16 */
    16 */
    17 
    17 
    18 #ifndef VIDEOLISTSELECTIONDIALOG_H
    18 #ifndef VIDEOLISTSELECTIONDIALOG_H
    19 #define VIDEOLISTSELECTIONDIALOG_H
    19 #define VIDEOLISTSELECTIONDIALOG_H
    20 
    20 
    21 #include <hbdialog.h>
    21 #include <hbselectiondialog.h>
    22 #include <qset.h>
    22 #include <qset.h>
    23 #include <qitemselectionmodel.h>
       
    24 #include <mpxitemid.h>
    23 #include <mpxitemid.h>
    25 
    24 #include <qpointer.h>
    26 class QGraphicItem;
    25 
    27 class QItemSelection;
    26 class QGraphicsItem;
    28 class HbWidget;
    27 class QTimer;
    29 class HbLabel;
    28 class VideoProxyModelGeneric;
    30 class HbCheckBox;
       
    31 class HbStackedWidget;
       
    32 class VideoCollectionUiLoader;
    29 class VideoCollectionUiLoader;
    33 class VideoCollectionWrapper;
    30 
    34 class VideoProxyModelGeneric;
    31 class VideoListSelectionDialog: public HbSelectionDialog
    35 class VideoListWidget;
    32 {
    36 
       
    37 class VideoListSelectionDialog: public HbDialog
       
    38 {     
       
    39     /**
    33     /**
    40      * definition required for emitting / connecting signals 
    34      * definition required for emitting / connecting signals 
    41      */
    35      */
    42     Q_OBJECT
    36     Q_OBJECT
    43     
    37     
    49     
    43     
    50 public: 
    44 public: 
    51     
    45     
    52     enum TSelectionFunction
    46     enum TSelectionFunction
    53     {
    47     {
       
    48         ENoFunction = -1,
    54         EDeleteVideos,
    49         EDeleteVideos,
    55         EAddToCollection,        
    50         EAddToCollection,        
    56         ERemoveFromCollection,
    51         ERemoveFromCollection,
    57         ECreateCollection,
    52         ECreateCollection,
    58         ESelectCollection
    53         ESelectCollection
    59     };
    54     };
    60     
    55     
    61     /**
    56     /**
    62      * Constructor
    57      * Constructor
    63      *
    58      *
    64      * @param uiLoader used to load UI components from docml
       
    65      * @param parent item's parent component
    59      * @param parent item's parent component
    66      */
    60      */
    67     VideoListSelectionDialog(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent=0);
    61     VideoListSelectionDialog(QGraphicsItem *parent=0);
    68     
    62 
    69     /**
    63     /**
    70      * Destructor
    64      * Destructor
    71      */
    65      */
    72     ~VideoListSelectionDialog();
    66     ~VideoListSelectionDialog();
    73    
    67    
    78      * is in invalid state and cannot be shown using exec.
    72      * is in invalid state and cannot be shown using exec.
    79      *
    73      *
    80      * @param type selection dialog function typy
    74      * @param type selection dialog function typy
    81      * @param activeItem id of item that the selection concerns
    75      * @param activeItem id of item that the selection concerns
    82      */
    76      */
    83     void setupContent(int type, TMPXItemId activeItem = TMPXItemId::InvalidId());
    77     void setupContent(VideoListSelectionDialog::TSelectionFunction type, TMPXItemId activeItem = TMPXItemId::InvalidId());
    84     
    78 
    85 public slots:
    79 public slots:
    86 
    80 
    87     /**
    81     /**
    88      * Shows modal dialog build from the provided Videolistwidget.
    82      * Shows modal dialog build from the provided Videolistwidget.
    89      *
    83      *
    96     void newAlbumNameDialogFinished(HbAction *action);    
    90     void newAlbumNameDialogFinished(HbAction *action);    
    97     
    91     
    98 private slots:
    92 private slots:
    99     
    93     
   100     /**
    94     /**
   101      * Slot connected to mCheckBox's stateChanged -signal. 
       
   102      * Selects or deselects all items if mForcedCheck -flag is false.
       
   103      * 
       
   104      * If Forcedcehck is true, it indeicates that we want to change the checked state
       
   105      * only, not slect or deselect anything. This is needed for example if after 
       
   106      * all items are marked, user manually deselects item's. In that case all is not
       
   107      * marked, so checked state needs to be changed. 
       
   108      *
       
   109      * @param state Qt::Checked everything should be set as selected.
       
   110      */
       
   111     void markAllStateChangedSlot(int state);
       
   112     
       
   113     /**
       
   114      * disables or enables popup's primary action in case selection changes
    95      * disables or enables popup's primary action in case selection changes
   115      *
    96      */
   116      * @param selected item selection list containing selected
    97     void selectionChangedSlot();
   117      * @param deselected item selection list containing  not selected (not used in this scope)
    98 
   118      */
       
   119     void selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected); 
       
   120     
       
   121     /**
       
   122      * connected to list's activated -signal. Called when singel item is selected.
       
   123      * If dialog's selection type is ESelectCollection, saves mpx id from provided index.
       
   124      * and closes dialog by triggering primary action
       
   125      *
       
   126      * @param index of item selected
       
   127      */
       
   128     void singleItemSelectedSlot(const QModelIndex &index); 
       
   129     
       
   130     /**
    99     /**
   131      * Handles model ready signal from model.
   100      * Handles model ready signal from model.
   132      */
   101      */
   133     void modelReadySlot();
   102     void modelReadySlot();
   134     
   103     
   136      * Handles album list ready signal from model.
   105      * Handles album list ready signal from model.
   137      */
   106      */
   138     void albumListReadySlot();
   107     void albumListReadySlot();
   139     
   108     
   140     /**
   109     /**
   141      * Changes the counter value. Sets the checkbutton state based on selection count.
       
   142      *
       
   143      */
       
   144     void updateCounterSlot();
       
   145     
       
   146     /**
       
   147      * Primary action triggered signal slot.
   110      * Primary action triggered signal slot.
   148      * 
   111      * 
   149      */
   112      */
   150     void primaryActionTriggeredSlot();
   113     void primaryActionTriggeredSlot();
   151     
   114     
   153      * called when dialog has been finished
   116      * called when dialog has been finished
   154      * 
   117      * 
   155      * @param action causing the finished
   118      * @param action causing the finished
   156      */
   119      */
   157     void finishedSlot(HbAction *action);
   120     void finishedSlot(HbAction *action);
   158       
   121 
       
   122     /**
       
   123      * Signaled when view scrolling starts, pauses thumbnail creation.
       
   124      *
       
   125      */
       
   126     void scrollingStartedSlot();
       
   127 
       
   128     /**
       
   129      * Signaled when view scrolling ends, initiates thumbnail fetching
       
   130      * at index of first visible item and enables creation of thumbnails.
       
   131      *
       
   132      */
       
   133     void scrollingEndedSlot();
       
   134 
       
   135     /**
       
   136      * Signaled when view scroll position changes, initiates timer to
       
   137      * fetch thumbnails at index of first visible item.
       
   138      *
       
   139      * @param newPosition scroll position
       
   140      *
       
   141      */
       
   142     void scrollPositionChangedSlot(const QPointF &newPosition);
       
   143 
       
   144     /**
       
   145      * Signaled when scroll position timer triggers. Starts fetching thumbnails
       
   146      * for visible items.
       
   147      *
       
   148      */
       
   149     void scrollPositionTimerSlot();
       
   150 
       
   151     /**
       
   152      * Fetches thumbnails for the visible items.
       
   153      *
       
   154      */
       
   155     void fetchThumbnailsForVisibleItems();
       
   156 
   159 private:
   157 private:
   160     
   158     
   161     /**
   159     /**
   162      * Method initializes dialog by getting all ui components and 
   160      * Method initializes dialog by getting all ui components and 
   163      * checking if they are valid
   161      * checking if they are valid
   164      * 
   162      * 
   165      * @return bool true if inisializaion ok
   163      * @return bool true if inisializaion ok
   166      */
   164      */
   167     bool initDialog();
   165     bool initDialog();
   168     
   166 
       
   167     /**
       
   168      * Method initializes list by setting the model
       
   169      *
       
   170      * @param model to be set
       
   171      *
       
   172      * @return bool true if inisializaion ok
       
   173      */
       
   174     bool initList(VideoProxyModelGeneric *model);
       
   175 
   169     /**
   176     /**
   170      * Method activated dialog based on value in mTypeOfSelection
   177      * Method activated dialog based on value in mTypeOfSelection
   171      */
   178      *
   172     void activateSelection();
   179      * @param changeMode true if dialog mode is changed from multiselection to noselection while visible
   173     
   180      *
       
   181      */
       
   182     void activateSelection(bool changeMode = false);
       
   183 
   174     /**
   184     /**
   175      * connects all required signals into appropriate slots 
   185      * connects all required signals into appropriate slots 
   176      * for selection mode
   186      * for selection mode
   177      */
   187      */
   178     void connectSignals();
   188     void connectSignals();
   195     void finalize(QString albumName = "");
   205     void finalize(QString albumName = "");
   196     
   206     
   197 private:
   207 private:
   198    
   208    
   199     /**
   209     /**
   200      * docml UI loader, not owned
       
   201      */
       
   202     VideoCollectionUiLoader *mUiLoader;
       
   203     
       
   204     /**
       
   205      * type for defining selection functionality
   210      * type for defining selection functionality
   206      */
   211      */
   207     int mTypeOfSelection;
   212     VideoListSelectionDialog::TSelectionFunction mTypeOfSelection;
   208     
   213 
   209     /**
       
   210      * Selection 
       
   211      */
       
   212     QItemSelection mSelection;
       
   213     
       
   214     /**
   214     /**
   215      * Selected video items
   215      * Selected video items
   216      */
   216      */
   217     QSet<TMPXItemId> mSelectedVideos;
   217     QSet<TMPXItemId> mSelectedVideos;
   218     
   218     
   225      * Text for a new album.
   225      * Text for a new album.
   226      */
   226      */
   227     QString mNewAlbumText;
   227     QString mNewAlbumText;
   228     
   228     
   229     /**
   229     /**
   230      * header label
       
   231      */
       
   232     HbLabel *mHeading;
       
   233     
       
   234     /**
       
   235      * container widget for itemcount and checkbox;
       
   236      */
       
   237     HbWidget *mCheckboxContainer;
       
   238     
       
   239     /**
       
   240      * counter label from docml
       
   241      */
       
   242     HbLabel *mItemCount;
       
   243     
       
   244     /**
       
   245      * checkbox label from docml
       
   246      */
       
   247     HbLabel *mCheckBoxText;
       
   248     
       
   249     /**
       
   250      * mark all checkbox
       
   251      */
       
   252     HbCheckBox *mCheckBox;
       
   253     
       
   254     /**
       
   255      * videolist container in dialog
       
   256      */
       
   257     HbStackedWidget *mListContainer;
       
   258     
       
   259     /**
       
   260      * flag indicating that we've changed check-btn state 
       
   261      * explicitly and don't wanna handle selection based on that 
       
   262      */
       
   263     bool mForcedCheck;  
       
   264     
       
   265     /**
       
   266      * Video list model
   230      * Video list model
   267      */
   231      */
   268     VideoProxyModelGeneric *mModel;
   232     VideoProxyModelGeneric *mModel;
   269     
   233     
   270     /**
   234     /**
   274     
   238     
   275     /**
   239     /**
   276      * Boolean to know if album list is ready or not.
   240      * Boolean to know if album list is ready or not.
   277      */
   241      */
   278     bool mAlbumListReady;
   242     bool mAlbumListReady;
   279     
   243 
   280     /** 
   244     /**
   281      * List widget to show in selection
   245      * Boolean to know if listview has been initialised or not.
   282      */
   246      */
   283     VideoListWidget *mListWidget;
   247     bool mListInitialised;
   284     
   248 
   285     /**
   249     /**
   286      * Action to accept the selection dialog. 
   250      * Action to accept the selection dialog. 
   287      */
   251      */
   288     HbAction *mPrimaryAction;
   252     QPointer<HbAction> mPrimaryAction;
   289     
   253 
   290     /**
   254     /**
   291      * Action to cancel the selection dialog.
   255      * Action to cancel the selection dialog.
   292      */
   256      */
   293     HbAction *mSecondaryAction;
   257     QPointer<HbAction> mSecondaryAction;
       
   258 
       
   259     /**
       
   260      * Timer used to report thumbnail fetches class index of
       
   261      * first visible item when view is scrolling.
       
   262      */
       
   263     QPointer<QTimer> mScrollPositionTimer;
   294 };
   264 };
   295 
   265 
   296 #endif  //VIDEOLISTSELECTIONDIALOG_H
   266 #endif  //VIDEOLISTSELECTIONDIALOG_H