Skip to content

Commit

Permalink
Fix code that looked up tree items by their displayed text
Browse files Browse the repository at this point in the history
This no longer works for pages now that they might have IDs displayed.
For ages it's technically still fine, but better to fix those as well to
avoid unpleasant surprises later.
  • Loading branch information
dgelessus committed Mar 2, 2024
1 parent 9af3132 commit 0e021b2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/PrpShop/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,10 @@ QPlasmaTreeItem* PrpShopMain::ensurePath(const plLocation& loc, short objType)
plPageInfo* page = fResMgr.FindPage(loc);
QPlasmaTreeItem* ageItem = NULL;
QString ageName = st2qstr(page->getAge());
QString pageName = st2qstr(page->getPage());
for (int i=0; i<fBrowserTree->topLevelItemCount(); i++) {
if (fBrowserTree->topLevelItem(i)->text(0) == ageName) {
ageItem = (QPlasmaTreeItem*)fBrowserTree->topLevelItem(i);
auto topLevelItem = static_cast<QPlasmaTreeItem*>(fBrowserTree->topLevelItem(i));
if (topLevelItem->age() == ageName) {
ageItem = topLevelItem;
break;
}
}
Expand All @@ -607,8 +607,9 @@ QPlasmaTreeItem* PrpShopMain::ensurePath(const plLocation& loc, short objType)

QPlasmaTreeItem* pageItem = NULL;
for (int i=0; i<ageItem->childCount(); i++) {
if (ageItem->child(i)->text(0) == pageName) {
pageItem = (QPlasmaTreeItem*)ageItem->child(i);
auto child = static_cast<QPlasmaTreeItem*>(ageItem->child(i));
if (child->page()->getLocation() == loc) {
pageItem = child;
break;
}
}
Expand Down Expand Up @@ -1106,8 +1107,9 @@ QPlasmaTreeItem* PrpShopMain::loadPage(plPageInfo* page, QString filename)
// Find or create the Age folder
QString ageName = st2qstr(page->getAge());
for (int i=0; i<fBrowserTree->topLevelItemCount(); i++) {
if (fBrowserTree->topLevelItem(i)->text(0) == ageName) {
parent = (QPlasmaTreeItem*)fBrowserTree->topLevelItem(i);
auto topLevelItem = static_cast<QPlasmaTreeItem*>(fBrowserTree->topLevelItem(i));
if (topLevelItem->age() == ageName) {
parent = topLevelItem;
break;
}
}
Expand Down

0 comments on commit 0e021b2

Please sign in to comment.