Commit 30304b76 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Sort the contents of a KisCmbIDList

Add sort function to use with qSort of std::sort KoID and use that
to make sure that every KoID combobox is sorted.
parent b6d238cf
......@@ -89,6 +89,13 @@ public:
friend inline bool operator<(const KoID &, const KoID &);
friend inline bool operator>(const KoID &, const KoID &);
static bool compareNames(const KoID &id1, const KoID &id2)
{
return id1.name() < id2.name();
}
private:
QString m_id;
......
......@@ -40,7 +40,9 @@ KisCmbIDList::~KisCmbIDList()
void KisCmbIDList::setIDList(const QList<KoID> & list)
{
clear();
m_list = list;
qSort(m_list.begin(), m_list.end(), KoID::compareNames);
for (qint32 i = 0; i < m_list.count(); ++i) {
addItem(m_list.at(i).name());
}
......
......@@ -41,6 +41,12 @@ public:
public:
/**
* @brief setIDList clears the combobox and sorts
* the given list by user-visible name and then adds
* the items to the combobox
* @param list the (unsorted) list of KoID's
*/
void setIDList(const QList<KoID> & list);
void setCurrent(const KoID id);
void setCurrent(const QString & s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment