Implemented waitForFinished() (fixes #28)
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QEventLoop>
|
||||
#include <QMessageBox>
|
||||
#include <QStringBuilder>
|
||||
|
||||
@@ -73,11 +72,7 @@ void AdvanvedViewDialog::contextMenuBooking(const QPoint &pos)
|
||||
dialog.getText()
|
||||
);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
{
|
||||
@@ -123,11 +118,7 @@ void AdvanvedViewDialog::contextMenuBooking(const QPoint &pos)
|
||||
dialog.getText()
|
||||
);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
{
|
||||
@@ -150,11 +141,7 @@ void AdvanvedViewDialog::contextMenuBooking(const QPoint &pos)
|
||||
{
|
||||
auto reply = m_stripsWidget.mainWindow().erfassung().doDeleteBooking(booking.id);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
m_stripsWidget.refreshBookings();
|
||||
@@ -193,11 +180,7 @@ void AdvanvedViewDialog::contextMenuTimeAssignment(const QPoint &pos)
|
||||
dialog.getText()
|
||||
);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
{
|
||||
@@ -248,11 +231,7 @@ void AdvanvedViewDialog::contextMenuTimeAssignment(const QPoint &pos)
|
||||
dialog.getText()
|
||||
);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
{
|
||||
@@ -275,11 +254,7 @@ void AdvanvedViewDialog::contextMenuTimeAssignment(const QPoint &pos)
|
||||
{
|
||||
auto reply = m_stripsWidget.mainWindow().erfassung().doDeleteTimeAssignment(timeAssignment.id);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QEventLoop>
|
||||
#include <QMessageBox>
|
||||
#include <QSplashScreen>
|
||||
#include <QPixmap>
|
||||
@@ -175,11 +174,7 @@ bool loadLoginPage(QSplashScreen &splashScreen, ZeiterfassungSettings &settings,
|
||||
again:
|
||||
auto reply = erfassung.doLoginPage();
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
QObject::connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
@@ -222,11 +217,7 @@ bool doAuthentication(QSplashScreen &splashScreen, ZeiterfassungSettings &settin
|
||||
again:
|
||||
auto reply = erfassung.doLogin(settings.username(), settings.password());
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
QObject::connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
@@ -257,11 +248,7 @@ bool loadUserInfo(QSplashScreen &splashScreen, ZeiterfassungApi &erfassung, GetU
|
||||
{
|
||||
auto reply = erfassung.doUserInfo();
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
QObject::connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <QTimer>
|
||||
#include <QStringBuilder>
|
||||
#include <QMenu>
|
||||
#include <QEventLoop>
|
||||
#include <QLabel>
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
@@ -247,11 +246,7 @@ void MainWindow::pushButtonStartPressed()
|
||||
timeNormalise(ui->timeEditTime->time()), QTime(0, 0),
|
||||
QStringLiteral("K"), QStringLiteral(""));
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
@@ -277,11 +272,7 @@ void MainWindow::pushButtonStartPressed()
|
||||
timeAssignment.project, timeAssignment.subproject,
|
||||
timeAssignment.workpackage, timeAssignment.text);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(reply->success())
|
||||
timeAssignmentTime = timeAdd(timeAssignmentTime, timespan);
|
||||
@@ -300,11 +291,7 @@ void MainWindow::pushButtonStartPressed()
|
||||
ui->comboBoxProject->currentData().toString(), ui->comboBoxSubproject->currentText(),
|
||||
ui->comboBoxWorkpackage->currentText(), ui->comboBoxText->currentText());
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
@@ -350,11 +337,7 @@ void MainWindow::pushButtonEndPressed()
|
||||
timeAssignment.project, timeAssignment.subproject,
|
||||
timeAssignment.workpackage, timeAssignment.text);
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), SIGNAL(finished()), &eventLoop, SLOT(quit()));
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
@@ -369,11 +352,7 @@ void MainWindow::pushButtonEndPressed()
|
||||
timeNormalise(ui->timeEditTime->time()), QTime(0, 0),
|
||||
QStringLiteral("G"), QStringLiteral(""));
|
||||
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
reply->waitForFinished();
|
||||
|
||||
if(!reply->success())
|
||||
{
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "zeiterfassungreply.h"
|
||||
|
||||
#include <QEventLoop>
|
||||
|
||||
#include "zeiterfassungapi.h"
|
||||
|
||||
ZeiterfassungReply::ZeiterfassungReply(ZeiterfassungApi *zeiterfassung) :
|
||||
@@ -20,6 +22,13 @@ const QString &ZeiterfassungReply::message() const
|
||||
return m_message;
|
||||
}
|
||||
|
||||
void ZeiterfassungReply::waitForFinished()
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
connect(this, &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
}
|
||||
|
||||
ZeiterfassungApi *ZeiterfassungReply::zeiterfassung() const
|
||||
{
|
||||
return m_zeiterfassung;
|
||||
|
@@ -17,6 +17,8 @@ public:
|
||||
bool success() const;
|
||||
const QString &message() const;
|
||||
|
||||
void waitForFinished();
|
||||
|
||||
Q_SIGNALS:
|
||||
void finished();
|
||||
|
||||
|
Reference in New Issue
Block a user