make sure applets are sorted by id
As with containment, make sure Containment::applets() is always sorted by id, to have the least sursprises possible it adds a test Change-Id: Ib1aeeff7c70bb6969b32b2fef8557889a43edf09
This commit is contained in:
parent
a159208d54
commit
37b34711d8
@ -169,7 +169,10 @@ void CoronaTest::checkOrder()
|
|||||||
QCOMPARE(m_corona->containments()[1]->id(), (uint)4);
|
QCOMPARE(m_corona->containments()[1]->id(), (uint)4);
|
||||||
QCOMPARE(m_corona->containments()[2]->id(), (uint)5);
|
QCOMPARE(m_corona->containments()[2]->id(), (uint)5);
|
||||||
|
|
||||||
//TODO: Containment::applets() order check
|
//check applets order
|
||||||
|
QCOMPARE(m_corona->containments()[0]->applets().count(), 2);
|
||||||
|
QCOMPARE(m_corona->containments()[0]->applets()[0]->id(), (uint)2);
|
||||||
|
QCOMPARE(m_corona->containments()[0]->applets()[1]->id(), (uint)3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoronaTest::startupCompletion()
|
void CoronaTest::startupCompletion()
|
||||||
|
@ -6,14 +6,16 @@ lastScreen=0
|
|||||||
location=0
|
location=0
|
||||||
plugin=simplecontainment
|
plugin=simplecontainment
|
||||||
|
|
||||||
[Containments][1][Applets][2]
|
#those two applets are not ordered by id
|
||||||
immutability=1
|
#but applets() should be ordered anyways
|
||||||
plugin=invalid
|
|
||||||
|
|
||||||
[Containments][1][Applets][3]
|
[Containments][1][Applets][3]
|
||||||
immutability=1
|
immutability=1
|
||||||
plugin=simpleapplet
|
plugin=simpleapplet
|
||||||
|
|
||||||
|
[Containments][1][Applets][2]
|
||||||
|
immutability=1
|
||||||
|
plugin=invalid
|
||||||
|
|
||||||
#empty panel: should emit complete even if empty
|
#empty panel: should emit complete even if empty
|
||||||
[Containments][4]
|
[Containments][4]
|
||||||
formfactor=2
|
formfactor=2
|
||||||
|
@ -260,10 +260,14 @@ void Containment::restoreContents(KConfigGroup &group)
|
|||||||
{
|
{
|
||||||
KConfigGroup applets(&group, "Applets");
|
KConfigGroup applets(&group, "Applets");
|
||||||
|
|
||||||
|
//restore the applets ordered by id
|
||||||
|
QStringList groups = applets.groupList();
|
||||||
|
qSort(groups.begin(), groups.end());
|
||||||
|
|
||||||
// Sort the applet configs in order of geometry to ensure that applets
|
// Sort the applet configs in order of geometry to ensure that applets
|
||||||
// are added from left to right or top to bottom for a panel containment
|
// are added from left to right or top to bottom for a panel containment
|
||||||
QList<KConfigGroup> appletConfigs;
|
QList<KConfigGroup> appletConfigs;
|
||||||
foreach (const QString &appletGroup, applets.groupList()) {
|
foreach (const QString &appletGroup, groups) {
|
||||||
//qDebug() << "reading from applet group" << appletGroup;
|
//qDebug() << "reading from applet group" << appletGroup;
|
||||||
KConfigGroup appletConfig(&applets, appletGroup);
|
KConfigGroup appletConfig(&applets, appletGroup);
|
||||||
appletConfigs.append(appletConfig);
|
appletConfigs.append(appletConfig);
|
||||||
@ -414,7 +418,11 @@ void Containment::addApplet(Applet *applet)
|
|||||||
applet->setParent(this);
|
applet->setParent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->applets << applet;
|
//make sure the applets are sorted by id
|
||||||
|
auto position = std::lower_bound(d->applets.begin(), d->applets.end(), applet, [](Plasma::Applet *a1, Plasma::Applet *a2) {
|
||||||
|
return a1->id() < a2->id();
|
||||||
|
});
|
||||||
|
d->applets.insert(position, applet);
|
||||||
|
|
||||||
if (!d->uiReady) {
|
if (!d->uiReady) {
|
||||||
d->loadingApplets << applet;
|
d->loadingApplets << applet;
|
||||||
|
Loading…
Reference in New Issue
Block a user