Commit 1ad1c3df authored by Laurent Montel's avatar Laurent Montel
Browse files

Fix coding style (use kde clang format)

parent 6085a865
Pipeline #211831 canceled with stage
in 59 seconds
......@@ -24,6 +24,10 @@ include(KDECMakeSettings)
include(FeatureSummary)
include(GenerateExportHeader)
include(ECMSetupVersion)
include(KDEGitCommitHooks)
include(KDEClangFormat)
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.90.0")
......@@ -281,3 +285,5 @@ install(FILES org.kde.kig.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
if (BUILD_TESTING)
add_subdirectory(tests)
endif ()
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
......@@ -14,15 +14,14 @@ class KigWidget;
/**
* Export to Asymptote.
*/
class AsyExporter
: public KigExporter
class AsyExporter : public KigExporter
{
public:
~AsyExporter();
QString exportToStatement() const override;
QString menuEntryName() const override;
QString menuIcon() const override;
void run( const KigPart& doc, KigWidget& w ) override;
~AsyExporter();
QString exportToStatement() const override;
QString menuEntryName() const override;
QString menuIcon() const override;
void run(const KigPart &doc, KigWidget &w) override;
};
#endif
......@@ -9,9 +9,9 @@
#include "../kig/kig_part.h"
#include "../kig/kig_view.h"
#include "../objects/bezier_imp.h"
#include "../objects/circle_imp.h"
#include "../objects/cubic_imp.h"
#include "../objects/bezier_imp.h"
#include "../objects/curve_imp.h"
#include "../objects/line_imp.h"
#include "../objects/locus_imp.h"
......@@ -23,96 +23,96 @@
#include "../objects/polygon_imp.h"
#include "../objects/text_imp.h"
class AsyExporterImpVisitor
: public ObjectImpVisitor
class AsyExporterImpVisitor : public ObjectImpVisitor
{
QTextStream& mstream;
ObjectHolder* mcurobj;
const KigWidget& mw;
Rect msr;
QTextStream &mstream;
ObjectHolder *mcurobj;
const KigWidget &mw;
Rect msr;
public:
void visit( ObjectHolder* obj );
void visit(ObjectHolder *obj);
AsyExporterImpVisitor( QTextStream& s, const KigWidget& w )
: mstream( s ), mw( w ), msr( mw.showingRect() )
AsyExporterImpVisitor(QTextStream &s, const KigWidget &w)
: mstream(s)
, mw(w)
, msr(mw.showingRect())
{
}
using ObjectImpVisitor::visit;
void visit( const LineImp* imp ) override;
void visit( const PointImp* imp ) override;
void visit( const TextImp* imp ) override;
void visit( const AngleImp* imp ) override;
void visit( const VectorImp* imp ) override;
void visit( const LocusImp* imp ) override;
void visit( const CircleImp* imp ) override;
void visit( const ConicImp* imp ) override;
void visit( const CubicImp* imp ) override;
void visit( const SegmentImp* imp ) override;
void visit( const RayImp* imp ) override;
void visit( const ArcImp* imp ) override;
void visit( const FilledPolygonImp* imp ) override;
void visit( const ClosedPolygonalImp* imp ) override;
void visit( const OpenPolygonalImp* imp ) override;
void visit ( const BezierImp* imp ) override;
void visit ( const RationalBezierImp* imp ) override;
double unit;
using ObjectImpVisitor::visit;
void visit(const LineImp *imp) override;
void visit(const PointImp *imp) override;
void visit(const TextImp *imp) override;
void visit(const AngleImp *imp) override;
void visit(const VectorImp *imp) override;
void visit(const LocusImp *imp) override;
void visit(const CircleImp *imp) override;
void visit(const ConicImp *imp) override;
void visit(const CubicImp *imp) override;
void visit(const SegmentImp *imp) override;
void visit(const RayImp *imp) override;
void visit(const ArcImp *imp) override;
void visit(const FilledPolygonImp *imp) override;
void visit(const ClosedPolygonalImp *imp) override;
void visit(const OpenPolygonalImp *imp) override;
void visit(const BezierImp *imp) override;
void visit(const RationalBezierImp *imp) override;
double unit;
private:
/** Maximal line length in the output file. To avoid too long line which
* can cause error in asy and latex parsing. (Note: this is not 100% strict,
* the lines may have a few more characters.)
*/
static const uint maxlinelength = 500;
/**
* Return the pen color definition as a string.
*/
QString emitPenColor( const QColor& c );
/**
* Return the pen style definition as a string.
*/
QString emitPenStyle( const Qt::PenStyle& style );
/**
* Return the pen width definition as a string.
*/
QString emitPenSize( const int width );
/**
* Return the full pen definition including color, size and style as a string.
*/
QString emitPen( const QColor& c, const int width, const Qt::PenStyle& style );
/**
* Converts Kig coords to Asymptote coord system and sends them to stream
* using the format (xcoord,ycoord) which is of asymptote data type "pair".
*/
QString emitCoord( const Coordinate& c );
/**
* Draws a line (segment) or a vector if vector is true.
*/
void emitLine( const Coordinate& a, const Coordinate& b, const int width,
const Qt::PenStyle s, bool vector = false );
/**
* Sends a new line character ( \n ) to stream.
*/
void newLine();
/**
* Use to convert a dimension "on the screen" to a dimension wrt.
* Kig coordinate system.
*/
double dimRealToCoord( int dim );
/**
* Plots a generic curve though its points calc'ed with getPoint.
*/
void plotGenericCurve( const CurveImp* imp );
/** Maximal line length in the output file. To avoid too long line which
* can cause error in asy and latex parsing. (Note: this is not 100% strict,
* the lines may have a few more characters.)
*/
static const uint maxlinelength = 500;
/**
* Return the pen color definition as a string.
*/
QString emitPenColor(const QColor &c);
/**
* Return the pen style definition as a string.
*/
QString emitPenStyle(const Qt::PenStyle &style);
/**
* Return the pen width definition as a string.
*/
QString emitPenSize(const int width);
/**
* Return the full pen definition including color, size and style as a string.
*/
QString emitPen(const QColor &c, const int width, const Qt::PenStyle &style);
/**
* Converts Kig coords to Asymptote coord system and sends them to stream
* using the format (xcoord,ycoord) which is of asymptote data type "pair".
*/
QString emitCoord(const Coordinate &c);
/**
* Draws a line (segment) or a vector if vector is true.
*/
void emitLine(const Coordinate &a, const Coordinate &b, const int width, const Qt::PenStyle s, bool vector = false);
/**
* Sends a new line character ( \n ) to stream.
*/
void newLine();
/**
* Use to convert a dimension "on the screen" to a dimension wrt.
* Kig coordinate system.
*/
double dimRealToCoord(int dim);
/**
* Plots a generic curve though its points calc'ed with getPoint.
*/
void plotGenericCurve(const CurveImp *imp);
};
#endif
......@@ -9,25 +9,24 @@
class Ui_AsyExporterOptionsWidget;
class AsyExporterOptions
: public QWidget
class AsyExporterOptions : public QWidget
{
Q_OBJECT
Q_OBJECT
Ui_AsyExporterOptionsWidget* expwidget;
Ui_AsyExporterOptionsWidget *expwidget;
public:
explicit AsyExporterOptions( QWidget* parent );
~AsyExporterOptions();
explicit AsyExporterOptions(QWidget *parent);
~AsyExporterOptions();
void setGrid( bool grid );
bool showGrid() const;
void setGrid(bool grid);
bool showGrid() const;
void setAxes( bool axes );
bool showAxes() const;
void setAxes(bool axes);
bool showAxes() const;
void setExtraFrame( bool frame );
bool showExtraFrame() const;
void setExtraFrame(bool frame);
bool showExtraFrame() const;
};
#endif
......@@ -22,18 +22,18 @@ class CabriReader;
* format from zero, by just looking at the input and output from a
* (properly licensed) Cabri program...
*/
class KigFilterCabri
: public KigFilter
class KigFilterCabri : public KigFilter
{
KigFilterCabri();
~KigFilterCabri();
KigFilterCabri();
~KigFilterCabri();
public:
static KigFilterCabri* instance();
static KigFilterCabri *instance();
bool supportMime(const QString &mime) override;
KigDocument *load(const QString &fromfile) override;
bool supportMime ( const QString& mime ) override;
KigDocument* load ( const QString& fromfile ) override;
friend class CabriReader;
friend class CabriReader;
};
#endif
......@@ -23,28 +23,23 @@ class KigFilterCabri;
namespace CabriNS
{
/**
* Cabri versions we try to read from.
*/
enum CabriVersion
{
CV_1_0,
CV_1_2
};
enum CabriGonio
{
/**
* Cabri versions we try to read from.
*/
enum CabriVersion { CV_1_0, CV_1_2 };
enum CabriGonio {
CG_Deg,
CG_Rad
// TODO
};
};
/**
* Read a line from a Cabri file, stripping the \\n and \\r characters.
*/
QString readLine( QFile& file );
/**
* Read a line from a Cabri file, stripping the \\n and \\r characters.
*/
QString readLine(QFile &file);
QString readText( QFile& f, const QString& s, const QString& sep = QStringLiteral( "\n" ) );
QString readText(QFile &f, const QString &s, const QString &sep = QStringLiteral("\n"));
}
/**
......@@ -56,51 +51,48 @@ namespace CabriNS
class CabriObject
{
public:
CabriObject();
uint id;
QByteArray type;
int specification;
QColor color;
QColor fillColor;
int thick;
int lineSegLength;
int lineSegSplit;
// int specialAppearanceSwitch;
bool visible;
int intersectionId;
int ticks;
int side;
// bool fixed;
std::vector<int> parents;
std::vector<double> data;
QString name;
QString text;
Rect textRect;
std::vector<int> incs;
CabriNS::CabriGonio gonio;
CabriObject();
uint id;
QByteArray type;
int specification;
QColor color;
QColor fillColor;
int thick;
int lineSegLength;
int lineSegSplit;
// int specialAppearanceSwitch;
bool visible;
int intersectionId;
int ticks;
int side;
// bool fixed;
std::vector<int> parents;
std::vector<double> data;
QString name;
QString text;
Rect textRect;
std::vector<int> incs;
CabriNS::CabriGonio gonio;
};
class CabriObject_v10
: public CabriObject
class CabriObject_v10 : public CabriObject
{
public:
CabriObject_v10();
CabriObject_v10();
int specialAppearanceSwitch;
bool fixed;
int specialAppearanceSwitch;
bool fixed;
};
class CabriObject_v12
: public CabriObject
class CabriObject_v12 : public CabriObject
{
public:
CabriObject_v12();
CabriObject_v12();
int pointStyle;
int pointStyle;
};
/**
* Base reader for a Cabri figure. It basically reads all the things
* it can from a Cabri figure, even if they are not used.
......@@ -108,54 +100,52 @@ public:
class CabriReader
{
protected:
const KigFilterCabri* m_filter;
const KigFilterCabri *m_filter;
CabriReader( const KigFilterCabri* filter );
CabriReader(const KigFilterCabri *filter);
static void initColorMap();
void parseError( const QString& explanation = QString() ) const;
static void initColorMap();
void parseError(const QString &explanation = QString()) const;
public:
virtual ~CabriReader();
virtual ~CabriReader();
/**
* Translate a color from a 1 to 3 character sequence.
*/
static QColor translateColor( const QString& s );
/**
* Translate a color from a 1 to 3 character sequence.
*/
static QColor translateColor(const QString &s);
virtual bool readWindowMetrics( QFile& f ) = 0;
virtual CabriObject* readObject( QFile& f ) = 0;
virtual void decodeStyle( CabriObject* obj, Qt::PenStyle& ps, Kig::PointStyle& pointType ) = 0;
virtual bool readWindowMetrics(QFile &f) = 0;
virtual CabriObject *readObject(QFile &f) = 0;
virtual void decodeStyle(CabriObject *obj, Qt::PenStyle &ps, Kig::PointStyle &pointType) = 0;
};
class CabriReader_v10
: public CabriReader
class CabriReader_v10 : public CabriReader
{
public:
explicit CabriReader_v10( const KigFilterCabri* filter );
virtual ~CabriReader_v10();
explicit CabriReader_v10(const KigFilterCabri *filter);
virtual ~CabriReader_v10();
bool readWindowMetrics( QFile& f ) override;
CabriObject* readObject( QFile& f ) override;
void decodeStyle( CabriObject* obj, Qt::PenStyle& ps, Kig::PointStyle& pointType ) override;
bool readWindowMetrics(QFile &f) override;
CabriObject *readObject(QFile &f) override;
void decodeStyle(CabriObject *obj, Qt::PenStyle &ps, Kig::PointStyle &pointType) override;
};
class CabriReader_v12
: public CabriReader
class CabriReader_v12 : public CabriReader
{
private:
static void initColorMap();
bool readStyles( const QString& s, CabriObject_v12* myobj );
static void initColorMap();
bool readStyles(const QString &s, CabriObject_v12 *myobj);
public:
explicit CabriReader_v12( const KigFilterCabri* filter );
virtual ~CabriReader_v12();
explicit CabriReader_v12(const KigFilterCabri *filter);
virtual ~CabriReader_v12();
static QColor translateColor( const QString& s );
static QColor translateColor(const QString &s);
bool readWindowMetrics( QFile& f ) override;
CabriObject* readObject( QFile& f ) override;
void decodeStyle( CabriObject* obj, Qt::PenStyle& ps, Kig::PointStyle& pointType ) override;
bool readWindowMetrics(QFile &f) override;
CabriObject *readObject(QFile &f) override;
void decodeStyle(CabriObject *obj, Qt::PenStyle &ps, Kig::PointStyle &pointType) override;
};
#endif
......@@ -15,19 +15,20 @@ class QString;
/**
* This is an import filter for the GNOME geometry program DrGeo.
*/
class KigFilterDrgeo
: public KigFilter
class KigFilterDrgeo : public KigFilter
{
protected:
KigFilterDrgeo();
~KigFilterDrgeo();
KigFilterDrgeo();
~KigFilterDrgeo();
public:
static KigFilterDrgeo* instance();
static KigFilterDrgeo *instance();
bool supportMime(const QString &mime) override;
KigDocument *load(const QString &file) override;
bool supportMime( const QString& mime ) override;
KigDocument* load( const QString& file ) override;
private:
KigDocument* importFigure( const QDomNode& f, const bool grid );
KigDocument *importFigure(const QDomNode &f, const bool grid);
};
#endif
......@@ -18,28 +18,27 @@ class KigExporter;
class KigExportManager
{
std::vector<KigExporter*> mexporters;
KigExportManager();
~KigExportManager();
std::vector<KigExporter *> mexporters;
KigExportManager();
~KigExportManager();
public:
static KigExportManager* instance();
void addMenuAction( const KigPart* doc, KigWidget* w,
KActionCollection* coll );
static KigExportManager *instance();
void addMenuAction(const KigPart *doc, KigWidget *w, KActionCollection *coll);
};
class ExporterAction
: public QAction
class ExporterAction : public QAction
{
Q_OBJECT
Q_OBJECT
KigExporter *mexp;
const KigPart *mdoc;
KigWidget *mw;
KigExporter* mexp;
const KigPart* mdoc;
KigWidget* mw;
public:
ExporterAction( const KigPart* doc, KigWidget* w,
KActionCollection* parent, KigExporter* exp );
ExporterAction(const KigPart *doc, KigWidget *w, KActionCollection *parent, KigExporter *exp);
private slots:
void slotActivated();
void slotActivated();
};
/**
......@@ -50,41 +49,40 @@ private slots:
class KigExporter
{
public:
virtual ~KigExporter();
/**
* Returns a statement like i18n( "Export to image" )
*/
virtual QString exportToStatement() const = 0;
/**
* Returns a string like i18n( "Image..." )
*/
virtual QString menuEntryName() const = 0;
/**
* Returns a string with the name of the icon
*/
virtual QString menuIcon() const = 0;
/**
* Do what you need to do. It's up to the individual exporters to
* ask the user for which file to export to etc., because they can
* do a much better job at that..
*/
virtual void run( const KigPart& doc, KigWidget& w ) = 0;
virtual ~KigExporter();
/**
* Returns a statement like i18n( "Export to image" )
*/
virtual QString exportToStatement() const = 0;
/**
* Returns a string like i18n( "Image..." )
*/
virtual QString menuEntryName() const = 0;
/**
* Returns a string with the name of the icon
*/
virtual QString menuIcon() const = 0;