videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/videolistselectiondialogtester.h
changeset 15 cf5481c2bc0b
child 40 13331705e488
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /**
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   VideoListSelectionDialogTester class
       
    15 * 
       
    16 */
       
    17 
       
    18 #ifndef __VIDEOLISTSELECTIONDIALOGTESTER_H__
       
    19 #define __VIDEOLISTSELECTIONDIALOGTESTER_H__
       
    20 
       
    21 #include "videolistselectiondialog.h"
       
    22 
       
    23 class VideoListSelectionDialogTesterHelper : public QObject
       
    24 {
       
    25     Q_OBJECT
       
    26     
       
    27 signals:
       
    28     
       
    29     void markAllSignal(int);
       
    30     
       
    31     void selectionChangedSignal(const QItemSelection&, const QItemSelection&);
       
    32     
       
    33     void singleItemSelectedSignal(const QModelIndex&);
       
    34     
       
    35     void modelReadySignal();
       
    36     
       
    37     void updateCounterSignal();
       
    38     
       
    39     void primaryActionTriggeredSignal();
       
    40     
       
    41     void finishedSignal(HbAction*);
       
    42     
       
    43 public:
       
    44     
       
    45     VideoListSelectionDialogTesterHelper(VideoListSelectionDialog *testable = 0) 
       
    46     : mTestable(testable) {};
       
    47     
       
    48     ~VideoListSelectionDialogTesterHelper() {};
       
    49     
       
    50     bool connectSignals()
       
    51     {
       
    52         if(!mTestable)
       
    53         {
       
    54             return false;
       
    55         }
       
    56         // disconnect first to make sure there signals are not connected twice
       
    57         disconnectSignals();
       
    58         if(!connect(this, SIGNAL(markAllSignal(int)), mTestable, SLOT(markAllStateChangedSlot(int))))
       
    59         {
       
    60             return false;
       
    61         }
       
    62         if(!connect(this, SIGNAL(selectionChangedSignal(const QItemSelection&, const QItemSelection&)), 
       
    63                 mTestable, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&))))
       
    64         {
       
    65             return false;
       
    66         }
       
    67         if(!connect(this, SIGNAL(singleItemSelectedSignal(const QModelIndex&)), 
       
    68                 mTestable, SLOT(singleItemSelectedSlot(const QModelIndex&))))
       
    69         {
       
    70             return false;
       
    71         }
       
    72         if(!connect(this, SIGNAL(modelReadySignal()), mTestable, SLOT(modelReadySlot())))
       
    73         {
       
    74             return false;
       
    75         }
       
    76         if(!connect(this, SIGNAL(updateCounterSignal()), mTestable, SLOT(updateCounterSlot())))
       
    77         {
       
    78             return false;
       
    79         }
       
    80         if(!connect(this, SIGNAL(primaryActionTriggeredSignal()), 
       
    81                 mTestable, SLOT(primaryActionTriggeredSlot())))
       
    82         {
       
    83             return false;
       
    84         }
       
    85         if(!connect(this, SIGNAL(finishedSignal(HbAction*)), mTestable, SLOT(finishedSlot(HbAction*))))
       
    86         {
       
    87             return false;
       
    88         }
       
    89         return true;
       
    90     }
       
    91     
       
    92     void disconnectSignals()
       
    93     {
       
    94         disconnect(this, SIGNAL(markAllSignal(int)), mTestable, SLOT(markAllStateChangedSlot(int)));
       
    95         disconnect(this, SIGNAL(selectionChangedSignal(const QItemSelection&, const QItemSelection&)), 
       
    96                         mTestable, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&)));
       
    97         disconnect(this, SIGNAL(singleItemSelectedSignal(const QModelIndex&)), 
       
    98                         mTestable, SLOT(singleItemSelectedSlot(const QModelIndex&)));
       
    99         disconnect(this, SIGNAL(modelReadySignal()), mTestable, SLOT(modelReadySlot()));
       
   100         disconnect(this, SIGNAL(updateCounterSignal()), mTestable, SLOT(updateCounterSlot()));
       
   101         disconnect(this, SIGNAL(primaryActionTriggeredSignal()), 
       
   102                         mTestable, SLOT(primaryActionTriggeredSlot()));
       
   103         disconnect(this, SIGNAL(finishedSignal(HbAction*)), mTestable, SLOT(finishedSlot(HbAction*)));
       
   104     }
       
   105     
       
   106     void emitMarkAllStateChanged(int state)
       
   107     {
       
   108         emit markAllSignal(state);
       
   109     }
       
   110 
       
   111     void emitSelectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
       
   112     {
       
   113         emit selectionChangedSignal(selected, deselected);
       
   114     }
       
   115     
       
   116     void emitSingleItemSelectedSlot(const QModelIndex &index)
       
   117     {
       
   118         emit singleItemSelectedSignal(index);
       
   119     }
       
   120     
       
   121     void emitModelReadySlot()
       
   122     {
       
   123         emit modelReadySignal();
       
   124     }
       
   125     
       
   126     void emitUpdateCounterSlot()
       
   127     {
       
   128         emit updateCounterSignal();
       
   129     }
       
   130     
       
   131     void emitPrimaryActionTriggeredSlot()
       
   132     {
       
   133         emit primaryActionTriggeredSignal();
       
   134     }
       
   135     
       
   136     void emitFinishedSlot(HbAction *action)
       
   137     {
       
   138         emit finishedSignal(action);
       
   139     }
       
   140     
       
   141     VideoListSelectionDialog *mTestable;
       
   142 };
       
   143 
       
   144 #endif