Skip to content
Snippets Groups Projects
Commit 71e593f8 authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files

[ #10222 ] Use categorized views, fix bookmark

parent 90426a19
No related branches found
No related tags found
No related merge requests found
......@@ -126,10 +126,11 @@ class LIB_EXPORT CallModel : public CallModelBase {
void removeConference ( Call* call );
//Getters
int size ();
CallList getCallList ();
static const CallHash& getHistory ();
static const QStringList getHistoryCallId ();
int size ();
CallList getCallList ();
static const CallHash& getHistory ();
static const QStringList getNumbersByPopularity ();
static const QStringList getHistoryCallId ();
//Account related
static Account* getCurrentAccount ( );
......
......@@ -53,6 +53,27 @@ template <typename CallWidget, typename Index> typename CallModel<CallWidget,In
template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalIndex CallModel<CallWidget,Index>::m_sPrivateCallList_index ;
template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalWidget CallModel<CallWidget,Index>::m_sPrivateCallList_widget ;
/*****************************************************************************
* *
* Private classes *
* *
****************************************************************************/
class SortableCallSource {
public:
SortableCallSource(Call* call=0) : count(0),callInfo(call) {}
uint count;
Call* callInfo;
const bool operator<(SortableCallSource other) {
return (other.count > count);
}
};
inline bool operator< (const SortableCallSource & s1, const SortableCallSource & s2)
{
return s1.count < s2.count;
}
/*****************************************************************************
* *
* Constructor *
......@@ -427,6 +448,32 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::
}
}
///Sort all history call by popularity and return the result (most popular first)
template<typename CallWidget, typename Index> const QStringList CallModel<CallWidget,Index>::getNumbersByPopularity()
{
QHash<QString,SortableCallSource*> hc;
foreach (Call* call, getHistory()) {
if (!hc[call->getPeerPhoneNumber()]) {
hc[call->getPeerPhoneNumber()] = new SortableCallSource(call);
}
hc[call->getPeerPhoneNumber()]->count++;
}
QList<SortableCallSource> userList;
foreach (SortableCallSource* i,hc) {
userList << *i;
}
qSort(userList);
QStringList cl;
for (int i=userList.size()-1;i >=0 ;i--) {
cl << userList[i].callInfo->getPeerPhoneNumber();
}
foreach (SortableCallSource* i,hc) {
delete i;
}
return cl;
}
/*****************************************************************************
* *
* Account related code *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment