Commit 0f1d2ae1 authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Chris Rizzitello

Clang Format improvements

Not all of the clang-format improvements were added,
specially large connects that spanned four lines where
changed to one lines, I removed those from the commits.

Also maps and lists that where transformed into one liners
also removed.
parent ac340f78
......@@ -23,6 +23,15 @@ option(BUILD_DOCS "Build and Install Documents (Requires Doxygen)")
option(BUILD_TESTS "Build and Run Unittests")
option(DEPLOY_PLUGINS_WITH_BINARY "Deploy Plugins to bin/plugins (Use for win/mac)")
include(KDEClangFormat)
file(GLOB_RECURSE
ALL_CLANG_FORMAT_SOURCE_FILES
*.cpp
*.h
)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
set_package_properties(
ECM PROPERTIES
TYPE REQUIRED
......
......@@ -17,7 +17,8 @@ There are several ways you can contribute
## General Contribution Workflow
The Following Is the General work flow for most contrubitions
- Create changes on your local fork in a new branch
- When your ready to submit your change create a Merge Request on [KDE Invent]
- Format your code by building the clang-format target.
- Submit your change create a Merge Request on [KDE Invent]
- Wait for review
- Update your commits with any changes, and update your Merge Request after.
- Mark all your "Issues" resolved in your MR.
......@@ -30,22 +31,29 @@ The following guidelines apply to all submited code.
- Follow the [KDE style guidelines]
- Use constant referances when possible
- Includes should be alphabetical.
- Run the style script before you commit.
- Use the target clang-format before you commit to format your code.
- Headers should use `#pragma once`.
- Auto should not be used if the type is not explict.
- Doxygen comments should be created/updated with code.
- Objects should have logical varible and function names
- Code should always be readable, comment your code when it makes sense.
- Code should always be readable, comment your code when it makes sense.
#### Using Clang format
You can use the make target clang-format to format your source code correctly.
to do so you must first have run cmake to generate build file.
In your IDE you can build the target "clang-format"
Or manually from inside your build directory with `make clang-format`
### Commit Guidelines
Keeping a clean project history requires that we take care when choosing how we will commit our code. Consider the following when creating commits. ALL COMMITS MUST BE REVIEWED BEFORE PUSHING TO MASTER.
- Follow the [KDE commit guidelines]
- Format your code using the clang-format make target (see above)
- Reviewers: rizzitello, patrickelectric, laysrodrigues, tcanabrava
- Be sure to make any review issues as resolved.
- Keep your base upto date.
- Amend your local commits to fix review issues.
- Always Ammend commits to update them
- Always Ammend commits to update them
- Never fix a commit with another commit.
- Update your commits with `git commit --amend`
- Update your MR with `git push --force`
......
#!/bin/sh
# To install:
# - Move to .git/hooks/
# - Rename it pre-commit
# - Turn executatble $ chmod +x pre-commit
# Check if this is the initial commit
if git rev-parse --verify HEAD >/dev/null 2>&1
then
echo "pre-commit: About to create a new commit..."
against=HEAD
else
echo "pre-commit: About to create the first commit..."
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Use git diff-index to check for whitespace errors
echo "pre-commit: Running style correction script..."
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)
echo $files
if [ "$files" != "" ]
then
sh scripts/style.sh
git add $files
fi
#!/bin/sh
# Apply kdelibs coding style to all c, cpp and header files in and below the current directory
#
# The coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style
#
# Requirements:
# - installed astyle, with patches below
#
# IMPORTANT: astyle misparses the Qt "keywords" like foreach and Q_FOREACH, which
# makes it style wrongly not just the space after the keyword, but also everything
# inside the parenthesis, leading to things like:
# Q_FOREACH(const QString & it, l) // note the space after the '&'.
#
# To fix this, patch astyle with http://www.davidfaure.fr/kde/astyle_qt.diff
# Mentionned upstream in https://sourceforge.net/p/astyle/bugs/154/
#
# Another feature was implemented: removing spaces before ',' and ';'.
# Apply http://www.davidfaure.fr/kde/astyle_comma.diff
# This has been sent upstream in https://sourceforge.net/p/astyle/bugs/100/
#
# Instructions for OpenSuSE users:
# zypper si astyle
# cd ~/rpmbuild/SOURCES ; wget http://www.davidfaure.fr/kde/astyle_qt.diff
# wget http://www.davidfaure.fr/kde/astyle_comma.diff
# cd ../SPECS ; wget http://www.davidfaure.fr/kde/astyle.spec.diff
# patch astyle.spec < astyle.spec.diff
# rpmbuild -ba astyle.spec
# sudo rpm -Uvh --force ~/rpmbuild/RPMS/x86_64/astyle-*.rpm
files=`find -type f -name '*.c' -or -name '*.cpp' -or -name '*.cc' -or -name '*.h'`
if [ -z "$files" ]; then
# nothing to do
exit 0
fi
astyle -n -Q \
--indent=spaces=4 --style=otbs \
--indent-labels --pad-oper --unpad-paren --pad-header \
--keep-one-line-statements \
--convert-tabs \
--indent-preprocessor \
--align-pointer=name \
$files
# --max-code-length=100 is not used, on purpose. It's a hard limit, sometimes making things
# less readable than if the code is kept on a single line. 100 is just a recommendation
# in the coding style.
# Watch out for things that lead to method implementations being parsed as if inside other methods,
# e.g. due to '{' inside #ifdef and #else and '}' outside.
grep '^\S* \S*::.*) {$' $files && echo "WARNING: check for wrong '{' placement in method definitions, in above grep results"
# Remove old emacs mode-lines
perl -pi -e '$_ = "" if /c-basic-offset: [1-8]/' $files
# Remove old kate mode-lines
perl -pi -e '$_ = "" if /kate: .*indent-width/ || /kate:.*tab-width/' $files
# Remove old vim mode-lines
perl -pi -e '$_ = "" if /\/\/.* vim:/' $files
# They are often in a two-liner C comment, so we need a bit of perl magic to remove these
perl - $files <<EOF
foreach my \$file (@ARGV) {
open F, "+<", \$file or do { print STDERR "open(\$file) failed : \"\$!\"\n"; next };
my \$str = join '', <F>;
if( \$str =~ m/vim:/ ) {
#print STDERR "Removing multi-line vim modeline from \$file\n";
\$str =~ s!/\*\**\s*\**\s*vim:[^\n]*\n\s*\*/!!smg;
seek F, 0, 0;
print F \$str;
truncate F, tell(F);
}
close F;
}
EOF
# Remove consecutive blank lines
perl - $files <<EOF
foreach my \$file (@ARGV) {
open F, "+<", \$file or do { print STDERR "open(\$file) failed : \"\$!\"\n"; next };
my \$str = join '', <F>;
if (\$str =~ s/\s*\n\s*\n\s*\n\n*/\n\n/smg ) {
seek F, 0, 0;
print F \$str;
truncate F, tell(F);
}
close F;
}
EOF
# TODO: add command-line option to trigger this
# It's not wanted when working on a fix
#git commit -q -a -m "Code reformatted using kde-dev-scripts/astyle-kdelibs.
#Use git blame -w `git rev-parse --short HEAD` to show authorship as it was before this commit."
This diff is collapsed.
......@@ -24,15 +24,15 @@
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <memory>
#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <memory>
#include "ifirmware.h"
#include "temperature.h"
#include "atcore_export.h"
#include "beddeform.h"
#include "ifirmware.h"
#include "temperature.h"
class SerialLayer;
class IFirmware;
......@@ -76,46 +76,46 @@ class ATCORE_EXPORT AtCore : public QObject
Q_PROPERTY(Temperature *temperature READ temperature CONSTANT)
friend class AtCoreTests;
//Add friends as Sd Card support is extended to more plugins.
// Add friends as Sd Card support is extended to more plugins.
friend class RepetierPlugin;
friend class MarlinPlugin;
//friend class SmoothiePlugin;
//friend class TeacupPlugin;
//friend class AprinterPlugin;
//friend class SprinterPlugin;
// friend class SmoothiePlugin;
// friend class TeacupPlugin;
// friend class AprinterPlugin;
// friend class SprinterPlugin;
public:
/**
* @brief STATES enum Possible states the printer can be in
*/
enum STATES {
DISCONNECTED, //!< Not Connected to a printer, initial state
CONNECTING, //!<Attempting to connect, Fw not probed
IDLE, //!<Connected to printer and ready for commands
BUSY, //!<Printer is Printing or working
PAUSE, //!<Printer is paused
ERRORSTATE, //!<Printer Returned Error
STOP, //!<Stop Printing and Clean Queue
STARTPRINT, //!<Just Starting a print job
FINISHEDPRINT, //!<Just Finished print job
DISCONNECTED, //!< Not Connected to a printer, initial state
CONNECTING, //!< Attempting to connect, Fw not probed
IDLE, //!< Connected to printer and ready for commands
BUSY, //!< Printer is Printing or working
PAUSE, //!< Printer is paused
ERRORSTATE, //!< Printer Returned Error
STOP, //!< Stop Printing and Clean Queue
STARTPRINT, //!< Just Starting a print job
FINISHEDPRINT, //!< Just Finished print job
};
Q_ENUM(STATES)
/**
* @brief The AXES enum - Printer Axes.
*/
enum AXES {
X = 1 << 0, //!<X Axis: X Motor
Y = 1 << 1, //!<Y Axis Y Motor
Z = 1 << 2, //!<Z Axis Z Motor
E = 1 << 3, //!<E Axis: Extruder Motor 0
X = 1 << 0, //!< X Axis: X Motor
Y = 1 << 1, //!< Y Axis Y Motor
Z = 1 << 2, //!< Z Axis Z Motor
E = 1 << 3, //!< E Axis: Extruder Motor 0
};
Q_ENUM(AXES)
/**
* @brief The UNITS enum - Possible Mesurment Units
*/
enum UNITS {
METRIC, //!< Metric Units (Meters)
IMPERIAL //!< Imperial Units (Feet)
METRIC, //!< Metric Units (Meters)
IMPERIAL //!< Imperial Units (Feet)
};
Q_ENUM(UNITS)
/**
......@@ -210,13 +210,13 @@ public:
Temperature *temperature();
/**
* @brief Return the amount of miliseconds the serialTimer is set to. 0 = Disabled
*/
* @brief Return the amount of miliseconds the serialTimer is set to. 0 = Disabled
*/
int serialTimerInterval() const;
/**
* @brief Return the amount of miliseconds the temperatureTimer is set to. 0 = Disabled
*/
* @brief Return the amount of miliseconds the temperatureTimer is set to. 0 = Disabled
*/
int temperatureTimerInterval() const;
/**
......@@ -283,15 +283,15 @@ signals:
void receivedMessage(const QByteArray &message);
/**
* @brief New interval for serial timer
* @sa setSerialTimerInterval()
*/
* @brief New interval for serial timer
* @sa setSerialTimerInterval()
*/
void serialTimerIntervalChanged(const int newTime);
/**
* @brief New interval for temperature timer
* @sa setTemperatureTimerInterval()
*/
* @brief New interval for temperature timer
* @sa setTemperatureTimerInterval()
*/
void temperatureTimerIntervalChanged(const int newTime);
/**
......@@ -301,9 +301,9 @@ signals:
void autoTemperatureReportChanged(bool autoReport);
/**
* @brief New interval for automatic temperature report
* @sa setautoTemperatureReport()
*/
* @brief New interval for automatic temperature report
* @sa setautoTemperatureReport()
*/
void autoCheckTemperatureIntervalChanged(const int newTime);
/**
......@@ -579,7 +579,6 @@ private slots:
void handleSerialError(QSerialPort::SerialPortError error);
private:
/**
* @brief Load A firmware plugin
* @param fwName : name of the firmware
......
......@@ -20,8 +20,8 @@
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QRegularExpressionMatch>
#include "beddeform.h"
#include <QRegularExpressionMatch>
struct BedDeform::BedDeformPrivate {
/** bedData Beddeform data*/
......@@ -34,7 +34,7 @@ struct BedDeform::BedDeformPrivate {
/**
* @brief Line with the pattern of digit(s) a single space then '+' or '-'.
* Examples:
* 0 -0.155 +5.123 -4.567
* 0 -0.155 +5.123 -4.567
* 10 +8.901 -2.345 +6.789
*/
const QRegularExpression BedDeform::BedDeformPrivate::lineRegEx = QRegularExpression(QStringLiteral(R"((?:\d+\s(\+|\-)))"));
......
......@@ -61,6 +61,7 @@ public:
QVariantList bedDeformationGrid();
signals:
void dataChanged(const QVariantList &data);
private:
struct BedDeformPrivate;
BedDeformPrivate *d;
......
This diff is collapsed.
......@@ -25,8 +25,8 @@
*/
#pragma once
#include <QString>
#include <QObject>
#include <QString>
#include "atcore_export.h"
/**
......@@ -37,75 +37,252 @@ class ATCORE_EXPORT GCode
{
Q_GADGET
friend class GCodeTests;
public:
/**
* @brief The GCommands enum
*/
enum GCommands {
G0, G1, G2, G3, G4,
G10 = 10, G11,
G20 = 20, G21, G22, G23, G28 = 28, G29,
G30, G31, G32, G33,
G90 = 90, G91, G92,
G100 = 100,
G130 = 130, G131, G132, G133,
G161 = 161, G162
};
enum GCommands { G0, G1, G2, G3, G4, G10 = 10, G11, G20 = 20, G21, G22, G23, G28 = 28, G29, G30, G31, G32, G33, G90 = 90, G91, G92, G100 = 100, G130 = 130, G131, G132, G133, G161 = 161, G162 };
Q_ENUM(GCommands)
/**
* @brief The MCommands enum
*/
enum MCommands {
M0, M1, M2, M6 = 6,
M17 = 17, M18,
M20 = 20, M21, M22, M23, M24, M25, M26, M27, M28, M29,
M30, M31, M32, M33, M34, M36 = 36, M37, M38,
M40 = 40, M41, M42, M43, M48 = 48,
M70 = 70, M72 = 72, M73,
M80 = 80, M81, M82, M83, M84, M85,
M92 = 92, M93, M98 = 98, M99,
M101 = 101, M102, M103, M104, M105, M106, M107, M108, M109,
M110, M111, M112, M113, M114, M115, M116, M117, M118, M119,
M120, M121, M122, M123, M124, M126 = 126, M127, M128, M129,
M130, M131, M132, M133, M134, M135, M136,
M140 = 140, M141, M142, M143, M144, M146 = 146, M149 = 149,
M150 = 150, M155 = 155,
M160 = 160, M163 = 163, M164 = 164,
M190 = 190, M191,
M200 = 200, M201, M202, M203, M204, M205, M206, M207, M208, M209,
M210, M211, M212, M218 = 218,
M220 = 220, M221, M222, M223, M224, M225, M226, M227, M228, M229,
M230, M231, M232,
M240 = 240, M241, M245 = 245, M246,
M250 = 250, M251,
M0,
M1,
M2,
M6 = 6,
M17 = 17,
M18,
M20 = 20,
M21,
M22,
M23,
M24,
M25,
M26,
M27,
M28,
M29,
M30,
M31,
M32,
M33,
M34,
M36 = 36,
M37,
M38,
M40 = 40,
M41,
M42,
M43,
M48 = 48,
M70 = 70,
M72 = 72,
M73,
M80 = 80,
M81,
M82,
M83,
M84,
M85,
M92 = 92,
M93,
M98 = 98,
M99,
M101 = 101,
M102,
M103,
M104,
M105,
M106,
M107,
M108,
M109,
M110,
M111,
M112,
M113,
M114,
M115,
M116,
M117,
M118,
M119,
M120,
M121,
M122,
M123,
M124,
M126 = 126,
M127,
M128,
M129,
M130,
M131,
M132,
M133,
M134,
M135,
M136,
M140 = 140,
M141,
M142,
M143,
M144,
M146 = 146,
M149 = 149,
M150 = 150,
M155 = 155,
M160 = 160,
M163 = 163,
M164 = 164,
M190 = 190,
M191,
M200 = 200,
M201,
M202,
M203,
M204,
M205,
M206,
M207,
M208,
M209,
M210,
M211,
M212,
M218 = 218,
M220 = 220,
M221,
M222,
M223,
M224,
M225,
M226,
M227,
M228,
M229,
M230,
M231,
M232,
M240 = 240,
M241,
M245 = 245,
M246,
M250 = 250,
M251,
M280 = 280,
M300 = 300, M301, M302, M303, M304, M305, M306,
M320 = 320, M321, M322, M323,
M300 = 300,
M301,
M302,
M303,
M304,
M305,
M306,
M320 = 320,
M321,
M322,
M323,
M340 = 340,
M350 = 350, M351, M355 = 355,
M360 = 360, M361, M362, M363, M364, M365, M366,
M370 = 370, M371, M372, M373, M374, M375,
M380 = 380, M381,
M400 = 400, M401, M402, M404 = 404, M405, M406, M407, M408,
M420 = 420, M421,
M450 = 450, M451, M452, M453,
M350 = 350,
M351,
M355 = 355,
M360 = 360,
M361,
M362,
M363,
M364,
M365,
M366,
M370 = 370,
M371,
M372,
M373,
M374,
M375,
M380 = 380,
M381,
M400 = 400,
M401,
M402,
M404 = 404,
M405,
M406,
M407,
M408,
M420 = 420,
M421,
M450 = 450,
M451,
M452,
M453,
M460 = 460,
M500 = 500, M501, M502, M503,
M500 = 500,
M501,
M502,
M503,
M540 = 540,
M550 = 550, M551, M552, M553, M554, M555, M556, M557, M558, M559,
M560, M561, M562, M563, M564, M565, M566, M567, M568, M569,
M570, M571, M572, M573, M574, M575, M577 = 577, M578, M579,
M580 = 580, M581, M582, M583, M584,
M600 = 600, M605 = 605, M665 = 665, M666 = 666, M667, M668,
M700 = 700, M701, M702, M703,
M550 = 550,
M551,
M552,
M553,
M554,
M555,
M556,
M557,
M558,
M559,
M560,
M561,
M562,
M563,
M564,
M565,
M566,
M567,
M568,
M569,
M570,
M571,
M572,
M573,
M574,
M575,
M577 = 577,
M578,
M579,
M580 = 580,
M581,
M582,
M583,
M584,
M600 = 600,
M605 = 605,