diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 0e5ead9..fa386c9 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -110,8 +110,7 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa { SavegameWidget *sgdWidget = new SavegameWidget(); sgdWidget->setSavegameData(savegame, savegamePath); - ui->vlSavegame->addWidget(sgdWidget); - widgets[sgdWidget] = "SavegameWidget"; + widgets[sgdWidget] = "SGD" + QFileInfo(savegamePath).fileName(); savegames.append(savegame); if (selectedWidgts != 0) { sgdWidget->setSelectionMode(true); } QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(savegameDeleted())); @@ -125,8 +124,7 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, QString pictureP { SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, threadDB); picWidget->setSnapmaticPicture(picture, picturePath); - ui->vlSnapmatic->addWidget(picWidget); - widgets[picWidget] = "SnapmaticWidget"; + widgets[picWidget] = "PIC" + picture->getPictureSortStr(); pictures.append(picture); if (selectedWidgts != 0) { picWidget->setSelectionMode(true); } QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(pictureDeleted())); @@ -145,6 +143,20 @@ void ProfileInterface::loadingProgress(int value, int maximum) void ProfileInterface::profileLoaded_p() { + QStringList widgetsKeyList = widgets.values(); + qSort(widgetsKeyList.begin(), widgetsKeyList.end()); + foreach(QString widgetKey, widgetsKeyList) + { + ProfileWidget *widget = widgets.key(widgetKey); + if (widget->getWidgetType() == "SnapmaticWidget") + { + ui->vlSnapmatic->insertWidget(0, widget); + } + else if (widget->getWidgetType() == "SavegameWidget") + { + ui->vlSavegame->addWidget(widget); + } + } saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); ui->saProfileContent->layout()->addItem(saSpacerItem); ui->swProfile->setCurrentWidget(ui->pageProfile); @@ -418,11 +430,11 @@ void ProfileInterface::exportSelected() { if (widget->isSelected()) { - if (widgets[widget] == "SnapmaticWidget") + if (widget->getWidgetType() == "SnapmaticWidget") { exportPictures++; } - else if (widgets[widget] == "SavegameWidgets") + else if (widget->getWidgetType() == "SavegameWidgets") { exportSavegames++; } @@ -537,7 +549,7 @@ void ProfileInterface::deleteSelected() { if (widget->isSelected()) { - if (widgets[widget] == "SnapmaticWidget") + if (widget->getWidgetType() == "SnapmaticWidget") { SnapmaticWidget *picWidget = (SnapmaticWidget*)widget; SnapmaticPicture *picture = picWidget->getPicture(); @@ -547,7 +559,7 @@ void ProfileInterface::deleteSelected() pictureDeleted_f(picWidget); } } - else if (widgets[widget] == "SavegameWidget") + else if (widget->getWidgetType() == "SavegameWidget") { SavegameWidget *sgdWidget = (SavegameWidget*)widget; SavegameData *savegame = sgdWidget->getSavegame(); diff --git a/ProfileWidget.cpp b/ProfileWidget.cpp index e0190de..ac76743 100755 --- a/ProfileWidget.cpp +++ b/ProfileWidget.cpp @@ -43,3 +43,9 @@ void ProfileWidget::setSelectionMode(bool selectionMode) { qDebug() << "ProfileWidget::setSelectionMode got used without overwrite, result:" << selectionMode; } + +QString ProfileWidget::getWidgetType() +{ + qDebug() << "ProfileWidget::getWidgetType got used without overwrite"; + return "ProfileWidget"; +} diff --git a/ProfileWidget.h b/ProfileWidget.h index 3fc46fb..c6b8267 100755 --- a/ProfileWidget.h +++ b/ProfileWidget.h @@ -29,6 +29,7 @@ public: virtual void setSelectionMode(bool selectionMode); virtual void setSelected(bool isSelected); virtual bool isSelected(); + virtual QString getWidgetType(); ~ProfileWidget(); signals: diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index a9b04e0..5d43187 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -224,3 +224,8 @@ SavegameData* SavegameWidget::getSavegame() { return sgdata; } + +QString SavegameWidget::getWidgetType() +{ + return "SavegameWidget"; +} diff --git a/SavegameWidget.h b/SavegameWidget.h index b3f38ed..bc931a7 100755 --- a/SavegameWidget.h +++ b/SavegameWidget.h @@ -40,6 +40,7 @@ public: void setSelectionMode(bool selectionMode); void setSelected(bool isSelected); SavegameData* getSavegame(); + QString getWidgetType(); bool isSelected(); ~SavegameWidget(); diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 8a95ec6..3d66be1 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -233,3 +233,8 @@ SnapmaticPicture* SnapmaticWidget::getPicture() { return smpic; } + +QString SnapmaticWidget::getWidgetType() +{ + return "SnapmaticWidget"; +} diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index dffab50..b628de3 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -41,8 +41,9 @@ public: void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); void setSelectionMode(bool selectionMode); void setSelected(bool isSelected); - bool isSelected(); SnapmaticPicture *getPicture(); + QString getWidgetType(); + bool isSelected(); ~SnapmaticWidget(); private slots: