Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit ef7795c2 authored by Laurent Montel's avatar Laurent Montel 😁

constify

parent e0cf269c
......@@ -56,7 +56,7 @@ void FractionBaseWidget::updateAndRepaint()
update();
}
void FractionBaseWidget::paintRatio(QPainter & paint, Ratio tmp_ratio, int & x_pos, int & y_pos, QFontMetrics & fm, bool show_mixed, bool addMargin, bool show_center)
void FractionBaseWidget::paintRatio(QPainter & paint, const Ratio &tmp_ratio, int & x_pos, int & y_pos, QFontMetrics & fm, bool show_mixed, bool addMargin, bool show_center)
{
QPen pen = paint.pen(); // get the pen
int fontHeight = fm.lineSpacing(); // get the font height
......
......@@ -62,7 +62,7 @@ protected:
//virtual void paintEvent(QPaintEvent*) = 0;
/** paints a ratio at the given position */
void paintRatio(QPainter & paint, Ratio tmp_ratio, int & x_pos, int & y_pos, QFontMetrics & fm, bool addMargin = true, bool show_mixed = true, bool show_center = false);
void paintRatio(QPainter & paint, const Ratio &tmp_ratio, int & x_pos, int & y_pos, QFontMetrics & fm, bool addMargin = true, bool show_mixed = true, bool show_center = false);
/** paints a string in the vertical middle (aligned to the operation signs) */
void paintMiddle(QPainter & paint, const QString& paint_str, int & x_pos, int & y_pos, QFontMetrics & fm, const QColor &color, bool addMargin = true);
......
......@@ -45,7 +45,7 @@ PrimeFactorsLineEdit::~PrimeFactorsLineEdit()
#endif
}
void PrimeFactorsLineEdit::textHasChanged(QString text)
void PrimeFactorsLineEdit::textHasChanged(const QString &text)
{
QPalette palette;
......
......@@ -47,7 +47,7 @@ public:
QStringList getFactors() const;
/** called when the text in QLineEdit's content changes */
void textHasChanged(QString text);
void textHasChanged(const QString &text);
Q_SIGNALS:
/** emitted when QLineEdit's content changes and it's correct
......
......@@ -162,7 +162,7 @@ void Ratio::setRatio(int pinteger, int pnumerator, int pdenominator, bool reduce
/* add a ratio to a ratio like c = a + b */
Ratio Ratio::operator+ (Ratio addend)
Ratio Ratio::operator+ (const Ratio &addend)
{
// this object will be returned as the sum
Ratio sum(0, 1);
......@@ -198,7 +198,7 @@ Ratio Ratio::operator- (Ratio subtrahend)
}
/* mul a ratio with a ratio like c = a * b */
Ratio Ratio::operator*(Ratio factor)
Ratio Ratio::operator*(const Ratio &factor)
{
// this object will be returned as the product
Ratio product(0, 1);
......@@ -240,7 +240,7 @@ Ratio Ratio::operator= (int dummy)
}
/* check, if the ratios are equivalent; -1/2 == 1/-2 -> true */
bool Ratio::operator== (Ratio right)
bool Ratio::operator== (const Ratio &right)
{
signed short orig_sign = 1, right_sign = 1;
......@@ -266,7 +266,7 @@ bool Ratio::operator== (Ratio right)
return true;
}
bool Ratio::operator< (Ratio right)
bool Ratio::operator< (const Ratio &right)
{
signed short sign = 1;
Ratio tmp_ratio = Ratio(m_numerator, m_denominator) - right;
......@@ -289,7 +289,7 @@ bool Ratio::operator< (Ratio right)
}
}
bool Ratio::operator> (Ratio right)
bool Ratio::operator> (const Ratio &right)
{
signed short sign = 1;
Ratio tmp_ratio = Ratio(m_numerator, m_denominator) - right;
......
......@@ -70,13 +70,13 @@ public:
void setRatio(int pinteger, int pnumerator, int pdenominator, bool reduce = true);
/** operator overloading for: c = object + summand */
Ratio operator+ (Ratio addend);
Ratio operator+ (const Ratio &addend);
/** operator overloading for: c = object - subtrahend */
Ratio operator- (Ratio subtrahend);
/** operator overloading for: c = object * factor */
Ratio operator*(Ratio factor);
Ratio operator*(const Ratio &factor);
/** operator overloading for: c = object / divisor */
Ratio operator/ (Ratio divisor);
......@@ -85,13 +85,13 @@ public:
Ratio operator= (int dummy);
/** compares the current ratio with a given one */
bool operator== (Ratio right);
bool operator== (const Ratio &right);
/** compares the current ratio with a given one */
bool operator< (Ratio right);
bool operator< (const Ratio &right);
/** compares the current ratio with a given one */
bool operator> (Ratio right);
bool operator> (const Ratio &right);
/** exchange numerator and denominator */
void reziproc();
......
......@@ -29,7 +29,7 @@
#endif
RatioWidget::RatioWidget(QWidget * parent,
const Ratio para_ratio) :
const Ratio &para_ratio) :
FractionBaseWidget(parent), m_ratio(para_ratio)
{
#ifdef DEBUG
......@@ -44,7 +44,7 @@ RatioWidget::~RatioWidget()
#endif
}
void RatioWidget::setRatio(const Ratio para_ratio)
void RatioWidget::setRatio(const Ratio &para_ratio)
{
m_ratio = para_ratio;
update();
......
......@@ -35,13 +35,13 @@ class RatioWidget : public FractionBaseWidget
{
public:
/** constructor */
explicit RatioWidget(QWidget * parent = nullptr, const Ratio para_ratio = Ratio());
explicit RatioWidget(QWidget * parent = nullptr, const Ratio &para_ratio = Ratio());
/** destructor */
~RatioWidget();
/** set the task to be displayed */
void setRatio(const Ratio para_ratio);
void setRatio(const Ratio &para_ratio);
void setQuestionMixed(bool value);
......
......@@ -35,7 +35,7 @@
#include "settingsclass.h"
ResultWidget::ResultWidget(QWidget * parent, const uintList para_factors) :
ResultWidget::ResultWidget(QWidget * parent, const uintList &para_factors) :
FractionBaseWidget(parent), m_factors(para_factors)
{
#ifdef DEBUG
......@@ -46,7 +46,7 @@ ResultWidget::ResultWidget(QWidget * parent, const uintList para_factors) :
}
ResultWidget::ResultWidget(QWidget * parent,
const Ratio para_result) :
const Ratio &para_result) :
FractionBaseWidget(parent), m_result(para_result)
{
#ifdef DEBUG
......@@ -66,7 +66,7 @@ ResultWidget::ResultWidget(QWidget * parent) :
m_ExerciseView = 2;
}
void ResultWidget::setFactors(const uintList para_factors)
void ResultWidget::setFactors(const uintList &para_factors)
{
m_factors = para_factors;
update();
......@@ -165,7 +165,7 @@ void ResultWidget::showResult()
update();
}
void ResultWidget::setResult(const Ratio para_result, int k)
void ResultWidget::setResult(const Ratio &para_result, int k)
{
#ifdef DEBUG
qDebug() << QStringLiteral("ResultWidget::setResult");
......
......@@ -40,21 +40,21 @@ class ResultWidget : public FractionBaseWidget
{
public:
/** constructors */
ResultWidget(QWidget * parent, const Ratio para_result);
ResultWidget(QWidget * parent, const uintList para_factors);
ResultWidget(QWidget * parent, const Ratio &para_result);
ResultWidget(QWidget * parent, const uintList &para_factors);
explicit ResultWidget(QWidget * parent = nullptr);
/** destructor */
~ResultWidget();
/** set the task to be displayed */
void setResult(const Ratio para_result, int k);
void setResult(const Ratio &para_result, int k);
void setResult(int k);
int KindView();
/** set the task to be displayed */
void setFactors(const uintList para_factors);
void setFactors(const uintList &para_factors);
void setAnswerMixed(bool value);
......
......@@ -112,7 +112,7 @@ void Task::set_ratio_n(unsigned short number, int numerator, int denominator)
}
/** set ratio n in the ratio_vector */
void Task::set_ratio_n(unsigned short number, Ratio fraction)
void Task::set_ratio_n(unsigned short number, const Ratio &fraction)
{
/* do not set something outside our vector */
if (number > ratio_vector.size() - 1)
......@@ -151,7 +151,7 @@ short Task::get_op_n(unsigned short number) const
}
/** add a new ratio at the end of the ratio vector */
void Task::add_ratio(Ratio new_ratio)
void Task::add_ratio(const Ratio &new_ratio)
{
ratio_vector.push_back(new_ratio);
return;
......
......@@ -84,7 +84,7 @@ public:
int denominator = 1);
/** set ratio n */
void set_ratio_n(unsigned short number, Ratio fraction);
void set_ratio_n(unsigned short number, const Ratio &fraction);
/** returns ration n */
Ratio get_ratio_n(unsigned short number = 0) const;
......@@ -96,7 +96,7 @@ public:
short get_op_n(unsigned short number = 0) const;
/** add a ratio to the end of the task */
void add_ratio(Ratio new_ratio);
void add_ratio(const Ratio &new_ratio);
/** add a ratio to the end of the task */
void add_ratio(int numerator = 0, int denominator = 1);
......
......@@ -32,7 +32,7 @@
#endif
TaskWidget::TaskWidget(QWidget * parent,
const Task para_task) :
const Task &para_task) :
FractionBaseWidget(parent), m_task(para_task)
{
#ifdef DEBUG
......@@ -47,7 +47,7 @@ TaskWidget::~TaskWidget()
#endif
}
void TaskWidget::setTask(const Task para_task)
void TaskWidget::setTask(const Task &para_task)
{
m_task = para_task;
update();
......
......@@ -45,13 +45,13 @@ class TaskWidget : public FractionBaseWidget
{
public:
/** constructor */
explicit TaskWidget(QWidget * parent = nullptr, const Task para_task = Task());
explicit TaskWidget(QWidget * parent = nullptr, const Task &para_task = Task());
/** destructor */
~TaskWidget();
/** set the task to be displayed */
void setTask(const Task para_task);
void setTask(const Task &para_task);
void setQuestionMixed(bool value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment