Skip to content

Commit

Permalink
Merge pull request opengribs#149 from did-g/cleanup_c++11
Browse files Browse the repository at this point in the history
Cleanup c++11
  • Loading branch information
norulz authored Nov 17, 2018
2 parents 7508e37 + e78c0c2 commit aca4d12
Show file tree
Hide file tree
Showing 78 changed files with 458 additions and 546 deletions.
4 changes: 2 additions & 2 deletions src/BoardPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void BoardPanel::showDataPointInfo (

}
//===================================================================================
QString BoardPanel::formatWave (QString title, float ht, float dir, float per)
QString BoardPanel::formatWave (const QString &title, float ht, float dir, float per)
{
QString r = title;

Expand Down Expand Up @@ -560,7 +560,7 @@ void BoardPanel::createMenuPopup ()
addAction (tr("Waves"), "boardPanelWaves", cellWaves);
}
//-------------------------------------------------------
void BoardPanel::addAction (QString title, QString settingName,
void BoardPanel::addAction (const QString& title, const QString& settingName,
BoardPanelCell *cell)
{
QAction *ac = new QAction (title, menuPopup);
Expand Down
4 changes: 2 additions & 2 deletions src/BoardPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class BoardPanel : public QDockWidget

void mouseReleaseEvent (QMouseEvent *);
void createMenuPopup ();
void addAction (QString title, QString settingName,
void addAction (const QString& title, const QString& settingName,
BoardPanelCell *cell);

QHash <QAction*,QString> hashActionSettingName;
Expand Down Expand Up @@ -147,7 +147,7 @@ class BoardPanel : public QDockWidget
//QLabel lbWaves_pek;
QLabel lbWaves_wcap;

QString formatWave (QString title, float ht, float dir, float per);
QString formatWave (const QString &title, float ht, float dir, float per);
Altitude lastDefinedTempAltitude;
};

Expand Down
8 changes: 4 additions & 4 deletions src/ColorScale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ QRgb ColorScale::getColor (double v, bool smooth)
}

//--------------------------------------------
bool ColorScale::readFile (QString filename, double kv, double offset)
bool ColorScale::readFile (const QString& filename, double kv, double offset)
{
ColorElement *ea, *eb;
char buf [1000];
Expand Down Expand Up @@ -127,14 +127,14 @@ bool ColorScale::readFile (QString filename, double kv, double offset)
void ColorScale::dbg ()
{
DBG("--- ColorScale (sz=%d) ---", (int)colors.size());
for (uint i=0; i<colors.size(); i++) {
colors[i] -> dbg();
for (auto & color : colors) {
color -> dbg();
}
}
//--------------------------------------------
void ColorScale::addColor (ColorElement *color)
{
if (color && ( colors.size()==0
if (color && ( colors.empty()
|| color->vmin==colors[colors.size()-1]->vmax)
) {
colors.push_back (color);
Expand Down
2 changes: 1 addition & 1 deletion src/ColorScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ColorScale {
ColorScale ();
~ColorScale ();

bool readFile (QString filename, double kv, double offset);
bool readFile (const QString& filename, double kv, double offset);
void addColor (ColorElement *color);
QRgb getColor (double v, bool smooth);
void dbg ();
Expand Down
6 changes: 3 additions & 3 deletions src/DataColors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ QColor DataColors::getContrastedColor (const QColor &base)
{
double gris = 0.30*base.redF() + 0.59*base.greenF() + 0.11*base.blueF();
if (gris < 0.35)
return QColor(230,225,200);
else if (gris < 0.45)
return QColor(240,235,210);
return {230,225,200};
if (gris < 0.45)
return {240,235,210};

return Qt::black;
}
Expand Down
6 changes: 3 additions & 3 deletions src/DateChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ DateChooserPopup::DateChooserPopup (QWidget *parent)
setAutoFillBackground (true);
}
//-------------------------------------------------
void DateChooserPopup::setText (QString txt)
void DateChooserPopup::setText (const QString& txt)
{
label.setText(txt);
}
Expand Down Expand Up @@ -158,13 +158,13 @@ void DateChooser::setListDates (std::set<time_t> * setDates,
nbDates = 0;
this->currentDate = currentDate;
int current = 0;
if (setDates && setDates->size()>0)
if (setDates && !setDates->empty())
{
nbDates = setDates->size();
tabDates = new time_t [nbDates];
int i=0;
std::set<time_t>::iterator it;
for (it=setDates->begin(); it!=setDates->end(); it++, i++) {
for (it=setDates->begin(); it!=setDates->end(); ++it, i++) {
tabDates [i] = *it;
if (*it == currentDate)
current = i;
Expand Down
2 changes: 1 addition & 1 deletion src/DateChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DateChooserPopup : public QWidget
public:
DateChooserPopup (QWidget *parent);
void setDate (time_t date);
void setText (QString txt);
void setText (const QString& txt);

private:
QLabel label;
Expand Down
4 changes: 2 additions & 2 deletions src/DialogBoxColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

//==============================================================================
DialogBoxColumn::DialogBoxColumn (QWidget *parent,
int nbColumn, QString windowTitle, QString title, int nbButtons)
int nbColumn, const QString& windowTitle, const QString& title, int nbButtons)
: DialogBoxBase (parent)
{
setWindowTitle (windowTitle);
Expand Down Expand Up @@ -110,7 +110,7 @@ void DialogBoxColumn::slotBtCancel()
}

//-----------------------------------------------------------------------------
void DialogBoxColumn::addLabeledWidget (int col, QString label, QWidget *widget)
void DialogBoxColumn::addLabeledWidget (int col, const QString& label, QWidget *widget)
{
if (col>=0 && col < nbColumn)
{
Expand Down
4 changes: 2 additions & 2 deletions src/DialogBoxColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class DialogBoxColumn : public DialogBoxBase

DialogBoxColumn ( QWidget *parent,
int nbColumn,
QString windowTitle, QString title,
const QString& windowTitle, const QString& title,
int nbButtons=2 );

bool isAccepted () {return accepted;}

protected :
void addLabeledWidget (int column, QString label, QWidget *widget);
void addLabeledWidget (int column, const QString& label, QWidget *widget);

private slots:
void slotBtOK();
Expand Down
2 changes: 1 addition & 1 deletion src/DialogFonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

//==============================================================================
//==============================================================================
FontSelector::FontSelector (FontCode code, QString txtlabel, QWidget *parent)
FontSelector::FontSelector (FontCode code, const QString& txtlabel, QWidget *parent)
: QWidget(parent)
{
this->code = code;
Expand Down
2 changes: 1 addition & 1 deletion src/DialogFonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
class FontSelector : public QWidget
{ Q_OBJECT
public:
FontSelector (FontCode code, QString txtlabel, QWidget *parent);
FontSelector (FontCode code, const QString& txtlabel, QWidget *parent);

FontCode getFontCode() { return code; }
QFont getFont() { return font; }
Expand Down
4 changes: 2 additions & 2 deletions src/DialogGraphicsParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
//===========================================================================
// DialogGraphicsParams
//===========================================================================
DialogChooseLang::DialogChooseLang (QWidget *parent, QString defaultlang)
DialogChooseLang::DialogChooseLang (QWidget *parent, const QString& defaultlang)
: DialogBoxColumn ( parent, 1,
"Welcome to XyGrib",
"Choose your language",
Expand Down Expand Up @@ -118,7 +118,7 @@ QString DialogChooseLang::getLanguage ()
return "en";
}
//--------------------------------------------------------------------------------
QRadioButton * DialogChooseLang::addLanguage (QString name, QString iconfile)
QRadioButton * DialogChooseLang::addLanguage (const QString& name, const QString& iconfile)
{
QRadioButton *bt = new QRadioButton (name, this);
assert (bt);
Expand Down
4 changes: 2 additions & 2 deletions src/DialogGraphicsParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
class DialogChooseLang : public DialogBoxColumn
{ Q_OBJECT
public:
DialogChooseLang (QWidget *parent, QString defaultlang);
DialogChooseLang (QWidget *parent, const QString& defaultlang);
QString getLanguage ();

private:
QRadioButton * addLanguage (QString name, QString iconfile);
QRadioButton * addLanguage (const QString& name, const QString& iconfile);
QButtonGroup *btGroup;

QRadioButton *bt_de;
Expand Down
4 changes: 2 additions & 2 deletions src/DialogLoadGRIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ DialogLoadGRIB::~DialogLoadGRIB()
}

//----------------------------------------------------
void DialogLoadGRIB::slotGribMessage(QString msg)
void DialogLoadGRIB::slotGribMessage(const QString& msg)
{
labelMsg->setText(msg);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ void DialogLoadGRIB::slotGribDataReceived (QByteArray *content, QString fileName
}

//----------------------------------------------------
void DialogLoadGRIB::slotGribLoadError (QString error)
void DialogLoadGRIB::slotGribLoadError (const QString& error)
{
setCursor(oldcursor);
if (! loadInProgress)
Expand Down
4 changes: 2 additions & 2 deletions src/DialogLoadGRIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class DialogLoadGRIB : public DialogBoxBase
void slotBtProxy();
void slotGribDataReceived(QByteArray *content, QString fileName);
void slotGribReadProgress(int step, int done, int total);
void slotGribLoadError(QString error);
void slotGribMessage(QString msg);
void slotGribLoadError(const QString& error);
void slotGribMessage(const QString& msg);
void slotGribStartLoadData();
void slotAtmModelSettings();
void slotWaveModelSettings();
Expand Down
4 changes: 2 additions & 2 deletions src/DialogProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ void DialogProxy::slotUseProxyChanged ()
lineProxyUserName->setEnabled (usep);
lineProxyUserPassword->setEnabled (usep);
cbProxyType->setEnabled (usep);
for (int i=0; i < listProxyLabels.size(); i++) {
listProxyLabels[i]->setEnabled (usep);
for (auto & listProxyLabel : listProxyLabels) {
listProxyLabel->setEnabled (usep);
}
}
//-------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions src/DialogSelectMetar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ void DialogSelectMetar::make_metar_tree ()
QTreeWidgetItem *itemCountry = nullptr;
QTreeWidgetItem *itemState = nullptr;
QTreeWidgetItem *itemRoot = nullptr;
for (int i=0; i < allAirports.size(); i++)
for (auto a : allAirports)
{
Airport a = allAirports.at(i);
if (curCountry != a.country) {
if (curCountry != a.country) {
curCountry = a.country;
itemCountry = new QTreeWidgetItem (treeWidget);
assert (itemCountry);
Expand Down
6 changes: 3 additions & 3 deletions src/FileLoaderGRIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ void FileLoaderGRIB::stop ()

//-------------------------------------------------------------------------------
void FileLoaderGRIB::getGribFile(
QString atmModel,
const QString& atmModel,
float x0, float x1, float y0, float y1,
float resolution, int interval, int days,
QString cycle,
const QString& cycle,
bool wind, bool pressure, bool rain,
bool cloud, bool temp, bool humid, bool isotherm0,
bool snowDepth,
Expand All @@ -87,7 +87,7 @@ void FileLoaderGRIB::getGribFile(
bool altitudeData925,
bool skewTData,
bool GUSTsfc,
QString wvModel,
const QString& wvModel,
bool sgwh,
bool swell,
bool wwav
Expand Down
6 changes: 3 additions & 3 deletions src/FileLoaderGRIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class FileLoaderGRIB : public QObject, FileLoader
FileLoaderGRIB (QNetworkAccessManager *manager, QWidget *parent);
~FileLoaderGRIB();

void getGribFile( QString atmModel,
void getGribFile( const QString& atmModel,
float x0, float y0, float x1, float y1,
float resolution, int interval, int days,
QString cycle,
const QString& cycle,
bool wind, bool pressure, bool rain,
bool cloud, bool temp, bool humid, bool isotherm0,
bool snowDepth,
Expand All @@ -58,7 +58,7 @@ class FileLoaderGRIB : public QObject, FileLoader
bool altitudeData925,
bool skewTData,
bool GUSTsfc,
QString wvModel,
const QString& wvModel,
bool sgwh,
bool swell,
bool wwav
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/ColorEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ColorTestZone::paintEvent(QPaintEvent *)


//=================================================================================
ColorEditorWidget::ColorEditorWidget( QWidget *parent, QColor color, QColor defaultColor)
ColorEditorWidget::ColorEditorWidget( QWidget *parent, const QColor &color, const QColor &defaultColor)
: QWidget(parent)
{
setupUi(this);
Expand Down
10 changes: 5 additions & 5 deletions src/GUI/ColorEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ class /*QDESIGNER_WIDGET_EXPORT*/ ColorEditorWidget
{
Q_OBJECT
public:
ColorEditorWidget(QWidget *parent = 0,
QColor color = Qt::white,
QColor defaultColor = Qt::white );
ColorEditorWidget(QWidget *parent = 0,
const QColor &color = Qt::white,
const QColor &defaultColor = Qt::white );

QColor getColor()
{return testZone->getColor();}

void setColor(QColor c)
void setColor(const QColor &c)
{testZone->setColor(c);}

void setDefaultColor(QColor c)
void setDefaultColor(const QColor &c)
{defaultColor = c;}

private slots:
Expand Down
7 changes: 5 additions & 2 deletions src/GUI/LineEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ LineTestZone::LineTestZone(QWidget *parent)
lineColor = Qt::yellow;
}

void LineTestZone::setLineColor(const QColor &c)
{lineColor=c; update();}

//----------------------------------------------------------------------
void LineTestZone::mouseReleaseEvent(QMouseEvent *)
{
Expand Down Expand Up @@ -41,8 +44,8 @@ void LineTestZone::paintEvent(QPaintEvent *)
//=================================================================================
LineEditorWidget::LineEditorWidget (
QWidget *parent,
double width, QColor color,
double defaultWidth, QColor defaultColor,
double width, const QColor &color,
double defaultWidth, const QColor &defaultColor,
double minWidth, double maxWidth
)
: QWidget(parent)
Expand Down
19 changes: 9 additions & 10 deletions src/GUI/LineEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class LineTestZone : public QWidget
{return lineWidth;}

public slots:
void setLineColor(QColor c)
{lineColor=c; update();}
void setLineColor(const QColor &c);
void setLineWidth(double w)
{lineWidth=w; update();}

Expand All @@ -43,14 +42,14 @@ class /*QDESIGNER_WIDGET_EXPORT*/ LineEditorWidget
Q_OBJECT
public:
LineEditorWidget
( QWidget *parent = 0,
double width = 1.0,
QColor color = Qt::black,
double defaultWidth = 1.0,
QColor defaultColor = Qt::black,
double minWidth = 0.2,
double maxWidth = 6
);
(QWidget *parent = 0,
double width = 1.0,
const QColor &color = Qt::black,
double defaultWidth = 1.0,
const QColor &defaultColor = Qt::black,
double minWidth = 0.2,
double maxWidth = 6
);

QColor getLineColor()
{return testZone->getLineColor();}
Expand Down
4 changes: 2 additions & 2 deletions src/GUI/PositionEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ PositionEditorWidget::PositionEditorWidget
( QWidget *parent,
double lat,
double lon,
QString userOrient_lat, /* "Auto" "North+" "South+" */
QString userOrient_lon /* "Auto" "East+" "West+" */
const QString & userOrient_lat, /* "Auto" "North+" "South+" */
const QString & userOrient_lon /* "Auto" "East+" "West+" */
)
: QWidget(parent)
{
Expand Down
Loading

0 comments on commit aca4d12

Please sign in to comment.