The never ending, futile fight for whitespace consistency

I just need to write a tool that does this...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-05-22 21:25:05 -07:00
parent 7757363953
commit 115e5e5fbc
16 changed files with 116 additions and 130 deletions

View file

@ -194,9 +194,9 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
int used = 0; int used = 0;
int first_gas_explicit = 0; int first_gas_explicit = 0;
while (dc){ while (dc) {
struct event *event = dc->events; struct event *event = dc->events;
while(event){ while (event) {
if (event->value) { if (event->value) {
if (event->name && !strcmp(event->name, "gaschange")) { if (event->name && !strcmp(event->name, "gaschange")) {
unsigned int event_he = event->value >> 16; unsigned int event_he = event->value >> 16;
@ -204,7 +204,7 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
if (event->time.seconds < 30) if (event->time.seconds < 30)
first_gas_explicit = 1; first_gas_explicit = 1;
if (is_air(o2, he)){ if (is_air(o2, he)) {
if (is_air(event_o2 * 10, event_he * 10)) if (is_air(event_o2 * 10, event_he * 10))
used = 1; used = 1;
} }

View file

@ -34,7 +34,7 @@ void DiveListView::reload()
m->setSourceModel(new DiveTripModel(this)); m->setSourceModel(new DiveTripModel(this));
sortByColumn(0, Qt::DescendingOrder); sortByColumn(0, Qt::DescendingOrder);
QModelIndex firstDiveOrTrip = m->index(0,0); QModelIndex firstDiveOrTrip = m->index(0,0);
if (firstDiveOrTrip.isValid()){ if (firstDiveOrTrip.isValid()) {
if (m->index(0,0, firstDiveOrTrip).isValid()) if (m->index(0,0, firstDiveOrTrip).isValid())
setCurrentIndex(m->index(0,0, firstDiveOrTrip)); setCurrentIndex(m->index(0,0, firstDiveOrTrip));
else else
@ -42,12 +42,12 @@ void DiveListView::reload()
} }
// Populate the context menu of the headers that will show // Populate the context menu of the headers that will show
// the menu to show / hide columns. // the menu to show / hide columns.
if (!header()->actions().size()){ if (!header()->actions().size()) {
QAction *visibleAction = new QAction("Visible:", header()); QAction *visibleAction = new QAction("Visible:", header());
header()->addAction(visibleAction); header()->addAction(visibleAction);
QSettings s; QSettings s;
s.beginGroup("DiveListColumnState"); s.beginGroup("DiveListColumnState");
for(int i = 0; i < model()->columnCount(); i++){ for(int i = 0; i < model()->columnCount(); i++) {
QString title = QString("show %1").arg(model()->headerData( i, Qt::Horizontal).toString()); QString title = QString("show %1").arg(model()->headerData( i, Qt::Horizontal).toString());
QAction *a = new QAction(title, header()); QAction *a = new QAction(title, header());
a->setCheckable(true); a->setCheckable(true);
@ -103,7 +103,7 @@ void DiveListView::mouseReleaseEvent(QMouseEvent* event)
void DiveListView::keyPressEvent(QKeyEvent* event) void DiveListView::keyPressEvent(QKeyEvent* event)
{ {
if(event->modifiers()) if (event->modifiers())
mouseClickSelection = true; mouseClickSelection = true;
QTreeView::keyPressEvent(event); QTreeView::keyPressEvent(event);
} }
@ -124,7 +124,7 @@ void DiveListView::currentChanged(const QModelIndex& current, const QModelIndex&
if (!dive) { // it's a trip! select first child. if (!dive) { // it's a trip! select first child.
dive = (struct dive*) model->data(current.child(0,0), TreeItemDT::DIVE_ROLE).value<void*>(); dive = (struct dive*) model->data(current.child(0,0), TreeItemDT::DIVE_ROLE).value<void*>();
selectedDive = get_divenr(dive); selectedDive = get_divenr(dive);
}else{ } else {
selectedDive = get_divenr(dive); selectedDive = get_divenr(dive);
} }
if (selectedDive == selected_dive) if (selectedDive == selected_dive)

View file

@ -69,11 +69,11 @@ void DownloadFromDCWidget::fill_computer_list()
const char *vendor = dc_descriptor_get_vendor(descriptor); const char *vendor = dc_descriptor_get_vendor(descriptor);
const char *product = dc_descriptor_get_product(descriptor); const char *product = dc_descriptor_get_product(descriptor);
if (!vendorList.contains( vendor )) if (!vendorList.contains(vendor))
vendorList.append( vendor ); vendorList.append(vendor);
if( !productList[vendor].contains( product )) if (!productList[vendor].contains(product))
productList[vendor].push_back( product ); productList[vendor].push_back(product);
descriptorLookup[QString(vendor) + QString(product)] = descriptor; descriptorLookup[QString(vendor) + QString(product)] = descriptor;
} }
@ -91,11 +91,11 @@ void DownloadFromDCWidget::fill_computer_list()
mydescriptor->type = DC_FAMILY_NULL; mydescriptor->type = DC_FAMILY_NULL;
mydescriptor->model = 0; mydescriptor->model = 0;
if(!vendorList.contains( "Uemis")) if (!vendorList.contains("Uemis"))
vendorList.append("Uemis"); vendorList.append("Uemis");
if( !productList["Uemis"].contains( "Zurich" )) if (!productList["Uemis"].contains("Zurich"))
productList["Uemis"].push_back( "Zurich" ); productList["Uemis"].push_back("Zurich");
descriptorLookup[QString("UemisZurich")] = (dc_descriptor_t *)mydescriptor; descriptorLookup[QString("UemisZurich")] = (dc_descriptor_t *)mydescriptor;
} }
@ -103,7 +103,7 @@ void DownloadFromDCWidget::fill_computer_list()
void DownloadFromDCWidget::on_cancel_clicked() void DownloadFromDCWidget::on_cancel_clicked()
{ {
import_thread_cancelled = true; import_thread_cancelled = true;
if(thread){ if (thread) {
thread->wait(); thread->wait();
thread->deleteLater(); thread->deleteLater();
thread = 0; thread = 0;
@ -119,7 +119,7 @@ void DownloadFromDCWidget::on_ok_clicked()
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->progressBar->show(); ui->progressBar->show();
if(thread){ if (thread) {
thread->deleteLater(); thread->deleteLater();
} }
@ -159,7 +159,7 @@ void InterfaceThread::run()
DownloadThread *download = new DownloadThread(data); DownloadThread *download = new DownloadThread(data);
download->start(); download->start();
while(download->isRunning()){ while (download->isRunning()) {
msleep(200); msleep(200);
updateInterface(progress_bar_fraction *100); updateInterface(progress_bar_fraction *100);
} }

View file

@ -15,8 +15,8 @@ struct device_data_t;
class DownloadThread : public QThread{ class DownloadThread : public QThread{
Q_OBJECT Q_OBJECT
public: public:
explicit DownloadThread(device_data_t* data); explicit DownloadThread(device_data_t* data);
virtual void run(); virtual void run();
private: private:
device_data_t *data; device_data_t *data;
}; };
@ -25,7 +25,7 @@ class InterfaceThread : public QThread{
Q_OBJECT Q_OBJECT
public: public:
InterfaceThread(QObject *parent, device_data_t *data) ; InterfaceThread(QObject *parent, device_data_t *data) ;
virtual void run(); virtual void run();
Q_SIGNALS: Q_SIGNALS:
void updateInterface(int value); void updateInterface(int value);
@ -37,7 +37,7 @@ class QStringListModel;
class DownloadFromDCWidget : public QDialog{ class DownloadFromDCWidget : public QDialog{
Q_OBJECT Q_OBJECT
public: public:
explicit DownloadFromDCWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); explicit DownloadFromDCWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
public slots: public slots:
void on_ok_clicked(); void on_ok_clicked();

View file

@ -21,33 +21,33 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
setMapThemeId("earth/bluemarble/bluemarble.dgml"); setMapThemeId("earth/bluemarble/bluemarble.dgml");
//setMapThemeId("earth/openstreetmap/openstreetmap.dgml"); //setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
setProjection( Marble::Spherical ); setProjection(Marble::Spherical);
setAnimationsEnabled(true); setAnimationsEnabled(true);
setShowClouds( false ); setShowClouds(false);
setShowBorders( false ); setShowBorders(false);
setShowPlaces( true ); setShowPlaces(true);
setShowCrosshairs( false ); setShowCrosshairs(false);
setShowGrid( false ); setShowGrid(false);
setShowOverviewMap(false); setShowOverviewMap(false);
setShowScaleBar(true); setShowScaleBar(true);
Q_FOREACH( AbstractFloatItem * floatItem, floatItems() ){ Q_FOREACH(AbstractFloatItem * floatItem, floatItems()) {
if ( floatItem && floatItem->nameId() == "compass" ) { if (floatItem && floatItem->nameId() == "compass") {
floatItem->setPosition( QPoint( 10, 10 ) ); floatItem->setPosition(QPoint(10, 10));
floatItem->setContentSize( QSize( 50, 50 ) ); floatItem->setContentSize(QSize(50, 50));
} }
} }
} }
void GlobeGPS::reload() void GlobeGPS::reload()
{ {
if (loadedDives){ if (loadedDives) {
model()->treeModel()->removeDocument(loadedDives); model()->treeModel()->removeDocument(loadedDives);
delete loadedDives; delete loadedDives;
} }
if (editingDiveCoords){ if (editingDiveCoords) {
editingDiveCoords = 0; editingDiveCoords = 0;
} }
@ -61,22 +61,22 @@ void GlobeGPS::reload()
for_each_dive(idx, dive) { for_each_dive(idx, dive) {
if (dive_has_gps_location(dive)) { if (dive_has_gps_location(dive)) {
// don't add dive locations twice. // don't add dive locations twice.
if( diveLocations.contains( QString(dive->location))) if (diveLocations.contains(QString(dive->location)))
continue; continue;
diveLocations.append( QString(dive->location) ); diveLocations.append(QString(dive->location));
GeoDataPlacemark *place = new GeoDataPlacemark( dive->location ); GeoDataPlacemark *place = new GeoDataPlacemark(dive->location);
place->setCoordinate(dive->longitude.udeg / 1000000.0,dive->latitude.udeg / 1000000.0 , 0, GeoDataCoordinates::Degree ); place->setCoordinate(dive->longitude.udeg / 1000000.0,dive->latitude.udeg / 1000000.0 , 0, GeoDataCoordinates::Degree);
loadedDives->append( place ); loadedDives->append(place);
} }
} }
model()->treeModel()->addDocument( loadedDives ); model()->treeModel()->addDocument(loadedDives);
} }
void GlobeGPS::centerOn(dive* dive) void GlobeGPS::centerOn(dive* dive)
{ {
// dive has changed, if we had the 'editingDive', hide it. // dive has changed, if we had the 'editingDive', hide it.
if(messageWidget->isVisible() && (!dive || dive_has_gps_location(dive))){ if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive))) {
messageWidget->animatedHide(); messageWidget->animatedHide();
} }
@ -85,7 +85,7 @@ void GlobeGPS::centerOn(dive* dive)
qreal longitude = dive->longitude.udeg / 1000000.0; qreal longitude = dive->longitude.udeg / 1000000.0;
qreal latitude = dive->latitude.udeg / 1000000.0; qreal latitude = dive->latitude.udeg / 1000000.0;
if (!longitude || !latitude){ if (!longitude || !latitude) {
prepareForGetDiveCoordinates(dive); prepareForGetDiveCoordinates(dive);
return; return;
} }
@ -107,12 +107,12 @@ void GlobeGPS::prepareForGetDiveCoordinates(dive* dive)
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
{ {
// convert to degrees if in radian. // convert to degrees if in radian.
if (unit == GeoDataCoordinates::Radian){ if (unit == GeoDataCoordinates::Radian) {
lon = lon * 180 / M_PI; lon = lon * 180 / M_PI;
lat = lat * 180 / M_PI; lat = lat * 180 / M_PI;
} }
if (!editingDiveCoords){ if (!editingDiveCoords) {
return; return;
} }
@ -127,7 +127,7 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
void GlobeGPS::mousePressEvent(QMouseEvent* event) void GlobeGPS::mousePressEvent(QMouseEvent* event)
{ {
qreal lat, lon; qreal lat, lon;
if (editingDiveCoords && geoCoordinates(event->pos().x(), event->pos().y(), lon,lat, GeoDataCoordinates::Radian)){ if (editingDiveCoords && geoCoordinates(event->pos().x(), event->pos().y(), lon,lat, GeoDataCoordinates::Radian)) {
changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Radian); changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Radian);
} }
} }

View file

@ -12,7 +12,7 @@ struct dive;
class GlobeGPS : public MarbleWidget{ class GlobeGPS : public MarbleWidget{
Q_OBJECT Q_OBJECT
void prepareForGetDiveCoordinates(struct dive* dive); void prepareForGetDiveCoordinates(struct dive* dive);
public: public:
using MarbleWidget::centerOn; using MarbleWidget::centerOn;
GlobeGPS(QWidget *parent); GlobeGPS(QWidget *parent);
@ -20,12 +20,12 @@ public:
void centerOn(struct dive* dive); void centerOn(struct dive* dive);
protected: protected:
virtual void mousePressEvent(QMouseEvent* event); virtual void mousePressEvent(QMouseEvent* event);
private: private:
GeoDataDocument *loadedDives; GeoDataDocument *loadedDives;
QStringList diveLocations; QStringList diveLocations;
struct dive* editingDiveCoords; struct dive* editingDiveCoords;
KMessageWidget* messageWidget; KMessageWidget* messageWidget;
public Q_SLOTS: public Q_SLOTS:

View file

@ -79,10 +79,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->model(), SLOT(remove(QModelIndex))); connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->model(), SLOT(remove(QModelIndex)));
connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex))); connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex)));
ui->cylinders->setColumnWidth( CylindersModel::REMOVE, 24); ui->cylinders->setColumnWidth(CylindersModel::REMOVE, 24);
ui->cylinders->horizontalHeader()->setResizeMode (CylindersModel::REMOVE , QHeaderView::Fixed); ui->cylinders->horizontalHeader()->setResizeMode (CylindersModel::REMOVE , QHeaderView::Fixed);
ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate()); ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
ui->weights->setColumnWidth( WeightModel::REMOVE, 24); ui->weights->setColumnWidth(WeightModel::REMOVE, 24);
ui->cylinders->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed); ui->cylinders->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
} }
@ -90,19 +90,19 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
void MainTab::resizeEvent(QResizeEvent* event) void MainTab::resizeEvent(QResizeEvent* event)
{ {
if (ui->cylindersGroup->isVisible()) if (ui->cylindersGroup->isVisible())
addCylinder->setGeometry( ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24); addCylinder->setGeometry(ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24);
if (ui->weightGroup->isVisible()) if (ui->weightGroup->isVisible())
addWeight->setGeometry( ui->weightGroup->contentsRect().width() - 30, 2, 24,24); addWeight->setGeometry(ui->weightGroup->contentsRect().width() - 30, 2, 24,24);
QTabWidget::resizeEvent(event); QTabWidget::resizeEvent(event);
} }
void MainTab::showEvent(QShowEvent* event) void MainTab::showEvent(QShowEvent* event)
{ {
QTabWidget::showEvent(event); QTabWidget::showEvent(event);
addCylinder->setGeometry( ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24); addCylinder->setGeometry(ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24);
addWeight->setGeometry( ui->weightGroup->contentsRect().width() - 30, 2, 24,24); addWeight->setGeometry(ui->weightGroup->contentsRect().width() - 30, 2, 24,24);
} }

View file

@ -38,8 +38,8 @@ public:
void reload(); void reload();
bool eventFilter(QObject* , QEvent*); bool eventFilter(QObject* , QEvent*);
virtual void resizeEvent(QResizeEvent* ); virtual void resizeEvent(QResizeEvent*);
virtual void showEvent(QShowEvent* ); virtual void showEvent(QShowEvent*);
public Q_SLOTS: public Q_SLOTS:
void addCylinder_clicked(); void addCylinder_clicked();

View file

@ -405,7 +405,7 @@ void MainWindow::readSettings()
#if ONCE_WE_HAVE_MAPS #if ONCE_WE_HAVE_MAPS
v = settings.value(QString_int("map_provider")); v = settings.value(QString_int("map_provider"));
if(v.isValid()) if (v.isValid())
prefs.map_provider = v.toInt(); prefs.map_provider = v.toInt();
#endif #endif
} }

View file

@ -51,15 +51,14 @@ QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem& option, const QM
QWidget* TankInfoDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const QWidget* TankInfoDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{ {
QComboBox *comboDelegate = new QComboBox(parent); QComboBox *comboDelegate = new QComboBox(parent);
TankInfoModel *model = new TankInfoModel; TankInfoModel *model = new TankInfoModel;
QString data = index.model()->data(index, Qt::DisplayRole).toString(); QString data = index.model()->data(index, Qt::DisplayRole).toString();
comboDelegate->setModel(model); comboDelegate->setModel(model);
int i; int i;
for(i = 0; i < model->rowCount(); i++){ for (i = 0; i < model->rowCount(); i++) {
if (model->data(model->index(i,0), Qt::DisplayRole).toString() == data){ if (model->data(model->index(i,0), Qt::DisplayRole).toString() == data)
break; break;
}
} }
if (i != model->rowCount()) if (i != model->rowCount())
comboDelegate->setCurrentIndex(i); comboDelegate->setCurrentIndex(i);

View file

@ -6,9 +6,9 @@
class StarWidgetsDelegate : public QStyledItemDelegate { class StarWidgetsDelegate : public QStyledItemDelegate {
Q_OBJECT Q_OBJECT
public: public:
explicit StarWidgetsDelegate(QWidget* parent = 0); explicit StarWidgetsDelegate(QWidget* parent = 0);
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
private: private:
QWidget *parentWidget; QWidget *parentWidget;
}; };
@ -16,8 +16,8 @@ private:
class TankInfoDelegate : public QStyledItemDelegate{ class TankInfoDelegate : public QStyledItemDelegate{
Q_OBJECT Q_OBJECT
public: public:
explicit TankInfoDelegate(QObject* parent = 0); explicit TankInfoDelegate(QObject* parent = 0);
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
}; };
#endif #endif

View file

@ -103,12 +103,9 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
ret = QString("%1%").arg((cyl->gasmix.he.permille + 5) / 10); ret = QString("%1%").arg((cyl->gasmix.he.permille + 5) / 10);
break; break;
} }
} } else if (role == Qt::DecorationRole) {
if (index.column() == REMOVE)
else if (role == Qt::DecorationRole){
if (index.column() == REMOVE){
ret = QIcon(":trash"); ret = QIcon(":trash");
}
} }
return ret; return ret;
@ -237,7 +234,7 @@ void CylindersModel::setDive(dive* d)
clear(); clear();
int amount = MAX_CYLINDERS; int amount = MAX_CYLINDERS;
for(int i = 0; i < MAX_CYLINDERS; i++){ for(int i = 0; i < MAX_CYLINDERS; i++) {
cylinder_t *cylinder = &d->cylinder[i]; cylinder_t *cylinder = &d->cylinder[i];
if (cylinder_none(cylinder)) { if (cylinder_none(cylinder)) {
amount = i; amount = i;
@ -260,7 +257,7 @@ Qt::ItemFlags CylindersModel::flags(const QModelIndex& index) const
void CylindersModel::remove(const QModelIndex& index) void CylindersModel::remove(const QModelIndex& index)
{ {
if (index.column() != REMOVE){ if (index.column() != REMOVE) {
return; return;
} }
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly. beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
@ -272,7 +269,7 @@ void CylindersModel::remove(const QModelIndex& index)
void WeightModel::remove(const QModelIndex& index) void WeightModel::remove(const QModelIndex& index)
{ {
if (index.column() != REMOVE){ if (index.column() != REMOVE) {
return; return;
} }
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly. beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
@ -312,12 +309,9 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
ret = get_weight_string(ws->weight, TRUE); ret = get_weight_string(ws->weight, TRUE);
break; break;
} }
} } else if (role == Qt::DecorationRole) {
if (index.column() == REMOVE)
else if (role == Qt::DecorationRole){
if (index.column() == REMOVE){
ret = QIcon(":trash"); ret = QIcon(":trash");
}
} }
return ret; return ret;
} }
@ -493,7 +487,7 @@ TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1)
void TankInfoModel::update() void TankInfoModel::update()
{ {
if(rows > -1) { if (rows > -1) {
beginRemoveRows(QModelIndex(), 0, rows); beginRemoveRows(QModelIndex(), 0, rows);
endRemoveRows(); endRemoveRows();
} }
@ -548,7 +542,7 @@ QVariant TreeItemDT::data(int column, int role) const
ret = tr("min"); ret = tr("min");
break; break;
case TEMPERATURE: case TEMPERATURE:
ret = QString("%1%2").arg(UTF8_DEGREE).arg( (get_units()->temperature == units::CELSIUS) ? "C" : "F"); ret = QString("%1%2").arg(UTF8_DEGREE).arg((get_units()->temperature == units::CELSIUS) ? "C" : "F");
break; break;
case TOTALWEIGHT: case TOTALWEIGHT:
ret = (get_units()->weight == units::KG) ? tr("kg") : tr("lbs"); ret = (get_units()->weight == units::KG) ? tr("kg") : tr("lbs");
@ -789,7 +783,7 @@ QVariant DiveTripModel::data(const QModelIndex& index, int role) const
if (!index.isValid()) if (!index.isValid())
return QVariant(); return QVariant();
if (role == Qt::FontRole){ if (role == Qt::FontRole) {
QFont font; QFont font;
font.setPointSizeF(font.pointSizeF() * 0.7); font.setPointSizeF(font.pointSizeF() * 0.7);
return font; return font;

View file

@ -90,7 +90,7 @@ private:
*/ */
struct TreeItemDT { struct TreeItemDT {
Q_DECLARE_TR_FUNCTIONS ( TreeItemDT ); Q_DECLARE_TR_FUNCTIONS (TreeItemDT);
public: public:
enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT,
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, DIVE, COLUMNS }; SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, DIVE, COLUMNS };
@ -102,7 +102,7 @@ public:
return COLUMNS; return COLUMNS;
}; };
virtual QVariant data ( int column, int role ) const; virtual QVariant data (int column, int role) const;
int row() const; int row() const;
QList<TreeItemDT *> children; QList<TreeItemDT *> children;
TreeItemDT *parent; TreeItemDT *parent;

View file

@ -130,8 +130,8 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
defaultPen.setWidth(2); defaultPen.setWidth(2);
defaultPen.setCosmetic(true); defaultPen.setCosmetic(true);
setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
fill_profile_color(); fill_profile_color();
} }
@ -141,20 +141,20 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
if (!toolTip) if (!toolTip)
return; return;
setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom // Scale the view / do the zoom
QPoint toolTipPos = mapFromScene(toolTip->pos()); QPoint toolTipPos = mapFromScene(toolTip->pos());
double scaleFactor = 1.15; double scaleFactor = 1.15;
if(event->delta() > 0 && zoomLevel <= 10) { if (event->delta() > 0 && zoomLevel <= 10) {
scale(scaleFactor, scaleFactor); scale(scaleFactor, scaleFactor);
zoomLevel++; zoomLevel++;
} else if (zoomLevel >= 0) { } else if (zoomLevel >= 0) {
// Zooming out // Zooming out
scale(1.0 / scaleFactor, 1.0 / scaleFactor); scale(1.0 / scaleFactor, 1.0 / scaleFactor);
zoomLevel--; zoomLevel--;
} }
toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y()); toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
} }
void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event) void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
@ -206,7 +206,7 @@ void ProfileGraphicsView::showEvent(QShowEvent* event)
// but the dive was not ploted. // but the dive was not ploted.
// force a replot by modifying the dive // force a replot by modifying the dive
// hold by the view, and issuing a plot. // hold by the view, and issuing a plot.
if (dive){ if (dive) {
dive = 0; dive = 0;
plot(get_dive(selected_dive)); plot(get_dive(selected_dive));
} }
@ -234,7 +234,7 @@ void ProfileGraphicsView::plot(struct dive *d)
dive = d; dive = d;
diveDC = d ? dc : NULL; diveDC = d ? dc : NULL;
if(!isVisible() || !dive){ if (!isVisible() || !dive) {
return; return;
} }
@ -358,7 +358,7 @@ void ProfileGraphicsView::plot(struct dive *d)
QRectF r = scene()->itemsBoundingRect(); QRectF r = scene()->itemsBoundingRect();
scene()->setSceneRect(r.x() - 15, r.y() -15, r.width() + 30, r.height() + 30); scene()->setSceneRect(r.x() - 15, r.y() -15, r.width() + 30, r.height() + 30);
if(zoomLevel == 0){ if (zoomLevel == 0) {
fitInView(sceneRect()); fitInView(sceneRect());
} }
} }
@ -430,7 +430,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->pn2)); from = QPointF(SCALEGC(entry->sec, entry->pn2));
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
if (entry->pn2 < prefs.pp_graphs.pn2_threshold){ if (entry->pn2 < prefs.pp_graphs.pn2_threshold) {
to = QPointF(SCALEGC(entry->sec, entry->pn2)); to = QPointF(SCALEGC(entry->sec, entry->pn2));
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y()); QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
QPen pen(defaultPen); QPen pen(defaultPen);
@ -438,8 +438,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
item->setPen(pen); item->setPen(pen);
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(entry->sec, entry->pn2)); from = QPointF(SCALEGC(entry->sec, entry->pn2));
} }
} }
@ -449,7 +448,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->pn2)); from = QPointF(SCALEGC(entry->sec, entry->pn2));
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
if (entry->pn2 >= prefs.pp_graphs.pn2_threshold){ if (entry->pn2 >= prefs.pp_graphs.pn2_threshold) {
to = QPointF(SCALEGC(entry->sec, entry->pn2)); to = QPointF(SCALEGC(entry->sec, entry->pn2));
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y()); QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
QPen pen(defaultPen); QPen pen(defaultPen);
@ -457,8 +456,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
item->setPen(pen); item->setPen(pen);
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(entry->sec, entry->pn2)); from = QPointF(SCALEGC(entry->sec, entry->pn2));
} }
} }
@ -471,7 +469,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->phe)); from = QPointF(SCALEGC(entry->sec, entry->phe));
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
if (entry->phe < prefs.pp_graphs.phe_threshold){ if (entry->phe < prefs.pp_graphs.phe_threshold) {
to = QPointF(SCALEGC(entry->sec, entry->phe)); to = QPointF(SCALEGC(entry->sec, entry->phe));
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y()); QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
QPen pen(defaultPen); QPen pen(defaultPen);
@ -479,8 +477,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
item->setPen(pen); item->setPen(pen);
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(entry->sec, entry->phe)); from = QPointF(SCALEGC(entry->sec, entry->phe));
} }
} }
@ -490,7 +487,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->phe)); from = QPointF(SCALEGC(entry->sec, entry->phe));
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
if (entry->phe >= prefs.pp_graphs.phe_threshold){ if (entry->phe >= prefs.pp_graphs.phe_threshold) {
to = QPointF(SCALEGC(entry->sec, entry->phe)); to = QPointF(SCALEGC(entry->sec, entry->phe));
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y()); QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
QPen pen(defaultPen); QPen pen(defaultPen);
@ -498,8 +495,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
item->setPen(pen); item->setPen(pen);
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(entry->sec, entry->phe)); from = QPointF(SCALEGC(entry->sec, entry->phe));
} }
} }
@ -510,7 +506,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->po2)); from = QPointF(SCALEGC(entry->sec, entry->po2));
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
if (entry->po2 < prefs.pp_graphs.po2_threshold){ if (entry->po2 < prefs.pp_graphs.po2_threshold) {
to = QPointF(SCALEGC(entry->sec, entry->po2)); to = QPointF(SCALEGC(entry->sec, entry->po2));
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y()); QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
QPen pen(defaultPen); QPen pen(defaultPen);
@ -518,8 +514,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
item->setPen(pen); item->setPen(pen);
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(entry->sec, entry->po2)); from = QPointF(SCALEGC(entry->sec, entry->po2));
} }
} }
@ -529,14 +524,13 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->po2)); from = QPointF(SCALEGC(entry->sec, entry->po2));
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
if (entry->po2 >= prefs.pp_graphs.po2_threshold){ if (entry->po2 >= prefs.pp_graphs.po2_threshold) {
to = QPointF(SCALEGC(entry->sec, entry->po2)); to = QPointF(SCALEGC(entry->sec, entry->po2));
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y()); QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
item->setPen(QPen(c)); item->setPen(QPen(c));
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(entry->sec, entry->po2)); from = QPointF(SCALEGC(entry->sec, entry->po2));
} }
} }
@ -806,7 +800,7 @@ void ProfileGraphicsView::plot_events(struct divecomputer *dc)
{ {
struct event *event = dc->events; struct event *event = dc->events;
// if (gc->printer){ // if (gc->printer) {
// return; // return;
// } // }
@ -1130,7 +1124,7 @@ QGraphicsSimpleTextItem *ProfileGraphicsView::plot_text(text_render_options_t *t
item->setBrush(QBrush(profile_color[tro->color].first())); item->setBrush(QBrush(profile_color[tro->color].first()));
item->setFlag(QGraphicsItem::ItemIgnoresTransformations); item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
if(!parent) if (!parent)
scene()->addItem(item); scene()->addItem(item);
return item; return item;
} }
@ -1168,8 +1162,7 @@ void ProfileGraphicsView::plot_temperature_profile()
item->setPen(pen); item->setPen(pen);
scene()->addItem(item); scene()->addItem(item);
from = to; from = to;
} } else {
else{
from = QPointF(SCALEGC(sec, mkelvin)); from = QPointF(SCALEGC(sec, mkelvin));
} }
last = mkelvin; last = mkelvin;
@ -1292,7 +1285,7 @@ void ToolTipItem::collapse()
void ToolTipItem::expand() void ToolTipItem::expand()
{ {
if (!title){ if (!title) {
return; return;
} }
@ -1309,7 +1302,7 @@ void ToolTipItem::expand()
if (width < title->boundingRect().width() + SPACING*2) if (width < title->boundingRect().width() + SPACING*2)
width = title->boundingRect().width() + SPACING*2; width = title->boundingRect().width() + SPACING*2;
if(height < ICON_SMALL) if (height < ICON_SMALL)
height = ICON_SMALL; height = ICON_SMALL;
nextRectangle.setWidth(width); nextRectangle.setWidth(width);

View file

@ -68,9 +68,9 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event); void wheelEvent(QWheelEvent* event);
void showEvent(QShowEvent* event); void showEvent(QShowEvent* event);
private: private:
void plot_depth_profile(); void plot_depth_profile();

View file

@ -26,7 +26,7 @@ int StarWidget::currentStars() const
void StarWidget::mouseReleaseEvent(QMouseEvent* event) void StarWidget::mouseReleaseEvent(QMouseEvent* event)
{ {
if (readOnly){ if (readOnly) {
return; return;
} }
@ -65,7 +65,7 @@ StarWidget::StarWidget(QWidget* parent, Qt::WindowFlags f):
QWidget(parent, f), QWidget(parent, f),
current(0) current(0)
{ {
if(!activeStar){ if (!activeStar) {
activeStar = new QPixmap(); activeStar = new QPixmap();
QSvgRenderer render(QString(":star")); QSvgRenderer render(QString(":star"));
QPixmap renderedStar(IMG_SIZE, IMG_SIZE); QPixmap renderedStar(IMG_SIZE, IMG_SIZE);
@ -76,7 +76,7 @@ StarWidget::StarWidget(QWidget* parent, Qt::WindowFlags f):
render.render(&painter, QRectF(0, 0, IMG_SIZE, IMG_SIZE)); render.render(&painter, QRectF(0, 0, IMG_SIZE, IMG_SIZE));
(*activeStar) = renderedStar; (*activeStar) = renderedStar;
} }
if(!inactiveStar){ if (!inactiveStar) {
inactiveStar = new QPixmap(); inactiveStar = new QPixmap();
(*inactiveStar) = grayImage(activeStar); (*inactiveStar) = grayImage(activeStar);
} }