messagingapp/msgui/appengine/src/conversationssummarymodel.cpp
changeset 44 36f374c67aa8
parent 43 35b64624a9e7
child 47 5b14749788d7
child 52 12db4185673b
equal deleted inserted replaced
43:35b64624a9e7 44:36f374c67aa8
    36 // @see header
    36 // @see header
    37 //---------------------------------------------------------------
    37 //---------------------------------------------------------------
    38 ConversationsSummaryModel::ConversationsSummaryModel(QObject* parent)
    38 ConversationsSummaryModel::ConversationsSummaryModel(QObject* parent)
    39 :QStandardItemModel(parent)
    39 :QStandardItemModel(parent)
    40     {
    40     {
       
    41     QStandardItemModel::setSortRole(TimeStamp);
       
    42     QStandardItemModel::sort(0, Qt::DescendingOrder);
    41     }
    43     }
    42 
    44 
    43 //---------------------------------------------------------------
    45 //---------------------------------------------------------------
    44 // ConversationsSummaryModel::~ConversationsSummaryModel
    46 // ConversationsSummaryModel::~ConversationsSummaryModel
    45 // @see header
    47 // @see header
   154 //---------------------------------------------------------------
   156 //---------------------------------------------------------------
   155 // ConversationsSummaryModel::addRow
   157 // ConversationsSummaryModel::addRow
   156 // @see header
   158 // @see header
   157 //---------------------------------------------------------------
   159 //---------------------------------------------------------------
   158 void ConversationsSummaryModel::addRow(
   160 void ConversationsSummaryModel::addRow(
   159         const CCsClientConversation& conversation)
   161         const CCsClientConversation& conversation, bool caching)
   160     {  
   162     {  
   161     int convId = conversation.GetConversationEntryId();
   163     int convId = conversation.GetConversationEntryId();
   162     
   164     
   163     //match convId in model, if found update else add item
   165     //match convId in model, if found update else add item
   164     QModelIndexList indexList = this->match(index(0, 0), 
   166     QModelIndexList indexList = this->match(index(0, 0), 
   176     {
   178     {
   177         // Update an existing item
   179         // Update an existing item
   178         QModelIndex index = indexList[0];
   180         QModelIndex index = indexList[0];
   179         QStandardItem* item = this->item(index.row(), 0);
   181         QStandardItem* item = this->item(index.row(), 0);
   180         populateItem(*item,conversation);
   182         populateItem(*item,conversation);
   181     }        
   183     }  
       
   184     // no need to sort if it is initial caching, as sorting is already done
       
   185     if (!caching)
       
   186         {
       
   187         QStandardItemModel::sort(0, Qt::DescendingOrder);
       
   188         }
   182     }
   189     }
   183 
   190 
   184 //---------------------------------------------------------------
   191 //---------------------------------------------------------------
   185 // ConversationsSummaryModel::deleteRow
   192 // ConversationsSummaryModel::deleteRow
   186 // @see header
   193 // @see header