hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mywindow.cpp
branchGCC_SURGE
changeset 10 c348b9772569
parent 8 15f034b8a3b5
child 17 a10844a9914d
equal deleted inserted replaced
4:463f1934e292 10:c348b9772569
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 *  Version     : %version: 1 %
    16 *  Version     : %version: 8 %
    17 */
    17 */
    18 #include "mywindow.h"
    18 #include "mywindow.h"
    19 #include <hbmenu.h>
    19 #include <HbMenu>
    20 #include <hbaction.h>
    20 #include <HbAction>
    21 #include <hbmainwindow.h>
    21 #include <HbMainWindow>
    22 #include <hbslider.h>
    22 #include <HbSlider>
    23 #include <QTimer>
    23 #include <QTimer>
    24 #include <QtGui>
    24 #include <QtGui>
    25 #include <QDebug>
    25 #include <QDebug>
    26 #include <QPushButton>
    26 #include <QPushButton>
    27 #include <QApplication>
    27 #include <QApplication>
    28 #include <QGraphicsLinearLayout>
    28 #include <QGraphicsLinearLayout>
    29 #include <QCoreApplication>
    29 #include <QCoreApplication>
    30 #include <hbgridview.h>
    30 #include <HbGridView>
    31 #include <hbinstance.h>
    31 #include <HbInstance>
       
    32 #include <HbInputDialog>
    32 #include <QFileSystemWatcher>
    33 #include <QFileSystemWatcher>
    33 #include <hgwidgets/hgcacheproxymodel.h>
    34 #include <hgwidgets/hgcacheproxymodel.h>
       
    35 #include <hgwidgets/hgmediawall.h>
       
    36 #include <hgwidgets/hggrid.h>
    34 
    37 
    35 #include "mydataprovider.h"
    38 #include "mydataprovider.h"
    36 #include "hglogger.h"
    39 #include "hglogger.h"
    37 
    40 
    38 
    41 const int KGridViewCommand = 1;
    39 const QStringList KViewNames = (QStringList() << "GridView" << "ListView" );
    42 const int KListViewCommand = 2;
       
    43 const int KMediaWallViewCommand = 3;
       
    44 const int KHgGridViewCommand = 4;
       
    45 
       
    46 const int KSort1Command = 1101;
       
    47 const int KSort2Command = 1102;
       
    48 const int KSort3Command = 1103;
       
    49 const int KSortCaseSensitiveCommand = 1104;
       
    50 const int KSortCaseInsensitiveCommand = 1105;
       
    51 const int KDisableFilterCommand = 1200;
       
    52 const int KFilter1Command = 1201;
       
    53 const int KFilter2Command = 1202;
       
    54 const int KTogleDynamicCommand = 1000;
       
    55 const int KTogleSortTestCommand = 1001;
       
    56 const int KTogleFilterTestCommand = 1002;
       
    57 
       
    58 const int KInsert0Command = 2100;
       
    59 const int KInsert50Command = 2101;
       
    60 const int KInsert101Command = 2102;
       
    61 const int KInsert257Command = 2103;
       
    62 const int KInsert1000Command = 2104;
       
    63 const int KInsertEndCommand = 2105;
       
    64 const int KInsertEnd10Command = 2106;
       
    65 const int KInsertCustomCommand = 2107;
       
    66 const int KRemove0Command = 2200;
       
    67 const int KRemove50Command = 2201;
       
    68 const int KRemove101Command = 2202;
       
    69 const int KRemove257Command = 2203;
       
    70 const int KRemove1000Command = 2204;
       
    71 const int KRemoveLastCommand = 2205;
       
    72 const int KRemoveEnd10Command = 2206;
       
    73 const int KRemoveCustomCommand = 2207;
       
    74 const int KShowImagesCommand = 2300;
       
    75 const int KShowAudioCommand = 2301;
       
    76 const int KHbIconModeCommand = 2400;
       
    77 const int KQIconModeCommand = 2401;
       
    78 const int KQImageModeCommand = 2402;
       
    79 const int KQPixmapModeCommand = 2403;
       
    80 
       
    81 const int KResetCommand = 10000;
    40 
    82 
    41 MyWindow::MyWindow()
    83 MyWindow::MyWindow()
    42     : HbMainWindow(), 
    84     : HbMainWindow(), 
    43     mView(0),
    85     mView(0),
    44     mModel(0),
    86     mModel(0),
    45     mMyDataProvider(0),
    87     mMyDataProvider(0),
    46     mTimer(new QTimer(this))
    88     mSortTestTimer(new QTimer(this)),
       
    89     mSortTestVal(-1),
       
    90     mFilterTestTimer(new QTimer(this)),
       
    91     mFilterTestVal(-1)
    47 {
    92 {
    48     mMainView = new HbView();
    93     mMainView = new HbView();
    49     addView( mMainView );
    94     addView( mMainView );
    50 
    95 
    51     mMainView->setMenu( createMainMenu() ); 
    96     mMainView->setMenu( createMainMenu() ); 
    52     
    97     
    53     mMyDataProvider = new MyDataProvider(this);
    98     mMyDataProvider = new MyDataProvider(this);
    54     mModel = new HgCacheProxyModel(this);
    99     mModel = new HgCacheProxyModel(this);
    55     mModel->setDataProvider(mMyDataProvider, 120, 20);
   100     mModel->setDataProvider(mMyDataProvider, 120, 20);
    56 
   101 
    57     connect(mTimer, SIGNAL(timeout()), this, SLOT(timeout()));
   102     connect(mSortTestTimer, SIGNAL(timeout()), this, SLOT(sortTestTimeout()));
       
   103     connect(mSortTestTimer, SIGNAL(timeout()), this, SLOT(filterTestTimeout()));
    58     
   104     
    59     HbAction action;
   105     HbAction action;
    60 	action.setData ( QVariant(1) );	//select Grid
   106 	action.setData ( QVariant(KGridViewCommand) );	//select Grid
    61 	processAction(&action);
   107 	processAction(&action);
    62 }
   108 }
    63 
   109 
    64 MyWindow::~MyWindow()
   110 MyWindow::~MyWindow()
    65 {
   111 {
    69 HbMenu *MyWindow::createMainMenu()
   115 HbMenu *MyWindow::createMainMenu()
    70 {
   116 {
    71     HbMenu* mainMenu = new HbMenu( );
   117     HbMenu* mainMenu = new HbMenu( );
    72     connect(mainMenu, SIGNAL(triggered(HbAction*)),this, SLOT(processAction(HbAction*)));
   118     connect(mainMenu, SIGNAL(triggered(HbAction*)),this, SLOT(processAction(HbAction*)));
    73 
   119 
    74     HbMenu *viewSubMenu = mainMenu->addMenu("Change view");
   120     addChangeViewMenu(mainMenu);
    75     QString temporaryString;
   121     addCacheProxyModelMenu(mainMenu);
    76     int i(0);
   122     addDataProviderMenu(mainMenu);
    77     foreach (temporaryString , KViewNames) {
   123     
    78         HbAction* subAction = viewSubMenu->addAction(temporaryString);
   124     HbAction* action = mainMenu->addAction("Reset");
    79         subAction->setData (QVariant(++i));
   125     action->setData(QVariant(KResetCommand));
    80     }
   126 
    81     
   127     return mainMenu;
    82     HbMenu *sortSubMenu = mainMenu->addMenu("Sort");
   128 }
       
   129 
       
   130 void MyWindow::addChangeViewMenu(HbMenu* parent)
       
   131 {
       
   132     HbMenu *viewSubMenu = parent->addMenu("Change view");
       
   133     HbAction* action = viewSubMenu->addAction("Orbit Grid View");
       
   134     action->setData(QVariant(KGridViewCommand));
       
   135     action = viewSubMenu->addAction("Orbit List View");
       
   136     action->setData(QVariant(KListViewCommand));
       
   137     action = viewSubMenu->addAction("Hg MediaWall");
       
   138     action->setData(QVariant(KMediaWallViewCommand));
       
   139     action = viewSubMenu->addAction("Hg Grid");
       
   140     action->setData(QVariant(KHgGridViewCommand));
       
   141     
       
   142     
       
   143 }
       
   144 
       
   145 void MyWindow::addCacheProxyModelMenu(HbMenu* parent)
       
   146 {
       
   147     
       
   148     HbMenu *cpSubMenu = parent->addMenu("CacheProxyModel");
       
   149     
       
   150     HbMenu *sortSubMenu = cpSubMenu->addMenu("Sort");
    83     HbAction* action = sortSubMenu->addAction("Sort1");
   151     HbAction* action = sortSubMenu->addAction("Sort1");
    84     action->setData(QVariant(101));
   152     action->setData(QVariant(KSort1Command));
    85     action = sortSubMenu->addAction("Sort2");
   153     action = sortSubMenu->addAction("Sort2");
    86     action->setData(QVariant(102));    
   154     action->setData(QVariant(KSort2Command));    
    87     action = sortSubMenu->addAction("Sort3");
   155     action = sortSubMenu->addAction("Sort3");
    88     action->setData(QVariant(103));
   156     action->setData(QVariant(KSort3Command));
    89     HbMenu *sort4SubMenu = sortSubMenu->addMenu("Sort4 (String)");
   157     HbMenu *sort4SubMenu = sortSubMenu->addMenu("Sort4 (String)");
    90     action = sort4SubMenu->addAction("CaseSensitive");
   158     action = sort4SubMenu->addAction("CaseSensitive");
    91     action->setData(QVariant(104));
   159     action->setData(QVariant(KSortCaseSensitiveCommand));
    92     action = sort4SubMenu->addAction("CaseInsensitive");
   160     action = sort4SubMenu->addAction("CaseInsensitive");
    93     action->setData(QVariant(105));
   161     action->setData(QVariant(KSortCaseInsensitiveCommand));
    94     
   162     
    95     HbMenu *filterSubMenu = mainMenu->addMenu("Filter");
   163     HbMenu *filterSubMenu = cpSubMenu->addMenu("Filter");
    96     action = filterSubMenu->addAction("Disable filter");
   164     action = filterSubMenu->addAction("Disable filter");
    97     action->setData(QVariant(201));
   165     action->setData(QVariant(KDisableFilterCommand));
    98     action = filterSubMenu->addAction("Filter ITEM* (Case Sensitive)");
   166     action = filterSubMenu->addAction("Filter ITEM* (Case Sensitive)");
    99     action->setData(QVariant(202));
   167     action->setData(QVariant(KFilter1Command));
   100     action = filterSubMenu->addAction("Filter ITEM1*(Case Insensitive)");
   168     action = filterSubMenu->addAction("Filter ITEM1*(Case Insensitive)");
   101     action->setData(QVariant(203));
   169     action->setData(QVariant(KFilter2Command));
   102     
   170     
   103     action = mainMenu->addAction("Reset");
   171     action = cpSubMenu->addAction("Enable dynamic Sort/Filter");
   104     action->setData(QVariant(1000));
   172     action->setData(QVariant(KTogleDynamicCommand));
   105     action = mainMenu->addAction("Enable dynamic Sort/Filter");
   173     
   106     action->setData(QVariant(1001));    
   174     action = cpSubMenu->addAction("Start Sort Test");
   107 
   175     action->setData(QVariant(KTogleSortTestCommand));
   108     action = mainMenu->addAction("Test");
   176 
   109     action->setData(QVariant(1002));
   177     action = cpSubMenu->addAction("Start Filter Test");
   110 
   178     action->setData(QVariant(KTogleFilterTestCommand));
   111     action = mainMenu->addAction("Stop Test");
   179 
   112     action->setData(QVariant(1003));
   180     
   113     
   181 }
   114     return mainMenu;
   182 
   115 }
   183 void MyWindow::addDataProviderMenu(HbMenu* parent)
       
   184 {
       
   185     HbMenu *dpSubMenu = parent->addMenu("DataProvider");
       
   186     
       
   187     HbMenu *insertSubMenu = dpSubMenu->addMenu("Insert Item");
       
   188     HbAction* action = insertSubMenu->addAction("at 0");
       
   189     action->setData(QVariant(KInsert0Command));
       
   190     action = insertSubMenu->addAction("at 50");
       
   191     action->setData(QVariant(KInsert50Command));    
       
   192     action = insertSubMenu->addAction("at 101");
       
   193     action->setData(QVariant(KInsert101Command));
       
   194     action = insertSubMenu->addAction("at 257");
       
   195     action->setData(QVariant(KInsert257Command));
       
   196     action = insertSubMenu->addAction("at 1000");
       
   197     action->setData(QVariant(KInsert1000Command));
       
   198     action = insertSubMenu->addAction("at end");
       
   199     action->setData(QVariant(KInsertEndCommand));
       
   200     action = insertSubMenu->addAction("at end-10");
       
   201     action->setData(QVariant(KInsertEnd10Command));
       
   202     action = insertSubMenu->addAction("at ...");
       
   203     action->setData(QVariant(KInsertCustomCommand));
       
   204     
       
   205     HbMenu *removeSubMenu = dpSubMenu->addMenu("Remove Item");
       
   206     action = removeSubMenu->addAction("at 0");
       
   207     action->setData(QVariant(KRemove0Command));
       
   208     action = removeSubMenu->addAction("at 50");
       
   209     action->setData(QVariant(KRemove50Command));    
       
   210     action = removeSubMenu->addAction("at 101");
       
   211     action->setData(QVariant(KRemove101Command));
       
   212     action = removeSubMenu->addAction("at 257");
       
   213     action->setData(QVariant(KRemove257Command));
       
   214     action = removeSubMenu->addAction("at 1000");
       
   215     action->setData(QVariant(KRemove1000Command));
       
   216     action = removeSubMenu->addAction("last");
       
   217     action->setData(QVariant(KRemoveLastCommand));
       
   218     action = removeSubMenu->addAction("at end-10");
       
   219     action->setData(QVariant(KRemoveEnd10Command));
       
   220     action = removeSubMenu->addAction("at ...");
       
   221     action->setData(QVariant(KRemoveCustomCommand));
       
   222 
       
   223     action = dpSubMenu->addAction("Show Images");
       
   224     action->setData(QVariant(KShowImagesCommand));
       
   225     action = dpSubMenu->addAction("Show Audio");
       
   226     action->setData(QVariant(KShowAudioCommand));
       
   227 
       
   228     action = dpSubMenu->addAction("HbIcon Mode");
       
   229     action->setData(QVariant(KHbIconModeCommand));
       
   230     action = dpSubMenu->addAction("QIcon Mode");
       
   231     action->setData(QVariant(KQIconModeCommand));
       
   232     action = dpSubMenu->addAction("QImage Mode");
       
   233     action->setData(QVariant(KQImageModeCommand));
       
   234     action = dpSubMenu->addAction("QPixmap Mode");
       
   235     action->setData(QVariant(KQPixmapModeCommand));
       
   236     
       
   237 }
       
   238 
   116 
   239 
   117 
   240 
   118 void MyWindow::processAction( HbAction* action )
   241 void MyWindow::processAction( HbAction* action )
   119 {
   242 {
   120     int command = action->data().toInt();
   243     int command = action->data().toInt();
   121     if ( command == 1) {
   244     
   122         HbGridView* view = new HbGridView();
   245     switch (command){
   123 		if ( orientation() == Qt::Horizontal ) {
   246         case KGridViewCommand : {
   124 			view->setColumnCount( 5 );
   247             HbGridView* view = new HbGridView();
   125 			view->setRowCount( 3 );
   248             if ( orientation() == Qt::Horizontal ) {
   126 		}else {
   249                 view->setColumnCount( 5 );
   127 			view->setColumnCount( 3 );
   250                 view->setRowCount( 3 );
   128 			view->setRowCount( 5 );			
   251             }else {
   129 		}
   252                 view->setColumnCount( 3 );
   130 //        view->setTextVisible(false);
   253                 view->setRowCount( 5 );         
   131 		view->setUniformItemSizes( true );
   254             }
   132 		view->setItemRecycling( true );
   255     //        view->setTextVisible(false);
   133 		//this could be done to change mode, for images it doesn't make sence, becouse images thumbnails are created by default only for medium and fullsize
   256             view->setUniformItemSizes( true );
   134 //		AbstractDataProvider *data = mModel->DataProvider();
   257             view->setItemRecycling( true );
   135 //		MyDataProvider *prov = static_cast<MyDataProvider*>(data); //of course we have already poiter to that - mMyDataProvider, but it is example how to get it from model
   258             view->setModel(mModel);
   136 //		prov->changeIconSize(ThumbnailManager::ThumbnailMedium);
   259             mMainView->setWidget( view );
   137 		view->setModel(mModel);
   260             mView = view;
   138 		mMainView->setWidget( view );
   261             break;
   139         mView = view;
   262         }
   140     } else if (command == 2) {
   263         case KListViewCommand : {
   141         HbListView* view = new HbListView();
   264             HbListView* view = new HbListView();
   142 		view->setUniformItemSizes( true );
   265             view->setUniformItemSizes( true );
   143 		view->setItemRecycling( true );
   266             view->setItemRecycling( true );
   144 		//this could be done to change mode, for images it doesn't make sence, becouse images thumbnails are created by default only for medium and fullsize
   267             view->setModel(mModel);
   145 //		AbstractDataProvider *data = mModel->DataProvider();
   268             mMainView->setWidget( view );
   146 //		MyDataProvider *prov = static_cast<MyDataProvider*>(data); //of course we have already poiter to that - mMyDataProvider, but it is example how to get it from model
   269             mView = view;            
   147 //		prov->changeIconSize(ThumbnailManager::ThumbnailSmall);
   270             break;
   148 		view->setModel(mModel);
   271         }
   149 		mMainView->setWidget( view );
   272         case KMediaWallViewCommand : {
   150         mView = view;
   273             HgMediawall * view = new HgMediawall();
   151 	} else if (command == 101) { //sort by KSort1Role
   274             view->setModel(mModel);
   152         mModel->setSortRole(Qt::UserRole+2);
   275             mMainView->setWidget( view );
   153         mModel->sort(0);
   276             mView = view;
   154 	} else if (command == 102) { //sort by KSort2Role
   277             break;
   155         mModel->setSortRole(Qt::UserRole+3);
   278         }
   156         mModel->sort(0);
   279         case KHgGridViewCommand : {
   157     } else if (command == 103) { //sort by KSort3Role
   280         HgGrid * view = new HgGrid(Qt::Vertical);
   158         mModel->setSortRole(Qt::UserRole+4);
   281             view->setModel(mModel);
   159         mModel->sort(0);
   282             mMainView->setWidget( view );
   160     } else if (command == 104) { //sort by DisplayRole CaseSensitive
   283             mView = view;
   161         mModel->setSortRole(Qt::DisplayRole);
   284             break;
   162         mModel->setSortCaseSensitivity(Qt::CaseSensitive);  
   285         }
   163         mModel->sort(0);
   286         case KSort1Command : {
   164     } else if (command == 105) { //sort by DisplayRole CaseInsensitive
   287             mModel->setSortRole(Qt::UserRole+2);
   165         mModel->setSortRole(Qt::DisplayRole);
   288             mModel->sort(0);
   166         mModel->setSortCaseSensitivity(Qt::CaseInsensitive);
   289             break;
   167         mModel->sort(0);
   290         }
   168     } else if (command == 201) { //disable filter
   291         case KSort2Command : {
   169         QRegExp reg = QRegExp();
   292             mModel->setSortRole(Qt::UserRole+3);
   170         mModel->setFilterRegExp(reg);
   293             mModel->sort(0);
   171     } else if (command == 202) { //Filter ITEM* (Case Sensitive)
   294             break;
   172         QRegExp reg = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard);
   295         }
   173         mModel->setFilterCaseSensitivity(Qt::CaseSensitive);
   296         case KSort3Command : {
   174         mModel->setFilterRegExp(reg);        
   297             mModel->setSortRole(Qt::UserRole+4);
   175     } else if (command == 203) { //Filter ITEM1*(Case Insensitive)
   298             mModel->sort(0);
   176         QRegExp reg = QRegExp("ITEM1*", Qt::CaseInsensitive, QRegExp::Wildcard);
   299             break;
   177         mModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
   300         }
   178         mModel->setFilterRegExp(reg);
   301         case KSortCaseSensitiveCommand : {
   179     } else if (command == 1000) { //reset
   302             mModel->setSortRole(Qt::DisplayRole);
   180         mMyDataProvider->resetModel();
   303             mModel->setSortCaseSensitivity(Qt::CaseSensitive);  
   181     } else if (command == 1001) { //reset
   304             mModel->sort(0);
   182         bool current = !mModel->dynamicSortFilter();
   305             break;
   183         mModel->setDynamicSortFilter(current);
   306         }
   184         if (current){
   307         case KSortCaseInsensitiveCommand : {
   185             action->setText("Disable dynamic Sort/Filter");
   308             mModel->setSortRole(Qt::DisplayRole);
   186         }else{
   309             mModel->setSortCaseSensitivity(Qt::CaseInsensitive);
   187             action->setText("Enable dynamic Sort/Filter");            
   310             mModel->sort(0);
   188         }
   311             break;
   189     } else if (command == 1002) {
   312         }
   190         mTestVal = 500;
   313         case KDisableFilterCommand : {
   191         timeout();
   314             QRegExp reg = QRegExp();
   192     } else if (command == 1003) {
   315             mModel->setFilterRegExp(reg);
   193         mTestVal = -1;
   316             break;
       
   317         }
       
   318         case KFilter1Command : {
       
   319             QRegExp reg = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard);
       
   320             mModel->setFilterCaseSensitivity(Qt::CaseSensitive);
       
   321             mModel->setFilterRegExp(reg);        
       
   322             break;
       
   323         }
       
   324         case KFilter2Command : {
       
   325             QRegExp reg = QRegExp("ITEM1*", Qt::CaseInsensitive, QRegExp::Wildcard);
       
   326             mModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
       
   327             mModel->setFilterRegExp(reg);
       
   328             break;
       
   329         }
       
   330         case KTogleDynamicCommand : {
       
   331             bool current = !mModel->dynamicSortFilter();
       
   332             mModel->setDynamicSortFilter(current);
       
   333             if (current){
       
   334                 action->setText("Disable dynamic Sort/Filter");
       
   335             }else{
       
   336                 action->setText("Enable dynamic Sort/Filter");            
       
   337             }
       
   338             break;
       
   339         }
       
   340         case KTogleSortTestCommand : {
       
   341             if (mSortTestVal == -1){
       
   342                 mSortTestVal = 500;
       
   343                 action->setText("Stop Sort Test");            
       
   344                 sortTestTimeout();
       
   345             }else{
       
   346                 mSortTestVal = -1;
       
   347                 action->setText("Start Sort Test");            
       
   348             }
       
   349             break;
       
   350         }
       
   351         case KTogleFilterTestCommand : {
       
   352             if (mFilterTestVal == -1){
       
   353                 mFilterTestVal = 500;
       
   354                 action->setText("Stop Filter Test");            
       
   355                 sortTestTimeout();
       
   356             }else{
       
   357                 mFilterTestVal = -1;
       
   358                 action->setText("Start Filter Test");            
       
   359             }
       
   360             break;
       
   361         }
       
   362         case KInsert0Command : {
       
   363             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   364             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   365             mMyDataProvider->testInsertItem(0, data);
       
   366             delete data;
       
   367             break;
       
   368         }
       
   369         case KInsert50Command : {
       
   370             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   371             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   372             mMyDataProvider->testInsertItem(50, data);
       
   373             delete data;
       
   374             break;
       
   375         }
       
   376         case KInsert101Command : {
       
   377             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   378             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   379             mMyDataProvider->testInsertItem(101, data);
       
   380             delete data;
       
   381             break;
       
   382         }
       
   383         case KInsert257Command : {
       
   384             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   385             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   386             mMyDataProvider->testInsertItem(257, data);
       
   387             delete data;
       
   388             break;
       
   389         }
       
   390         case KInsert1000Command : {
       
   391             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   392             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   393             mMyDataProvider->testInsertItem(1000, data);
       
   394             delete data;
       
   395             break;
       
   396         }
       
   397         case KInsertEndCommand : {
       
   398             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   399             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   400             mMyDataProvider->testInsertItem(mMyDataProvider->rowCount(QModelIndex()), data);
       
   401             delete data;
       
   402             break;
       
   403         }
       
   404         case KInsertEnd10Command : {
       
   405             QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   406             data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   407             mMyDataProvider->testInsertItem(mMyDataProvider->rowCount(QModelIndex())-10, data);
       
   408             delete data;
       
   409             break;
       
   410         }
       
   411         case KInsertCustomCommand : {
       
   412 		//TODO fix me
       
   413 //            int val = HbInputDialog::getInteger( QString("Insert at position:"));
       
   414 //            QList< QPair< QVariant, int > >* data = new QList< QPair< QVariant, int > >();
       
   415 //            data->append( QPair< QVariant, int >(QString("NEW ITEM!!!!"), Qt::DisplayRole) );
       
   416 //            mMyDataProvider->testInsertItem(val, data);
       
   417             break;
       
   418         }
       
   419         case KRemove0Command : {
       
   420             mMyDataProvider->testRemoveItem(0);
       
   421             break;
       
   422         }
       
   423         case KRemove50Command : {
       
   424             mMyDataProvider->testRemoveItem(50);
       
   425             break;
       
   426         }
       
   427         case KRemove101Command : {
       
   428             mMyDataProvider->testRemoveItem(101);
       
   429             break;
       
   430         }
       
   431         case KRemove257Command : {
       
   432             mMyDataProvider->testRemoveItem(257);
       
   433             break;
       
   434         }
       
   435         case KRemove1000Command : {
       
   436         mMyDataProvider->testRemoveItem(1000);            
       
   437             break;
       
   438         }
       
   439         case KRemoveLastCommand : {
       
   440                 mMyDataProvider->testRemoveItem(mMyDataProvider->rowCount(QModelIndex())-1);
       
   441             break;
       
   442         }
       
   443         case KRemoveEnd10Command : {
       
   444             mMyDataProvider->testRemoveItem(mMyDataProvider->rowCount(QModelIndex()) - 10);
       
   445             break;
       
   446         }
       
   447         case KRemoveCustomCommand : {
       
   448 		//TODO fix me		
       
   449 //            int val = HbInputDialog::getInteger( QString("Remove from position:"));
       
   450 //            mMyDataProvider->testRemoveItem(val);
       
   451             break;
       
   452         }
       
   453         case KShowImagesCommand : {
       
   454             mMyDataProvider->changeIconSize(ThumbnailManager::ThumbnailMedium);
       
   455             mMyDataProvider->changeMode(0);
       
   456             break;
       
   457         }
       
   458         case KShowAudioCommand : {
       
   459             mMyDataProvider->changeIconSize(ThumbnailManager::ThumbnailSmall);
       
   460             mMyDataProvider->changeMode(1);
       
   461             break;
       
   462         }
       
   463         
       
   464         case KHbIconModeCommand : {
       
   465             mMyDataProvider->setIconMode(HgDataProviderModel::HgDataProviderIconHbIcon);
       
   466             break;
       
   467         }
       
   468         case KQIconModeCommand : {
       
   469             mMyDataProvider->setIconMode(HgDataProviderModel::HgDataProviderIconQIcon);
       
   470             break;
       
   471         }
       
   472             case KQImageModeCommand : {
       
   473             mMyDataProvider->setIconMode(HgDataProviderModel::HgDataProviderIconQImage);
       
   474             break;
       
   475         }
       
   476             case KQPixmapModeCommand : {
       
   477             mMyDataProvider->setIconMode(HgDataProviderModel::HgDataProviderIconQPixmap);
       
   478             break;
       
   479         }
       
   480         case KResetCommand : {
       
   481             mMyDataProvider->resetModel();
       
   482             break;
       
   483         }
       
   484         default: {
       
   485             break;
       
   486         }
   194     }
   487     }
   195 }
   488 }
   196 
   489 
   197 void MyWindow::setIndex(int /*index*/)
   490 void MyWindow::sortTestTimeout()
   198 {
       
   199     update();
       
   200 }
       
   201 
       
   202 void MyWindow::timeout()
       
   203 {   
   491 {   
   204     HbAction action;
   492     if (mSortTestVal>0){
   205     action.setData ( QVariant(101 + mTestVal%4) );
   493         HbAction action;
   206     processAction(&action);
   494         action.setData ( QVariant(KSort1Command + mSortTestVal%(KSortCaseInsensitiveCommand - KSort1Command + 1) ) );
   207 
   495         processAction(&action);
   208     
   496         mSortTestVal--;
   209     if (mTestVal>=0){
   497         if (mSortTestVal==0){
   210         mTestVal--;
   498             mSortTestVal = 500;
   211         if (mTestVal==0){
   499         }
   212             mTestVal = 500;
   500         mSortTestTimer->start(2000);
   213         }
       
   214         mTimer->start(2000);
       
   215     }
   501     }
   216 }
   502 }
   217 
   503 
       
   504 void MyWindow::filterTestTimeout()
       
   505 {
       
   506     if (mFilterTestVal>0){
       
   507         HbAction action;
       
   508         action.setData ( QVariant(KDisableFilterCommand + mFilterTestVal%(KFilter2Command - KDisableFilterCommand + 1 ) ) );
       
   509         processAction(&action);
       
   510         mFilterTestVal--;
       
   511         if (mFilterTestVal==0){
       
   512             mFilterTestVal = 500;
       
   513         }
       
   514         mFilterTestTimer->start(2000);
       
   515     }
       
   516 }
       
   517 
   218 //eof
   518 //eof