diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp
index 3c1d9fa..bf321fd 100755
--- a/ProfileInterface.cpp
+++ b/ProfileInterface.cpp
@@ -33,7 +33,7 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
ui(new Ui::ProfileInterface)
{
ui->setupUi(this);
- ui->labProfileContent->setVisible(false);
+ ui->saProfile->setVisible(false);
contentStr = ui->labProfileContent->text();
profileFolder = "";
}
@@ -51,11 +51,11 @@ void ProfileInterface::setProfileFolder(QString folder, QString profile)
void ProfileInterface::setupProfileInterface()
{
- ui->labProfileContent->setText(contentStr.arg(profileName));
-
ProfileLoader *profileLoader = new ProfileLoader(profileFolder, crewDB);
QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(on_savegameLoaded(SavegameData*, QString)));
QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(on_pictureLoaded(SnapmaticPicture*, QString)));
+ QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(on_loadingProgress(int,int)));
+ QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(on_profileLoaded()));
profileLoader->start();
}
@@ -73,6 +73,23 @@ void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString pictu
ui->vlSnapmatic->addWidget(picWidget);
}
+void ProfileInterface::on_loadingProgress(int value, int maximum)
+{
+ ui->pbPictureLoading->setMaximum(maximum);
+ ui->pbPictureLoading->setValue(value);
+ ui->labProfileContent->setText(contentStr.arg(QString::number(value), QString::number(maximum)));
+}
+
+void ProfileInterface::on_profileLoaded()
+{
+ QSpacerItem *saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
+ ui->saProfileContent->layout()->addItem(saSpacerItem);
+ ui->saProfile->setVisible(true);
+ ui->pbPictureLoading->setVisible(false);
+ ui->labProfileContent->setVisible(false);
+ ui->frmLoading->setVisible(false);
+}
+
void ProfileInterface::on_cmdCloseProfile_clicked()
{
this->close();
diff --git a/ProfileInterface.h b/ProfileInterface.h
index 8af4375..b851882 100755
--- a/ProfileInterface.h
+++ b/ProfileInterface.h
@@ -42,6 +42,8 @@ private slots:
void on_cmdCloseProfile_clicked();
void on_pictureLoaded(SnapmaticPicture *picture, QString picturePath);
void on_savegameLoaded(SavegameData *savegame, QString savegamePath);
+ void on_loadingProgress(int value, int maximum);
+ void on_profileLoaded();
private:
ProfileDatabase *profileDB;
diff --git a/ProfileInterface.ui b/ProfileInterface.ui
index 9c6fa19..6a6de86 100755
--- a/ProfileInterface.ui
+++ b/ProfileInterface.ui
@@ -27,13 +27,70 @@
0
-
-
-
- Content of Profile %1
+
+
+ QFrame::NoFrame
-
- Qt::AlignCenter
+
+ QFrame::Plain
+
+ 0
+
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Loading %1 files of %2
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ 0
+
+
+ false
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 0
+
+
+
+
+
-
@@ -47,7 +104,7 @@
0
0
398
- 232
+ 121
diff --git a/ProfileLoader.cpp b/ProfileLoader.cpp
index e7ad0c4..1f6839a 100755
--- a/ProfileLoader.cpp
+++ b/ProfileLoader.cpp
@@ -32,15 +32,25 @@ ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObjec
void ProfileLoader::run()
{
+ int loadedV = 0;
QDir profileDir;
profileDir.setPath(profileFolder);
+
profileDir.setNameFilters(QStringList("SGTA*"));
QStringList SavegameFiles = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
+ profileDir.setNameFilters(QStringList("PGTA*"));
+ QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
+
+ SavegameFiles.removeDuplicates();
+ SnapmaticPics.removeDuplicates();
foreach(const QString &BackupFile, BackupFiles)
{
SavegameFiles.removeAll(BackupFile);
}
+
+ int maximumV = SavegameFiles.length() + SnapmaticPics.length();
+
foreach(const QString &SavegameFile, SavegameFiles)
{
QString sgdPath = profileFolder + "/" + SavegameFile;
@@ -49,10 +59,9 @@ void ProfileLoader::run()
{
emit savegameLoaded(savegame, sgdPath);
}
+ loadedV++;
+ emit loadingProgress(loadedV, maximumV);
}
-
- profileDir.setNameFilters(QStringList("PGTA*"));
- QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
foreach(const QString &SnapmaticPic, SnapmaticPics)
{
QString picturePath = profileFolder + "/" + SnapmaticPic;
@@ -62,5 +71,7 @@ void ProfileLoader::run()
emit pictureLoaded(picture, picturePath);
crewDB->addCrew(picture->getCrewNumber());
}
+ loadedV++;
+ emit loadingProgress(loadedV, maximumV);
}
}
diff --git a/ProfileLoader.h b/ProfileLoader.h
index d4fc99c..5fa7321 100755
--- a/ProfileLoader.h
+++ b/ProfileLoader.h
@@ -41,6 +41,7 @@ private:
signals:
void pictureLoaded(SnapmaticPicture *picture, QString picturePath);
void savegameLoaded(SavegameData *savegame, QString savegamePath);
+ void loadingProgress(int value, int maximum);
};
#endif // PROFILELOADER_H