mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make the classes generated by uic be real members of our classes
This means we don't have to new/delete them, which is a waste of overhead. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f0f76056ac
commit
8e81d3f100
22 changed files with 563 additions and 572 deletions
|
|
@ -23,13 +23,13 @@ SubsurfaceWebServices* SubsurfaceWebServices::instance()
|
|||
}
|
||||
|
||||
SubsurfaceWebServices::SubsurfaceWebServices(QWidget* parent, Qt::WindowFlags f)
|
||||
: ui( new Ui::SubsurfaceWebServices()){
|
||||
ui->setupUi(this);
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||
connect(ui->download, SIGNAL(clicked(bool)), this, SLOT(startDownload()));
|
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
{
|
||||
ui.setupUi(this);
|
||||
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||
connect(ui.download, SIGNAL(clicked(bool)), this, SLOT(startDownload()));
|
||||
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
QSettings s;
|
||||
ui->userID->setText(s.value("webservice_uid").toString());
|
||||
ui.userID->setText(s.value("webservice_uid").toString());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -43,8 +43,8 @@ static void clear_table(struct dive_table *table)
|
|||
|
||||
void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
switch(ui->buttonBox->buttonRole(button)){
|
||||
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
switch(ui.buttonBox->buttonRole(button)){
|
||||
case QDialogButtonBox::ApplyRole:{
|
||||
clear_table(&gps_location_table);
|
||||
QByteArray url = tr("Webservice").toLocal8Bit();
|
||||
|
|
@ -57,7 +57,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
|
|||
|
||||
/* store last entered uid in config */
|
||||
QSettings s;
|
||||
s.setValue("webservice_uid", ui->userID->text());
|
||||
s.setValue("webservice_uid", ui.userID->text());
|
||||
s.sync();
|
||||
hide();
|
||||
close();
|
||||
|
|
@ -68,7 +68,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
|
|||
// makes Subsurface throw a SIGSEGV...
|
||||
// manager->deleteLater();
|
||||
reply->deleteLater();
|
||||
ui->progressBar->setMaximum(1);
|
||||
ui.progressBar->setMaximum(1);
|
||||
break;
|
||||
case QDialogButtonBox::HelpRole:
|
||||
QDesktopServices::openUrl(QUrl("http://api.hohndel.org"));
|
||||
|
|
@ -81,17 +81,17 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
|
|||
void SubsurfaceWebServices::startDownload()
|
||||
{
|
||||
QUrl url("http://api.hohndel.org/api/dive/get/");
|
||||
url.setQueryItems( QList<QPair<QString,QString> >() << qMakePair(QString("login"), ui->userID->text()));
|
||||
url.setQueryItems( QList<QPair<QString,QString> >() << qMakePair(QString("login"), ui.userID->text()));
|
||||
|
||||
manager = new QNetworkAccessManager(this);
|
||||
QNetworkRequest request;
|
||||
request.setUrl(url);
|
||||
request.setRawHeader("Accept", "text/xml");
|
||||
reply = manager->get(request);
|
||||
ui->status->setText(tr("Wait a bit untill we have something..."));
|
||||
ui->progressBar->setRange(0,0); // this makes the progressbar do an 'infinite spin'
|
||||
ui->download->setEnabled(false);
|
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
ui.status->setText(tr("Wait a bit untill we have something..."));
|
||||
ui.progressBar->setRange(0,0); // this makes the progressbar do an 'infinite spin'
|
||||
ui.download->setEnabled(false);
|
||||
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
|
|
@ -100,16 +100,16 @@ void SubsurfaceWebServices::startDownload()
|
|||
|
||||
void SubsurfaceWebServices::downloadFinished()
|
||||
{
|
||||
ui->progressBar->setRange(0,1);
|
||||
ui.progressBar->setRange(0,1);
|
||||
downloadedData = reply->readAll();
|
||||
|
||||
ui->download->setEnabled(true);
|
||||
ui->status->setText(tr("Download Finished"));
|
||||
ui.download->setEnabled(true);
|
||||
ui.status->setText(tr("Download Finished"));
|
||||
|
||||
uint resultCode = download_dialog_parse_response(downloadedData);
|
||||
setStatusText(resultCode);
|
||||
if (resultCode == DD_STATUS_OK){
|
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
|
||||
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
|
||||
}
|
||||
manager->deleteLater();
|
||||
reply->deleteLater();
|
||||
|
|
@ -117,9 +117,9 @@ void SubsurfaceWebServices::downloadFinished()
|
|||
|
||||
void SubsurfaceWebServices::downloadError(QNetworkReply::NetworkError error)
|
||||
{
|
||||
ui->download->setEnabled(true);
|
||||
ui->progressBar->setRange(0,1);
|
||||
ui->status->setText(QString::number((int)QNetworkRequest::HttpStatusCodeAttribute));
|
||||
ui.download->setEnabled(true);
|
||||
ui.progressBar->setRange(0,1);
|
||||
ui.status->setText(QString::number((int)QNetworkRequest::HttpStatusCodeAttribute));
|
||||
manager->deleteLater();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ void SubsurfaceWebServices::setStatusText(int status)
|
|||
case DD_STATUS_ERROR_PARSE: text = tr("Cannot parse response!"); break;
|
||||
case DD_STATUS_OK: text = tr("Download Success!"); break;
|
||||
}
|
||||
ui->status->setText(text);
|
||||
ui.status->setText(text);
|
||||
}
|
||||
|
||||
void SubsurfaceWebServices::runDialog()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue