emailuis/nmailuiengine/src/nmfolderlistmodel.cpp
branchGCC_SURGE
changeset 55 cdd802add233
parent 30 759dc5235cdb
equal deleted inserted replaced
28:011f79704660 55:cdd802add233
    35     QList<NmFolderMetaData*> mMetaDataList;
    35     QList<NmFolderMetaData*> mMetaDataList;
    36 };
    36 };
    37 
    37 
    38 NmFolderListModelPrivate::NmFolderListModelPrivate()
    38 NmFolderListModelPrivate::NmFolderListModelPrivate()
    39 {
    39 {
       
    40     NM_FUNCTION;
    40 }
    41 }
    41 
    42 
    42 NmFolderListModelPrivate::~NmFolderListModelPrivate()
    43 NmFolderListModelPrivate::~NmFolderListModelPrivate()
    43 {
    44 {
       
    45     NM_FUNCTION;
       
    46     
    44     while (!mMetaDataList.isEmpty()) {
    47     while (!mMetaDataList.isEmpty()) {
    45         delete mMetaDataList.takeLast();
    48         delete mMetaDataList.takeLast();
    46     }
    49     }
    47 }
    50 }
    48 
    51 
    51  */
    54  */
    52 NmFolderListModel::NmFolderListModel(NmDataManager &dataManager, QObject *parent) 
    55 NmFolderListModel::NmFolderListModel(NmDataManager &dataManager, QObject *parent) 
    53 :QAbstractListModel(parent),
    56 :QAbstractListModel(parent),
    54 mDataManager(dataManager)
    57 mDataManager(dataManager)
    55 {
    58 {
       
    59     NM_FUNCTION;
       
    60     
    56     d = new NmFolderListModelPrivate;
    61     d = new NmFolderListModelPrivate;
    57 }
    62 }
    58 
    63 
    59 /*!
    64 /*!
    60 	Destructor
    65 	Destructor
    61  */
    66  */
    62 NmFolderListModel::~NmFolderListModel()
    67 NmFolderListModel::~NmFolderListModel()
    63 {
    68 {
       
    69     NM_FUNCTION;
       
    70     
    64     delete d;
    71     delete d;
    65 }
    72 }
    66 
    73 
    67 /*!
    74 /*!
    68     Returns parent index.
    75     Returns parent index.
    69  */
    76  */
    70 QModelIndex NmFolderListModel::parent(const QModelIndex &child) const
    77 QModelIndex NmFolderListModel::parent(const QModelIndex &child) const
    71 {
    78 {
       
    79     NM_FUNCTION;
       
    80     
    72     Q_UNUSED(child);
    81     Q_UNUSED(child);
    73     return QModelIndex();
    82     return QModelIndex();
    74 }
    83 }
    75 
    84 
    76 /*!
    85 /*!
    77     Returns the number of list boxes for the current protocol plugin.
    86     Returns the number of list boxes for the current protocol plugin.
    78  */
    87  */
    79 int NmFolderListModel::rowCount(const QModelIndex &parent) const
    88 int NmFolderListModel::rowCount(const QModelIndex &parent) const
    80 {
    89 {
       
    90     NM_FUNCTION;
       
    91     
    81     Q_UNUSED(parent);
    92     Q_UNUSED(parent);
    82     return d->mMetaDataList.size();
    93     return d->mMetaDataList.size();
    83 }
    94 }
    84 
    95 
    85 /*!
    96 /*!
    86     This returns always 1.
    97     This returns always 1.
    87  */
    98  */
    88 int NmFolderListModel::columnCount(const QModelIndex &parent) const
    99 int NmFolderListModel::columnCount(const QModelIndex &parent) const
    89 {
   100 {
       
   101     NM_FUNCTION;
       
   102     
    90     Q_UNUSED(parent);
   103     Q_UNUSED(parent);
    91 	return 1;
   104 	return 1;
    92 }
   105 }
    93 
   106 
    94 /*!
   107 /*!
    95     Returns data specified by \a index. Only Qt::DisplayRole is supported in \a role.
   108     Returns data specified by \a index. Only Qt::DisplayRole is supported in \a role.
    96     The refresh method must have been called before this method can return any real data.
   109     The refresh method must have been called before this method can return any real data.
    97  */
   110  */
    98 QVariant NmFolderListModel::data(const QModelIndex &index, int role) const
   111 QVariant NmFolderListModel::data(const QModelIndex &index, int role) const
    99 {
   112 {
       
   113     NM_FUNCTION;
       
   114     
   100     if (!index.isValid())
   115     if (!index.isValid())
   101         return QVariant();
   116         return QVariant();
   102 
   117 
   103     if (index.row() >= rowCount())
   118     if (index.row() >= rowCount())
   104         return QVariant();
   119         return QVariant();
   118     This refreshes the data of the model.
   133     This refreshes the data of the model.
   119  */
   134  */
   120 void NmFolderListModel::refresh(
   135 void NmFolderListModel::refresh(
   121         QList<NmFolder*>& folderList)
   136         QList<NmFolder*>& folderList)
   122 {
   137 {
   123     NMLOG("nmuiengine: folder list model refresh");
   138     NM_FUNCTION;
       
   139     
   124     while (!d->mMetaDataList.isEmpty()) {
   140     while (!d->mMetaDataList.isEmpty()) {
   125         delete d->mMetaDataList.takeLast();
   141         delete d->mMetaDataList.takeLast();
   126     }
   142     }
   127     d->mMetaDataList.clear();
   143     d->mMetaDataList.clear();
   128     QList<NmFolder*>::const_iterator it = folderList.constBegin();
   144     QList<NmFolder*>::const_iterator it = folderList.constBegin();