added name updating while window open

This commit is contained in:
Rafael 2016-03-22 05:59:17 +01:00
parent 49d29aa3ec
commit 4334537966
5 changed files with 41 additions and 7 deletions

View file

@ -46,7 +46,7 @@ void DatabaseThread::run()
QString memberListUrl = "http://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=" + crewID;
QNetworkRequest netRequest(memberListUrl);
netRequest.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0");
netRequest.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0 gta5sync/1.0");
netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
netRequest.setRawHeader("Connection", "keep-alive");
@ -84,6 +84,8 @@ void DatabaseThread::run()
}
}
emit playerNameUpdated();
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
goto dbtBegin;

View file

@ -37,6 +37,7 @@ protected:
signals:
void playerNameFound(int playerID, QString playerName);
void playerNameUpdated();
};

View file

@ -40,6 +40,11 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui->cmdExport->setDefault(0);
ui->cmdClose->setDefault(1);
ui->cmdClose->setFocus();
plyrsList = QStringList();
crewID = "";
locX = "";
locY = "";
locZ = "";
}
PictureDialog::~PictureDialog()
@ -62,11 +67,11 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
}
if (picture->isJsonOk())
{
QString locX = QString::number(picture->getLocationX());
QString locY = QString::number(picture->getLocationY());
QString locZ = QString::number(picture->getLocationZ());
QString crewID = QString::number(picture->getCrewNumber());
QStringList plyrsList = picture->getPlayers();
locX = QString::number(picture->getLocationX());
locY = QString::number(picture->getLocationY());
locZ = QString::number(picture->getLocationZ());
crewID = QString::number(picture->getCrewNumber());
plyrsList = picture->getPlayers();
QString plyrsStr;
if (plyrsList.length() >= 1)
@ -95,6 +100,21 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
}
}
void PictureDialog::on_playerNameUpdated()
{
if (plyrsList.count() >= 1)
{
QString plyrsStr;
foreach (const QString &player, plyrsList)
{
plyrsStr.append(", ");
plyrsStr.append(profileDB->getPlayerName(player.toInt()));
}
plyrsStr.remove(0,2);
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID));
}
}
void PictureDialog::on_cmdClose_clicked()
{
this->close();

View file

@ -35,15 +35,23 @@ public:
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
~PictureDialog();
public slots:
void on_playerNameUpdated();
private slots:
void on_cmdClose_clicked();
void on_cmdExport_clicked();
private:
Ui::PictureDialog *ui;
ProfileDatabase *profileDB;
QString jsonDrawString;
QString windowTitleStr;
ProfileDatabase *profileDB;
QStringList plyrsList;
QString crewID;
QString locX;
QString locY;
QString locZ;
};
#endif // PICTUREDIALOG_H

View file

@ -71,9 +71,12 @@ int main(int argc, char *argv[])
bool readOk = picture.readingPictureFromFile(arg1);
picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog->setSnapmaticPicture(&picture, readOk);
int crewID = picture.getCrewNumber();
if (crewID != 0) { crewDB->addCrew(crewID); }
if (!readOk) { return 1; }
QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(on_playerNameUpdated()));
picDialog->show();
return a.exec();