Skip to content

Commit f4b5e7f

Browse files
author
Alexander McNurlan
committed
Inital Commit.
0 parents  commit f4b5e7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3913
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.pro.user
2+
Quake ML 2 BasicEventDescription_diagram.pdf
3+
FDSN-WS-Specifications-1.1.pdf
4+
5+
6+
/build*/
7+
8+
/EMV/EarthWorm/

EMV/Dialogs/connectdialog.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include "connectdialog.h"
2+
#include "ui_connectdialog.h"
3+
4+
ConnectDialog::ConnectDialog(QWidget *parent) :
5+
QDialog(parent),
6+
ui(new Ui::ConnectDialog)
7+
{
8+
ui->setupUi(this);
9+
10+
//Add another SIGNAL from net, the one that gives progress updates and display to user
11+
connect(&net, SIGNAL(finished(QNetworkReply*)), this, SLOT(ReplyFinished(QNetworkReply*)));
12+
}
13+
14+
ConnectDialog::~ConnectDialog()
15+
{
16+
delete ui;
17+
}
18+
19+
void ConnectDialog::showEvent(QShowEvent *)
20+
{
21+
if (url.isEmpty())
22+
return;
23+
24+
if (started.testAndSetOrdered(0, 1))
25+
{
26+
net.get(QNetworkRequest(url));
27+
}
28+
}
29+
30+
void ConnectDialog::ReplyFinished(QNetworkReply* response)
31+
{
32+
if (ProcessReply(response))
33+
this->accept();
34+
else
35+
this->reject();
36+
}
37+
38+
bool ConnectDialog::ProcessReply(QNetworkReply* response)
39+
{
40+
// QString status = response->error()==QNetworkReply::NoError ? "Success" : "Error";
41+
// QMessageBox::information(this, "Network response.", status);
42+
43+
response->deleteLater();
44+
45+
if (response->error() != QNetworkReply::NoError) {
46+
qDebug() << "Network error.\n" << response->errorString();
47+
return false;
48+
}
49+
50+
QByteArray bytes = response->readAll();
51+
QString strResponse = QString(bytes);
52+
53+
int httpCode = response->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
54+
55+
if (httpCode != 200)
56+
{
57+
//Default message
58+
QString message = "Failed to retreive data \n Response: \n" + strResponse;
59+
60+
if (httpCode == 204)
61+
message = "Request Successful, However No Data Matches Selection";
62+
63+
QMessageBox::critical(this, "FDSN response", message);
64+
return false;
65+
}
66+
67+
xmlResponse = strResponse;
68+
69+
return true;
70+
}
71+
72+
73+
74+
void ConnectDialog::on_CancelButton_clicked()
75+
{
76+
this->reject();
77+
}

EMV/Dialogs/connectdialog.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#ifndef CONNECTDIALOG_H
2+
#define CONNECTDIALOG_H
3+
4+
#include <QDialog>
5+
#include <QMessageBox>
6+
#include <QUrl>
7+
#include <QNetworkAccessManager>
8+
#include <QNetworkReply>
9+
10+
#include <QAtomicInt>
11+
12+
namespace Ui {
13+
class ConnectDialog;
14+
}
15+
16+
class ConnectDialog : public QDialog
17+
{
18+
Q_OBJECT
19+
20+
public:
21+
explicit ConnectDialog(QWidget *parent = 0);
22+
~ConnectDialog();
23+
24+
void SetURL(QUrl url) { this->url = url; }
25+
QString RetrieveResponse() { return xmlResponse; }
26+
27+
protected:
28+
virtual void showEvent(QShowEvent *);
29+
30+
private:
31+
bool ProcessReply(QNetworkReply* response);
32+
33+
private slots:
34+
void ReplyFinished(QNetworkReply*);
35+
36+
37+
// Members
38+
void on_CancelButton_clicked();
39+
40+
private:
41+
Ui::ConnectDialog *ui;
42+
43+
QNetworkAccessManager net;
44+
45+
QAtomicInt started {0}; ///< Started if !0
46+
47+
QUrl url;
48+
49+
QString xmlResponse;
50+
};
51+
52+
#endif // CONNECTDIALOG_H

EMV/Dialogs/connectdialog.ui

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ConnectDialog</class>
4+
<widget class="QDialog" name="ConnectDialog">
5+
<property name="windowModality">
6+
<enum>Qt::ApplicationModal</enum>
7+
</property>
8+
<property name="geometry">
9+
<rect>
10+
<x>0</x>
11+
<y>0</y>
12+
<width>280</width>
13+
<height>47</height>
14+
</rect>
15+
</property>
16+
<property name="windowTitle">
17+
<string>Dialog</string>
18+
</property>
19+
<layout class="QHBoxLayout" name="horizontalLayout">
20+
<item>
21+
<widget class="QLabel" name="ConnectingLabel">
22+
<property name="text">
23+
<string>Connecting</string>
24+
</property>
25+
</widget>
26+
</item>
27+
<item>
28+
<spacer name="horizontalSpacer">
29+
<property name="orientation">
30+
<enum>Qt::Horizontal</enum>
31+
</property>
32+
<property name="sizeHint" stdset="0">
33+
<size>
34+
<width>84</width>
35+
<height>20</height>
36+
</size>
37+
</property>
38+
</spacer>
39+
</item>
40+
<item>
41+
<widget class="QPushButton" name="CancelButton">
42+
<property name="text">
43+
<string>Cancel</string>
44+
</property>
45+
</widget>
46+
</item>
47+
</layout>
48+
</widget>
49+
<resources/>
50+
<connections/>
51+
</ui>

EMV/Dialogs/earthwormsettings.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include "earthwormsettings.h"
2+
#include "ui_earthwormsettings.h"
3+
4+
EarthWormSettings::EarthWormSettings(QWidget *parent) :
5+
QDialog(parent),
6+
ui(new Ui::EarthWormSettings)
7+
{
8+
ui->setupUi(this);
9+
10+
ui->EW_Startup_Connect->setChecked(qsettings.value("EW/autostart", false).toBool());
11+
ui->EarthWormIP->setText(qsettings.value("EW/IP", "").toString());
12+
ui->EarthWormPort->setText(qsettings.value("EW/Port", "").toString());
13+
14+
ui->MoleDBUrl->setText(qsettings.value("EW/MoleURL","").toString());
15+
16+
ui->TimeAmountSelect->setValue(qsettings.value("EW/TimeAmount", 0).toInt());
17+
18+
QString TimeUnit = qsettings.value("EW/TimeUnit", "").toString();
19+
ui->TimeUnitSelect->setCurrentText(TimeUnit);
20+
21+
ui->ZoomLevel->setText(qsettings.value("EW/ZoomOnResponse", "").toString());
22+
23+
ui->EarthWormImportFile->setText(qsettings.value("EW/ImportFile", "").toString());
24+
}
25+
26+
EarthWormSettings::~EarthWormSettings()
27+
{
28+
delete ui;
29+
}
30+
31+
void EarthWormSettings::closeEvent(QCloseEvent *)
32+
{
33+
//Autostart
34+
qsettings.setValue("EW/autostart", ui->EW_Startup_Connect->isChecked());
35+
36+
//IP
37+
QString IP = ui->EarthWormIP->text().trimmed();
38+
if (IP.isEmpty())
39+
qsettings.remove("EW/IP");
40+
else
41+
qsettings.setValue("EW/IP", IP);
42+
43+
//Port
44+
QString Port = ui->EarthWormPort->text().trimmed();
45+
if (Port.isEmpty())
46+
qsettings.remove("EW/Port");
47+
else
48+
qsettings.setValue("EW/Port", ui->EarthWormPort->text());
49+
50+
//MoleURL
51+
QString URL = ui->MoleDBUrl->text().trimmed();
52+
if (URL.isEmpty())
53+
qsettings.remove("EW/MoleURL");
54+
else
55+
qsettings.setValue("EW/MoleURL", URL);
56+
57+
//Time
58+
qsettings.setValue("EW/TimeAmount", ui->TimeAmountSelect->text().trimmed());
59+
qsettings.setValue("EW/TimeUnit", ui->TimeUnitSelect->currentText().trimmed());
60+
61+
//Zoom
62+
QString ZoomLevel = ui->ZoomLevel->text().trimmed();
63+
if (ZoomLevel.isEmpty())
64+
qsettings.remove("EW/ZoomOnResponse");
65+
else
66+
qsettings.setValue("EW/ZoomOnResponse", ZoomLevel);
67+
68+
QString ImportFile = ui->EarthWormImportFile->text().trimmed();
69+
if (ImportFile.isEmpty())
70+
qsettings.remove("EW/ImportFile");
71+
else
72+
qsettings.setValue("EW/ImportFile", ImportFile);
73+
}
74+
75+
void EarthWormSettings::on_pushButton_clicked()
76+
{
77+
QString value = QFileDialog::getOpenFileName(this, tr("Open Files"), QDir::homePath());
78+
if (!value.isNull())
79+
ui->EarthWormImportFile->setText(value);
80+
81+
}

EMV/Dialogs/earthwormsettings.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef EARTHWORMSETTINGS_H
2+
#define EARTHWORMSETTINGS_H
3+
4+
#include <QDebug>
5+
#include <QDialog>
6+
#include <QSettings>
7+
#include <QDateTime>
8+
#include <QFileDialog>
9+
10+
11+
namespace Ui {
12+
class EarthWormSettings;
13+
}
14+
15+
class EarthWormSettings : public QDialog
16+
{
17+
Q_OBJECT
18+
19+
public:
20+
explicit EarthWormSettings(QWidget *parent = 0);
21+
~EarthWormSettings();
22+
23+
protected:
24+
void closeEvent(QCloseEvent *) override;
25+
26+
private slots:
27+
void on_pushButton_clicked();
28+
29+
private:
30+
Ui::EarthWormSettings *ui;
31+
QSettings qsettings;
32+
};
33+
34+
#endif // EARTHWORMSETTINGS_H

0 commit comments

Comments
 (0)