controlpanelui/src/tonefetcher/src/tonefetchermodel.h
changeset 19 36aa4756ee82
child 17 4a9568303383
equal deleted inserted replaced
12:624337f114fe 19:36aa4756ee82
       
     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:
       
    15  *     The header file for tone list model
       
    16  *     
       
    17  */
       
    18 
       
    19 #ifndef TONEFETCHERMODEL_H
       
    20 #define TONEFETCHERMODEL_H
       
    21 
       
    22 #include <QStandardItemModel>
       
    23 #include <QStringList>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 /**
       
    27  *  This class is used for storing tone list items.
       
    28  *  inherited from QStandardItemModel so that many existing functions could be used.
       
    29  *
       
    30  */
       
    31 class ToneFetcherModel : public QStandardItemModel
       
    32 {
       
    33 public:
       
    34     explicit ToneFetcherModel( QObject *parent );
       
    35     virtual ~ToneFetcherModel();
       
    36     //from QAbstractItemModel
       
    37     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
       
    38     void insertInOrder(QStandardItem *fileName, QStandardItem *filePath, int role = Qt::DisplayRole);    
       
    39     QString path(const QModelIndex &index) const;
       
    40     void refresh();
       
    41     void clearAll();
       
    42 private:
       
    43     /*
       
    44      * binary search (ascendant) for the correct index to insert.
       
    45      * @param low the start of search
       
    46      * @param high the end of search.
       
    47      * @return the correct index
       
    48      */
       
    49     int insertIndex(int low, int high, QString variant);
       
    50     
       
    51     /*
       
    52      * save the absolute path of the tone.
       
    53      */
       
    54     QStringList mUserDataLst;   
       
    55     
       
    56 };
       
    57 
       
    58 #endif /* TONEFETCHERMODEL_H_ */