summaryrefslogtreecommitdiffstats
path: root/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-27 20:09:57 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-27 20:09:57 -0800
commit76e6420f6b3503b76bd3eec00ab0e53d6ea17a20 (patch)
tree8b50298f41bd29d55bbd6f4301f36ad31dc0b008 /qthelper.cpp
parent006265d7a088cff4fea665159dbb454956c2cd76 (diff)
downloadsubsurface-76e6420f6b3503b76bd3eec00ab0e53d6ea17a20.tar.gz
Massive automated whitespace cleanup
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r--qthelper.cpp97
1 files changed, 60 insertions, 37 deletions
diff --git a/qthelper.cpp b/qthelper.cpp
index 6f15517d4..352d3c4bd 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -9,23 +9,23 @@
#define tr(_arg) MainWindow::instance()->information()->tr(_arg)
DiveComputerList::DiveComputerList()
{
-
}
DiveComputerList::~DiveComputerList()
{
-
}
-bool DiveComputerNode::operator == (const DiveComputerNode &a) const {
+bool DiveComputerNode::operator==(const DiveComputerNode &a) const
+{
return this->model == a.model &&
- this->deviceId == a.deviceId &&
- this->firmware == a.firmware &&
- this->serialNumber == a.serialNumber &&
- this->nickName == a.nickName;
+ this->deviceId == a.deviceId &&
+ this->firmware == a.firmware &&
+ this->serialNumber == a.serialNumber &&
+ this->nickName == a.nickName;
}
-bool DiveComputerNode::operator !=(const DiveComputerNode &a) const {
+bool DiveComputerNode::operator!=(const DiveComputerNode &a) const
+{
return !(*this == a);
}
@@ -36,13 +36,13 @@ bool DiveComputerNode::changesValues(const DiveComputerNode &b) const
return false;
}
return (b.firmware != "" && this->firmware != b.firmware) ||
- (b.serialNumber != "" && this->serialNumber != b.serialNumber) ||
- (b.nickName != "" && this->nickName != b.nickName);
+ (b.serialNumber != "" && this->serialNumber != b.serialNumber) ||
+ (b.nickName != "" && this->nickName != b.nickName);
}
const DiveComputerNode *DiveComputerList::getExact(QString m, uint32_t d)
{
- for (QMap<QString,DiveComputerNode>::iterator it = dcMap.find(m); it != dcMap.end() && it.key() == m; ++it)
+ for (QMap<QString, DiveComputerNode>::iterator it = dcMap.find(m); it != dcMap.end() && it.key() == m; ++it)
if (it->deviceId == d)
return &*it;
return NULL;
@@ -50,7 +50,7 @@ const DiveComputerNode *DiveComputerList::getExact(QString m, uint32_t d)
const DiveComputerNode *DiveComputerList::get(QString m)
{
- QMap<QString,DiveComputerNode>::iterator it = dcMap.find(m);
+ QMap<QString, DiveComputerNode>::iterator it = dcMap.find(m);
if (it != dcMap.end())
return &*it;
return NULL;
@@ -90,21 +90,26 @@ QString weight_string(int weight_in_grams)
if (get_units()->weight == units::KG) {
int gr = weight_in_grams % 1000;
int kg = weight_in_grams / 1000;
- if (kg >= 20.0) {
- str = QString("0");
- } else {
- str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100);
- }
+ if (kg >= 20.0) {
+ str = QString("0");
+ } else {
+ str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100);
+ }
} else {
double lbs = grams_to_lbs(weight_in_grams);
- str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1 );
+ str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);
}
return (str);
}
-bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
+bool parseGpsText(const QString &gps_text, double *latitude, double *longitude)
{
- enum { ISO6709D, SECONDS, MINUTES, DECIMAL } gpsStyle = ISO6709D;
+ enum {
+ ISO6709D,
+ SECONDS,
+ MINUTES,
+ DECIMAL
+ } gpsStyle = ISO6709D;
int eastWest = 4;
int northSouth = 1;
QString regExp;
@@ -123,41 +128,59 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
if (gps_text.at(0).isDigit() && (gps_text.count(",") % 2) == 0) {
gpsStyle = ISO6709D;
regExp = QString("(\\d+)[" UTF8_DEGREE "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([NS%1%2])"
- "\\s*(\\d+)[" UTF8_DEGREE "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([EW%3%4])")
- .arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W"));
+ "\\s*(\\d+)[" UTF8_DEGREE "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([EW%3%4])")
+ .arg(tr("N"))
+ .arg(tr("S"))
+ .arg(tr("E"))
+ .arg(tr("W"));
} else if (gps_text.count(QChar('"')) == 2) {
gpsStyle = SECONDS;
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?[^EW%3%4]*"
- "([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?")
- .arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
+ "([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?")
+ .arg(tr("N"))
+ .arg(tr("S"))
+ .arg(tr("E"))
+ .arg(tr("W"))
+ .arg(tr("E"))
+ .arg(tr("W"));
} else if (gps_text.count(QChar('\'')) == 2) {
gpsStyle = MINUTES;
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?[^EW%3%4]*"
- "([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?")
- .arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
+ "([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?")
+ .arg(tr("N"))
+ .arg(tr("S"))
+ .arg(tr("E"))
+ .arg(tr("W"))
+ .arg(tr("E"))
+ .arg(tr("W"));
} else {
gpsStyle = DECIMAL;
regExp = QString("\\s*([-NS%1%2]?)\\s*(\\d+)[,\\.](\\d+)[^-EW%3%4\\d]*([-EW%5%6]?)\\s*(\\d+)[,\\.](\\d+)")
- .arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
+ .arg(tr("N"))
+ .arg(tr("S"))
+ .arg(tr("E"))
+ .arg(tr("W"))
+ .arg(tr("E"))
+ .arg(tr("W"));
}
QRegExp r(regExp);
if (r.indexIn(gps_text) != -1) {
// qDebug() << "Hemisphere" << r.cap(1) << "deg" << r.cap(2) << "min" << r.cap(3) << "decimal" << r.cap(4);
// qDebug() << "Hemisphere" << r.cap(5) << "deg" << r.cap(6) << "min" << r.cap(7) << "decimal" << r.cap(8);
- switch(gpsStyle) {
+ switch (gpsStyle) {
case ISO6709D:
*latitude = r.cap(1).toInt() + r.cap(2).toInt() / 60.0 +
- (r.cap(3) + QString(".") + r.cap(5)).toDouble() / 3600.0;
+ (r.cap(3) + QString(".") + r.cap(5)).toDouble() / 3600.0;
*longitude = r.cap(7).toInt() + r.cap(8).toInt() / 60.0 +
- (r.cap(9) + QString(".") + r.cap(11)).toDouble() / 3600.0;
+ (r.cap(9) + QString(".") + r.cap(11)).toDouble() / 3600.0;
northSouth = 6;
eastWest = 12;
break;
case SECONDS:
*latitude = r.cap(2).toInt() + r.cap(3).toInt() / 60.0 +
- (r.cap(4) + QString(".") + r.cap(6)).toDouble() / 3600.0;
+ (r.cap(4) + QString(".") + r.cap(6)).toDouble() / 3600.0;
*longitude = r.cap(8).toInt() + r.cap(9).toInt() / 60.0 +
- (r.cap(10) + QString(".") + r.cap(12)).toDouble() / 3600.0;
+ (r.cap(10) + QString(".") + r.cap(12)).toDouble() / 3600.0;
eastWest = 7;
break;
case MINUTES:
@@ -166,7 +189,7 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
eastWest = 6;
break;
case DECIMAL:
- default:
+ default:
*latitude = (r.cap(2) + QString(".") + r.cap(3)).toDouble();
*longitude = (r.cap(5) + QString(".") + r.cap(6)).toDouble();
break;
@@ -181,7 +204,7 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
return false;
}
-bool gpsHasChanged(struct dive *dive, struct dive *master, const QString& gps_text, bool *parsed)
+bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed)
{
double latitude, longitude;
int latudeg, longudeg;
@@ -207,12 +230,12 @@ bool gpsHasChanged(struct dive *dive, struct dive *master, const QString& gps_te
return true;
}
-QList< int > getDivesInTrip ( dive_trip_t* trip )
+QList<int> getDivesInTrip(dive_trip_t *trip)
{
QList<int> ret;
- for(int i = 0; i < dive_table.nr; i++){
+ for (int i = 0; i < dive_table.nr; i++) {
struct dive *d = get_dive(i);
- if (d->divetrip == trip){
+ if (d->divetrip == trip) {
ret.push_back(get_divenr(d));
}
}