Index: datahandlers/catalogdb.cpp =================================================================== --- datahandlers/catalogdb.cpp +++ datahandlers/catalogdb.cpp @@ -546,7 +546,7 @@ for (; i < lines.size(); ++i) { QString d(lines.at(i)); // current data line - if (d.left(1) != "#") + if (d.at(0) != '#') break; // no longer in header! int idelimiter = d.indexOf("# Delimiter: "); @@ -624,7 +624,7 @@ if (catEpoch == 0.) { bool ok(false); - catEpoch = d.mid(iepoch).toFloat(&ok); + catEpoch = d.midRef(iepoch).toFloat(&ok); if (!ok) { if (showerrs) Index: kstars/auxiliary/colorscheme.h =================================================================== --- kstars/auxiliary/colorscheme.h +++ kstars/auxiliary/colorscheme.h @@ -15,8 +15,7 @@ * * ***************************************************************************/ -#ifndef COLORSCHEME_H_ -#define COLORSCHEME_H_ +#pragma once #include #include @@ -38,56 +37,65 @@ class ColorScheme { public: - /** Constructor. Enter all adjustable colors and their default - * values into the QMap. Also assign the corresponding long names. - */ + /** + * Constructor. Enter all adjustable colors and their default + * values into the QMap. Also assign the corresponding long names. + */ ColorScheme(); /** @return true if the Palette contains the given key name */ bool hasColorNamed(const QString &name) const { return (Palette.contains(name)); } - /** @short Retrieve a color by name. - * @p name the key name of the color to be retrieved. - * @return the requested color, or Qt::white if color name not found. - */ + /** + * @short Retrieve a color by name. + * @p name the key name of the color to be retrieved. + * @return the requested color, or Qt::white if color name not found. + */ QColor colorNamed(const QString &name) const; - /** @p i the index of the color to retrieve - * @return a color by its index in the QMap - */ + /** + * @p i the index of the color to retrieve + * @return a color by its index in the QMap + */ QColor colorAt(int i) const; - /** @p i the index of the long name to retrieve - * @return the name of the color at index i - */ + /** + * @p i the index of the long name to retrieve + * @return the name of the color at index i + */ QString nameAt(int i) const; - /** @p i the index of the key name to retrieve - * @return the key name of the color at index i - */ + /** + * @p i the index of the key name to retrieve + * @return the key name of the color at index i + */ QString keyAt(int i) const; - /** @return the long name of the color whose key name is given - * @p key the key name identifying the color. - */ + /** + * @return the long name of the color whose key name is given + * @p key the key name identifying the color. + */ QString nameFromKey(const QString &key) const; - /** Change the color with the given key to the given value - * @p key the key-name of the color to be changed - * @p color the new color value - */ + /** + * Change the color with the given key to the given value + * @p key the key-name of the color to be changed + * @p color the new color value + */ void setColor(const QString &key, const QString &color); - /** Load a color scheme from a *.colors file - * @p filename the filename of the color scheme to be loaded. - * @return true if the scheme was successfully loaded - */ + /** + * Load a color scheme from a *.colors file + * @p filename the filename of the color scheme to be loaded. + * @return true if the scheme was successfully loaded + */ bool load(const QString &filename); - /** Save the current color scheme to a *.colors file. - * @p name the filename to create - * @return true if the color scheme is successfully writeen to a file - */ + /** + * Save the current color scheme to a *.colors file. + * @p name the filename to create + * @return true if the color scheme is successfully writeen to a file + */ bool save(const QString &name); /** @return the Filename associated with the color scheme. */ @@ -111,36 +119,39 @@ /** @return the star color intensity value used by the color scheme */ int starColorIntensity() const { return StarColorIntensity; } - /**Set the star color mode used by the color scheme - * @p mode the star color mode to use - */ + /** + * Set the star color mode used by the color scheme + * @p mode the star color mode to use + */ void setStarColorMode(int mode); - /**Set the star color intensity value used by the color scheme - * @p intens The star color intensity value - */ + /** + * Set the star color intensity value used by the color scheme + * @p intens The star color intensity value + */ void setStarColorIntensity(int intens); - /**Set the star color mode and intensity value used by the color scheme - * @p mode the star color mode to use - * @p intens The star color intensity value - */ + /** + * Set the star color mode and intensity value used by the color scheme + * @p mode the star color mode to use + * @p intens The star color intensity value + */ void setStarColorModeIntensity(int mode, int intens); /** - * @brief setDarkPalette Set whether the color schemes uses dark palette - * @param enable True to use dark palette. False to use application default palette - */ + * @brief setDarkPalette Set whether the color schemes uses dark palette + * @param enable True to use dark palette. False to use application default palette + */ void setDarkPalette(bool enable); private: /** Append items to all string lists. */ - void appendItem(QString key, QString name, QString def); + void appendItem(const QString &key, const QString &name, const QString &def); - int StarColorMode, StarColorIntensity, DarkPalette; + int StarColorMode { 0 }; + int StarColorIntensity { 0 }; + int DarkPalette { 0 }; QString FileName; QStringList KeyName, Name, Default; QMap Palette; }; - -#endif Index: kstars/auxiliary/colorscheme.cpp =================================================================== --- kstars/auxiliary/colorscheme.cpp +++ kstars/auxiliary/colorscheme.cpp @@ -17,32 +17,20 @@ #include "colorscheme.h" -#include -#include -#include - -#include -#include -#include - -#ifndef KSTARS_LITE -#include -#endif - -#include -#include -#include - +#include "kspaths.h" #include "ksutils.h" #include "Options.h" +#include "auxiliary/ksnotification.h" #include "skyobjects/starobject.h" #ifdef KSTARS_LITE #include "skymaplite.h" #else #include "skyqpainter.h" #endif -#include "kspaths.h" -#include "auxiliary/ksnotification.h" + +#ifndef KSTARS_LITE +#include +#endif ColorScheme::ColorScheme() : FileName() { @@ -102,7 +90,7 @@ DarkPalette = 0; } -void ColorScheme::appendItem(QString key, QString name, QString def) +void ColorScheme::appendItem(const QString &key, const QString &name, const QString &def) { KeyName.append(key); Name.append(name); @@ -180,7 +168,7 @@ if (!ok) { - qDebug() << QString("Unable to load color scheme named %1. Also tried %2.").arg(name).arg(filename); + qDebug() << QString("Unable to load color scheme named %1. Also tried %2.").arg(name, filename); return false; } } Index: kstars/auxiliary/downloadhelper.cpp =================================================================== --- kstars/auxiliary/downloadhelper.cpp +++ kstars/auxiliary/downloadhelper.cpp @@ -30,7 +30,7 @@ QStringList nameFilter("*.fits"); QDir directory(astrometryDataDir); QStringList indexList = directory.entryList(nameFilter); - foreach (QString fileName, indexList) + for (auto& fileName : indexList) { if (fileName.contains(indexSetName.left(10))) { Index: kstars/auxiliary/ksnotification.h =================================================================== --- kstars/auxiliary/ksnotification.h +++ kstars/auxiliary/ksnotification.h @@ -8,17 +8,15 @@ */ -#ifndef KSNotifications_H -#define KSNotifications_H +#pragma once -#include #include +#include + namespace KSNotification { void error(const QString &message, const QString &title = i18n("Error")); void sorry(const QString &message, const QString &title = i18n("Sorry")); void info(const QString &message, const QString &title = i18n("Info")); } - -#endif // KSNotifications_H Index: kstars/auxiliary/ksuserdb.cpp =================================================================== --- kstars/auxiliary/ksuserdb.cpp +++ kstars/auxiliary/ksuserdb.cpp @@ -1477,11 +1477,11 @@ if (pi->city.isEmpty() == false) { if (!query.exec(QString("UPDATE profile SET city='%1',province='%2',country='%3' WHERE id=%4") - .arg(pi->city) - .arg(pi->province) - .arg(pi->country) + .arg(pi->city, pi->province, pi->country) .arg(pi->id))) + { qDebug() << query.lastQuery() << query.lastError().text(); + } } // Update Auto Connect Info @@ -1512,10 +1512,11 @@ { i.next(); if (!query.exec(QString("INSERT INTO driver (label, role, profile) VALUES('%1','%2',%3)") - .arg(i.value()) - .arg(i.key()) + .arg(i.value(), i.key()) .arg(pi->id))) + { qDebug() << query.lastQuery() << query.lastError().text(); + } } /*if (pi->customDrivers.isEmpty() == false && !query.exec(QString("INSERT INTO custom_driver (drivers, profile) VALUES('%1',%2)").arg(pi->customDrivers).arg(pi->id))) Index: kstars/auxiliary/qcustomplot.h =================================================================== --- kstars/auxiliary/qcustomplot.h +++ kstars/auxiliary/qcustomplot.h @@ -136,22 +136,22 @@ namespace QCP { #else -class QCP // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace +class QCP // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUM/Q_FLAGS features in namespace { Q_GADGET - Q_ENUMS(ExportPen) - Q_ENUMS(ResolutionUnit) - Q_ENUMS(SignDomain) - Q_ENUMS(MarginSide) + Q_ENUM(ExportPen) + Q_ENUM(ResolutionUnit) + Q_ENUM(SignDomain) + Q_ENUM(MarginSide) Q_FLAGS(MarginSides) - Q_ENUMS(AntialiasedElement) + Q_ENUM(AntialiasedElement) Q_FLAGS(AntialiasedElements) - Q_ENUMS(PlottingHint) + Q_ENUM(PlottingHint) Q_FLAGS(PlottingHints) - Q_ENUMS(Interaction) + Q_ENUM(Interaction) Q_FLAGS(Interactions) - Q_ENUMS(SelectionRectMode) - Q_ENUMS(SelectionType) + Q_ENUM(SelectionRectMode) + Q_ENUM(SelectionType) public: #endif @@ -572,7 +572,7 @@ pmNonCosmetic = 0x04 ///< 0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.) }; - Q_ENUMS(PainterMode) + Q_ENUM(PainterMode) Q_FLAGS(PainterModes) Q_DECLARE_FLAGS(PainterModes, PainterMode) @@ -747,7 +747,7 @@ , lmBuffered ///< Layer has its own paint buffer and may be replotted individually (see \ref replot). }; - Q_ENUMS(LayerMode) + Q_ENUM(LayerMode) QCPLayer(QCustomPlot *parentPlot, const QString &layerName); virtual ~QCPLayer(); @@ -1325,7 +1325,7 @@ , upLayout ///< Final phase in which the layout system places the rects of the elements }; - Q_ENUMS(UpdatePhase) + Q_ENUM(UpdatePhase) explicit QCPLayoutElement(QCustomPlot *parentPlot = 0); virtual ~QCPLayoutElement(); @@ -1454,7 +1454,7 @@ , foColumnsFirst ///< Columns are filled first, and a new element is wrapped to the next row if the column count would exceed \ref setWrap. }; - Q_ENUMS(FillOrder) + Q_ENUM(FillOrder) explicit QCPLayoutGrid(); virtual ~QCPLayoutGrid(); @@ -1532,7 +1532,7 @@ , ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment }; - Q_ENUMS(InsetPlacement) + Q_ENUM(InsetPlacement) explicit QCPLayoutInset(); virtual ~QCPLayoutInset(); @@ -1614,7 +1614,7 @@ , esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength) }; - Q_ENUMS(EndingStyle) + Q_ENUM(EndingStyle) QCPLineEnding(); QCPLineEnding(EndingStyle style, double width = 8, double length = 10, bool inverted = false); @@ -1666,7 +1666,7 @@ , tssMeetTickCount ///< Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick count }; - Q_ENUMS(TickStepStrategy) + Q_ENUM(TickStepStrategy) QCPAxisTicker(); virtual ~QCPAxisTicker(); @@ -1778,7 +1778,7 @@ tuHours, tuDays }; - Q_ENUMS(TimeUnit) + Q_ENUM(TimeUnit) QCPAxisTickerTime(); @@ -1832,7 +1832,7 @@ , ssPowers ///< An integer power of the specified tick step is allowed. }; - Q_ENUMS(ScaleStrategy) + Q_ENUM(ScaleStrategy) QCPAxisTickerFixed(); @@ -1913,7 +1913,7 @@ , fsUnicodeFractions ///< Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol. }; - Q_ENUMS(FractionStyle) + Q_ENUM(FractionStyle) QCPAxisTickerPi(); @@ -2103,7 +2103,7 @@ , atBottom = 0x08 ///< 0x08 Axis is horizontal and on the bottom side of the axis rect }; - Q_ENUMS(AxisType) + Q_ENUM(AxisType) Q_FLAGS(AxisTypes) Q_DECLARE_FLAGS(AxisTypes, AxisType) /*! @@ -2117,7 +2117,7 @@ , lsOutside ///< Tick labels will be displayed outside the axis rect }; - Q_ENUMS(LabelSide) + Q_ENUM(LabelSide) /*! Defines the scale of an axis. \see setScaleType @@ -2128,7 +2128,7 @@ , stLogarithmic ///< Logarithmic scaling with correspondingly transformed axis coordinates (possibly also \ref setTicker to a \ref QCPAxisTickerLog instance). }; - Q_ENUMS(ScaleType) + Q_ENUM(ScaleType) /*! Defines the selectable parts of an axis. \see setSelectableParts, setSelectedParts @@ -2143,7 +2143,7 @@ , spAxisLabel = 0x004 ///< The axis label }; - Q_ENUMS(SelectablePart) + Q_ENUM(SelectablePart) Q_FLAGS(SelectableParts) Q_DECLARE_FLAGS(SelectableParts, SelectablePart) @@ -2454,7 +2454,7 @@ , spAll = 0xFF ///< 0xFF All properties }; - Q_ENUMS(ScatterProperty) + Q_ENUM(ScatterProperty) Q_FLAGS(ScatterProperties) Q_DECLARE_FLAGS(ScatterProperties, ScatterProperty) @@ -2503,7 +2503,7 @@ , ssCustom ///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath) }; - Q_ENUMS(ScatterShape) + Q_ENUM(ScatterShape) QCPScatterStyle(); QCPScatterStyle(ScatterShape shape, double size = 6); @@ -3668,7 +3668,7 @@ , ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes). }; - Q_ENUMS(PositionType) + Q_ENUM(PositionType) QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name); virtual ~QCPItemPosition(); @@ -3821,7 +3821,7 @@ , limAbove ///< Layer is inserted above other layer }; - Q_ENUMS(LayerInsertMode) + Q_ENUM(LayerInsertMode) /*! Defines with what timing the QCustomPlot surface is refreshed after a replot. @@ -3838,7 +3838,7 @@ , rpQueuedReplot ///< Queues the entire replot for the next event loop iteration. This way multiple redundant replots can be avoided. The actual replot is then done with \ref rpRefreshHint priority. }; - Q_ENUMS(RefreshPriority) + Q_ENUM(RefreshPriority) explicit QCustomPlot(QWidget *parent = 0); virtual ~QCustomPlot(); @@ -4683,7 +4683,7 @@ , ciHSV ///< Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance) }; - Q_ENUMS(ColorInterpolation) + Q_ENUM(ColorInterpolation) /*! Defines the available presets that can be loaded with \ref loadPreset. See the documentation @@ -4715,7 +4715,7 @@ , gpHues ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic) }; - Q_ENUMS(GradientPreset) + Q_ENUM(GradientPreset) QCPColorGradient(); QCPColorGradient(GradientPreset preset); @@ -4791,7 +4791,7 @@ , bsUserStyle ///< Start custom bracket styles at this index when subclassing and reimplementing \ref drawBracket. }; - Q_ENUMS(BracketStyle) + Q_ENUM(BracketStyle) QCPSelectionDecoratorBracket(); virtual ~QCPSelectionDecoratorBracket(); @@ -5086,7 +5086,7 @@ , spItems = 0x002 ///< 0x002 Legend items individually (see \ref selectedItems) }; - Q_ENUMS(SelectablePart) + Q_ENUM(SelectablePart) Q_FLAGS(SelectableParts) Q_DECLARE_FLAGS(SelectableParts, SelectablePart) @@ -5438,7 +5438,7 @@ , lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line }; - Q_ENUMS(LineStyle) + Q_ENUM(LineStyle) explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPGraph(); @@ -5578,7 +5578,7 @@ , lsLine ///< Data points are connected with a straight line }; - Q_ENUMS(LineStyle) + Q_ENUM(LineStyle) explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPCurve(); @@ -5675,7 +5675,7 @@ , stPlotCoords ///< Bar spacing is in key coordinates and thus scales with the key axis range }; - Q_ENUMS(SpacingType) + Q_ENUM(SpacingType) QCPBarsGroup(QCustomPlot *parentPlot); virtual ~QCPBarsGroup(); @@ -5783,7 +5783,7 @@ , wtPlotCoords ///< Bar width is in key coordinates and thus scales with the key axis range }; - Q_ENUMS(WidthType) + Q_ENUM(WidthType) explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPBars(); @@ -6177,7 +6177,7 @@ , wtPlotCoords ///< width is in key coordinates and thus scales with the key axis range }; - Q_ENUMS(WidthType) + Q_ENUM(WidthType) /*! Defines the possible representations of OHLC data in the plot. @@ -6190,7 +6190,7 @@ , csCandlestick ///< Candlestick representation }; - Q_ENUMS(ChartStyle) + Q_ENUM(ChartStyle) explicit QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPFinancial(); @@ -6325,7 +6325,7 @@ , etValueError ///< The errors are for the value dimension (bars appear parallel to the value axis) }; - Q_ENUMS(ErrorType) + Q_ENUM(ErrorType) explicit QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPErrorBars(); @@ -6897,7 +6897,7 @@ , tsSquare ///< A square }; - Q_ENUMS(TracerStyle) + Q_ENUM(TracerStyle) explicit QCPItemTracer(QCustomPlot *parentPlot); virtual ~QCPItemTracer(); @@ -6982,7 +6982,7 @@ , bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression }; - Q_ENUMS(BracketStyle) + Q_ENUM(BracketStyle) explicit QCPItemBracket(QCustomPlot *parentPlot); virtual ~QCPItemBracket(); Index: kstars/auxiliary/thumbnailpicker.h =================================================================== --- kstars/auxiliary/thumbnailpicker.h +++ kstars/auxiliary/thumbnailpicker.h @@ -36,9 +36,11 @@ explicit ThumbnailPickerUI(QWidget *p); }; -/** @short Dialog for modifying an object's thumbnail image - *@author Jason Harris - */ +/** + * @short Dialog for modifying an object's thumbnail image + * + * @author Jason Harris + */ class ThumbnailPicker : public QDialog { Q_OBJECT @@ -60,7 +62,7 @@ void slotFillList(); void slotProcessGoogleResult(KJob *); - /**Make sure download has finished, then make sure file exists, then add image to list */ + /** Make sure download has finished, then make sure file exists, then add image to list */ void slotJobResult(KJob *); private: Index: kstars/auxiliary/thumbnailpicker.cpp =================================================================== --- kstars/auxiliary/thumbnailpicker.cpp +++ kstars/auxiliary/thumbnailpicker.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include ThumbnailPickerUI::ThumbnailPickerUI(QWidget *parent) : QFrame(parent) @@ -147,7 +146,6 @@ //Add images from the ImageList for (int i = 0; i < ImageList.size(); ++i) { - QString s(ImageList[i]); QUrl u(ImageList[i]); if (u.isValid()) Index: kstars/dialogs/detaildialog.h =================================================================== --- kstars/dialogs/detaildialog.h +++ kstars/dialogs/detaildialog.h @@ -15,39 +15,32 @@ * * ***************************************************************************/ -#ifndef DETAILDIALOG_H_ -#define DETAILDIALOG_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include +#pragma once -//UI headers #include "ui_details_data.h" #include "ui_details_data_comet.h" -#include "ui_details_position.h" -#include "ui_details_links.h" #include "ui_details_database.h" +#include "ui_details_links.h" #include "ui_details_log.h" +#include "ui_details_position.h" + +#include + +#include +#include + +#include -class GeoLocation; -class QHBoxLayout; class QListWidgetItem; class QPixmap; -class QString; -class QStringList; + +class DataCometWidget; +class DataWidget; +class GeoLocation; class KStars; class KStarsDateTime; class SkyObject; -class DataWidget; -class DataCometWidget; class PositionWidget; class LinksWidget; class DatabaseWidget; @@ -61,205 +54,203 @@ }; /** - *@class DetailDialog - * DetailDialog is a window showing detailed information for a selected object. - *The window is split into four Tabs: General, Links, Advanced and Log. - *The General Tab displays some type-specific data about the object, as well as its - *present coordinates and Rise/Set/Transit times for the current date. The Type-specific - *data are: - *@li Stars: common name, genetive name, Spectral type, magnitude, distance - *@li Solar System: name, object type (planet/comet/asteroid), Distance, magnitude (TBD), - *angular size (TBD) - *@li Deep Sky: Common name, other names, object type, magnitude, angular size + * @class DetailDialog + * DetailDialog is a window showing detailed information for a selected object. + * The window is split into four Tabs: General, Links, Advanced and Log. + * The General Tab displays some type-specific data about the object, as well as its + * present coordinates and Rise/Set/Transit times for the current date. The Type-specific + * data are: + * @li Stars: common name, genetive name, Spectral type, magnitude, distance + * @li Solar System: name, object type (planet/comet/asteroid), Distance, magnitude (TBD), + * angular size (TBD) + * @li Deep Sky: Common name, other names, object type, magnitude, angular size * - *The Links Tab allows the user to manage the list of Image and Information links - *listed in the object's popup menu. The Advanced Tab allows the user to query - *a number of professional-grade online astronomical databases for data on the object. - *The Log tab allows the user to attach their own text notes about the object. + * The Links Tab allows the user to manage the list of Image and Information links + * listed in the object's popup menu. The Advanced Tab allows the user to query + * a number of professional-grade online astronomical databases for data on the object. + * The Log tab allows the user to attach their own text notes about the object. * - *The General Tab includes a clickable image of the object. Clicking the image opens - *a Thumbnail picker tool, which downloads a list of mages of the object from the - *network, which the user may select as the new image for this objects Details window. + * The General Tab includes a clickable image of the object. Clicking the image opens + * a Thumbnail picker tool, which downloads a list of mages of the object from the + * network, which the user may select as the new image for this objects Details window. * - *@author Jason Harris, Jasem Mutlaq - *@version 1.0 + * @author Jason Harris, Jasem Mutlaq + * @version 1.0 */ class DetailDialog : public KPageDialog { Q_OBJECT public: - /**Constructor - */ + /** Constructor */ DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, QWidget *parent = 0); - /**Destructor - */ + /** Destructor */ ~DetailDialog(); - /** - *@return pointer to the QPixmap of the object's thumbnail image - */ - inline QPixmap *thumbnail() { return Thumbnail; } + /** @return pointer to the QPixmap of the object's thumbnail image */ + inline QPixmap *thumbnail() { return Thumbnail.get(); } public slots: - /** @short Slot to add this object to the observing list. - */ + /** @short Slot to add this object to the observing list. */ void addToObservingList(); - /** @short Slot to center this object in the display. - */ + /** @short Slot to center this object in the display. */ void centerMap(); - /** @short Slot to center this object in the telescope. - */ + /** @short Slot to center this object in the telescope. */ void centerTelescope(); //TODO: showThumbnail() is only called in the ctor; make it private and not a slot. - /** @short Slot to display the thumbnail image for the object - */ + /** @short Slot to display the thumbnail image for the object */ void showThumbnail(); - /** @short Slot to update thumbnail image for the object, using the Thumbnail - *Picker tool. - *@sa ThumbnailPicker - */ + /** + * @short Slot to update thumbnail image for the object, using the Thumbnail + * Picker tool. + * @sa ThumbnailPicker + */ void updateThumbnail(); - /** @short Slot for viewing the selected image or info URL in the web browser. - */ + /** @short Slot for viewing the selected image or info URL in the web browser. */ void viewLink(); - /**Popup menu function: Add a custom Image or Information URL. - * Opens the AddLinkDialog window. - */ + /** + * Popup menu function: Add a custom Image or Information URL. + * Opens the AddLinkDialog window. + */ void addLink(); /** - *@short Set the currently-selected URL resource. - * - *This function is needed because there are two QListWidgets, - *each with its own selection. We need to know which the user selected - *most recently. - */ + * @short Set the currently-selected URL resource. + * + * This function is needed because there are two QListWidgets, + * each with its own selection. We need to know which the user selected most recently. + */ void setCurrentLink(QListWidgetItem *it); - /** @short Rebuild the Image and Info URL lists for this object. - *@note used when an item is added to either list. - */ + /** + * @short Rebuild the Image and Info URL lists for this object. + * @note used when an item is added to either list. + */ void updateLists(); - /** @short Open a dialog to edit a URL in either the Images or Info lists, - *and update the user's *url.dat file. - */ + /** + * @short Open a dialog to edit a URL in either the Images or Info lists, + * and update the user's *url.dat file. + */ void editLinkDialog(); - /** @short remove a URL entry from either the Images or Info lists, and - *update the user's *url.dat file. - */ + /** + * @short remove a URL entry from either the Images or Info lists, and + * update the user's *url.dat file. + */ void removeLinkDialog(); - /**Open the web browser to the selected online astronomy database, - *with a query to the object of this Detail Dialog. - */ + /** + * Open the web browser to the selected online astronomy database, + * with a query to the object of this Detail Dialog. + */ void viewADVData(); - /**Save the User's text in the Log Tab to the userlog.dat file. - */ + /** Save the User's text in the Log Tab to the userlog.dat file. */ void saveLogData(); - /**Update View/Edit/Remove buttons - */ + /** Update View/Edit/Remove buttons */ void updateButtons(); private: - /**Build the General Data Tab for the current object. - */ + /** Build the General Data Tab for the current object. */ void createGeneralTab(); - /**Build the Position Tab for the current object. - */ + /** Build the Position Tab for the current object. */ void createPositionTab(const KStarsDateTime &ut, GeoLocation *geo); - /**Build the Links Tab, populating the image and info lists with the - *known URLs for the current Object. - */ + /** + * Build the Links Tab, populating the image and info lists with the + * known URLs for the current Object. + */ void createLinksTab(); - /**Build the Advanced Tab - */ + /** Build the Advanced Tab */ void createAdvancedTab(); - /**Build the Log Tab - */ + /** Build the Log Tab */ void createLogTab(); - /**Populate the TreeView of known astronomical databases in the Advanced Tab - */ + /** Populate the TreeView of known astronomical databases in the Advanced Tab */ void populateADVTree(); - /**Data for the Advanced Tab TreeView is stored in the file advinterface.dat. - *This function parses advinterface.dat. - */ + /** + * Data for the Advanced Tab TreeView is stored in the file advinterface.dat. + * This function parses advinterface.dat. + */ QString parseADVData(const QString &link); - /** Update the local info_url and image_url files - @param type The URL type. 0 for Info Links, 1 for Images. - @param search_line The line to be search for in the local URL files - @param replace_line The replacement line once search_line is found. - @note If replace_line is empty, the function will remove search_line from the file - */ + /** + * Update the local info_url and image_url files + * @param type The URL type. 0 for Info Links, 1 for Images. + * @param search_line The line to be search for in the local URL files + * @param replace_line The replacement line once search_line is found. + * @note If replace_line is empty, the function will remove search_line from the file + */ void updateLocalDatabase(int type, const QString &search_line, const QString &replace_line = QString()); - SkyObject *selectedObject; + SkyObject *selectedObject { nullptr }; QPalette titlePalette; - - QListWidgetItem *m_CurrentLink; - - QPixmap *Thumbnail; - QStringList dataList; - - DataWidget *Data; - DataCometWidget *DataComet; - PositionWidget *Pos; - LinksWidget *Links; - DatabaseWidget *Adv; - LogWidget *Log; + QListWidgetItem *m_CurrentLink { nullptr }; + std::unique_ptr Thumbnail; + DataWidget *Data { nullptr }; + DataCometWidget *DataComet { nullptr }; + PositionWidget *Pos { nullptr }; + LinksWidget *Links { nullptr }; + DatabaseWidget *Adv { nullptr }; + LogWidget *Log { nullptr }; }; class DataWidget : public QFrame, public Ui::DetailsData { + Q_OBJECT + public: explicit DataWidget(QWidget *parent = 0); }; class DataCometWidget : public QFrame, public Ui::DetailsDataComet { + Q_OBJECT + public: explicit DataCometWidget(QWidget *parent = 0); }; class PositionWidget : public QFrame, public Ui::DetailsPosition { + Q_OBJECT + public: explicit PositionWidget(QWidget *parent = 0); }; class LinksWidget : public QFrame, public Ui::DetailsLinks { + Q_OBJECT + public: explicit LinksWidget(QWidget *parent = 0); }; class DatabaseWidget : public QFrame, public Ui::DetailsDatabase { + Q_OBJECT + public: explicit DatabaseWidget(QWidget *parent = 0); }; class LogWidget : public QFrame, public Ui::DetailsLog { + Q_OBJECT + public: explicit LogWidget(QWidget *parent = 0); }; - -#endif Index: kstars/dialogs/detaildialog.cpp =================================================================== --- kstars/dialogs/detaildialog.cpp +++ kstars/dialogs/detaildialog.cpp @@ -17,57 +17,34 @@ #include "detaildialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include "config-kstars.h" +#include "addlinkdialog.h" +#include "kspaths.h" #include "kstars.h" #include "kstarsdata.h" -#include "kstarsdatetime.h" -#include "ksnumbers.h" -#include "geolocation.h" #include "ksutils.h" +#include "observinglist.h" #include "skymap.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/starobject.h" +#include "thumbnailpicker.h" +#include "skycomponents/constellationboundarylines.h" +#include "skycomponents/skymapcomposite.h" #include "skyobjects/deepskyobject.h" -#include "skyobjects/ksplanetbase.h" -#include "skyobjects/ksmoon.h" -#include "skyobjects/kscomet.h" #include "skyobjects/ksasteroid.h" +#include "skyobjects/kscomet.h" +#include "skyobjects/ksmoon.h" +#include "skyobjects/starobject.h" #include "skyobjects/supernova.h" #include "skycomponents/catalogcomponent.h" -#include "thumbnailpicker.h" -#include "Options.h" -#include "widgets/kshelplabel.h" -#include "addlinkdialog.h" -#include "observinglist.h" - -#include #ifdef HAVE_INDI #include #include "indi/indilistener.h" -#include "indi/indistd.h" -#include "indi/driverinfo.h" #endif -#include "skycomponents/constellationboundarylines.h" -#include "skycomponents/skymapcomposite.h" -#include "kspaths.h" +#include + +#include DetailDialog::DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, QWidget *parent) : KPageDialog(parent), selectedObject(o), Data(0), DataComet(0), Pos(0), Links(0), Adv(0), Log(0) @@ -83,7 +60,7 @@ titlePalette.setColor(foregroundRole(), palette().color(QPalette::Active, QPalette::HighlightedText)); //Create thumbnail image - Thumbnail = new QPixmap(200, 200); + Thumbnail.reset(new QPixmap(200, 200)); setWindowTitle(i18n("Object Details")); @@ -100,7 +77,6 @@ DetailDialog::~DetailDialog() { - delete Thumbnail; } void DetailDialog::createGeneralTab() @@ -974,9 +950,10 @@ void DetailDialog::removeLinkDialog() { int type = 0, row = 0; - QString currentItemURL, currentItemTitle, LineEntry, TempFileName, FileLine; + QString currentItemURL, currentItemTitle, LineEntry, TempFileName; QFile URLFile; QTemporaryFile TempFile; + TempFile.setAutoRemove(false); TempFile.open(); TempFileName = TempFile.fileName(); Index: kstars/dialogs/locationdialog.cpp =================================================================== --- kstars/dialogs/locationdialog.cpp +++ kstars/dialogs/locationdialog.cpp @@ -167,9 +167,9 @@ if (!loc->province().isEmpty()) sp = loc->translatedProvince(); - if (sc.toLower().startsWith(ld->CityFilter->text().toLower()) && - sp.toLower().startsWith(ld->ProvinceFilter->text().toLower()) && - ss.toLower().startsWith(ld->CountryFilter->text().toLower())) + if (sc.startsWith(ld->CityFilter->text(), Qt::CaseInsensitive) && + sp.startsWith(ld->ProvinceFilter->text(), Qt::CaseInsensitive) && + ss.startsWith(ld->CountryFilter->text(), Qt::CaseInsensitive)) { ld->GeoBox->addItem(loc->fullName()); filteredCityList.append(loc); Index: kstars/ekos/align/align.cpp =================================================================== --- kstars/ekos/align/align.cpp +++ kstars/ekos/align/align.cpp @@ -30,6 +30,7 @@ #include "dialogs/finddialog.h" #include "ekos/ekosmanager.h" #include "ekos/auxiliary/darklibrary.h" +#include "fitsviewer/fitsdata.h" #include "fitsviewer/fitstab.h" #include "indi/clientmanager.h" #include "indi/driverinfo.h" @@ -417,7 +418,7 @@ dir.setNameFilters(QStringList() << "fits*" << "tmp.*"); dir.setFilter(QDir::Files); - foreach (QString dirFile, dir.entryList()) + for (auto &dirFile : dir.entryList()) dir.remove(dirFile); } void Align::selectSolutionTableRow(int row, int column) @@ -508,11 +509,11 @@ "" "") .arg(point + 1) - .arg(solutionTable->item(point, 2)->text()) - .arg(solutionTable->item(point, 0)->text()) - .arg(solutionTable->item(point, 1)->text()) - .arg(solutionTable->item(point, 4)->text()) - .arg(solutionTable->item(point, 5)->text()), + .arg(solutionTable->item(point, 2)->text(), + solutionTable->item(point, 0)->text(), + solutionTable->item(point, 1)->text(), + solutionTable->item(point, 4)->text(), + solutionTable->item(point, 5)->text()), alignPlot, alignPlot->rect()); } } @@ -2372,7 +2373,7 @@ dir.setNameFilters(QStringList() << "fits*" << "tmp.*"); dir.setFilter(QDir::Files); - foreach (QString dirFile, dir.entryList()) + for (auto &dirFile : dir.entryList()) dir.remove(dirFile); //} @@ -2694,7 +2695,8 @@ double deDiff = (alignCoord.dec().Degrees() - targetCoord.dec().Degrees()) * 3600; dms RADiff(fabs(raDiff) / 3600.0), DEDiff(deDiff / 3600.0); - dRAOut->setText(QString("%1%2").arg(raDiff > 0 ? "+" : "-").arg(RADiff.toHMSString())); + + dRAOut->setText(QString("%1%2").arg((raDiff > 0 ? "+" : "-"), RADiff.toHMSString())); dDEOut->setText(DEDiff.toDMSString(true)); pixScaleOut->setText(QString::number(pixscale, 'f', 2)); Index: kstars/ekos/align/offlineastrometryparser.cpp =================================================================== --- kstars/ekos/align/offlineastrometryparser.cpp +++ kstars/ekos/align/offlineastrometryparser.cpp @@ -353,7 +353,7 @@ double ra = 0, dec = 0, orientation = 0, pixscale = 0; - foreach (QString key, wcskeys) + for (auto &key : wcskeys) { key_value = key.split(" "); Index: kstars/ekos/align/opsastrometryindexfiles.h =================================================================== --- kstars/ekos/align/opsastrometryindexfiles.h +++ kstars/ekos/align/opsastrometryindexfiles.h @@ -1,12 +1,15 @@ -#ifndef OPSASTROMETRYINDEXFILES_H -#define OPSASTROMETRYINDEXFILES_H -#include +#pragma once + #include "ui_opsastrometryindexfiles.h" -#include "QNetworkAccessManager" -#include "kauth.h" +#include +#include +#include +class QNetworkAccessManager; + +class Align; class KConfigDialog; namespace Ekos @@ -30,14 +33,14 @@ void downloadOrDeleteIndexFiles(bool checked); private: - KConfigDialog *m_ConfigDialog; - Align *alignModule; - QNetworkAccessManager *manager; bool getAstrometryDataDir(QString &dataDir); - void downloadIndexFile(QString URL, QString fileN, QCheckBox *checkBox, int currentIndex, int maxIndex); - QMap astrometryIndex; + void downloadIndexFile(const QString &URL, const QString &fileN, QCheckBox *checkBox, int currentIndex, + int maxIndex); bool astrometryIndicesAreAvailable(); + + KConfigDialog *m_ConfigDialog { nullptr }; + Align *alignModule { nullptr }; + QNetworkAccessManager *manager { nullptr }; + QMap astrometryIndex; }; } - -#endif // OPSASTROMETRYINDEXFILES_H Index: kstars/ekos/align/opsastrometryindexfiles.cpp =================================================================== --- kstars/ekos/align/opsastrometryindexfiles.cpp +++ kstars/ekos/align/opsastrometryindexfiles.cpp @@ -1,16 +1,14 @@ -#include "opsastrometryindexfiles.h" -#include "ui_opsastrometryindexfiles.h" -#include -#include -#include +#include "opsastrometryindexfiles.h" -#include "kstars.h" #include "align.h" +#include "kstars.h" #include "Options.h" #include #include +#include +#include namespace Ekos { @@ -48,14 +46,14 @@ QList checkboxes = findChildren(); - foreach (QCheckBox *checkBox, checkboxes) + for (auto &checkBox : checkboxes) { connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(downloadOrDeleteIndexFiles(bool))); } QList progressBars = findChildren(); - foreach (QProgressBar *bar, progressBars) + for (auto &bar : progressBars) { bar->setVisible(false); } @@ -79,7 +77,7 @@ double fov_check = qMax(fov_w, fov_h); - FOVOut->setText(QString("%1' x %2'").arg(QString::number(fov_w, 'f', 2)).arg(QString::number(fov_h, 'f', 2))); + FOVOut->setText(QString("%1' x %2'").arg(QString::number(fov_w, 'f', 2), QString::number(fov_h, 'f', 2))); QString astrometryDataDir; @@ -92,7 +90,7 @@ QDir directory(astrometryDataDir); QStringList indexList = directory.entryList(nameFilter); - foreach (QString indexName, indexList) + for (auto &indexName : indexList) { indexName = indexName.replace("-", "_").left(10); QCheckBox *indexCheckBox = findChild(indexName); @@ -102,14 +100,15 @@ QList checkboxes = findChildren(); - foreach (QCheckBox *checkBox, checkboxes) + for (auto &checkBox : checkboxes) { checkBox->setIcon(QIcon(":/icons/breeze/default/security-low.svg")); checkBox->setToolTip(i18n("Optional")); } float last_skymarksize = 2; - foreach (float skymarksize, astrometryIndex.keys()) + + for (auto &skymarksize : astrometryIndex.keys()) { if ((skymarksize >= 0.40 * fov_check && skymarksize <= 0.9 * fov_check) || (fov_check > last_skymarksize && fov_check < skymarksize)) @@ -221,8 +220,8 @@ return wasSuccessful; } -void OpsAstrometryIndexFiles::downloadIndexFile(QString URL, QString fileN, QCheckBox *checkBox, int currentIndex, - int maxIndex) +void OpsAstrometryIndexFiles::downloadIndexFile(const QString &URL, const QString &fileN, QCheckBox *checkBox, + int currentIndex, int maxIndex) { QString indexString = QString::number(currentIndex); if (currentIndex < 10) @@ -319,7 +318,7 @@ progressBarName = progressBarName.replace("-", "_").left(10) + "_progress"; QProgressBar *indexDownloadProgress = findChild(progressBarName); QString filePath = astrometryDataDir + "/" + indexSetName; - int indexFileNum = indexSetName.mid(8, 2).toInt(); + int indexFileNum = indexSetName.midRef(8, 2).toInt(); if (checked) { checkBox->setChecked(!checked); @@ -359,7 +358,7 @@ QStringList nameFilter("*.fits"); QDir directory(astrometryDataDir); QStringList indexList = directory.entryList(nameFilter); - foreach (QString fileName, indexList) + for (auto &fileName : indexList) { if (fileName.contains(indexSetName.left(10))) { Index: kstars/ekos/auxiliary/darklibrary.cpp =================================================================== --- kstars/ekos/auxiliary/darklibrary.cpp +++ kstars/ekos/auxiliary/darklibrary.cpp @@ -14,6 +14,7 @@ #include "kstars.h" #include "kspaths.h" #include "kstarsdata.h" +#include "fitsviewer/fitsdata.h" #include "fitsviewer/fitsview.h" namespace Ekos Index: kstars/ekos/capture/capture.cpp =================================================================== --- kstars/ekos/capture/capture.cpp +++ kstars/ekos/capture/capture.cpp @@ -19,12 +19,13 @@ #include "skymap.h" #include "ui_calibrationoptions.h" #include "auxiliary/QProgressIndicator.h" -#include "indi/driverinfo.h" -#include "indi/indifilter.h" -#include "indi/clientmanager.h" #include "ekos/ekosmanager.h" #include "ekos/auxiliary/darklibrary.h" +#include "fitsviewer/fitsdata.h" #include "fitsviewer/fitsview.h" +#include "indi/driverinfo.h" +#include "indi/indifilter.h" +#include "indi/clientmanager.h" #include @@ -141,7 +142,7 @@ fitsDir->setText(Options::fitsDir()); - foreach (QString filter, FITSViewer::filterTypes) + for (auto &filter : FITSViewer::filterTypes) filterCombo->addItem(filter); guideDeviationCheck->setChecked(Options::enforceGuideDeviation()); @@ -1523,7 +1524,7 @@ { bool indexOK = false; - newFileIndex = tempName.mid(lastUnderScoreIndex + 1).toInt(&indexOK); + newFileIndex = tempName.midRef(lastUnderScoreIndex + 1).toInt(&indexOK); if (indexOK && newFileIndex >= nextSequenceID) nextSequenceID = newFileIndex + 1; } @@ -4498,8 +4499,8 @@ QList m_observerList; KStars::Instance()->data()->userdb()->GetAllObservers(m_observerList); QStringList observers; - foreach (OAL::Observer *o, m_observerList) - observers << QString("%1 %2").arg(o->name()).arg(o->surname()); + for (auto &o : m_observerList) + observers << QString("%1 %2").arg(o->name(), o->surname()); QDialog observersDialog(this); observersDialog.setWindowTitle(i18n("Select Current Observer")); @@ -4523,8 +4524,8 @@ QList m_observerList; KStars::Instance()->data()->userdb()->GetAllObservers(m_observerList); QStringList observers; - foreach (OAL::Observer *o, m_observerList) - observers << QString("%1 %2").arg(o->name()).arg(o->surname()); + for (auto &o : m_observerList) + observers << QString("%1 %2").arg(o->name(), o->surname()); observerCombo.clear(); observerCombo.addItems(observers); Index: kstars/ekos/capture/rotatorsettings.cpp =================================================================== --- kstars/ekos/capture/rotatorsettings.cpp +++ kstars/ekos/capture/rotatorsettings.cpp @@ -12,6 +12,8 @@ #include #include +#include + RotatorSettings::RotatorSettings(QWidget *parent) : QDialog(parent) { setupUi(this); Index: kstars/ekos/ekosmanager.cpp =================================================================== --- kstars/ekos/ekosmanager.cpp +++ kstars/ekos/ekosmanager.cpp @@ -18,6 +18,7 @@ #include "profilewizard.h" #include "skymap.h" #include "auxiliary/darklibrary.h" +#include "auxiliary/QProgressIndicator.h" #include "capture/sequencejob.h" #include "fitsviewer/fitstab.h" #include "fitsviewer/fitsview.h" Index: kstars/ekos/focus/focus.cpp =================================================================== --- kstars/ekos/focus/focus.cpp +++ kstars/ekos/focus/focus.cpp @@ -16,6 +16,7 @@ #include "auxiliary/kspaths.h" #include "ekos/ekosmanager.h" #include "ekos/auxiliary/darklibrary.h" +#include "fitsviewer/fitsdata.h" #include "fitsviewer/fitstab.h" #include "fitsviewer/fitsview.h" #include "indi/indifilter.h" @@ -191,7 +192,7 @@ appendLogText(i18n("Idle.")); - foreach (QString filter, FITSViewer::filterTypes) + for (auto &filter : FITSViewer::filterTypes) filterCombo->addItem(filter); filterCombo->setCurrentIndex(Options::focusEffect()); Index: kstars/ekos/guide/externalguide/linguider.cpp =================================================================== --- kstars/ekos/guide/externalguide/linguider.cpp +++ kstars/ekos/guide/externalguide/linguider.cpp @@ -359,7 +359,7 @@ bool LinGuider::dither(double pixels) { QString pixelsString = QString::number(pixels, 'f', 2); - QString args = QString("%1 %2").arg(pixelsString).arg(pixelsString); + QString args = QString("%1 %2").arg(pixelsString, pixelsString); sendCommand(SET_DITHERING_RANGE, args); Index: kstars/ekos/guide/guide.h =================================================================== --- kstars/ekos/guide/guide.h +++ kstars/ekos/guide/guide.h @@ -7,28 +7,23 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef guide_H -#define guide_H - -#include -#include +#pragma once +#include "ui_guide.h" #include "ekos/ekos.h" - -#include "indi/indistd.h" -#include "indi/inditelescope.h" #include "indi/indiccd.h" +#include "indi/inditelescope.h" -#include "guide.h" - -#include "fitsviewer/fitscommon.h" - -#include "ui_guide.h" +#include +#include +#include +class QProgressIndicator; class QTabWidget; + class FITSView; +class FITSViewer; class ScrollGraph; -class QProgressIndicator; namespace Ekos { @@ -40,12 +35,13 @@ class LinGuider; /** - *@class Guide - *@short Performs calibration and autoguiding using an ST4 port or directly via the INDI driver. Can be used with the following external guiding applications: + * @class Guide + * @short Performs calibration and autoguiding using an ST4 port or directly via the INDI driver. Can be used with the following external guiding applications: * PHD2 * LinGuider - *@author Jasem Mutlaq - *@version 1.4 + * + * @author Jasem Mutlaq + * @version 1.4 */ class Guide : public QWidget, public Ui::Guide { @@ -442,26 +438,32 @@ QStack operationStack; // Devices - ISD::CCD *currentCCD; - ISD::Telescope *currentTelescope; - ISD::ST4 *ST4Driver; - ISD::ST4 *AODriver; - ISD::ST4 *GuideDriver; + ISD::CCD *currentCCD { nullptr }; + ISD::Telescope *currentTelescope { nullptr }; + ISD::ST4 *ST4Driver { nullptr }; + ISD::ST4 *AODriver { nullptr }; + ISD::ST4 *GuideDriver { nullptr }; // Device Containers QList ST4List; QList CCDs; // Guider process - GuideInterface *guider; + GuideInterface *guider { nullptr }; GuiderType guiderType; // Star QVector3D starCenter; // Guide Params - double ccdPixelSizeX, ccdPixelSizeY, mountAperture, mountFocalLength, guideDeviationRA, guideDeviationDEC, - pixScaleX, pixScaleY; + double ccdPixelSizeX { 0 }; + double ccdPixelSizeY { 0 }; + double mountAperture { 0 }; + double mountFocalLength { 0 }; + double guideDeviationRA { 0 }; + double guideDeviationDEC { 0 }; + double pixScaleX { 0 }; + double pixScaleY { 0 }; // Rapid Guide //bool rapidGuideReticleSet; @@ -474,7 +476,7 @@ // Capture timeout timer QTimer captureTimeout; - uint8_t captureTimeoutCounter = 0; + uint8_t captureTimeoutCounter { 0 }; // Pulse Timer QTimer pulseTimer; @@ -483,26 +485,23 @@ QStringList logText; // Misc - bool useGuideHead; + bool useGuideHead { false }; // Progress Activity Indicator - QProgressIndicator *pi; + QProgressIndicator *pi { nullptr }; // Options - OpsCalibration *opsCalibration; - OpsGuide *opsGuide; + OpsCalibration *opsCalibration { nullptr }; + OpsGuide *opsGuide { nullptr }; // Guide Frame - FITSView *guideView; - - // Auto star operation - bool autoStarCaptured; + FITSView *guideView { nullptr }; // Calibration done already? - bool calibrationComplete = false; + bool calibrationComplete { false }; // Was the modified frame subFramed? - bool subFramed; + bool subFramed { false }; // CCD Chip frame settings QMap frameSettings; @@ -511,7 +510,7 @@ QPixmap profilePixmap; // Flag to start auto calibration followed immediately by guiding - bool autoCalibrateGuide; + bool autoCalibrateGuide { false }; // Pointers of guider processes QPointer internalGuider; @@ -520,5 +519,3 @@ QPointer fv; }; } - -#endif // guide_H Index: kstars/ekos/guide/guide.cpp =================================================================== --- kstars/ekos/guide/guide.cpp +++ kstars/ekos/guide/guide.cpp @@ -9,40 +9,24 @@ #include "guide.h" -#include -#include - -#include -#include -#include -#include - -#include - -#include "Options.h" +#include "guideadaptor.h" +#include "kstarsdata.h" #include "opscalibration.h" #include "opsguide.h" - -#include "internalguide/internalguider.h" -#include "externalguide/phd2.h" -#include "externalguide/linguider.h" - -#include "ekos/auxiliary/darklibrary.h" +#include "Options.h" #include "auxiliary/QProgressIndicator.h" - -#include "indi/driverinfo.h" -#include "indi/clientmanager.h" - -#include "fitsviewer/fitsviewer.h" +#include "ekos/auxiliary/darklibrary.h" +#include "externalguide/linguider.h" +#include "externalguide/phd2.h" +#include "fitsviewer/fitsdata.h" #include "fitsviewer/fitsview.h" +#include "fitsviewer/fitsviewer.h" +#include "internalguide/internalguider.h" -#include "guideadaptor.h" -#include "kspaths.h" -#include "kstarsdata.h" -#include "auxiliary/qcustomplot.h" +#include + +#include -#define driftGraph_WIDTH 200 -#define driftGraph_HEIGHT 200 #define CAPTURE_TIMEOUT_THRESHOLD 10000 #define MAX_GUIDE_STARS 10 @@ -66,9 +50,6 @@ // ST4 Driver GuideDriver = nullptr; - // Auto Star - autoStarCaptured = false; - // Subframe subFramed = false; @@ -97,7 +78,7 @@ loadSettings(); // Image Filters - foreach (QString filter, FITSViewer::filterTypes) + for (auto &filter : FITSViewer::filterTypes) filterCombo->addItem(filter); // Progress Indicator @@ -529,17 +510,27 @@ l_Focal->setText(QString::number(mountFocalLength, 'f', 1)); l_Aperture->setText(QString::number(mountAperture, 'f', 1)); - l_FbyD->setText(QString::number(mountFocalLength / mountAperture, 'f', 1)); + if (mountAperture == 0) + { + l_FbyD->setText("0"); + // Pixel scale in arcsec/pixel + pixScaleX = 0; + pixScaleY = 0; + } + else + { + l_FbyD->setText(QString::number(mountFocalLength / mountAperture, 'f', 1)); + // Pixel scale in arcsec/pixel + pixScaleX = 206264.8062470963552 * ccdPixelSizeX / 1000.0 / mountFocalLength; + pixScaleY = 206264.8062470963552 * ccdPixelSizeY / 1000.0 / mountFocalLength; + } - // Pixel scale in arcsec/pixel - pixScaleX = 206264.8062470963552 * ccdPixelSizeX / 1000.0 / mountFocalLength; - pixScaleY = 206264.8062470963552 * ccdPixelSizeY / 1000.0 / mountFocalLength; // FOV in arcmin double fov_w = (w * pixScaleX) / 60.0; double fov_h = (h * pixScaleY) / 60.0; - l_FOV->setText(QString("%1x%2").arg(QString::number(fov_w, 'f', 1)).arg(QString::number(fov_h, 'f', 1))); + l_FOV->setText(QString("%1x%2").arg(QString::number(fov_w, 'f', 1), QString::number(fov_h, 'f', 1))); } } Index: kstars/ekos/profileeditor.h =================================================================== --- kstars/ekos/profileeditor.h +++ kstars/ekos/profileeditor.h @@ -7,14 +7,16 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef PROFILEEDITOR_H -#define PROFILEEDITOR_H - -#include +#pragma once #include "oal/scope.h" #include "ui_profileeditor.h" +#include +#include +#include +#include + class ProfileInfo; class ProfileEditorUI : public QFrame, public Ui::ProfileEditorUI @@ -22,8 +24,7 @@ Q_OBJECT public: - /** @short Constructor - */ + /** @short Constructor */ explicit ProfileEditorUI(QWidget *parent); }; @@ -31,17 +32,12 @@ { Q_OBJECT public: - /** - *@short Constructor. - */ + /** @short Constructor */ explicit ProfileEditor(QWidget *ks); - /** - *@short Destructor. - */ + /** @short Destructor */ ~ProfileEditor(); - ProfileInfo *getPi() const; void setPi(ProfileInfo *value); void loadDrivers(); @@ -62,9 +58,7 @@ void updateGuiderSelection(int id); private: - ProfileEditorUI *ui = nullptr; - ProfileInfo *pi = nullptr; + ProfileEditorUI *ui { nullptr }; + ProfileInfo *pi { nullptr }; QList m_scopeList; }; - -#endif // PROFILEEDITOR_H Index: kstars/ekos/profileeditor.cpp =================================================================== --- kstars/ekos/profileeditor.cpp +++ kstars/ekos/profileeditor.cpp @@ -7,23 +7,14 @@ version 2 of the License, or (at your option) any later version. */ -#include -#include - -#include - -#include "Options.h" +#include "profileeditor.h" -#include "kstarsdata.h" #include "geolocation.h" -#include "auxiliary/ksuserdb.h" +#include "kstarsdata.h" +#include "Options.h" #include "guide/guide.h" - -#include "indi/drivermanager.h" #include "indi/driverinfo.h" - -#include "profileeditor.h" -#include "profileinfo.h" +#include "indi/drivermanager.h" ProfileEditorUI::ProfileEditorUI(QWidget *p) : QFrame(p) { @@ -286,11 +277,6 @@ accept(); } -ProfileInfo *ProfileEditor::getPi() const -{ - return pi; -} - void ProfileEditor::setRemoteMode(bool enable) { loadDrivers(); //This is needed to reload the drivers because some may not be available locally @@ -336,10 +322,10 @@ if (pi->city.isEmpty() == false) { if (pi->province.isEmpty()) - ui->loadSiteCheck->setText(ui->loadSiteCheck->text() + QString(" (%1, %2)").arg(pi->country).arg(pi->city)); + ui->loadSiteCheck->setText(ui->loadSiteCheck->text() + QString(" (%1, %2)").arg(pi->country, pi->city)); else ui->loadSiteCheck->setText(ui->loadSiteCheck->text() + - QString(" (%1, %2, %3)").arg(pi->country).arg(pi->province).arg(pi->city)); + QString(" (%1, %2, %3)").arg(pi->country, pi->province, pi->city)); } if (pi->host.isEmpty() == false) Index: kstars/ekos/scheduler/scheduler.h =================================================================== --- kstars/ekos/scheduler/scheduler.h +++ kstars/ekos/scheduler/scheduler.h @@ -9,21 +9,26 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef SCHEDULER_H -#define SCHEDULER_H - -#include -#include -#include +#pragma once #include "ui_scheduler.h" -#include "scheduler.h" -#include "schedulerjob.h" -#include "auxiliary/QProgressIndicator.h" #include "ekos/align/align.h" -class KSMoon; +#include + +#include +#include +#include +#include +#include + +#include + +class QProgressIndicator; + class GeoLocation; +class KSMoon; +class SchedulerJob; class SkyObject; namespace Ekos @@ -529,76 +534,96 @@ bool &hasAutoFocus); int getCompletedFiles(const QString &path, const QString &seqPrefix); - Ekos::Scheduler *ui; - + Ekos::Scheduler *ui { nullptr }; //DBus interfaces - QDBusInterface *focusInterface; - QDBusInterface *ekosInterface; - QDBusInterface *captureInterface; - QDBusInterface *mountInterface; - QDBusInterface *alignInterface; - QDBusInterface *guideInterface; - QDBusInterface *domeInterface; - QDBusInterface *weatherInterface; - QDBusInterface *capInterface; - + QDBusInterface *focusInterface { nullptr }; + QDBusInterface *ekosInterface { nullptr }; + QDBusInterface *captureInterface { nullptr }; + QDBusInterface *mountInterface { nullptr }; + QDBusInterface *alignInterface { nullptr }; + QDBusInterface *guideInterface { nullptr }; + QDBusInterface *domeInterface { nullptr }; + QDBusInterface *weatherInterface { nullptr }; + QDBusInterface *capInterface { nullptr }; // Scheduler and job state and stages - SchedulerState state; - EkosState ekosState; - INDIState indiState; - StartupState startupState; - ShutdownState shutdownState; - ParkWaitStatus parkWaitState; - - QList jobs; // List of all jobs as entered by the user or file - SchedulerJob *currentJob; // Active job - - QUrl schedulerURL; // URL to store the scheduler file - QUrl sequenceURL; // URL for Ekos Sequence - QUrl fitsURL; // FITS URL to solve - QUrl startupScriptURL; // Startup script URL - QUrl shutdownScriptURL; // Shutdown script URL - - QStringList logText; // Store all log strings - - QProgressIndicator *pi; // Busy indicator widget - int jobUnderEdit; // Are we editing a job right now? Job row index - - KSMoon *moon; // Pointer to Moon object - GeoLocation *geo; // Pointer to Geograpic locatoin - - uint16_t captureBatch; // How many repeated job batches did we complete thus far? - - QProcess scriptProcess; // Startup and Shutdown scripts process - - double Dawn, Dusk; // Store day fraction of dawn and dusk to calculate dark skies range - QDateTime preDawnDateTime; // Pre-dawn is where we stop all jobs, it is a user-configurable value before Dawn. - QDateTime duskDateTime; // Dusk date time - bool mDirty; // Was job modified and needs saving? - IPState weatherStatus; // Keep watch of weather status - uint8_t noWeatherCounter; // Keep track of how many times we didn't receive weather updates - bool preemptiveShutdown; // Are we shutting down until later? - bool jobEvaluationOnly; // Only run job evaluation - bool loadAndSlewProgress; // Keep track of Load & Slew operation - bool - autofocusCompleted; // Check if initial autofocus is completed and do not run autofocus until there is a change is telescope position/alignment. - - uint8_t indiConnectFailureCount; // Keep track of INDI connection failures - uint8_t focusFailureCount; // Keep track of Ekos focus module failures - uint8_t guideFailureCount; // Keep track of Ekos guide module failures - uint8_t alignFailureCount; // Keep track of Ekos align module failures - uint8_t captureFailureCount; // Keep track of Ekos capture module failures - - QTimer - weatherTimer; // Call checkWeather when weatherTimer time expires. It is equal to the UpdatePeriod time in INDI::Weather device. - QTimer sleepTimer; // Timer to put the scheduler into sleep mode until a job is ready - QTimer schedulerTimer; // To call checkStatus - QTimer jobTimer; // To call checkJobStage - - QTime currentOperationTime; // Generic time to track timeout of current operation in progress + SchedulerState state { SCHEDULER_IDLE }; + EkosState ekosState { EKOS_IDLE }; + INDIState indiState { INDI_IDLE }; + StartupState startupState { STARTUP_IDLE }; + ShutdownState shutdownState { SHUTDOWN_IDLE }; + ParkWaitStatus parkWaitState { PARKWAIT_IDLE }; + /// List of all jobs as entered by the user or file + QList jobs; + /// Active job + SchedulerJob *currentJob { nullptr }; + /// URL to store the scheduler file + QUrl schedulerURL; + /// URL for Ekos Sequence + QUrl sequenceURL; + /// FITS URL to solve + QUrl fitsURL; + /// Startup script URL + QUrl startupScriptURL; + /// Shutdown script URL + QUrl shutdownScriptURL; + /// Store all log strings + QStringList logText; + /// Busy indicator widget + QProgressIndicator *pi { nullptr }; + /// Are we editing a job right now? Job row index + int jobUnderEdit { -1 }; + /// Pointer to Moon object + KSMoon *moon { nullptr }; + /// Pointer to Geograpic locatoin + GeoLocation *geo { nullptr }; + /// How many repeated job batches did we complete thus far? + uint16_t captureBatch { 0 }; + /// Startup and Shutdown scripts process + QProcess scriptProcess; + /// Store day fraction of dawn to calculate dark skies range + double Dawn { -1 }; + /// Store day fraction of dusk to calculate dark skies range + double Dusk { -1 }; + /// Pre-dawn is where we stop all jobs, it is a user-configurable value before Dawn. + QDateTime preDawnDateTime; + /// Dusk date time + QDateTime duskDateTime; + /// Was job modified and needs saving? + bool mDirty { false }; + /// Keep watch of weather status + IPState weatherStatus { IPS_IDLE }; + /// Keep track of how many times we didn't receive weather updates + uint8_t noWeatherCounter { 0 }; + /// Are we shutting down until later? + bool preemptiveShutdown { false }; + /// Only run job evaluation + bool jobEvaluationOnly { false }; + /// Keep track of Load & Slew operation + bool loadAndSlewProgress { false }; + /// Check if initial autofocus is completed and do not run autofocus until there is a change is telescope position/alignment. + bool autofocusCompleted { false }; + /// Keep track of INDI connection failures + uint8_t indiConnectFailureCount { 0 }; + /// Keep track of Ekos focus module failures + uint8_t focusFailureCount { 0 }; + /// Keep track of Ekos guide module failures + uint8_t guideFailureCount { 0 }; + /// Keep track of Ekos align module failures + uint8_t alignFailureCount { 0 }; + /// Keep track of Ekos capture module failures + uint8_t captureFailureCount { 0 }; + /// Call checkWeather when weatherTimer time expires. It is equal to the UpdatePeriod time in INDI::Weather device. + QTimer weatherTimer; + /// Timer to put the scheduler into sleep mode until a job is ready + QTimer sleepTimer; + /// To call checkStatus + QTimer schedulerTimer; + /// To call checkJobStage + QTimer jobTimer; + + /// Generic time to track timeout of current operation in progress + QTime currentOperationTime; QUrl dirPath; }; } - -#endif // SCHEDULER_H Index: kstars/ekos/scheduler/scheduler.cpp =================================================================== --- kstars/ekos/scheduler/scheduler.cpp +++ kstars/ekos/scheduler/scheduler.cpp @@ -9,32 +9,25 @@ version 2 of the License, or (at your option) any later version. */ -#include "Options.h" - -#include -#include - -#include -#include - -#include -#include -#include +#include "scheduler.h" -#include "scheduleradaptor.h" -#include "dialogs/finddialog.h" -#include "ekos/capture/sequencejob.h" -#include "ekos/ekosmanager.h" +#include "ksalmanac.h" +#include "ksnotification.h" #include "kstars.h" -#include "scheduler.h" -#include "skymapcomposite.h" #include "kstarsdata.h" -#include "ksmoon.h" -#include "ksalmanac.h" #include "ksutils.h" #include "mosaic.h" +#include "Options.h" +#include "scheduleradaptor.h" +#include "schedulerjob.h" +#include "skymapcomposite.h" +#include "auxiliary/QProgressIndicator.h" +#include "dialogs/finddialog.h" +#include "ekos/ekosmanager.h" +#include "ekos/capture/sequencejob.h" #include "skyobjects/starobject.h" -#include "ksnotification.h" + +#include #define BAD_SCORE -1000 #define MAX_FAILURE_ATTEMPTS 3 @@ -73,37 +66,6 @@ QDBusConnection::sessionBus().registerObject("/KStars/Ekos/Scheduler", this); dirPath = QUrl::fromLocalFile(QDir::homePath()); - state = SCHEDULER_IDLE; - ekosState = EKOS_IDLE; - indiState = INDI_IDLE; - - startupState = STARTUP_IDLE; - shutdownState = SHUTDOWN_IDLE; - - parkWaitState = PARKWAIT_IDLE; - - currentJob = nullptr; - geo = nullptr; - captureBatch = 0; - jobUnderEdit = -1; - mDirty = false; - jobEvaluationOnly = false; - loadAndSlewProgress = false; - autofocusCompleted = false; - preemptiveShutdown = false; - - Dawn = -1; - Dusk = -1; - - indiConnectFailureCount = 0; - focusFailureCount = 0; - guideFailureCount = 0; - alignFailureCount = 0; - captureFailureCount = 0; - - noWeatherCounter = 0; - - weatherStatus = IPS_IDLE; // Get current KStars time and set seconds to zero QDateTime currentDateTime = KStarsData::Instance()->lt(); @@ -4622,7 +4584,7 @@ if (createJobSequence(root, prefix, outputDir) == false) return; - QString filename = QString("%1/%2.esq").arg(outputDir).arg(prefix); + QString filename = QString("%1/%2.esq").arg(outputDir, prefix); sequenceEdit->setText(filename); sequenceURL = QUrl::fromLocalFile(filename); @@ -4641,7 +4603,7 @@ queueTable->removeRow(0); } - QUrl mosaicURL = QUrl::fromLocalFile((QString("%1/%2_mosaic.esl").arg(outputDir).arg(targetName))); + QUrl mosaicURL = QUrl::fromLocalFile((QString("%1/%2_mosaic.esl").arg(outputDir, targetName))); if (saveScheduler(mosaicURL)) { @@ -4715,7 +4677,7 @@ } else if (!strcmp(tagXMLEle(subEP), "FITSDirectory")) { - editXMLEle(subEP, QString("%1/%2").arg(outputDir).arg(prefix).toLatin1().constData()); + editXMLEle(subEP, QString("%1/%2").arg(outputDir, prefix).toLatin1().constData()); } } } @@ -4723,7 +4685,7 @@ QDir().mkpath(outputDir); - QString filename = QString("%1/%2.esq").arg(outputDir).arg(prefix); + QString filename = QString("%1/%2.esq").arg(outputDir, prefix); FILE *outputFile = fopen(filename.toLatin1().constData(), "w"); if (outputFile == nullptr) Index: kstars/fitsviewer/fitslabel.cpp =================================================================== --- kstars/fitsviewer/fitslabel.cpp +++ kstars/fitsviewer/fitslabel.cpp @@ -168,7 +168,7 @@ ra.setD(wcs_coord[index].ra); dec.setD(wcs_coord[index].dec); - emit newStatus(QString("%1 , %2").arg(ra.toHMSString()).arg(dec.toDMSString()), FITS_WCS); + emit newStatus(QString("%1 , %2").arg(ra.toHMSString(), dec.toDMSString()), FITS_WCS); } bool objFound = false; Index: kstars/fitsviewer/fitsviewer.cpp =================================================================== --- kstars/fitsviewer/fitsviewer.cpp +++ kstars/fitsviewer/fitsviewer.cpp @@ -222,7 +222,7 @@ int filterCounter = 1; - foreach (QString filter, FITSViewer::filterTypes) + for (auto& filter : FITSViewer::filterTypes) { action = actionCollection()->addAction(QString("filter%1").arg(filterCounter)); action->setText(i18n(filter.toUtf8().constData())); Index: kstars/indi/drivermanager.cpp =================================================================== --- kstars/indi/drivermanager.cpp +++ kstars/indi/drivermanager.cpp @@ -154,8 +154,7 @@ if (ui->localTreeWidget->currentItem()) currentDriver = ui->localTreeWidget->currentItem()->text(LOCAL_NAME_COLUMN); - foreach (QTreeWidgetItem *item, - ui->localTreeWidget->findItems(dv->getTreeLabel(), Qt::MatchExactly | Qt::MatchRecursive)) + for (auto &item : ui->localTreeWidget->findItems(dv->getTreeLabel(), Qt::MatchExactly | Qt::MatchRecursive)) { item->setText(LOCAL_VERSION_COLUMN, dv->getVersion()); @@ -237,8 +236,7 @@ } else { - foreach (QTreeWidgetItem *item, - ui->clientTreeWidget->findItems(dv->getName(), Qt::MatchExactly, HOST_NAME_COLUMN)) + for (auto &item : ui->clientTreeWidget->findItems(dv->getName(), Qt::MatchExactly, HOST_NAME_COLUMN)) { if (dv->getClientState()) { @@ -260,11 +258,11 @@ { bool found = false; - foreach (DriverInfo *dv, dList) + for (DriverInfo *dv : dList) { QList uList; - foreach (DriverInfo *idv, dList) + for (DriverInfo *idv : dList) { if (dv->getHost() == idv->getHost() && dv->getPort() == idv->getPort()) { @@ -285,9 +283,9 @@ found = false; - foreach (QList qdi, uHosts) + for (auto &qdi : uHosts) { - foreach (DriverInfo *di, qdi) + for (DriverInfo *di : qdi) { if (di == idv) { @@ -322,7 +320,7 @@ if (Options::iNDILogging()) qDebug() << "INDI: Starting local drivers..."; - foreach (QList qdv, uHosts) + for (auto &qdv : uHosts) { if (qdv.empty()) continue; @@ -362,7 +360,7 @@ if (Options::iNDILogging()) qDebug() << "INDI: INDI Server started locally on port " << port; - foreach (DriverInfo *dv, qdv) + for (DriverInfo *dv : qdv) { if (serverManager->startDriver(dv) == false) { @@ -380,7 +378,7 @@ clientManager = new ClientManager(); - foreach (DriverInfo *dv, qdv) + for (DriverInfo *dv : qdv) clientManager->appendManagedDriver(dv); connect(clientManager, SIGNAL(connectionFailure(ClientManager *)), this, @@ -430,7 +428,7 @@ msgBox->setIcon(QMessageBox::Critical); msgBox->show(); - foreach (DriverInfo *dv, qdv) + for (DriverInfo *dv : qdv) processDeviceStatus(dv); GUIManager::Instance()->removeClient(clientManager); @@ -449,7 +447,7 @@ qDebug() << "INDI: Stopping local drivers..."; // #1 Disconnect all clients - foreach (DriverInfo *dv, dList) + for (DriverInfo *dv : dList) { ClientManager *cm = dv->getClientManager(); @@ -469,7 +467,7 @@ } // #2 Disconnect all servers - foreach (DriverInfo *dv, dList) + for (DriverInfo *dv : dList) { ServerManager *sm = dv->getServerManager(); @@ -552,7 +550,7 @@ QString hostname = item->text(HOST_NAME_COLUMN); QString hostport = item->text(HOST_PORT_COLUMN); - foreach (DriverInfo *dv, driversList) + for (auto &dv : driversList) { if (hostname == dv->getName() && hostport == dv->getPort()) { @@ -643,7 +641,7 @@ if (server == nullptr) return; - foreach (DriverInfo *dv, driversList) + for (auto &dv : driversList) if (dv->getServerManager() == server) { dv->setServerState(false); @@ -669,7 +667,7 @@ if (!currentItem) return; - foreach (DriverInfo *dv, driversList) + for (auto &dv : driversList) { if (dv->getDriverSource() != HOST_SOURCE) continue; @@ -955,7 +953,7 @@ indiDir.setFilter(QDir::Files | QDir::NoSymLinks); QFileInfoList list = indiDir.entryInfoList(); - foreach (QFileInfo fileInfo, list) + for (auto &fileInfo : list) { // libindi 0.7.1: Skip skeleton files if (fileInfo.fileName().endsWith("_sk.xml")) @@ -974,7 +972,7 @@ } } - driverName = QString("%1/%2").arg(driversDir).arg(fileInfo.fileName()); + driverName = QString("%1/%2").arg(driversDir, fileInfo.fileName()); processXMLDriver(driverName); } @@ -1506,7 +1504,7 @@ DriverInfo *DriverManager::findDriverByName(const QString &name) { - foreach (DriverInfo *dv, driversList) + for (auto &dv : driversList) { if (dv->getName() == name) return dv; @@ -1517,7 +1515,7 @@ DriverInfo *DriverManager::findDriverByLabel(const QString &label) { - foreach (DriverInfo *dv, driversList) + for (auto &dv : driversList) { if (dv->getTreeLabel() == label) return dv; @@ -1528,7 +1526,7 @@ DriverInfo *DriverManager::findDriverByExec(const QString &exec) { - foreach (DriverInfo *dv, driversList) + for (auto &dv : driversList) { if (dv->getDriver() == exec) return dv; @@ -1542,13 +1540,16 @@ int nset = 0; QString uniqueLabel = label; - foreach (ClientManager *cm, clients) - foreach (INDI::BaseDevice *dv, cm->getDevices()) + for (auto &cm : clients) + { + auto& devices = cm->getDevices(); + + for (auto &dv : devices) { if (label == QString(dv->getDeviceName())) nset++; } - + } if (nset > 0) uniqueLabel = QString("%1 %2").arg(label).arg(nset + 1); Index: kstars/indi/indiccd.h =================================================================== --- kstars/indi/indiccd.h +++ kstars/indi/indiccd.h @@ -7,19 +7,20 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef INDICCD_H -#define INDICCD_H +#pragma once #include "indistd.h" +#include "auxiliary/imageviewer.h" +#include "fitsviewer/fitscommon.h" +#include "fitsviewer/fitsview.h" +#include "fitsviewer/fitsviewer.h" #include #include -#include -#include - -#include +#include +class FITSData; class FITSView; class StreamWG; @@ -56,8 +57,6 @@ bool getFrameMinMax(int *minX, int *maxX, int *minY, int *maxY, int *minW, int *maxW, int *minH, int *maxH); bool setFrame(int x, int y, int w, int h); - //bool getFocusFrame(int *x, int *y, int *w, int *h); - //bool setFocusFrame(int x, int y, int w, int h); bool resetFrame(); bool capture(double exposure); bool setFrameType(CCDFrameType fType); @@ -97,7 +96,6 @@ void setCanAbort(bool value); FITSData *getImageData() const; - void setImageData(FITSData *value); int getISOIndex() const; bool setISOIndex(int value); @@ -106,20 +104,18 @@ private: QPointer normalImage, focusImage, guideImage, calibrationImage, alignImage; - FITSData *imageData; - FITSMode captureMode; - FITSScale captureFilter; - INDI::BaseDevice *baseDevice; - ClientManager *clientManager; + FITSData *imageData { nullptr }; + FITSMode captureMode { FITS_NORMAL }; + FITSScale captureFilter { FITS_NONE }; + INDI::BaseDevice *baseDevice { nullptr }; + ClientManager *clientManager { nullptr }; ChipType type; - bool batchMode; - bool displayFITS; + bool batchMode { false }; QStringList frameTypes; - bool CanBin; - bool CanSubframe; - bool CanAbort; - ISD::CCD *parentCCD; - //int fx,fy,fw,fh; + bool CanBin { false }; + bool CanSubframe { false }; + bool CanAbort { false }; + ISD::CCD *parentCCD { nullptr }; }; /** @@ -134,7 +130,7 @@ Q_OBJECT public: - CCD(GDInterface *iPtr); + explicit CCD(GDInterface *iPtr); ~CCD(); typedef enum { UPLOAD_CLIENT, UPLOAD_LOCAL, UPLOAD_BOTH } UploadMode; @@ -237,31 +233,36 @@ void newFPS(double instantFPS, double averageFPS); private: - void addFITSKeywords(QString filename); - QString filter; + void addFITSKeywords(const QString& filename); - bool ISOMode; - bool HasGuideHead; - bool HasCooler; - bool HasCoolerControl; - bool HasVideoStream; + QString filter; + bool ISOMode { true }; + bool HasGuideHead { false }; + bool HasCooler { false }; + bool HasCoolerControl { false }; + bool HasVideoStream { false }; QString seqPrefix; QString fitsDir; char BLOBFilename[MAXINDIFILENAME]; - int nextSequenceID; - StreamWG *streamWindow; - int streamW, streamH; - ISD::ST4 *ST4Driver; - int normalTabID, calibrationTabID, focusTabID, guideTabID, alignTabID; - CCDChip *primaryChip, *guideChip; - TransferFormat transferFormat, targetTransferFormat; - TelescopeType telescopeType = TELESCOPE_PRIMARY; + int nextSequenceID { 0 }; + std::unique_ptr streamWindow; + int streamW { 0 }; + int streamH { 0 }; + int normalTabID { -1 }; + int calibrationTabID { -1 }; + int focusTabID { -1 }; + int guideTabID { -1 }; + int alignTabID { -1 }; + std::unique_ptr primaryChip; + std::unique_ptr guideChip; + TransferFormat transferFormat { FORMAT_FITS }; + TransferFormat targetTransferFormat { FORMAT_FITS }; + TelescopeType telescopeType { TELESCOPE_PRIMARY }; // Gain, since it is spread among different vector properties, let's try to find the property itself. - INumber *gainN = nullptr; + INumber *gainN { nullptr }; QPointer fv; QPointer imageViewer; }; } -#endif // INDICCD_H Index: kstars/indi/indiccd.cpp =================================================================== --- kstars/indi/indiccd.cpp +++ kstars/indi/indiccd.cpp @@ -7,41 +7,30 @@ version 2 of the License, or (at your option) any later version. */ -#include - -#include +#include "indiccd.h" -#include -#include -#include -#include - -#include +#include "config-kstars.h" +#include "clientmanager.h" +#include "driverinfo.h" +#include "guimanager.h" +#include "kspaths.h" +#include "kstarsdata.h" +#include "Options.h" +#include "streamwg.h" +#include "ekos/ekosmanager.h" #ifdef HAVE_CFITSIO -#include "fitsviewer/fitsviewer.h" -#include "fitsviewer/fitscommon.h" -#include "fitsviewer/fitsview.h" #include "fitsviewer/fitsdata.h" #endif +#include + +#include + #ifdef HAVE_LIBRAW #include #endif -#include "driverinfo.h" -#include "clientmanager.h" -#include "streamwg.h" -#include "indiccd.h" -#include "guimanager.h" -#include "kstarsdata.h" -#include "fov.h" -#include "kspaths.h" - -#include - -#include "Options.h" - const QStringList RAWFormats = { "cr2", "crw", "nef", "raf", "dng", "arw" }; namespace ISD @@ -52,19 +41,6 @@ clientManager = ccd->getDriverInfo()->getClientManager(); parentCCD = ccd; type = cType; - batchMode = false; - displayFITS = true; - CanBin = false; - CanSubframe = false; - CanAbort = false; - imageData = nullptr; - - captureMode = FITS_NORMAL; - captureFilter = FITS_NONE; - - //fx=fy=fw=fh=0; - - normalImage = focusImage = guideImage = calibrationImage = nullptr; } FITSView *CCDChip::getImageView(FITSMode imageType) @@ -457,26 +433,6 @@ return CanAbort; } -/*bool CCDChip::getFocusFrame(int *x, int *y, int *w, int *h) -{ - *x = fx; - *y = fy; - *w = fw; - *h = fh; - - return true; -} - -bool CCDChip::setFocusFrame(int x, int y, int w, int h) -{ - fx=x; - fy=y; - fw=w; - fh=h; - - return true; -}*/ - void CCDChip::setCanAbort(bool value) { CanAbort = value; @@ -487,10 +443,6 @@ return imageData; } -void CCDChip::setImageData(FITSData *value) -{ - imageData = value; -} int CCDChip::getISOIndex() const { ISwitchVectorProperty *isoProp = baseDevice->getSwitch("CCD_ISO"); @@ -828,33 +780,12 @@ CCD::CCD(GDInterface *iPtr) : DeviceDecorator(iPtr) { - dType = KSTARS_CCD; - ISOMode = true; - HasGuideHead = false; - HasCooler = false; - HasCoolerControl = false; - HasVideoStream = false; - fv = nullptr; - streamWindow = nullptr; - ST4Driver = nullptr; - nextSequenceID = 0; - - primaryChip = new CCDChip(this, CCDChip::PRIMARY_CCD); - - normalTabID = calibrationTabID = focusTabID = guideTabID = alignTabID = -1; - guideChip = nullptr; - - transferFormat = targetTransferFormat = FORMAT_FITS; + primaryChip.reset(new CCDChip(this, CCDChip::PRIMARY_CCD)); } CCD::~CCD() { -#ifdef HAVE_CFITSIO - delete (fv); -#endif - delete (primaryChip); - delete (guideChip); - delete (streamWindow); + delete fv; } void CCD::registerProperty(INDI::Property *prop) @@ -862,7 +793,7 @@ if (!strcmp(prop->getName(), "GUIDER_EXPOSURE")) { HasGuideHead = true; - guideChip = new CCDChip(this, CCDChip::GUIDE_CCD); + guideChip.reset(new CCDChip(this, CCDChip::GUIDE_CCD)); } else if (!strcmp(prop->getName(), "CCD_FRAME_TYPE")) { @@ -986,7 +917,7 @@ { INumber *np = IUFindNumber(nvp, "CCD_EXPOSURE_VALUE"); if (np) - emit newExposureValue(primaryChip, np->value, nvp->s); + emit newExposureValue(primaryChip.get(), np->value, nvp->s); } else if (!strcmp(nvp->name, "CCD_TEMPERATURE")) { @@ -999,7 +930,7 @@ { INumber *np = IUFindNumber(nvp, "GUIDER_EXPOSURE_VALUE"); if (np) - emit newExposureValue(guideChip, np->value, nvp->s); + emit newExposureValue(guideChip.get(), np->value, nvp->s); } else if (!strcmp(nvp->name, "FPS")) { @@ -1012,7 +943,7 @@ if (nvp->s == IPS_ALERT) { - emit newGuideStarData(primaryChip, -1, -1, -1); + emit newGuideStarData(primaryChip.get(), -1, -1, -1); } else { @@ -1027,7 +958,7 @@ fit = np->value; if (dx >= 0 && dy >= 0 && fit >= 0) - emit newGuideStarData(primaryChip, dx, dy, fit); + emit newGuideStarData(primaryChip.get(), dx, dy, fit); } } else if (!strcmp(nvp->name, "GUIDER_RAPID_GUIDE_DATA")) @@ -1037,7 +968,7 @@ if (nvp->s == IPS_ALERT) { - emit newGuideStarData(guideChip, -1, -1, -1); + emit newGuideStarData(guideChip.get(), -1, -1, -1); } else { @@ -1052,7 +983,7 @@ fit = np->value; if (dx >= 0 && dy >= 0 && fit >= 0) - emit newGuideStarData(guideChip, dx, dy, fit); + emit newGuideStarData(guideChip.get(), dx, dy, fit); } } @@ -1070,12 +1001,13 @@ { HasVideoStream = true; - if (streamWindow == nullptr && svp->sp[0].s == ISS_ON) + if (streamWindow.get() == nullptr && svp->sp[0].s == ISS_ON) { - streamWindow = new StreamWG(this); + streamWindow.reset(new StreamWG(this)); INumberVectorProperty *streamFrame = baseDevice->getNumber("CCD_STREAM_FRAME"); INumber *w = nullptr, *h = nullptr; + if (streamFrame) { w = IUFindNumber(streamFrame, "WIDTH"); @@ -1106,9 +1038,9 @@ streamWindow->setSize(streamW, streamH); } - if (streamWindow) + if (streamWindow.get() != nullptr) { - connect(streamWindow, SIGNAL(hidden()), this, SLOT(StreamWindowHidden()), Qt::UniqueConnection); + connect(streamWindow.get(), SIGNAL(hidden()), this, SLOT(StreamWindowHidden()), Qt::UniqueConnection); streamWindow->enableStream(svp->sp[0].s == ISS_ON); emit videoStreamToggled(svp->sp[0].s == ISS_ON); @@ -1150,13 +1082,12 @@ { ISwitch *dSwitch = IUFindSwitch(svp, "DISCONNECT"); - if (dSwitch && dSwitch->s == ISS_ON && streamWindow != nullptr) + if (dSwitch && dSwitch->s == ISS_ON && streamWindow.get() != nullptr) { streamWindow->enableStream(false); emit videoStreamToggled(false); streamWindow->close(); - delete (streamWindow); - streamWindow = nullptr; + streamWindow.reset(); } //emit switchUpdated(svp); @@ -1189,7 +1120,7 @@ QString format(bp->format); // If stream, process it first - if (format.contains("stream") && streamWindow) + if (format.contains("stream") && streamWindow.get() != nullptr) { if (streamWindow->isStreamEnabled() == false) return; @@ -1254,9 +1185,9 @@ CCDChip *targetChip = nullptr; if (!strcmp(bp->name, "CCD2")) - targetChip = guideChip; + targetChip = guideChip.get(); else - targetChip = primaryChip; + targetChip = primaryChip.get(); QString currentDir; @@ -1317,9 +1248,10 @@ } else filename += seqPrefix + (seqPrefix.isEmpty() ? "" : "_") + - QString("%1.%2").arg(QString().sprintf("%03d", nextSequenceID)).arg(QString(fmt)); + QString("%1.%2").arg(QString().sprintf("%03d", nextSequenceID), QString(fmt)); QFile fits_temp_file(filename); + if (!fits_temp_file.open(QIODevice::WriteOnly)) { qDebug() << "ISD:CCD Error: Unable to open " << fits_temp_file.fileName() << endl; @@ -1360,11 +1292,12 @@ if (BType == BLOB_RAW) { #ifdef HAVE_LIBRAW - QString rawFileName = filename; rawFileName = rawFileName.remove(0, rawFileName.lastIndexOf(QLatin1Literal("/"))); - QString templateName = QString("%1/%2.XXXXXX").arg(QDir::tempPath()).arg(rawFileName); + + QString templateName = QString("%1/%2.XXXXXX").arg(QDir::tempPath(), rawFileName); QTemporaryFile imgPreview(templateName); + imgPreview.setAutoRemove(false); imgPreview.open(); imgPreview.close(); @@ -1711,7 +1644,7 @@ emit BLOBUpdated(bp); } -void CCD::addFITSKeywords(QString filename) +void CCD::addFITSKeywords(const QString& filename) { #ifdef HAVE_CFITSIO int status = 0; @@ -1794,7 +1727,7 @@ } } - if (streamWindow) + if (streamWindow.get() != nullptr) streamWindow->disconnect(); } @@ -1837,11 +1770,11 @@ switch (cType) { case CCDChip::PRIMARY_CCD: - return primaryChip; + return primaryChip.get(); break; case CCDChip::GUIDE_CCD: - return guideChip; + return guideChip.get(); break; } @@ -1853,7 +1786,7 @@ ISwitchVectorProperty *rapidSP = nullptr; ISwitch *enableS = nullptr; - if (targetChip == primaryChip) + if (targetChip == primaryChip.get()) rapidSP = baseDevice->getSwitch("CCD_RAPID_GUIDE"); else rapidSP = baseDevice->getSwitch("GUIDER_RAPID_GUIDE"); @@ -1884,7 +1817,7 @@ ISwitchVectorProperty *rapidSP = nullptr; ISwitch *autoLoopS = nullptr, *sendImageS = nullptr, *showMarkerS = nullptr; - if (targetChip == primaryChip) + if (targetChip == primaryChip.get()) rapidSP = baseDevice->getSwitch("CCD_RAPID_GUIDE_SETUP"); else rapidSP = baseDevice->getSwitch("GUIDER_RAPID_GUIDE_SETUP"); @@ -2187,7 +2120,7 @@ bool CCD::isStreamingEnabled() { - if (HasVideoStream == false || streamWindow == nullptr) + if (HasVideoStream == false || streamWindow.get() == nullptr) return false; return streamWindow->isStreamEnabled(); Index: kstars/indi/indidbus.h =================================================================== --- kstars/indi/indidbus.h +++ kstars/indi/indidbus.h @@ -7,8 +7,7 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef INDIDBUS_H -#define INDIDBUS_H +#pragma once #include #include @@ -173,5 +172,3 @@ /** @}*/ }; - -#endif Index: kstars/indi/indidbus.cpp =================================================================== --- kstars/indi/indidbus.cpp +++ kstars/indi/indidbus.cpp @@ -7,9 +7,12 @@ version 2 of the License, or (at your option) any later version. */ +#include "indidbus.h" + #include -#include +#include "indiadaptor.h" +#include "nan.h" #include "indi/drivermanager.h" #include "indi/servermanager.h" #include "indi/driverinfo.h" @@ -17,10 +20,6 @@ #include "indi/indilistener.h" #include "indi/deviceinfo.h" -#include "nan.h" - -#include "indidbus.h" -#include "indiadaptor.h" INDIDBus::INDIDBus(QObject *parent) : QObject(parent) { @@ -32,7 +31,7 @@ { QList newDrivers; - foreach (QString driver, drivers) + for (auto &driver : drivers) { DriverInfo *drv = DriverManager::Instance()->findDriverByExec(driver); Index: kstars/indi/indistd.h =================================================================== --- kstars/indi/indistd.h +++ kstars/indi/indistd.h @@ -44,7 +44,7 @@ /** * @class GDInterface - * GDInterface is the Generic Device Interface for INDI devices. It is used as part of the Decorater Pattern when initially a new INDI device is created as a + * GDInterface is the Generic Device Interface for INDI devices. It is used as part of the Decorater Pattern when initially a new INDI device is created as a * Generic Device in INDIListener. If the device registers an INDI Standard Property belonging to one specific device type (e.g. Telescope), then the device functionality * is extended to the particular device type. * @@ -85,17 +85,17 @@ virtual ~GDInterface() {} - protected: - DeviceFamily dType; - QList properties; - public slots: virtual bool Connect() = 0; virtual bool Disconnect() = 0; virtual bool runCommand(int command, void *ptr = nullptr) = 0; virtual bool setProperty(QObject *) = 0; - signals: +protected: + DeviceFamily dType { KSTARS_CCD }; + QList properties; + +signals: void Connected(); void Disconnected(); void switchUpdated(ISwitchVectorProperty *svp); Index: kstars/indi/indiwebmanager.h =================================================================== --- kstars/indi/indiwebmanager.h +++ kstars/indi/indiwebmanager.h @@ -7,8 +7,13 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef INDIWEBMANAGER_H -#define INDIWEBMANAGER_H +#pragma once + +#include + +class QByteArray; +class QJsonDocument; +class QUrl; class ProfileInfo; @@ -24,5 +29,3 @@ bool stopProfile(ProfileInfo *pi); } } - -#endif // INDIWEBMANAGER_H Index: kstars/indi/indiwebmanager.cpp =================================================================== --- kstars/indi/indiwebmanager.cpp +++ kstars/indi/indiwebmanager.cpp @@ -7,20 +7,15 @@ version 2 of the License, or (at your option) any later version. */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "indiwebmanager.h" -#include "profileinfo.h" -#include "Options.h" -#include "drivermanager.h" + #include "driverinfo.h" +#include "drivermanager.h" +#include "Options.h" +#include "profileinfo.h" + +#include +#include namespace INDI { @@ -140,7 +135,7 @@ if (array.count() < piExecDrivers.count()) return false; - foreach (QJsonValue value, array) + for (auto value : array) { QJsonObject obj = value.toObject(); Index: kstars/indi/servermanager.h =================================================================== --- kstars/indi/servermanager.h +++ kstars/indi/servermanager.h @@ -1,6 +1,3 @@ -#ifndef SERVERMANAGER_H -#define SERVERMANAGER_H - /* INDI Server Manager Copyright (C) 2012 Jasem Mutlaq (mutlaqja@ikarustech.com) @@ -11,14 +8,16 @@ */ +#pragma once + +#include "indicommon.h" + +#include #include -#include #include -#include - -#include +#include -#include "indicommon.h" +#include class DriverInfo; @@ -33,15 +32,7 @@ Q_OBJECT public: - enum - { - INDI_DEVICE_NOT_FOUND = -1, - INDI_PROPERTY_INVALID = -2, - INDI_PROPERTY_DUPLICATED = -3, - INDI_DISPATCH_ERROR = -4 - }; - - ServerManager(QString inHost, uint inPort); + ServerManager(const QString& inHost, uint inPort); ~ServerManager(); bool start(); @@ -62,33 +53,28 @@ int size() { return managedDrivers.size(); } - bool isDriverManaged(DriverInfo *); +public slots: + void connectionSuccess(); + void processServerError(QProcess::ProcessError); + void processStandardError(); - private: +private: QTcpSocket serverSocket; - LilXML *XMLParser; QString host; QString port; QString serverBuffer; - QProcess *serverProcess; + std::unique_ptr serverProcess; ServerMode mode; - bool driverCrashed; + bool driverCrashed { false }; QList managedDrivers; QFile indiFIFO; - public slots: - void connectionSuccess(); - void processServerError(QProcess::ProcessError); - void processStandardError(); - signals: void serverFailure(ServerManager *); void newServerLog(); void started(); void finished(int exit_code, QProcess::ExitStatus exit_status); }; - -#endif // SERVERMANAGER_H Index: kstars/indi/servermanager.cpp =================================================================== --- kstars/indi/servermanager.cpp +++ kstars/indi/servermanager.cpp @@ -8,37 +8,20 @@ */ -#include -#include - -#include -#include +#include "servermanager.h" -#include +#include "driverinfo.h" +#include "drivermanager.h" +#include "Options.h" -#include -#include +#include -#include -#include -#include #include -#include -#include - -#include "servermanager.h" -#include "drivermanager.h" -#include "driverinfo.h" -#include "Options.h" -#include "kstars.h" -#include "kstarsdatetime.h" -#include "kspaths.h" +#include -ServerManager::ServerManager(QString inHost, uint inPort) +ServerManager::ServerManager(const QString& inHost, uint inPort) { - serverProcess = nullptr; - XMLParser = nullptr; host = inHost; port = QString::number(inPort); @@ -52,10 +35,8 @@ QFile::remove(indiFIFO.fileName()); - if (serverProcess) + if (serverProcess.get() != nullptr) serverProcess->close(); - - delete (serverProcess); } bool ServerManager::start() @@ -67,9 +48,9 @@ bool connected = false; int fd = 0; - if (serverProcess == nullptr) + if (serverProcess.get() == nullptr) { - serverProcess = new QProcess(this); + serverProcess.reset(new QProcess(this)); #ifdef Q_OS_OSX QString driversDir = Options::indiDriversDir(); if (Options::indiDriversAreInternal()) @@ -137,9 +118,9 @@ if (connected) { - connect(serverProcess, SIGNAL(error(QProcess::ProcessError)), this, + connect(serverProcess.get(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(processServerError(QProcess::ProcessError))); - connect(serverProcess, SIGNAL(readyReadStandardError()), this, SLOT(processStandardError())); + connect(serverProcess.get(), SIGNAL(readyReadStandardError()), this, SLOT(processStandardError())); emit started(); } @@ -238,20 +219,9 @@ dv->setPort(dv->getUserPort()); } -bool ServerManager::isDriverManaged(DriverInfo *di) -{ - foreach (DriverInfo *dv, managedDrivers) - { - if (dv == di) - return true; - } - - return false; -} - void ServerManager::stop() { - if (serverProcess == nullptr) + if (serverProcess.get() == nullptr) return; foreach (DriverInfo *device, managedDrivers) @@ -266,14 +236,12 @@ serverProcess->waitForFinished(); - delete serverProcess; - - serverProcess = nullptr; + serverProcess.reset(); } void ServerManager::terminate() { - if (serverProcess == nullptr) + if (serverProcess.get() == nullptr) return; serverProcess->terminate(); @@ -286,7 +254,7 @@ foreach (DriverInfo *device, managedDrivers) device->setServerState(true); - connect(serverProcess, SIGNAL(readyReadStandardError()), this, SLOT(processStandardError())); + connect(serverProcess.get(), SIGNAL(readyReadStandardError()), this, SLOT(processStandardError())); emit started(); } @@ -309,14 +277,14 @@ if (Options::iNDILogging()) { - foreach (QString msg, stderr.split("\n")) + for (auto &msg : stderr.split("\n")) qDebug() << "INDI Server: " << msg; } if (driverCrashed == false && (serverBuffer.contains("stdin EOF") || serverBuffer.contains("stderr EOF"))) { QStringList parts = serverBuffer.split("Driver"); - foreach (QString driver, parts) + for (auto &driver : parts) { if (driver.contains("stdin EOF") || driver.contains("stderr EOF")) { @@ -337,7 +305,7 @@ QString ServerManager::errorString() { - if (serverProcess) + if (serverProcess.get() != nullptr) return serverProcess->errorString(); return nullptr; Index: kstars/indi/telescopewizardprocess.h =================================================================== --- kstars/indi/telescopewizardprocess.h +++ kstars/indi/telescopewizardprocess.h @@ -7,14 +7,15 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef TELESCOPEWIZARDPROCESS_H_ -#define TELESCOPEWIZARDPROCESS_H_ +#pragma once + +#include "ui_telescopewizard.h" +#include "indi/indistd.h" -#include #include +#include -#include "indi/indistd.h" -#include "ui_telescopewizard.h" +#include class DriverInfo; @@ -25,7 +26,7 @@ Q_OBJECT public: - explicit telescopeWizardProcess(QWidget *parent = 0, const char *name = 0); + explicit telescopeWizardProcess(QWidget *parent = nullptr); ~telescopeWizardProcess(); unsigned int currentPage; @@ -38,29 +39,11 @@ PORT_P = 4 }; - private: - Ui::telescopeWizard *ui; - - ISD::GDInterface *scopeDevice; - - QProgressDialog *progressScan; - - QStringList portList; - QString currentDevice; - - int currentPort; - int timeOutCount; - bool INDIMessageBar; - bool linkRejected; - - QHash driversList; - - QList managedDevice; - +private: void establishLink(); void Reset(); - public slots: +public slots: void cancelCheck(); void processNext(); void processBack(); @@ -69,6 +52,15 @@ void processTelescope(ISD::GDInterface *); void scanPorts(); void linkSuccess(); -}; -#endif +private: + std::unique_ptr ui; + ISD::GDInterface *scopeDevice { nullptr }; + QProgressDialog *progressScan { nullptr }; + QStringList portList; + int currentPort { -1 }; + bool INDIMessageBar { false }; + bool linkRejected { false }; + QHash driversList; + QList managedDevice; +}; Index: kstars/indi/telescopewizardprocess.cpp =================================================================== --- kstars/indi/telescopewizardprocess.cpp +++ kstars/indi/telescopewizardprocess.cpp @@ -9,44 +9,29 @@ #include "telescopewizardprocess.h" -#include -#include -#include -#include -#include -#include - -#include - -#include "Options.h" -#include "kstars.h" -#include "kstarsdata.h" -#include "dialogs/timedialog.h" -#include "ksutils.h" - -#include "guimanager.h" -#include "indilistener.h" #include "driverinfo.h" #include "drivermanager.h" +#include "guimanager.h" +#include "indidevice.h" #include "indielement.h" +#include "indilistener.h" #include "indiproperty.h" -#include "indistd.h" -#include "indidevice.h" +#include "kstars.h" +#include "kstarsdata.h" +#include "ksutils.h" +#include "Options.h" +#include "dialogs/timedialog.h" -#define TIMEOUT_THRESHOLD 20 +#include +#include -telescopeWizardProcess::telescopeWizardProcess(QWidget *parent, const char * /*name*/) : QDialog(parent) +telescopeWizardProcess::telescopeWizardProcess(QWidget *parent) : QDialog(parent) { - currentPort = -1; - timeOutCount = 0; - progressScan = nullptr; - linkRejected = false; - ui = new Ui::telescopeWizard(); - ui->setupUi(this); - - QString locStr; QFile sideIMG; + ui.reset(new Ui::telescopeWizard()); + ui->setupUi(this); + if (KSUtils::openDataFile(sideIMG, "wzscope.png")) ui->wizardPix->setPixmap(QPixmap(sideIMG.fileName())); @@ -66,15 +51,15 @@ //if (KStars::Instance()->data()->geo()->translatedProvince().isEmpty()) if (KStars::Instance()->data()->geo()->translatedProvince() == QString("(I18N_EMPTY_MESSAGE)")) ui->locationOut->setText(QString("%1, %2") - .arg(KStars::Instance()->data()->geo()->translatedName()) - .arg(KStars::Instance()->data()->geo()->translatedCountry())); + .arg(KStars::Instance()->data()->geo()->translatedName(), + KStars::Instance()->data()->geo()->translatedCountry())); else ui->locationOut->setText(QString("%1, %2, %3") - .arg(KStars::Instance()->data()->geo()->translatedName()) - .arg(KStars::Instance()->data()->geo()->translatedProvince()) - .arg(KStars::Instance()->data()->geo()->translatedCountry())); + .arg(KStars::Instance()->data()->geo()->translatedName(), + KStars::Instance()->data()->geo()->translatedProvince(), + KStars::Instance()->data()->geo()->translatedCountry())); - foreach (DriverInfo *dv, DriverManager::Instance()->getDrivers()) + for (DriverInfo *dv : DriverManager::Instance()->getDrivers()) { if (dv->getType() == KSTARS_TELESCOPE) { @@ -107,7 +92,6 @@ telescopeWizardProcess::~telescopeWizardProcess() { Options::setShowINDIMessages(INDIMessageBar); - delete ui; //Reset(); } @@ -209,7 +193,7 @@ KStars::Instance()->slotGeoLocator(); GeoLocation *geo = KStars::Instance()->data()->geo(); ui->locationOut->setText( - QString("%1, %2, %3").arg(geo->translatedName()).arg(geo->translatedProvince()).arg(geo->translatedCountry())); + QString("%1, %2, %3").arg(geo->translatedName(),geo->translatedProvince(), geo->translatedCountry())); ui->timeOut->setText(QString().sprintf("%02d:%02d:%02d", KStars::Instance()->data()->lt().time().hour(), KStars::Instance()->data()->lt().time().minute(), KStars::Instance()->data()->lt().time().second())); @@ -380,7 +364,6 @@ void telescopeWizardProcess::Reset() { currentPort = -1; - timeOutCount = 0; linkRejected = false; delete (progressScan); Index: kstars/kstarsactions.cpp =================================================================== --- kstars/kstarsactions.cpp +++ kstars/kstarsactions.cpp @@ -15,91 +15,51 @@ * * ***************************************************************************/ -//needed in slotRunScript() for chmod() syscall (remote script downloaded to temp file) +// This file contains function definitions for Actions declared in kstars.h -#ifdef _WIN32 -#include -#undef interface -#endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include "options/opscatalog.h" -#include "options/opsguides.h" -#include "options/opssolarsystem.h" -#include "options/opssatellites.h" -#include "options/opssupernovae.h" -#include "options/opscolors.h" -#include "options/opsadvanced.h" - -#include "Options.h" #include "kstars.h" + +#include "imageexporter.h" #include "kstarsdata.h" -#include "kstarsdatetime.h" +#include "kswizard.h" +#include "Options.h" #include "skymap.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/ksplanetbase.h" -#include "simclock.h" -#include "dialogs/timedialog.h" -#include "dialogs/locationdialog.h" +#include "dialogs/exportimagedialog.h" #include "dialogs/finddialog.h" #include "dialogs/focusdialog.h" #include "dialogs/fovdialog.h" -#include "dialogs/exportimagedialog.h" +#include "dialogs/locationdialog.h" +#include "dialogs/timedialog.h" +#include "oal/execute.h" +#include "options/opsadvanced.h" +#include "options/opscatalog.h" +#include "options/opscolors.h" +#include "options/opsguides.h" +#include "options/opssatellites.h" +#include "options/opssolarsystem.h" +#include "options/opssupernovae.h" #include "printing/printingwizard.h" -#include "kswizard.h" -#include "tools/astrocalc.h" +#include "projections/projector.h" +#include "skycomponents/asteroidscomponent.h" +#include "skycomponents/cometscomponent.h" +#include "skycomponents/satellitescomponent.h" +#include "skycomponents/skymapcomposite.h" +#include "skycomponents/solarsystemcomposite.h" +#include "skycomponents/supernovaecomponent.h" +#include "tools/adddeepskyobject.h" #include "tools/altvstime.h" -#include "tools/wutdialog.h" -#include "tools/observinglist.h" +#include "tools/astrocalc.h" #include "tools/eyepiecefield.h" -#include "tools/adddeepskyobject.h" - -#include "tools/whatsinteresting/wiview.h" -#include "tools/whatsinteresting/wilpsettings.h" -#include "tools/whatsinteresting/wiequipsettings.h" - -#include "tools/skycalendar.h" -#include "tools/scriptbuilder.h" -#include "tools/planetviewer.h" -//#include "tools/jmoontool.h" -//FIXME Port to KF5 -//#include "tools/moonphasetool.h" #include "tools/flagmanager.h" #include "tools/horizonmanager.h" -#include "oal/execute.h" -#include "projections/projector.h" -#include "imageexporter.h" - -#include +#include "tools/observinglist.h" +#include "tools/planetviewer.h" +#include "tools/scriptbuilder.h" +#include "tools/skycalendar.h" +#include "tools/wutdialog.h" +#include "tools/whatsinteresting/wiequipsettings.h" +#include "tools/whatsinteresting/wilpsettings.h" +#include "tools/whatsinteresting/wiview.h" #ifdef HAVE_INDI #include @@ -110,18 +70,6 @@ #include "indi/indilistener.h" #endif -#ifdef HAVE_NOTIFYCONFIG -#include -#endif - -#include "skycomponents/catalogcomponent.h" -#include "skycomponents/skymapcomposite.h" -#include "skycomponents/solarsystemcomposite.h" -#include "skycomponents/cometscomponent.h" -#include "skycomponents/asteroidscomponent.h" -#include "skycomponents/supernovaecomponent.h" -#include "skycomponents/satellitescomponent.h" - #ifdef HAVE_CFITSIO #include "fitsviewer/fitsviewer.h" #include "fitsviewer/opsfits.h" @@ -135,9 +83,22 @@ #include "xplanet/opsxplanet.h" #endif -// #include "libkdeedu/kdeeduui/kdeeduglossary.h" +#ifdef HAVE_NOTIFYCONFIG +#include +#endif +#include +#include +#include +#include + +#include +#include -//This file contains function definitions for Actions declared in kstars.h +#ifdef _WIN32 +#include +#undef interface +#endif +#include /** ViewToolBar Action. All of the viewToolBar buttons are connected to this slot. **/ @@ -1155,7 +1116,7 @@ while (!istream.atEnd()) { line = istream.readLine(); - if (line.left(1) != "#" && line.left(9) != "dbus-send") + if (line.at(0) != '#' && line.left(9) != "dbus-send") { fileOK = false; break; Index: kstars/kstarsdata.cpp =================================================================== --- kstars/kstarsdata.cpp +++ kstars/kstarsdata.cpp @@ -460,10 +460,10 @@ { QStringList fields = line.split(' ', QString::SkipEmptyParts); QString id = fields[0]; - QTime stime = QTime(fields[3].left(fields[3].indexOf(':')).toInt(), - fields[3].mid(fields[3].indexOf(':') + 1, fields[3].length()).toInt()); - QTime rtime = QTime(fields[6].left(fields[6].indexOf(':')).toInt(), - fields[6].mid(fields[6].indexOf(':') + 1, fields[6].length()).toInt()); + QTime stime = QTime(fields[3].leftRef(fields[3].indexOf(':')).toInt(), + fields[3].midRef(fields[3].indexOf(':') + 1, fields[3].length()).toInt()); + QTime rtime = QTime(fields[6].leftRef(fields[6].indexOf(':')).toInt(), + fields[6].midRef(fields[6].indexOf(':') + 1, fields[6].length()).toInt()); Rulebook[id] = TimeZoneRule(fields[1], fields[2], stime, fields[4], fields[5], rtime); } @@ -980,8 +980,7 @@ if (!ok) qDebug() << QString("Unable to load color scheme named %1. Also tried %2.") - .arg(csName) - .arg(filename); + .arg(csName, filename); } } else if (fn[0] == "zoom" && fn.size() == 2) Index: kstars/kstarsdbus.cpp =================================================================== --- kstars/kstarsdbus.cpp +++ kstars/kstarsdbus.cpp @@ -17,38 +17,21 @@ //KStars DBUS functions -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include +#include "kstars.h" #include "colorscheme.h" -#include "kstars.h" -#include "kstarsdata.h" +#include "eyepiecefield.h" +#include "imageexporter.h" #include "ksdssdownloader.h" +#include "kstarsdata.h" +#include "observinglist.h" +#include "Options.h" #include "skymap.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/starobject.h" +#include "skycomponents/constellationboundarylines.h" +#include "skycomponents/skymapcomposite.h" #include "skyobjects/deepskyobject.h" #include "skyobjects/ksplanetbase.h" -#include "skycomponents/skymapcomposite.h" -#include "simclock.h" -#include "Options.h" -#include "imageexporter.h" -#include "skycomponents/constellationboundarylines.h" -#include "observinglist.h" -#include "eyepiecefield.h" - +#include "skyobjects/starobject.h" #include "tools/whatsinteresting/wiview.h" #ifdef HAVE_CFITSIO @@ -58,6 +41,8 @@ #endif #endif +#include + void KStars::setRaDec(double ra, double dec) { SkyPoint p(ra, dec); @@ -292,12 +277,10 @@ { if (province.isEmpty()) qDebug() - << QString("Error [D-Bus setGeoLocation]: city %1, %2 not found in database.").arg(city).arg(country); + << QString("Error [D-Bus setGeoLocation]: city %1, %2 not found in database.").arg(city, country); else qDebug() << QString("Error [D-Bus setGeoLocation]: city %1, %2, %3 not found in database.") - .arg(city) - .arg(province) - .arg(country); + .arg(city, province, country); } return cityFound; @@ -887,7 +870,8 @@ QString KStars::getObservingWishListObjectNames() { QString output; - foreach (QSharedPointer object, KStarsData::Instance()->observingList()->obsList()) + + for (auto &object : KStarsData::Instance()->observingList()->obsList()) { output.append(object->name() + '\n'); } @@ -897,7 +881,8 @@ QString KStars::getObservingSessionPlanObjectNames() { QString output; - foreach (QSharedPointer object, KStarsData::Instance()->observingList()->sessionList()) + + for (auto &object : KStarsData::Instance()->observingList()->sessionList()) { output.append(object->name() + '\n'); } Index: kstars/oal/execute.h =================================================================== --- kstars/oal/execute.h +++ kstars/oal/execute.h @@ -16,21 +16,17 @@ * * ***************************************************************************/ -#ifndef EXECUTE_H_ -#define EXECUTE_H_ +#pragma once #include "ui_execute.h" - -#include -#include - -#include "kstars.h" -#include "geolocation.h" #include "oal/oal.h" #include "oal/session.h" #include "skyobjects/skyobject.h" -class KStars; +#include + +class GeoLocation; +class SkyObject; /** * @class Execute @@ -40,78 +36,70 @@ class Execute : public QDialog { Q_OBJECT + public: - /** @short Default constructor - */ + /** @short Default constructor */ Execute(); - /** @short This initializes the combo boxes, and sets up the - * dateTime and geolocation from the OL - */ + /** + * @short This initializes the combo boxes, and sets up the + * dateTime and geolocation from the OL + */ void init(); public slots: - /** @short Function to handle the UI when the 'next' button is pressed - * This calls the corresponding functions based on the currentIndex - */ + /** + * @short Function to handle the UI when the 'next' button is pressed + * This calls the corresponding functions based on the currentIndex + */ void slotNext(); - /*Function to Save the session details*/ + /** Function to Save the session details */ bool saveSession(); - /** @short Function to save the user notes set for - * the current object in the target combo box - */ + /** + * @short Function to save the user notes set for the current object in the target combo box + */ void addTargetNotes(); - // void slotObserverAdd(); - // - /** @short Function to add the current observation to the observation list - */ + /** @short Function to add the current observation to the observation list */ bool addObservation(); - /** @short Function to handle the state of current observation, - * and hiding the execute window - */ + /** + * @short Function to handle the state of current observation, and hiding the execute window + */ void slotEndSession(); - /** @short Opens the location dialog for setting the current location - */ + /** @short Opens the location dialog for setting the current location */ void slotLocation(); - /** @short Loads the sessionlist from the OL - * into the target combo box - */ + /** @short Loads the sessionlist from the OL into the target combo box */ void loadTargets(); - /** @short Sorts the target list using the scheduled time - */ + /** @short Sorts the target list using the scheduled time */ void sortTargetList(); - /** @short set the currentTarget when the user selection - * is changed in the target combo box - */ + /** + * @short set the currentTarget when the user selection is changed in the target combo box + */ void slotSetTarget(QString name); - /** @short loads the equipment list from - * the global logObject into the comboBoxes - */ + /** @short loads the equipment list from the global logObject into the comboBoxes */ void loadEquipment(); - /** @short loads the observer list from - * the global logObject into the comboBoxes - */ + /** @short loads the observer list from the global logObject into the comboBoxes */ void loadObservers(); /** @short loads the observation edit page */ void loadObservationTab(); - /** @short get object name. If star has no name, generate a name based on catalog number. - * @param translated set to true if the translated name is required. - */ + /** + * @short get object name. If star has no name, generate a name based on catalog number. + * @param translated set to true if the translated name is required. + */ QString getObjectName(const SkyObject *o, bool translated = true); void selectNextTarget(); @@ -134,16 +122,16 @@ private: Ui::Execute ui; - OAL::Session *currentSession; - OAL::Log *logObject; - OAL::Observer *currentObserver; - OAL::Scope *currentScope; - OAL::Eyepiece *currentEyepiece; - OAL::Lens *currentLens; - OAL::Filter *currentFilter; - GeoLocation *geo; - SkyObject *currentTarget; - int nextSession, nextObservation, nextSite; + OAL::Session *currentSession { nullptr }; + OAL::Log *logObject { nullptr }; + OAL::Observer *currentObserver { nullptr }; + OAL::Scope *currentScope { nullptr }; + OAL::Eyepiece *currentEyepiece { nullptr }; + OAL::Lens *currentLens { nullptr }; + OAL::Filter *currentFilter { nullptr }; + GeoLocation *geo { nullptr }; + SkyObject *currentTarget { nullptr }; + int nextSession { 0 }; + int nextObservation { 0 }; + int nextSite { 0 }; }; - -#endif Index: kstars/oal/execute.cpp =================================================================== --- kstars/oal/execute.cpp +++ kstars/oal/execute.cpp @@ -18,24 +18,14 @@ #include "oal/execute.h" -#include - -#include -#include #include "kstarsdata.h" -#include "oal/observer.h" -#include "oal/site.h" -#include "oal/session.h" -#include "oal/scope.h" -#include "oal/eyepiece.h" -#include "oal/lens.h" -#include "oal/filter.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/starobject.h" -#include "dialogs/locationdialog.h" +#include "observinglist.h" #include "dialogs/finddialog.h" +#include "dialogs/locationdialog.h" #include "skycomponents/skymapcomposite.h" -#include "observinglist.h" +#include "skyobjects/starobject.h" + +#include Execute::Execute() { @@ -63,17 +53,6 @@ setWindowTitle(i18n("Execute Session")); - currentTarget = nullptr; - currentObserver = nullptr; - currentScope = nullptr; - currentEyepiece = nullptr; - currentLens = nullptr; - currentFilter = nullptr; - currentSession = nullptr; - nextSession = 0; - nextObservation = 0; - nextSite = 0; - //initialize the global logObject logObject = KStarsData::Instance()->logObject(); @@ -235,7 +214,8 @@ { ui.Target->clear(); sortTargetList(); - foreach (QSharedPointer o, KStarsData::Instance()->observingList()->sessionList()) + + for (auto &o : KStarsData::Instance()->observingList()->sessionList()) { ui.Target->addItem(getObjectName(o.data(), false)); } Index: kstars/options/opssatellites.h =================================================================== --- kstars/options/opssatellites.h +++ kstars/options/opssatellites.h @@ -18,17 +18,19 @@ #include "ui_opssatellites.h" +#include + #include #include -#include - class QStandardItem; class QStandardItemModel; class KStars; class SatelliteSortFilterProxyModel : public QSortFilterProxyModel { + Q_OBJECT + public: explicit SatelliteSortFilterProxyModel(QObject *parent); bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; @@ -46,20 +48,14 @@ Q_OBJECT public: - /** - * Constructor - */ + /** Constructor */ OpsSatellites(); - /** - * Destructor - */ + /** Destructor */ ~OpsSatellites(); private: - /** - * Refresh satellites list - */ + /** Refresh satellites list */ void updateListView(); /** Index: kstars/skycomponents/catalogcomponent.h =================================================================== --- kstars/skycomponents/catalogcomponent.h +++ kstars/skycomponents/catalogcomponent.h @@ -15,8 +15,7 @@ * * ***************************************************************************/ -#ifndef CATALOGCOMPONENT_H -#define CATALOGCOMPONENT_H +#pragma once #include "listcomponent.h" #include "Options.h" @@ -24,34 +23,32 @@ struct stat; /** -*@class CatalogComponent -*Represents a custom user-defined catalog. -Code adapted from CustomCatalogComponent.cpp originally authored -by Thomas Kabelmann --spacetime - -*@author Thomas Kabelmann - Rishab Arora (spacetime) -*@version 0.2 -*/ - + * @class CatalogComponent + * Represents a custom user-defined catalog. + * Code adapted from CustomCatalogComponent.cpp originally authored by Thomas Kabelmann --spacetime + * + * @author Thomas Kabelmann + * Rishab Arora (spacetime) + * @version 0.2 + */ class CatalogComponent : public ListComponent { public: /** - *@short Constructor - *@p parent Pointer to the parent SkyComposite object - */ + * @short Constructor + * @p parent Pointer to the parent SkyComposite object + */ CatalogComponent(SkyComposite *, const QString &fname, bool showerrs, int index, bool callLoadData = true); /** - *@short Destructor. Delete list members - */ + * @short Destructor. Delete list members + */ virtual ~CatalogComponent(); /** - *@short Draw custom catalog objects on the sky map. - *@p psky Reference to the QPainter on which to paint - */ + * @short Draw custom catalog objects on the sky map. + * @p psky Reference to the QPainter on which to paint + */ void draw(SkyPainter *skyp) Q_DECL_OVERRIDE; void update(KSNumbers *num) Q_DECL_OVERRIDE; @@ -69,24 +66,22 @@ inline QString catColor() { return m_catColor; } /** - *@return true if visibility Option is set for this catalog - *@note this is complicated for custom catalogs, because - *Options::showCatalog() returns a QList, not a bool. - *This function extracts the correct visibility value and - *returns the appropriate bool value - */ - inline bool getVisibility() { return (Options::showCatalog()[m_ccIndex] > 0) ? true : false; } - - /** - * @see SyncedCatalogItem - */ + * @return true if visibility Option is set for this catalog + * @note this is complicated for custom catalogs, because + * Options::showCatalog() returns a QList, not a bool. + * This function extracts the correct visibility value and + * returns the appropriate bool value + */ + bool getVisibility(); + + /** @see SyncedCatalogItem */ quint32 getUpdateID() { return updateID; } /** - * @brief Returns true if this catalog is to be drawn - * Overridden from SkyComponent::selected - * @return bool - **/ + * @brief Returns true if this catalog is to be drawn + * Overridden from SkyComponent::selected + * @return bool + **/ bool selected() Q_DECL_OVERRIDE; protected: @@ -98,13 +93,8 @@ // FIXME: There seems to be no way to remove catalogs from the program. -- asimha - QString m_catName, m_catPrefix, m_catColor, m_catFluxFreq, m_catFluxUnit; - float m_catEpoch; - bool m_Showerrs; - int m_ccIndex; - quint32 updateID; - - static QStringList m_Columns; + QString m_catName, m_catColor, m_catFluxFreq, m_catFluxUnit; + bool m_Showerrs { false }; + int m_ccIndex { 0 }; + quint32 updateID { 0 }; }; - -#endif Index: kstars/skycomponents/catalogcomponent.cpp =================================================================== --- kstars/skycomponents/catalogcomponent.cpp +++ kstars/skycomponents/catalogcomponent.cpp @@ -18,30 +18,10 @@ #include "catalogcomponent.h" #include "catalogdata.h" - -#include -#include -#ifndef KSTARS_LITE -#include -#endif -#include -#include -#include -#include - -#include "Options.h" - #include "kstarsdata.h" -#ifndef KSTARS_LITE -#include "skymap.h" -#endif #include "skypainter.h" #include "skyobjects/starobject.h" #include "skyobjects/deepskyobject.h" -#include "catalogdb.h" - -QStringList CatalogComponent::m_Columns = - QString("ID RA Dc Tp Nm Mg Flux Mj Mn PA Ig").split(' ', QString::SkipEmptyParts); CatalogComponent::CatalogComponent(SkyComposite *parent, const QString &catname, bool showerrs, int index, bool callLoadData) @@ -162,11 +142,9 @@ CatalogData loaded_catalog_data; KStarsData::Instance()->catalogdb()->GetCatalogData(m_catName, loaded_catalog_data); - m_catPrefix = loaded_catalog_data.prefix; m_catColor = loaded_catalog_data.color; m_catFluxFreq = loaded_catalog_data.fluxfreq; m_catFluxUnit = loaded_catalog_data.fluxunit; - m_catEpoch = loaded_catalog_data.epoch; } void CatalogComponent::update(KSNumbers *) @@ -248,11 +226,16 @@ } } +bool CatalogComponent::getVisibility() +{ + return (Options::showCatalog().at(m_ccIndex) > 0) ? true : false; +} + bool CatalogComponent::selected() { - if (Options::showCatalogNames().contains(m_catName) && - Options:: - showDeepSky()) // do not draw / update custom catalogs if show deep-sky is turned off, even if they are chosen. + // Do not draw / update custom catalogs if show deep-sky is turned off, even if they are chosen. + if (Options::showCatalogNames().contains(m_catName) && Options::showDeepSky()) return true; + return false; } Index: kstars/skycomponents/constellationboundarylines.cpp =================================================================== --- kstars/skycomponents/constellationboundarylines.cpp +++ kstars/skycomponents/constellationboundarylines.cpp @@ -97,11 +97,11 @@ } // read in the data from the line - ra = line.mid(0, 12).toDouble(&ok); + ra = line.midRef(0, 12).toDouble(&ok); if (ok) - dec = line.mid(13, 12).toDouble(&ok); + dec = line.midRef(13, 12).toDouble(&ok); if (ok) - flag = line.mid(26, 1).toInt(&ok); + flag = line.midRef(26, 1).toInt(&ok); if (!ok) { fprintf(stderr, "%s: conversion error on line: %d\n", fname, fileReader.lineNumber()); Index: kstars/skycomponents/constellationnamescomponent.h =================================================================== --- kstars/skycomponents/constellationnamescomponent.h +++ kstars/skycomponents/constellationnamescomponent.h @@ -15,14 +15,14 @@ * * ***************************************************************************/ -#ifndef CONSTELLATIONNAMESCOMPONENT_H -#define CONSTELLATIONNAMESCOMPONENT_H +#pragma once -#include #include "listcomponent.h" -class SkyLabeler; class CultureList; +class KSNumbers; +class SkyComposite; +class SkyPainter; /** * @class ConstellationNamesComponent @@ -34,34 +34,37 @@ class ConstellationNamesComponent : public ListComponent { public: - /** @short Constructor - * @p parent Pointer to the parent SkyComposite object - * - * Reads the constellation names data from cnames.dat - * Each line in the file is parsed according to column position: - * @li 0-1 RA hours [int] - * @li 2-3 RA minutes [int] - * @li 4-5 RA seconds [int] - * @li 6 Dec sign [char; '+' or '-'] - * @li 7-8 Dec degrees [int] - * @li 9-10 Dec minutes [int] - * @li 11-12 Dec seconds [int] - * @li 13-15 IAU Abbreviation [string] e.g., 'Ori' == Orion - * @li 17- Constellation name [string] - */ + /** + * @short Constructor + * @p parent Pointer to the parent SkyComposite object + * + * Reads the constellation names data from cnames.dat + * Each line in the file is parsed according to column position: + * @li 0-1 RA hours [int] + * @li 2-3 RA minutes [int] + * @li 4-5 RA seconds [int] + * @li 6 Dec sign [char; '+' or '-'] + * @li 7-8 Dec degrees [int] + * @li 9-10 Dec minutes [int] + * @li 11-12 Dec seconds [int] + * @li 13-15 IAU Abbreviation [string] e.g., 'Ori' == Orion + * @li 17- Constellation name [string] + */ ConstellationNamesComponent(SkyComposite *parent, CultureList *cultures); /** @short Destructor. Delete list members */ virtual ~ConstellationNamesComponent(); - /** @short Draw constellation names on the sky map. - * @p psky Reference to the QPainter on which to paint - */ + /** + * @short Draw constellation names on the sky map. + * @p psky Reference to the QPainter on which to paint + */ void draw(SkyPainter *skyp) Q_DECL_OVERRIDE; - /** @short we need a custom routine (for now) so we don't - * precess the locations of the names. - */ + /** + * @short we need a custom routine (for now) so we don't + * precess the locations of the names. + */ void update(KSNumbers *num) Q_DECL_OVERRIDE; /** @short Return true if we are using localized constellation names */ @@ -72,7 +75,5 @@ void loadData(CultureList *cultures); private: - bool localCNames; + bool localCNames { false }; }; - -#endif Index: kstars/skycomponents/constellationnamescomponent.cpp =================================================================== --- kstars/skycomponents/constellationnamescomponent.cpp +++ kstars/skycomponents/constellationnamescomponent.cpp @@ -14,22 +14,20 @@ * (at your option) any later version. * * * ***************************************************************************/ -#include "constellationnamescomponent.h" -#include -#include +#include "constellationnamescomponent.h" +#include "ksfilereader.h" #include "kstarsdata.h" +#include "Options.h" +#include "skylabeler.h" #ifndef KSTARS_LITE #include "skymap.h" #endif -#include "skyobjects/skyobject.h" +#include "projections/projector.h" #include "skycomponents/culturelist.h" -#include "Options.h" -#include "ksfilereader.h" -#include "skylabeler.h" -#include "projections/projector.h" +#include ConstellationNamesComponent::ConstellationNamesComponent(SkyComposite *parent, CultureList *cultures) : ListComponent(parent) @@ -74,14 +72,14 @@ if (culture) { - rah = line.mid(0, 2).toInt(); - ram = line.mid(2, 2).toInt(); - ras = line.mid(4, 2).toInt(); + rah = line.midRef(0, 2).toInt(); + ram = line.midRef(2, 2).toInt(); + ras = line.midRef(4, 2).toInt(); sgn = line.at(6); - dd = line.mid(7, 2).toInt(); - dm = line.mid(9, 2).toInt(); - ds = line.mid(11, 2).toInt(); + dd = line.midRef(7, 2).toInt(); + dm = line.midRef(9, 2).toInt(); + ds = line.midRef(11, 2).toInt(); abbrev = line.mid(13, 3); name = line.mid(17).trimmed(); Index: kstars/skycomponents/linelistindex.cpp =================================================================== --- kstars/skycomponents/linelistindex.cpp +++ kstars/skycomponents/linelistindex.cpp @@ -203,7 +203,7 @@ DrawID drawID = skyMesh()->drawID(); UpdateID updateID = KStarsData::Instance()->updateID(); - foreach (std::shared_ptr lineListList, m_lineIndex->values()) + for (auto &lineListList : m_lineIndex->values()) { for (int i = 0; i < lineListList->size(); i++) { Index: kstars/skycomponents/milkyway.cpp =================================================================== --- kstars/skycomponents/milkyway.cpp +++ kstars/skycomponents/milkyway.cpp @@ -107,8 +107,8 @@ continue; bool okRA = false, okDec = false; - double ra = line.mid(2, 8).toDouble(&okRA); - double dec = line.mid(11, 8).toDouble(&okDec); + double ra = line.midRef(2, 8).toDouble(&okRA); + double dec = line.midRef(11, 8).toDouble(&okDec); if (!okRA || !okDec) { Index: kstars/skycomponents/skymapcomposite.cpp =================================================================== --- kstars/skycomponents/skymapcomposite.cpp +++ kstars/skycomponents/skymapcomposite.cpp @@ -291,8 +291,9 @@ if (KStars::Instance()) { auto &obsList = KStarsData::Instance()->observingList()->sessionList(); + if (Options::obsListText()) - foreach (QSharedPointer obj_clone, obsList) + for (auto &obj_clone : obsList) { // Find the "original" obj SkyObject *o = findByName(obj_clone->name()); // FIXME: This is sloww.... and can also fail!!! Index: kstars/skymapevents.cpp =================================================================== --- kstars/skymapevents.cpp +++ kstars/skymapevents.cpp @@ -17,38 +17,22 @@ //This file contains Event handlers for the SkyMap class. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "skymap.h" -#include "skyqpainter.h" -#include "skyglpainter.h" -#include "Options.h" -#include "kstars.h" -#include "kstarsdata.h" -#include "ksutils.h" -#include "simclock.h" + +#include "ksplanetbase.h" #include "kspopupmenu.h" -#include "skyobjects/ksplanetbase.h" -#include "widgets/infoboxwidget.h" -#include "printing/simplefovexporter.h" #include "observinglist.h" - -#include "projections/projector.h" - -#include "skycomponents/skymapcomposite.h" - -// TODO: Remove if debug key binding is removed +#include "Options.h" +#include "skyglpainter.h" +#include "skyqpainter.h" +#include "printing/simplefovexporter.h" #include "skycomponents/skylabeler.h" +#include "skycomponents/skymapcomposite.h" #include "skycomponents/starcomponent.h" +#include "widgets/infoboxwidget.h" + +#include +#include void SkyMap::resizeEvent(QResizeEvent *) { @@ -68,7 +52,6 @@ void SkyMap::keyPressEvent(QKeyEvent *e) { - QString s; bool arrowKeyPressed(false); bool shiftPressed(false); float step = 1.0; Index: kstars/skyobjects/kscomet.cpp =================================================================== --- kstars/skyobjects/kscomet.cpp +++ kstars/skyobjects/kscomet.cpp @@ -118,9 +118,9 @@ cometType.insert('D', 3); cometType.insert('A', 4); } - qint64 type = cometType[rePro.cap(1)[0]]; // Type of comet + qint64 type = cometType[rePro.cap(1).at(0)]; // Type of comet qint64 year = rePro.cap(2).toInt(); // Year of discovery - qint64 halfMonth = letterToNum(rePro.cap(3)[0]); + qint64 halfMonth = letterToNum(rePro.cap(3).at(0)); qint64 nHalfMonth = rePro.cap(4).toInt(); qint64 fragment = letterDesigToN(rePro.cap(6)); Index: kstars/skyobjects/ksplanet.h =================================================================== --- kstars/skyobjects/ksplanet.h +++ kstars/skyobjects/ksplanet.h @@ -15,109 +15,107 @@ * * ***************************************************************************/ -#ifndef KSPLANET_H_ -#define KSPLANET_H_ +#pragma once + +#include "ksplanetbase.h" -#include #include +#include +#include -#include "ksplanetbase.h" -#include "dms.h" +class KSNumbers; -/** @class KSPlanet - *A subclass of KSPlanetBase for seven of the major planets in the solar system - *(Earth and Pluto have their own specialized classes derived from KSPlanetBase). - *@note The Sun is subclassed from KSPlanet. +/** + * @class KSPlanet + * A subclass of KSPlanetBase for seven of the major planets in the solar system + * (Earth and Pluto have their own specialized classes derived from KSPlanetBase). + * @note The Sun is subclassed from KSPlanet. + * + * KSPlanet contains internal classes to manage the computations of a planet's position. + * The position is computed as a series of sinusoidal sums, similar to a Fourier + * transform. See "Astronomical Algorithms" by Jean Meeus or the file README.planetmath + * for details. + * @short Provides necessary information about objects in the solar system. * - *KSPlanet contains internal classes to manage the computations of a planet's position. - *The position is computed as a series of sinusoidal sums, similar to a Fourier - *transform. See "Astronomical Algorithms" by Jean Meeus or the file README.planetmath - *for details. - *@short Provides necessary information about objects in the solar system. - *@author Jason Harris - *@version 1.0 + * @author Jason Harris + * @version 1.0 */ class KSPlanet : public KSPlanetBase { public: /** - * Constructor. - * @param s Name of planet - * @param image_file filename of the planet's image - * @param c the color for the planet - * @param pSize physical diameter of the planet, in km - */ + * Constructor. + * @param s Name of planet + * @param image_file filename of the planet's image + * @param c the color for the planet + * @param pSize physical diameter of the planet, in km + */ explicit KSPlanet(const QString &s = "unnamed", const QString &image_file = QString(), const QColor &c = Qt::white, double pSize = 0); /** - * Simplified constructor - * @param n identifier of the planet to be created - * @see PLANET enum - */ + * Simplified constructor + * @param n identifier of the planet to be created + * @see PLANET enum + */ explicit KSPlanet(int n); KSPlanet *clone() const Q_DECL_OVERRIDE; SkyObject::UID getUID() const Q_DECL_OVERRIDE; - /** - * Destructor (empty) - */ virtual ~KSPlanet() {} - /** @short return the untranslated name - *This is a dirty way to solve a lot of localization-related trouble for the KDE 4.2 release - *TODO: Change the whole architecture for names later - */ - QString untranslatedName(void) const; + /** + * @short return the untranslated name + * This is a dirty way to solve a lot of localization-related trouble for the KDE 4.2 release + * TODO: Change the whole architecture for names later + */ + QString untranslatedName() const; - /** @short Preload the data used by findPosition. - */ + /** @short Preload the data used by findPosition. */ bool loadData() Q_DECL_OVERRIDE; - /** Calculate the ecliptic longitude and latitude of the planet for - *the given date (expressed in Julian Millenia since J2000). A reference - *to the ecliptic coordinates is returned as the second object. - *@param jm Julian Millenia (=jd/1000) - *@param ret The ecliptic coordinates are returned by reference through this argument. - */ + /** + * Calculate the ecliptic longitude and latitude of the planet for + * the given date (expressed in Julian Millenia since J2000). A reference + * to the ecliptic coordinates is returned as the second object. + * @param jm Julian Millenia (=jd/1000) + * @param ret The ecliptic coordinates are returned by reference through this argument. + */ virtual void calcEcliptic(double jm, EclipticPosition &ret) const; protected: - bool data_loaded; - - /** Calculate the geocentric RA, Dec coordinates of the Planet. - *@note reimplemented from KSPlanetBase - *@param num pointer to object with time-dependent values for the desired date - *@param Earth pointer to the planet Earth (needed to calculate geocentric coords) - *@return true if position was successfully calculated. - */ + /** + * Calculate the geocentric RA, Dec coordinates of the Planet. + * @note reimplemented from KSPlanetBase + * @param num pointer to object with time-dependent values for the desired date + * @param Earth pointer to the planet Earth (needed to calculate geocentric coords) + * @return true if position was successfully calculated. + */ bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth = nullptr) Q_DECL_OVERRIDE; - /** @class OrbitData - *This class contains doubles A,B,C which represent a single term in a planet's - *positional expansion sums (each sum-term is A*COS(B+C*T)). - *@author Mark Hollomon - *@version 1.0 - */ + /** + * @class OrbitData + * This class contains doubles A,B,C which represent a single term in a planet's + * positional expansion sums (each sum-term is A*COS(B+C*T)). + * + * @author Mark Hollomon + * @version 1.0 + */ class OrbitData { public: - /** - *Default constructor - */ + /** Default constructor */ OrbitData() : A(0.), B(0.), C(0.) {} /** - *Constructor - *@param a the A value - *@param b the B value - *@param c the C value - */ + * Constructor + * @param a the A value + * @param b the B value + * @param c the C value + */ OrbitData(double a, double b, double c) : A(a), B(b), C(c) {} - /** - *Assignment operator - */ + /** Assignment operator */ OrbitData operator=(const OrbitData o) { return o; } double A, B, C; @@ -125,17 +123,19 @@ typedef QVector OBArray[6]; - /** OrbitDataColl contains three groups of six QVectors. Each QVector is a - *list of OrbitData objects, representing a single sum used in computing - *the planet's position. A set of six of these vectors comprises the large - *"meta-sum" which yields the planet's Longitude, Latitude, or Distance value. - *@author Mark Hollomon - *@version 1.0 - */ + /** + * OrbitDataColl contains three groups of six QVectors. Each QVector is a + * list of OrbitData objects, representing a single sum used in computing + * the planet's position. A set of six of these vectors comprises the large + * "meta-sum" which yields the planet's Longitude, Latitude, or Distance value. + * + * @author Mark Hollomon + * @version 1.0 + */ class OrbitDataColl { public: - /**Constructor*/ + /** Constructor */ OrbitDataColl(); OBArray Lon; @@ -143,44 +143,47 @@ OBArray Dst; }; - /** OrbitDataManager places the OrbitDataColl objects for all planets in a QDict - *indexed by the planets' names. It also loads the positional data of each planet - *from disk. - *@author Mark Hollomon - *@version 1.0 - */ + /** + * OrbitDataManager places the OrbitDataColl objects for all planets in a QDict + * indexed by the planets' names. It also loads the positional data of each planet from disk. + * + * @author Mark Hollomon + * @version 1.0 + */ class OrbitDataManager { public: - /** Constructor*/ + /** Constructor */ OrbitDataManager(); - /** Load orbital data for a planet from disk. - *The data is stored on disk in a series of files named - *"name.[LBR][0...5].vsop", where "L"=Longitude data, "B"=Latitude data, - *and R=Radius data. - *@param n the name of the planet whose data is to be loaded from disk. - *@param odc reference to the OrbitDataColl containing the planet's orbital data. - *@return true if data successfully loaded - */ + /** + * Load orbital data for a planet from disk. + * The data is stored on disk in a series of files named + * "name.[LBR][0...5].vsop", where "L"=Longitude data, "B"=Latitude data, + * and R=Radius data. + * @param n the name of the planet whose data is to be loaded from disk. + * @param odc reference to the OrbitDataColl containing the planet's orbital data. + * @return true if data successfully loaded + */ bool loadData(OrbitDataColl &odc, const QString &n); private: - /** Read a single orbital data file from disk into an OrbitData vector. - *The data files are named "name.[LBR][0...5].vsop", where - *"L"=Longitude data, "B"=Latitude data, and R=Radius data. - *@param fname the filename to be read. - *@param vector pointer to the OrbitData vector to be filled with these data. - */ + /** + * Read a single orbital data file from disk into an OrbitData vector. + * The data files are named "name.[LBR][0...5].vsop", where + * "L"=Longitude data, "B"=Latitude data, and R=Radius data. + * @param fname the filename to be read. + * @param vector pointer to the OrbitData vector to be filled with these data. + */ bool readOrbitData(const QString &fname, QVector *vector); QHash hash; }; - static OrbitDataManager odm; - private: void findMagnitude(const KSNumbers *) Q_DECL_OVERRIDE; -}; -#endif + protected: + bool data_loaded { false }; + static OrbitDataManager odm; +}; Index: kstars/skyobjects/ksplanet.cpp =================================================================== --- kstars/skyobjects/ksplanet.cpp +++ kstars/skyobjects/ksplanet.cpp @@ -17,19 +17,13 @@ #include "ksplanet.h" -#include - -#include - -#include -#include - -#include - #include "ksnumbers.h" #include "ksutils.h" #include "ksfilereader.h" +#include +#include + KSPlanet::OrbitDataManager KSPlanet::odm; KSPlanet::OrbitDataColl::OrbitDataColl() @@ -71,7 +65,7 @@ bool KSPlanet::OrbitDataManager::loadData(KSPlanet::OrbitDataColl &odc, const QString &n) { - QString fname, snum, line; + QString fname, snum; QFile f; int nCount = 0; QString nl = n.toLower(); @@ -128,7 +122,7 @@ } KSPlanet::KSPlanet(const QString &s, const QString &imfile, const QColor &c, double pSize) - : KSPlanetBase(s, imfile, c, pSize), data_loaded(false) + : KSPlanetBase(s, imfile, c, pSize) { } Index: kstars/skyobjects/satellite.cpp =================================================================== --- kstars/skyobjects/satellite.cpp +++ kstars/skyobjects/satellite.cpp @@ -17,35 +17,31 @@ #include "satellite.h" -#include - -#include "math.h" -#include - -#include "kstarsdata.h" #include "ksplanetbase.h" -#include "skymapcomposite.h" -#include "kssun.h" -#include "Options.h" #ifndef KSTARS_LITE #include "kspopupmenu.h" #endif +#include "kstarsdata.h" +#include "kssun.h" +#include "Options.h" +#include "skymapcomposite.h" + +#include + +#include +#include // Define some constants // WGS-72 constants -#define MU 398600.8 // Earth gravitational constant (km3/s2) #define RADIUSEARTHKM 6378.135 // Earth radius (km) #define XKE 0.07436691613317 // 60.0 / sqrt(RADIUSEARTHKM^3/MU) -#define TUMIN 13.44683969695931 // sqrt(RADIUSEARTHKM^3/MU) / 60.0 #define J2 0.001082616 // The second gravitational zonal harmonic of the Earth -#define J3 -0.00000253881 // The third gravitational zonal harmonic of the Earth #define J4 -0.00000165597 // The fourth gravitational zonal harmonic of the Earth #define J3OJ2 -2.34506972e-3 // J3 / J2 // Mathematical constants #define TWOPI 6.2831853071795864769 // 2*PI #define PIO2 1.5707963267948966192 // PI/2 -#define X3PIO2 4.7123889803846898577 // 3*PI/2 #define X2O3 .66666666666666666667 // 2/3 #define DEG2RAD 1.745329251994330e-2 // Deg -> Rad @@ -63,23 +59,23 @@ Satellite::Satellite(const QString name, const QString line1, const QString line2) { //m_name = name; - m_number = line1.mid(2, 5).toInt(); + m_number = line1.midRef(2, 5).toInt(); m_class = line1.at(7); m_id = line1.mid(9, 8); - m_epoch = line1.mid(18, 14).toDouble(); - m_first_deriv = line1.mid(33, 10).toDouble() / (XPDOTP * MINPD); + m_epoch = line1.midRef(18, 14).toDouble(); + m_first_deriv = line1.midRef(33, 10).toDouble() / (XPDOTP * MINPD); m_second_deriv = - line1.mid(44, 6).toDouble() * (1.0e-5 / pow(10.0, line1.mid(51, 1).toDouble())) / (XPDOTP * MINPD * MINPD); - m_bstar = line1.mid(53, 6).toDouble() * 1.0e-5 / pow(10.0, line1.mid(60, 1).toDouble()); - m_ephem_type = line1.mid(62, 1).toInt(); - m_elem_number = line1.mid(64, 4).toInt(); - m_inclination = line2.mid(8, 8).toDouble() * DEG2RAD; - m_ra = line2.mid(17, 8).toDouble() * DEG2RAD; - m_eccentricity = line2.mid(26, 7).toDouble() * 1.0e-7; - m_arg_perigee = line2.mid(34, 8).toDouble() * DEG2RAD; - m_mean_anomaly = line2.mid(43, 8).toDouble() * DEG2RAD; - m_mean_motion = line2.mid(52, 11).toDouble() * TWOPI / MINPD; - m_nb_revolution = line2.mid(63, 5).toInt(); + line1.midRef(44, 6).toDouble() * (1.0e-5 / pow(10.0, line1.midRef(51, 1).toDouble())) / (XPDOTP * MINPD * MINPD); + m_bstar = line1.midRef(53, 6).toDouble() * 1.0e-5 / pow(10.0, line1.midRef(60, 1).toDouble()); + m_ephem_type = line1.midRef(62, 1).toInt(); + m_elem_number = line1.midRef(64, 4).toInt(); + m_inclination = line2.midRef(8, 8).toDouble() * DEG2RAD; + m_ra = line2.midRef(17, 8).toDouble() * DEG2RAD; + m_eccentricity = line2.midRef(26, 7).toDouble() * 1.0e-7; + m_arg_perigee = line2.midRef(34, 8).toDouble() * DEG2RAD; + m_mean_anomaly = line2.midRef(43, 8).toDouble() * DEG2RAD; + m_mean_motion = line2.midRef(52, 11).toDouble() * TWOPI / MINPD; + m_nb_revolution = line2.midRef(63, 5).toInt(); setName(name); setName2(name); Index: kstars/time/kstarsdatetime.h =================================================================== --- kstars/time/kstarsdatetime.h +++ kstars/time/kstarsdatetime.h @@ -15,15 +15,14 @@ * * ***************************************************************************/ -#ifndef KSTARSDATETIME_H_ -#define KSTARSDATETIME_H_ +#pragma once + +#include #define J2000 2451545.0 //Julian Date for noon on Jan 1, 2000 (epoch J2000) #define B1950 2433282.4235 // Julian date for Jan 0.9235, 1950 #define SIDEREALSECOND 1.002737909 //number of sidereal seconds in one solar second -#include - class dms; /** @class KStarsDateTime @@ -228,7 +227,5 @@ */ dms GSTat0hUT() const; - long double DJD; + long double DJD { 0 }; }; - -#endif //KSTARSDATETIME_H_ Index: kstars/time/kstarsdatetime.cpp =================================================================== --- kstars/time/kstarsdatetime.cpp +++ kstars/time/kstarsdatetime.cpp @@ -17,11 +17,12 @@ #include "kstarsdatetime.h" -#include +#include "dms.h" +#include "ksnumbers.h" + #include -#include "ksnumbers.h" -#include "dms.h" +#include KStarsDateTime::KStarsDateTime() : QDateTime() { @@ -291,10 +292,10 @@ return epoch; if (eName.startsWith('J')) - epoch = eName.mid(1).toDouble(&ok); + epoch = eName.midRef(1).toDouble(&ok); else if (eName.startsWith('B')) { - epoch = eName.mid(1).toDouble(&ok); + epoch = eName.midRef(1).toDouble(&ok); epoch = jdToEpoch(epochToJd(epoch, BESSELIAN), JULIAN); // Convert Besselian epoch to Julian epoch } // Assume it's Julian Index: kstars/time/simclock.h =================================================================== --- kstars/time/simclock.h +++ kstars/time/simclock.h @@ -15,17 +15,16 @@ * * ***************************************************************************/ -#ifndef KSTARS_SIMCLOCK_H__ -#define KSTARS_SIMCLOCK_H__ +#pragma once + +#include "kstarsdatetime.h" -#include #ifndef KSTARS_LITE #include #endif +#include #include -#include "kstarsdatetime.h" - /** @class SimClock *@short kstars simulation clock *@author Mark Hollomon @@ -132,13 +131,14 @@ void clockToggled(bool); private: - long double julianmark; + long double julianmark { 0 }; KStarsDateTime UTC; QTimer tmr; - double Scale; + double Scale { 1 }; QTime sysmark; - int lastelapsed; - bool ManualMode, ManualActive; + int lastelapsed { 0 }; + bool ManualMode { false }; + bool ManualActive { false }; // used to generate names for dcop interfaces //static int idgen; @@ -149,5 +149,3 @@ SimClock(const SimClock &); SimClock &operator=(const SimClock &); }; - -#endif Index: kstars/time/simclock.cpp =================================================================== --- kstars/time/simclock.cpp +++ kstars/time/simclock.cpp @@ -17,14 +17,13 @@ #include "simclock.h" -#include -#include - #ifndef KSTARS_LITE #include "kstars.h" #include "simclockadaptor.h" #endif +#include + int SimClock::TimerInterval = 100; //msec SimClock::SimClock(QObject *parent, const KStarsDateTime &when) : QObject(parent), tmr(this) @@ -38,10 +37,6 @@ setUTC(when); julianmark = UTC.djd(); - Scale = 1.0; - ManualMode = false; - ManualActive = false; - QObject::connect(&tmr, SIGNAL(timeout()), this, SLOT(tick())); } @@ -172,8 +167,7 @@ } qDebug() << QString("Setting clock: UTC: %1 JD: %2") - .arg(UTC.toString()) - .arg(QLocale().toString((double)UTC.djd(), 'f', 2)); + .arg(UTC.toString(), QLocale().toString((double)UTC.djd(), 'f', 2)); emit timeChanged(); } else Index: kstars/time/timezonerule.h =================================================================== --- kstars/time/timezonerule.h +++ kstars/time/timezonerule.h @@ -15,8 +15,13 @@ * * ***************************************************************************/ -#ifndef TIMEZONERULE_H_ -#define TIMEZONERULE_H_ +#pragma once + +#include "kstarsdatetime.h" + +#include + +class QString; /** @class TimeZoneRule *This class provides the information needed to determine whether Daylight @@ -50,9 +55,6 @@ *@version 1.0 */ -#include -#include "kstarsdatetime.h" - class TimeZoneRule { public: @@ -156,14 +158,15 @@ *@return the calendar date, an integer between 1 and 31. */ int findRevertDay(const KStarsDateTime &d); - int StartDay, RevertDay; - int StartMonth, RevertMonth; - int StartWeek, RevertWeek; + int StartDay { 0 }; + int RevertDay { 0 }; + int StartMonth { 0 }; + int RevertMonth { 0 }; + int StartWeek { 0 }; + int RevertWeek { 0 }; QTime StartTime, RevertTime; KStarsDateTime next_change_utc; KStarsDateTime next_change_ltime; - double dTZ; - double HourOffset; + double dTZ { 0 }; + double HourOffset { 0 }; }; - -#endif Index: kstars/time/timezonerule.cpp =================================================================== --- kstars/time/timezonerule.cpp +++ kstars/time/timezonerule.cpp @@ -17,10 +17,10 @@ #include "timezonerule.h" -#include #include -#include "kstarsdatetime.h" +#include +#include TimeZoneRule::TimeZoneRule() { @@ -177,7 +177,7 @@ //3. 1,2 or 3 followed by 3-letter day of week string; this indicates // the (1st/2nd/3rd) weekday of the month. - int wn = dl.left(1).toInt(); + int wn = dl.leftRef(1).toInt(); if (wn > 0 && wn < 4) { QString dm = dl.mid(1, dl.length()).toLower(); Index: kstars/tools/altvstime.h =================================================================== --- kstars/tools/altvstime.h +++ kstars/tools/altvstime.h @@ -15,18 +15,23 @@ * * ***************************************************************************/ -#ifndef ALTVSTIME_H_ -#define ALTVSTIME_H_ +#pragma once #include #include #include "ui_altvstime.h" +class QCPAbstractPlottable; +class QCPItemPixmap; +class QCPRange; +class QMouseEvent; +class QPixmap; + +class GeoLocation; class KStarsDateTime; class SkyObject; class SkyPoint; -class GeoLocation; class AltVsTimeUI : public QFrame, public Ui::AltVsTime { @@ -35,7 +40,8 @@ explicit AltVsTimeUI(QWidget *p = 0); }; -/** @class AltVsTime +/** + * @class AltVsTime * @short the Altitude vs. Time Tool. * Plot the altitude as a function of time for any list of * objects, as seen from any location, on any date. @@ -47,69 +53,76 @@ Q_OBJECT public: - /**Constructor */ + /** Constructor */ explicit AltVsTime(QWidget *parent = 0); - /**Destructor */ + /** Destructor */ ~AltVsTime(); - /**Determine the limits for the sideral time axis, using - * the sidereal time at midnight for the current date - * and location settings. - */ + /** + * Determine the limits for the sideral time axis, using + * the sidereal time at midnight for the current date + * and location settings. + */ void setLSTLimits(); - /**Set the AltVsTime Date according to the current Date - * in the KStars main window. Currently, this is only - * used in the ctor to initialize the Date. - */ + /** + * Set the AltVsTime Date according to the current Date + * in the KStars main window. Currently, this is only + * used in the ctor to initialize the Date. + */ void showCurrentDate(); - /** @return a KStarsDateTime object constructed from the - * current setting in the Date widget. - */ + /** + * @return a KStarsDateTime object constructed from the + * current setting in the Date widget. + */ KStarsDateTime getDate(); - /**Determine the time of sunset and sunrise for the current - * date and location settings. Convert the times to doubles, - * expressing the times as fractions of a full day. - * Calls AVTPlotWidget::setSunRiseSetTimes() to send the - * numbers to the plot widget. - */ + /** + * Determine the time of sunset and sunrise for the current + * date and location settings. Convert the times to doubles, + * expressing the times as fractions of a full day. + * Calls AVTPlotWidget::setSunRiseSetTimes() to send the + * numbers to the plot widget. + */ void computeSunRiseSetTimes(); - /**Parse a string as an epoch number. If the string can't - * be parsed, return 2000.0. - * @param eName the epoch string to be parsed - * @return the epoch number - */ + /** + * Parse a string as an epoch number. If the string can't + * be parsed, return 2000.0. + * @param eName the epoch string to be parsed + * @return the epoch number + */ double getEpoch(const QString &eName); - /** @short Add a SkyObject to the display. - * Constructs a PLotObject representing the Alt-vs-time curve for the object. - * @param o pointer to the SkyObject to be added - * @param forceAdd if true, then the object will be added, even if there - * is already a curve for the same coordinates. - */ + /** + * @short Add a SkyObject to the display. + * Constructs a PLotObject representing the Alt-vs-time curve for the object. + * @param o pointer to the SkyObject to be added + * @param forceAdd if true, then the object will be added, even if there + * is already a curve for the same coordinates. + */ void processObject(SkyObject *o, bool forceAdd = false); - /** @short Determine the altitude coordinate of a SkyPoint, - * given an hour of the day. - * - * This is called for every 30-minute interval in the displayed Day, - * in order to construct the altitude curve for a given object. - * @param p the skypoint whose altitude is to be found - * @param hour the time in the displayed day, expressed in hours - * @return the Altitude, expresse in degrees - */ + /** + * @short Determine the altitude coordinate of a SkyPoint, + * given an hour of the day. + * + * This is called for every 30-minute interval in the displayed Day, + * in order to construct the altitude curve for a given object. + * @param p the skypoint whose altitude is to be found + * @param hour the time in the displayed day, expressed in hours + * @return the Altitude, expresse in degrees + */ double findAltitude(SkyPoint *p, double hour); - /** @short get object name. If star has no name, generate a name based on catalog number. - * @param translated set to true if the translated name is required. - */ + /** + * @short get object name. If star has no name, generate a name based on catalog number. + * @param translated set to true if the translated name is required. + */ QString getObjectName(const SkyObject *o, bool translated = true); - void setSunRiseSetTimes(double sunRise, double sunSet); void drawGradient(); public slots: @@ -146,51 +159,51 @@ /** @short Clear the edit boxes for specifying a new object. */ void slotClearBoxes(); - /** @short Add an object to the list of displayed objects, according - * to the data entered in the edit boxes. - */ + /** + * @short Add an object to the list of displayed objects, according + * to the data entered in the edit boxes. + */ void slotAddSource(); - /** @short Launch the Find Object window to select a new object for - * the list of displayed objects. - */ + /** + * @short Launch the Find Object window to select a new object for + * the list of displayed objects. + */ void slotBrowseObject(); /** @short Launch the Location dialog to choose a new location. */ void slotChooseCity(); - /** @short Move input keyboard focus to the next logical widget. - * We need a separate slot for this because we are intercepting - * Enter key events, which close the window by default, to - * advance input focus instead (when the Enter events occur in - * certain Edit boxes). - */ + /** + * @short Move input keyboard focus to the next logical widget. + * We need a separate slot for this because we are intercepting + * Enter key events, which close the window by default, to + * advance input focus instead (when the Enter events occur in + * certain Edit boxes). + */ void slotAdvanceFocus(); - /**Update the plot to highlight the altitude curve of the objects - * which is highlighted in the listbox. - */ + /** + * Update the plot to highlight the altitude curve of the objects + * which is highlighted in the listbox. + */ void slotHighlight(int); - /** @short Print plot widget - */ + /** @short Print plot widget */ void slotPrint(); private: /** @short find start of dawn, end of dusk, maximum and minimum elevation of the sun */ void setDawnDusk(); - AltVsTimeUI *avtUI; + AltVsTimeUI *avtUI { nullptr }; - GeoLocation *geo; + GeoLocation *geo { nullptr }; QList pList; QList deleteList; - int DayOffset; - int minAlt; - int maxAlt; - QCPItemPixmap *background; - QPixmap *gradient; - double sunRise, sunSet; + int DayOffset { 0 }; + int minAlt { 0 }; + int maxAlt { 0 }; + QCPItemPixmap *background { nullptr }; + QPixmap *gradient { nullptr }; }; - -#endif // ALTVSTIME_H_ Index: kstars/tools/altvstime.cpp =================================================================== --- kstars/tools/altvstime.cpp +++ kstars/tools/altvstime.cpp @@ -17,15 +17,7 @@ #include "altvstime.h" -#include -#include - -#include -#include -#include -#include -#include - +#include "avtplotwidget.h" #include "dms.h" #include "ksalmanac.h" #include "kstarsdata.h" @@ -40,9 +32,15 @@ #include "skyobjects/skyobject.h" #include "skyobjects/starobject.h" +#include #include -#include "avtplotwidget.h" -#include "ui_altvstime.h" + +#include +#include +#include +#include +#include +#include AltVsTimeUI::AltVsTimeUI(QWidget *p) : QFrame(p) { @@ -601,10 +599,10 @@ "%L4" "" "") - .arg(graph->name().isEmpty() ? "???" : graph->name()) - .arg(localTime.toString()) - .arg(localSiderealTime.toString()) - .arg(QString::number(yValue, 'f', 2) + " " + QChar(176)), + .arg((graph->name().isEmpty() ? "???" : graph->name()), + localTime.toString(), + localSiderealTime.toString(), + QString::number(yValue, 'f', 2) + " " + QChar(176)), avtUI->View, avtUI->View->rect()); } } @@ -884,15 +882,6 @@ KSAlmanac ksal; ksal.setDate(&today); ksal.setLocation(geo); - double sunRise = ksal.getSunRise(); - double sunSet = ksal.getSunSet(); - this->setSunRiseSetTimes(sunRise, sunSet); -} - -void AltVsTime::setSunRiseSetTimes(double sunRise, double sunSet) -{ - this->sunRise = sunRise; - this->sunSet = sunSet; } //FIXME @@ -1002,10 +991,9 @@ "%L4" "" "") - .arg(graph->name().isEmpty() ? "???" : graph->name()) - .arg(localTime.toString()) - .arg(localSiderealTime.toString()) - .arg(QString::number(yValue, 'f', 2) + " " + QChar(176)), + .arg((graph->name().isEmpty() ? "???" : graph->name()), + localTime.toString(), localSiderealTime.toString(), + QString::number(yValue, 'f', 2) + " " + QChar(176)), avtUI->View, avtUI->View->rect()); } else @@ -1210,10 +1198,6 @@ double SunRise, SunSet, Dawn, Dusk, SunMinAlt, SunMaxAlt; double MoonRise, MoonSet, MoonIllum; - //Default SunRise/SunSet values - SunRise = 0.25; - SunSet = 0.75; - ksal->setLocation(geoLoc); ksal->setDate(&utt); @@ -1472,7 +1456,6 @@ QPainter p; // Our painter object QPrinter printer; // Our printer object QString str_legend; // Text legend - QString str_year; // Calendar's year int text_height = 200; // Height of legend text zone in points QSize plot_size; // Initial plot widget size QFont plot_font; // Initial plot widget font Index: kstars/tools/conjunctions.h =================================================================== --- kstars/tools/conjunctions.h +++ kstars/tools/conjunctions.h @@ -22,26 +22,27 @@ * * ***************************************************************************/ -#ifndef CONJUNCTIONS_H_ -#define CONJUNCTIONS_H_ - -#include -#include -#include -#include +#pragma once +#include "dms.h" #include "ui_conjunctions.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/ksplanetbase.h" + +#include +#include +#include + +#include + +class QSortFilterProxyModel; +class QStandardItemModel; class GeoLocation; class KSPlanetBase; -class dms; +class SkyObject; /** - *@short Predicts conjunctions using KSConjunct in the background + * @short Predicts conjunctions using KSConjunct in the background */ - class ConjunctionsTool : public QFrame, public Ui::ConjunctionsDlg { Q_OBJECT @@ -63,22 +64,17 @@ void slotFilterReg(const QString &); private: - SkyObject *Object1; - KSPlanetBase *Object2; // Second object is always a planet. - - QHash pNames; // To store the names of Planets vs. values expected by KSPlanetBase::createPlanet() - QMap - outputJDList; // To store Julian Days corresponding to the row index in the output list widget - void showConjunctions(const QMap &conjunctionlist, const QString &object1, const QString &object2); - GeoLocation *geoPlace; - - QStandardItemModel *m_Model; - QSortFilterProxyModel *m_SortModel; - - int m_index; + std::unique_ptr Object1; + std::unique_ptr Object2; // Second object is always a planet. + /// To store the names of Planets vs. values expected by KSPlanetBase::createPlanet() + QHash pNames; + /// To store Julian Days corresponding to the row index in the output list widget + QMap outputJDList; + GeoLocation *geoPlace { nullptr }; + QStandardItemModel *m_Model { nullptr }; + QSortFilterProxyModel *m_SortModel { nullptr }; + int m_index { 0 }; }; - -#endif Index: kstars/tools/conjunctions.cpp =================================================================== --- kstars/tools/conjunctions.cpp +++ kstars/tools/conjunctions.cpp @@ -24,36 +24,22 @@ #include "conjunctions.h" -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "ksconjunct.h" #include "geolocation.h" -#include "dialogs/locationdialog.h" -#include "dms.h" +#include "ksconjunct.h" #include "kstars.h" #include "kstarsdata.h" -#include "ksnumbers.h" -#include "widgets/dmsbox.h" +#include "skymap.h" #include "dialogs/finddialog.h" -#include "skyobjects/kssun.h" -#include "skyobjects/ksplanet.h" -#include "skyobjects/ksplanetbase.h" -#include "skyobjects/ksmoon.h" -#include "skyobjects/kspluto.h" -#include "skyobjects/kscomet.h" -#include "skyobjects/ksasteroid.h" +#include "dialogs/locationdialog.h" #include "skycomponents/skymapcomposite.h" -#include "skymap.h" +#include "skyobjects/kscomet.h" +#include "skyobjects/kspluto.h" + +#include +#include +#include -ConjunctionsTool::ConjunctionsTool(QWidget *parentSplit) : QFrame(parentSplit), Object1(0), Object2(0) +ConjunctionsTool::ConjunctionsTool(QWidget *parentSplit) : QFrame(parentSplit) { setupUi(this); @@ -122,8 +108,6 @@ //FilterEdit->showClearButton = true; ClearFilterButton->setIcon(QIcon::fromTheme("edit-clear", QIcon(":/icons/breeze/default/edit-clear.svg"))); - m_index = 0; - // signals and slots connections connect(LocationButton, SIGNAL(clicked()), this, SLOT(slotLocation())); connect(Obj1FindButton, SIGNAL(clicked()), this, SLOT(slotFindObject())); @@ -140,8 +124,6 @@ ConjunctionsTool::~ConjunctionsTool() { - delete Object1; - delete Object2; } void ConjunctionsTool::slotGoto() @@ -167,11 +149,11 @@ QPointer fd = new FindDialog(KStars::Instance()); if (fd->exec() == QDialog::Accepted) { - delete Object1; + Object1.reset(); if (!fd->targetObject()) return; - Object1 = fd->targetObject()->clone(); - if (Object1) + Object1.reset(fd->targetObject()->clone()); + if (Object1.get() != nullptr) Obj1FindButton->setText(Object1->name()); } delete fd; @@ -263,13 +245,13 @@ } // Check if Object1 and Object2 are set - if (FilterTypeComboBox->currentIndex() == 0 && !Object1) + if (FilterTypeComboBox->currentIndex() == 0 && Object1.get() == nullptr) { KMessageBox::sorry( 0, i18n("Please select an object to check conjunctions with, by clicking on the \'Find Object\' button.")); return; } - Object2 = KSPlanetBase::createPlanet(Obj2ComboBox->currentIndex()); + Object2.reset(KSPlanetBase::createPlanet(Obj2ComboBox->currentIndex())); if (FilterTypeComboBox->currentIndex() == 0 && Object1->name() == Object2->name()) { // FIXME: Must free the created Objects @@ -355,7 +337,7 @@ progressDlg.setWindowModality(Qt::WindowModal); progressDlg.setValue(0); - foreach (QString object, objects) + for (auto &object : objects) { // If the user click on the 'cancel' button if (progressDlg.wasCanceled()) @@ -367,7 +349,7 @@ progressDlg.setLabelText(i18n("Compute conjunction between %1 and %2", Object2->name(), object)); // Compute conjuction - Object1 = data->skyComposite()->findByName(object); + Object1.reset(data->skyComposite()->findByName(object)); showConjunctions(ksc.findClosestApproach(*Object1, *Object2, startJD, stopJD, maxSeparation, opposition), object, Object2->name()); } @@ -388,8 +370,7 @@ QApplication::restoreOverrideCursor(); } - delete Object2; - Object2 = nullptr; + Object2.reset(); } void ConjunctionsTool::showProgress(int n) @@ -401,10 +382,9 @@ const QString &object2) { KStarsDateTime dt; - QMap::ConstIterator it; QList itemList; - for (it = conjunctionlist.constBegin(); it != conjunctionlist.constEnd(); ++it) + for (auto it = conjunctionlist.constBegin(); it != conjunctionlist.constEnd(); ++it) { dt.setDJD(it.key()); QStandardItem *typeItem; Index: kstars/tools/modcalcdaylength.h =================================================================== --- kstars/tools/modcalcdaylength.h +++ kstars/tools/modcalcdaylength.h @@ -15,25 +15,32 @@ * * ***************************************************************************/ -#ifndef MODCALCDAYLENGTH_H_ -#define MODCALCDAYLENGTH_H_ +#pragma once #include "ui_modcalcdaylength.h" -class GeoLocation; +#include + +class QDate; class QTextStream; +class QTime; + +class GeoLocation; -/** Module to compute the equatorial coordinates for a given date and time +/** + * Module to compute the equatorial coordinates for a given date and time * from a given epoch or equinox - *@author Pablo de Vicente - */ + * + * @author Pablo de Vicente + */ class modCalcDayLength : public QFrame, public Ui::modCalcDayLengthDlg { Q_OBJECT + public: - /**Constructor. */ + /** Constructor */ explicit modCalcDayLength(QWidget *p); - /**Destructor. */ + /** Destructor */ ~modCalcDayLength(); public slots: @@ -46,18 +53,17 @@ private: void updateAlmanac(const QDate &d, GeoLocation *geo); - QTime lengthOfDay(QTime setQTime, QTime riseQTime); + QTime lengthOfDay(const QTime &setQTime, const QTime &riseQTime); - void showCurrentDate(void); - void initGeo(void); + void showCurrentDate(); + void initGeo(); void processLines(QTextStream &istream); - GeoLocation *geoPlace, *geoBatch; + GeoLocation *geoPlace { nullptr }; + GeoLocation *geoBatch { nullptr }; QString srTimeString, stTimeString, ssTimeString; QString mrTimeString, mtTimeString, msTimeString; QString srAzString, stAltString, ssAzString; QString mrAzString, mtAltString, msAzString; QString daylengthString, lunarphaseString; }; - -#endif Index: kstars/tools/modcalcdaylength.cpp =================================================================== --- kstars/tools/modcalcdaylength.cpp +++ kstars/tools/modcalcdaylength.cpp @@ -17,19 +17,14 @@ #include "modcalcdaylength.h" -#include - -#include -#include - -#include "skyobjects/skyobject.h" #include "geolocation.h" #include "kstarsdata.h" -#include "skyobjects/kssun.h" -#include "skyobjects/ksmoon.h" -#include "ksnumbers.h" -#include "kstarsdatetime.h" #include "dialogs/locationdialog.h" +#include "skyobjects/ksmoon.h" +#include "skyobjects/kssun.h" +#include "skyobjects/skyobject.h" + +#include modCalcDayLength::modCalcDayLength(QWidget *parentSplit) : QFrame(parentSplit) { @@ -73,7 +68,7 @@ LocationBatch->setText(geoBatch->fullName()); } -QTime modCalcDayLength::lengthOfDay(QTime setQTime, QTime riseQTime) +QTime modCalcDayLength::lengthOfDay(const QTime &setQTime, const QTime &riseQTime) { QTime dL(0, 0, 0); int dds = riseQTime.secsTo(setQTime); @@ -296,7 +291,7 @@ //Write header ostream << "# " << i18nc("%1 is a location on earth", "Almanac for %1", geoBatch->fullName()) - << QString(" [%1, %2]").arg(geoBatch->lng()->toDMSString()).arg(geoBatch->lat()->toDMSString()) << endl + << QString(" [%1, %2]").arg(geoBatch->lng()->toDMSString(), geoBatch->lat()->toDMSString()) << endl << "# " << i18n("computed by KStars") << endl << "#" << endl << "# Date SRise STran SSet SRiseAz STranAlt SSetAz DayLen MRise MTran MSet " Index: kstars/tools/modcalcplanets.h =================================================================== --- kstars/tools/modcalcplanets.h +++ kstars/tools/modcalcplanets.h @@ -15,13 +15,12 @@ * * ***************************************************************************/ -#ifndef MODCALCPLANETS_H_ -#define MODCALCPLANETS_H_ - -#include +#pragma once #include "ui_modcalcplanets.h" +class QTextStream; + class GeoLocation; class KSPlanetBase; @@ -63,5 +62,3 @@ GeoLocation *geoPlace; }; - -#endif Index: kstars/tools/modcalcplanets.cpp =================================================================== --- kstars/tools/modcalcplanets.cpp +++ kstars/tools/modcalcplanets.cpp @@ -17,21 +17,11 @@ #include "modcalcplanets.h" -#include -#include - -#include - #include "geolocation.h" -#include "dialogs/locationdialog.h" -#include "dms.h" #include "kstarsdata.h" -#include "ksnumbers.h" -#include "skyobjects/kssun.h" -#include "skyobjects/ksplanet.h" +#include "dialogs/locationdialog.h" #include "skyobjects/ksmoon.h" -//#include "skyobjects/kspluto.h" -#include "widgets/dmsbox.h" +#include "skyobjects/kssun.h" modCalcPlanets::modCalcPlanets(QWidget *parentSplit) : QFrame(parentSplit) { @@ -259,7 +249,6 @@ fOut.open(QIODevice::WriteOnly); QTextStream ostream(&fOut); bool lineIsValid = true; - QString message; QChar space = ' '; QString planetB; Index: kstars/tools/modcalcvizequinox.h =================================================================== --- kstars/tools/modcalcvizequinox.h +++ kstars/tools/modcalcvizequinox.h @@ -15,17 +15,19 @@ * * ***************************************************************************/ -#ifndef MODCALCVIZEQUINOX_H_ -#define MODCALCVIZEQUINOX_H_ +#pragma once -#include "ui_modcalcvizequinox.h" #include "kstarsdatetime.h" +#include "ui_modcalcvizequinox.h" class QTextStream; +class KPlotObject; + /** - *@class modCalcEquinox - *@author Jason Harris + * @class modCalcEquinox + * + * @author Jason Harris */ class modCalcEquinox : public QFrame, public Ui::modCalcEquinox { @@ -35,7 +37,6 @@ modCalcEquinox(QWidget *p); ~modCalcEquinox(); - KStarsDateTime dSpring, dSummer, dAutumn, dWinter; double dmonth(int imonth); private slots: @@ -49,7 +50,9 @@ void addDateAxes(); KStarsDateTime findEquinox(int year, bool Spring, KPlotObject *po); KStarsDateTime findSolstice(int year, bool Summer); + + public: + KStarsDateTime dSpring, dSummer, dAutumn, dWinter; + private: double DMonth[12]; }; - -#endif Index: kstars/tools/modcalcvizequinox.cpp =================================================================== --- kstars/tools/modcalcvizequinox.cpp +++ kstars/tools/modcalcvizequinox.cpp @@ -17,22 +17,17 @@ #include "modcalcvizequinox.h" -#include //fabs() +#include "dms.h" +#include "kstarsdata.h" +#include "skyobjects/kssun.h" +#include "widgets/dmsbox.h" -#include +#include #include #include #include -#include -#include -#include -#include "dms.h" -#include "kstarsdata.h" -#include "kstarsdatetime.h" -#include "ksnumbers.h" -#include "skyobjects/kssun.h" -#include "widgets/dmsbox.h" +#include modCalcEquinox::modCalcEquinox(QWidget *parentSplit) : QFrame(parentSplit), dSpring(), dSummer(), dAutumn(), dWinter() { @@ -282,16 +277,16 @@ const int month = Spring ? 2 : 8; int i = QDate(year, month, 1).dayOfYear(); double dec1, dec2; - dec2 = ecl->points()[i]->y(); + dec2 = ecl->points().at(i)->y(); do { ++i; dec1 = dec2; - dec2 = ecl->points()[i]->y(); + dec2 = ecl->points().at(i)->y(); } while (dec1 * dec2 > 0.0); //when dec1*dec2<0.0, we bracket the zero - double x1 = ecl->points()[i - 1]->x(); - double x2 = ecl->points()[i]->x(); + double x1 = ecl->points().at(i-1)->x(); + double x2 = ecl->points().at(i)->x(); double d = fabs(dec2 - dec1); double f = 1.0 - fabs(dec2) / d; //fractional distance of the zero, from point1 to point2 Index: kstars/tools/observinglist.h =================================================================== --- kstars/tools/observinglist.h +++ kstars/tools/observinglist.h @@ -376,7 +376,7 @@ * @short Return the active itemmodel * @return the session model or the wishlist model depending on which tab is currently being viewed. */ - inline QStandardItemModel *getActiveModel() const { return ((sessionView) ? m_SessionModel : m_WishListModel); } + inline QStandardItemModel *getActiveModel() const { return (sessionView ? m_SessionModel.get() : m_WishListModel.get()); } /** * @short Return the active sort model @@ -384,7 +384,7 @@ */ inline QSortFilterProxyModel *getActiveSortModel() const { - return ((sessionView) ? m_SessionSortModel : m_WishListSortModel); + return (sessionView ? m_SessionSortModel.get() : m_WishListSortModel.get()); } /** @@ -399,22 +399,30 @@ */ inline QModelIndexList getSelectedItems() const { return getActiveView()->selectionModel()->selectedRows(); } - KSAlmanac *ksal; - ObservingListUI *ui; + std::unique_ptr ksal; + ObservingListUI *ui { nullptr }; QList> m_WishList, m_SessionList; - SkyObject *LogObject, *m_CurrentObject; - bool isModified, sessionView, dss, singleSelection, showScope, noSelection; + SkyObject *LogObject { nullptr }; + SkyObject *m_CurrentObject { nullptr }; + bool isModified { false }; + bool sessionView { false }; + bool dss { false }; + bool singleSelection { false }; + bool showScope { false }; + bool noSelection { false }; QString m_listFileName, m_currentImageFileName, m_currentThumbImageFileName; KStarsDateTime dt; - GeoLocation *geo; - QStandardItemModel *m_WishListModel, *m_SessionModel; - QSortFilterProxyModel *m_WishListSortModel, *m_SessionSortModel; + GeoLocation *geo { nullptr }; + std::unique_ptr m_WishListModel; + std::unique_ptr m_SessionModel; + std::unique_ptr m_WishListSortModel; + std::unique_ptr m_SessionSortModel; QHash TimeHash; std::unique_ptr pmenu; - KSDssDownloader *m_dl; + KSDssDownloader *m_dl { nullptr }; QHash ImagePreviewHash; QPixmap m_NoImagePixmap; - QTimer *m_altitudeUpdater; + QTimer *m_altitudeUpdater { nullptr }; std::function m_altCostHelper; - bool m_initialWishlistLoad = false; + bool m_initialWishlistLoad { false }; }; Index: kstars/tools/observinglist.cpp =================================================================== --- kstars/tools/observinglist.cpp +++ kstars/tools/observinglist.cpp @@ -88,8 +88,8 @@ m_listFileName = QString(); pmenu.reset(new ObsListPopupMenu()); //Set up the Table Views - m_WishListModel = new QStandardItemModel(0, 5, this); - m_SessionModel = new QStandardItemModel(0, 5); + m_WishListModel.reset(new QStandardItemModel(0, 5, this)); + m_SessionModel.reset(new QStandardItemModel(0, 5)); m_WishListModel->setHorizontalHeaderLabels( QStringList() << i18n("Name") << i18n("Alternate Name") << i18nc("Right Ascension", "RA (J2000)") @@ -101,21 +101,21 @@ << i18nc("Constellation", "Constell.") << i18n("Time") << i18nc("Altitude", "Alt") << i18nc("Azimuth", "Az")); - m_WishListSortModel = new QSortFilterProxyModel(this); - m_WishListSortModel->setSourceModel(m_WishListModel); + m_WishListSortModel.reset(new QSortFilterProxyModel(this)); + m_WishListSortModel->setSourceModel(m_WishListModel.get()); m_WishListSortModel->setDynamicSortFilter(true); m_WishListSortModel->setSortRole(Qt::UserRole); - ui->WishListView->setModel(m_WishListSortModel); + ui->WishListView->setModel(m_WishListSortModel.get()); ui->WishListView->horizontalHeader()->setStretchLastSection(true); ui->WishListView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - m_SessionSortModel = new SessionSortFilterProxyModel(); - m_SessionSortModel->setSourceModel(m_SessionModel); + m_SessionSortModel.reset(new SessionSortFilterProxyModel()); + m_SessionSortModel->setSourceModel(m_SessionModel.get()); m_SessionSortModel->setDynamicSortFilter(true); - ui->SessionView->setModel(m_SessionSortModel); + ui->SessionView->setModel(m_SessionSortModel.get()); ui->SessionView->horizontalHeader()->setStretchLastSection(true); ui->SessionView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - ksal = new KSAlmanac; + ksal.reset(new KSAlmanac); ksal->setLocation(geo); ui->avt->setGeoLocation(geo); ui->avt->setSunRiseSetTimes(ksal->getSunRise(), ksal->getSunSet()); @@ -221,10 +221,6 @@ ObservingList::~ObservingList() { - delete ksal; - delete m_SessionModel; - delete m_WishListModel; - delete m_SessionSortModel; } // Show Event @@ -367,10 +363,11 @@ dms lst(geo->GSTtoLST(dt.gst())); p.EquatorialToHorizontal(&lst, geo->lat()); - QString ra, dec, time = "--", alt = "--", az = "--"; + QString alt = "--", az = "--"; QStandardItem *BestTime = new QStandardItem(); - /*if(obj->name() == "star" ) { + /* QString ra, dec; + if(obj->name() == "star" ) { ra = obj->ra0().toHMSString(); dec = obj->dec0().toDMSString(); BestTime->setData( QString( "--" ), Qt::DisplayRole ); @@ -408,7 +405,7 @@ // Is the pointer supplied in our own lists? const QList> &list = (session ? sessionList() : obsList()); - QStandardItemModel *currentModel = (session ? m_SessionModel : m_WishListModel); + QStandardItemModel *currentModel = (session ? m_SessionModel.get() : m_WishListModel.get()); QSharedPointer o = findObject(_o, session); if (!o) @@ -1192,7 +1189,8 @@ ui->avt->removeAllPlotObjects(); //Creating a copy of the lists, we can't use the original lists as they'll keep getting modified as the loop iterates QList> _obsList = m_WishList, _SessionList = m_SessionList; - foreach (QSharedPointer o, _obsList) + + for (QSharedPointer &o : _obsList) { if (o->name() != "star") { @@ -1200,7 +1198,7 @@ slotAddObject(o.data(), false, true); } } - foreach (QSharedPointer obj, _SessionList) + for (QSharedPointer &obj : _SessionList) { if (obj->name() != "star") { Index: kstars/tools/scriptbuilder.h =================================================================== --- kstars/tools/scriptbuilder.h +++ kstars/tools/scriptbuilder.h @@ -15,20 +15,21 @@ * * ***************************************************************************/ -#ifndef SCRIPTBUILDER_H_ -#define SCRIPTBUILDER_H_ - -#include +#pragma once +#include "scriptargwidgets.h" #include "ui_scriptbuilder.h" #include "ui_scriptnamedialog.h" #include "ui_optionstreeview.h" -#include "scriptargwidgets.h" + +#include +#include + +#include class QTreeWidget; +class QTreeWidgetItem; class QTextStream; -class QVBoxLayout; -class QUrl; class KStars; class ScriptFunction; @@ -46,11 +47,12 @@ public: explicit OptionsTreeView(QWidget *p); ~OptionsTreeView(); + QTreeWidget *optionsList() { return otvw->OptionsList; } void resizeColumns(); private: - OptionsTreeViewWidget *otvw; + std::unique_ptr otvw; }; class ScriptNameWidget : public QFrame, public Ui::ScriptNameDialog @@ -73,8 +75,8 @@ void slotEnableOkButton(); private: - ScriptNameWidget *snw; - QPushButton *okB; + ScriptNameWidget *snw { nullptr }; + QPushButton *okB { nullptr }; }; class ScriptBuilderUI : public QFrame, public Ui::ScriptBuilder @@ -84,11 +86,13 @@ explicit ScriptBuilderUI(QWidget *p); }; -/** @class ScriptBuilder - *A GUI tool for building behavioral DBus scripts for KStars. - *@author Jason Harris - *@version 1.0 - */ +/** + * @class ScriptBuilder + * A GUI tool for building behavioral DBus scripts for KStars. + * + * @author Jason Harris + * @version 1.0 + */ class ScriptBuilder : public QDialog { Q_OBJECT @@ -177,9 +181,9 @@ void initViewOptions(); void warningMismatch(const QString &expected) const; - ScriptBuilderUI *sb; + ScriptBuilderUI *sb { nullptr }; - KStars *ks; //parent needed for sub-dialogs + KStars *ks { nullptr }; //parent needed for sub-dialogs QList KStarsFunctionList; QList SimClockFunctionList; @@ -189,23 +193,23 @@ QList ScriptList; - QWidget *argBlank; - ArgLookToward *argLookToward; - ArgFindObject *argFindObject; - ArgSetRaDec *argSetRaDec; - ArgSetAltAz *argSetAltAz; - ArgSetLocalTime *argSetLocalTime; - ArgWaitFor *argWaitFor; - ArgWaitForKey *argWaitForKey; - ArgSetTrack *argSetTracking; - ArgChangeViewOption *argChangeViewOption; - ArgSetGeoLocation *argSetGeoLocation; - ArgTimeScale *argTimeScale; - ArgZoom *argZoom; - ArgExportImage *argExportImage; - ArgPrintImage *argPrintImage; - ArgSetColor *argSetColor; - ArgLoadColorScheme *argLoadColorScheme; + QWidget *argBlank { nullptr }; + ArgLookToward *argLookToward { nullptr }; + ArgFindObject *argFindObject { nullptr }; + ArgSetRaDec *argSetRaDec { nullptr }; + ArgSetAltAz *argSetAltAz { nullptr }; + ArgSetLocalTime *argSetLocalTime { nullptr }; + ArgWaitFor *argWaitFor { nullptr }; + ArgWaitForKey *argWaitForKey { nullptr }; + ArgSetTrack *argSetTracking { nullptr }; + ArgChangeViewOption *argChangeViewOption { nullptr }; + ArgSetGeoLocation *argSetGeoLocation { nullptr }; + ArgTimeScale *argTimeScale { nullptr }; + ArgZoom *argZoom { nullptr }; + ArgExportImage *argExportImage { nullptr }; + ArgPrintImage *argPrintImage { nullptr }; + ArgSetColor *argSetColor { nullptr }; + ArgLoadColorScheme *argLoadColorScheme { nullptr }; #if 0 ArgStartINDI * argStartINDI; @@ -229,16 +233,21 @@ ArgSetFilterNumINDI * argSetFilterNumINDI; #endif - ScriptNameDialog *snd; - OptionsTreeView *otv; + ScriptNameDialog *snd { nullptr }; + OptionsTreeView *otv { nullptr }; - QTreeWidgetItem *opsGUI, *opsToolbar, *opsShowObj, *opsShowOther, *opsCName, *opsHide, *opsSkymap, *opsLimit; + QTreeWidgetItem *opsGUI { nullptr }; + QTreeWidgetItem *opsToolbar { nullptr }; + QTreeWidgetItem *opsShowObj { nullptr }; + QTreeWidgetItem *opsShowOther { nullptr }; + QTreeWidgetItem *opsCName { nullptr }; + QTreeWidgetItem *opsHide { nullptr }; + QTreeWidgetItem *opsSkymap { nullptr }; + QTreeWidgetItem *opsLimit { nullptr }; - bool UnsavedChanges; - bool checkForChanges; + bool UnsavedChanges { false }; + bool checkForChanges { false }; QUrl currentFileURL; QString currentDir; QString currentScriptName, currentAuthor; }; - -#endif Index: kstars/tools/scriptbuilder.cpp =================================================================== --- kstars/tools/scriptbuilder.cpp +++ kstars/tools/scriptbuilder.cpp @@ -17,23 +17,6 @@ #include "scriptbuilder.h" -//needed in slotSave() for chmod() syscall -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - #include "kspaths.h" #include "scriptfunction.h" #include "kstars.h" @@ -45,6 +28,22 @@ #include "widgets/dmsbox.h" #include "widgets/timestepbox.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + OptionsTreeViewWidget::OptionsTreeViewWidget(QWidget *p) : QFrame(p) { setupUi(this); @@ -55,11 +54,11 @@ OptionsTreeView::OptionsTreeView(QWidget *p) : QDialog(p) { - otvw = new OptionsTreeViewWidget(this); + otvw.reset(new OptionsTreeViewWidget(this)); QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(otvw); + mainLayout->addWidget(otvw.get()); setLayout(mainLayout); setWindowTitle(i18n("Options")); @@ -74,7 +73,6 @@ OptionsTreeView::~OptionsTreeView() { - delete otvw; } void OptionsTreeView::resizeColumns() @@ -1178,14 +1176,14 @@ if (cur.startsWith('\"')) { - arg += cur.right(cur.length() - 1); + arg += cur.rightRef(cur.length() - 1); arg += ' '; foundQuote = true; quoteProcessed = true; } else if (cur.endsWith('\"')) { - arg += cur.left(cur.length() - 1); + arg += cur.leftRef(cur.length() - 1); arg += '\''; foundQuote = false; } @@ -1447,7 +1445,6 @@ //Display the function's arguments widget if (sb->ScriptListBox->currentRow() > -1 && sb->ScriptListBox->currentRow() < ((int)sb->ScriptListBox->count())) { - QString t = sb->ScriptListBox->currentItem()->text(); unsigned int n = sb->ScriptListBox->currentRow(); ScriptFunction *sf = ScriptList.at(n); Index: kstars/tools/scriptfunction.h =================================================================== --- kstars/tools/scriptfunction.h +++ kstars/tools/scriptfunction.h @@ -15,8 +15,7 @@ * * ***************************************************************************/ -#ifndef SCRIPTFUNCTION_H_ -#define SCRIPTFUNCTION_H_ +#pragma once #include @@ -69,5 +68,3 @@ bool Valid, ClockFunction; int NumArgs; }; - -#endif Index: kstars/tools/scriptfunction.cpp =================================================================== --- kstars/tools/scriptfunction.cpp +++ kstars/tools/scriptfunction.cpp @@ -210,7 +210,6 @@ QString ScriptFunction::scriptLine() const { QString out(Name); - QString dbus_type; unsigned int i = 0; while (!ArgName[i].isEmpty() && i < 6) @@ -225,7 +224,7 @@ } else { - if (value.left(1) != "\"" && value.left(1) != "\'") + if (value.at(0) != '\"' && value.at(0) != '\'') { value = '\"' + value; } Index: kstars/widgets/magnitudespinbox.h =================================================================== --- kstars/widgets/magnitudespinbox.h +++ kstars/widgets/magnitudespinbox.h @@ -1,6 +1,3 @@ -#ifndef magnitudespinbox_h -#define magnitudespinbox_h - /*************************************************************************** magnitudespinbox.h - description ------------------- @@ -25,6 +22,7 @@ *@author Heiko Evermann *@version 1.0 */ +#pragma once #include @@ -32,14 +30,11 @@ class MagnitudeSpinBox : public QDoubleSpinBox { + Q_OBJECT public: - /**Default Constructor. - */ + /** Default Constructor */ explicit MagnitudeSpinBox(QWidget *parent = 0); - /**Constructor. Set minimum and maximum values for the spinbox. - */ - MagnitudeSpinBox(double minValue, double maxValue, QWidget *parent = 0); + /** Constructor. Set minimum and maximum values for the spinbox. */ + MagnitudeSpinBox(double minValue, double maxValue, QWidget *parent = nullptr); }; - -#endif Index: kstars/widgets/timespinbox.h =================================================================== --- kstars/widgets/timespinbox.h +++ kstars/widgets/timespinbox.h @@ -15,41 +15,43 @@ * * ***************************************************************************/ -#ifndef TIMESPINBOX_H -#define TIMESPINBOX_H +#pragma once #include +#include -class QStringList; - -/** @class TimeSpinBox - *Custom spinbox to handle selection of timestep values with variable units. - *@note this should only be used internally, embedded in a TimeStepBox widget. - *@author Jason Harris - *@version 1.0 - */ +/** + * @class TimeSpinBox + * Custom spinbox to handle selection of timestep values with variable units. + * @note this should only be used internally, embedded in a TimeStepBox widget. + * + * @author Jason Harris + * @version 1.0 + */ class TimeSpinBox : public QSpinBox { Q_OBJECT public: - /**Constructor */ + /** Constructor */ explicit TimeSpinBox(QWidget *parent, bool daysOnly = false); - /**Destructor (empty)*/ + /** Destructor (empty) */ ~TimeSpinBox() {} - /**Convert the internal value to a display string. - *@note reimplemented from QSpinBox - *@p value the internal value to convert to a display string - *@return the display string - */ + /** + * Convert the internal value to a display string. + * @note reimplemented from QSpinBox + * @p value the internal value to convert to a display string + * @return the display string + */ QString textFromValue(int value) const Q_DECL_OVERRIDE; - /**Convert the displayed string to an internal value. - *@note reimplemented from QSpinBox - *@p ok bool pointer set to true if conversion was successful - *@return internal value converted from displayed text - */ + /** + * Convert the displayed string to an internal value. + * @note reimplemented from QSpinBox + * @p ok bool pointer set to true if conversion was successful + * @return internal value converted from displayed text + */ int valueFromText(const QString &text) const Q_DECL_OVERRIDE; /** @return the current TimeStep setting */ @@ -72,5 +74,3 @@ float TimeScale[43]; QStringList TimeString; }; - -#endif Index: kstars/widgets/timespinbox.cpp =================================================================== --- kstars/widgets/timespinbox.cpp +++ kstars/widgets/timespinbox.cpp @@ -18,18 +18,15 @@ #include "timespinbox.h" -#include -#include +#include -#include +#include #include -#include -#include +#include #define SECS_PER_DAY 86400. #define SIDEREAL_YEAR 31558149.77 -#define TROPICAL_YEAR 31556925.19 //Time steps: //0-9: 0 sec, 0.1, 0.25, 0.5, 1, 2, 5, 10, 20, 30 sec @@ -205,8 +202,9 @@ QString TimeSpinBox::textFromValue(int value) const { - QString neg("-"), result; + QString result; int posval(abs(value)); + if (posval > TimeString.size() - 1) posval = 4; @@ -224,6 +222,7 @@ //Pick the closest value int imin = 0; float dx, dxlast(10000000000.0), dxmin(10000000000.0); + for (unsigned int i = 0; i < 42; ++i) { dx = fabs(TimeScale[i] - fabs(x)); Index: tools/run_clazy_static_code_analysis.sh =================================================================== --- /dev/null +++ tools/run_clazy_static_code_analysis.sh @@ -0,0 +1,9 @@ +# Create a separate build directory +rm -rf clazy_build +mkdir -p clazy_build +# Configure CMake +export CLANGXX=clang++-3.9 +export CLAZY_CHECKS="level0,level1,no-non-pod-global-static,no-container-anti-pattern" +cmake -Bclazy_build -H.. -DCMAKE_C_COMPILER=clang-3.9 -DCMAKE_CXX_COMPILER=clazy -DCCACHE_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Debug +# Do a Clang build with Clazy static analyzer +make -C clazy_build -j8