Commit 0d0f78eb authored by Laurent Montel's avatar Laurent Montel 😁

Consti'fy

parent 03316878
......@@ -388,7 +388,7 @@ QVector<int> CageGenerator::makeOneCage (int seedCell, int requiredSize)
return cage;
}
void CageGenerator::setCageTarget (QVector<int> cage,
void CageGenerator::setCageTarget (const QVector<int> &cage,
CageOperator & cageOperator,
int & cageValue)
{
......@@ -483,7 +483,7 @@ void CageGenerator::setCageTarget (QVector<int> cage,
cageValue = value;
}
bool CageGenerator::cageIsOK (const QVector<int> cage,
bool CageGenerator::cageIsOK (const QVector<int> &cage,
CageOperator cageOperator, int cageValue)
{
// TODO - Is it worth checking for duplicate digits in Mathdoku, before
......@@ -537,7 +537,7 @@ bool CageGenerator::cageIsOK (const QVector<int> cage,
return isOK;
}
void CageGenerator::setAllPossibilities (const QVector<int> cage, int nDigits,
void CageGenerator::setAllPossibilities (const QVector<int> &cage, int nDigits,
CageOperator cageOperator,
int cageValue)
{
......@@ -556,7 +556,7 @@ void CageGenerator::setAllPossibilities (const QVector<int> cage, int nDigits,
}
}
void CageGenerator::setPossibilities (const QVector<int> cage,
void CageGenerator::setPossibilities (const QVector<int> &cage,
CageOperator cageOperator, int cageValue)
{
// Generate sets of possible solution-values from the range 1 to mOrder.
......@@ -590,7 +590,7 @@ void CageGenerator::setPossibilities (const QVector<int> cage,
}
void CageGenerator::setPossibleAddsOrMultiplies
(const QVector<int> cage, CageOperator cageOperator, int requiredValue)
(const QVector<int> &cage, CageOperator cageOperator, int requiredValue)
{
int digits[MaxMathOrder]; // Maximum order of maths-based puzzles == 9.
int maxDigit = mOrder;
......@@ -691,7 +691,7 @@ bool CageGenerator::hasDuplicates (int nDigits, int digits[])
return false;
}
bool CageGenerator::isSelfConsistent (const QVector<int> cage,
bool CageGenerator::isSelfConsistent (const QVector<int> &cage,
int nDigits, int digits[])
{
QVector<int> usedGroups;
......
......@@ -154,23 +154,23 @@ private:
QVector<int> makeOneCage (int seedCell, int requiredSize);
// Choose an operator for the cage and calculate the cage's value.
void setCageTarget (QVector<int> cage, CageOperator & cageOperator,
void setCageTarget (const QVector<int> &cage, CageOperator & cageOperator,
int & cageValue);
// Check whether a generated cage is within parameter requirements.
bool cageIsOK (const QVector<int> cage, CageOperator cageOperator,
bool cageIsOK (const QVector<int> &cage, CageOperator cageOperator,
int cageValue);
// Set all possible values for the cells of a cage (used by the solver).
void setAllPossibilities (const QVector<int> cage, int nDigits,
void setAllPossibilities (const QVector<int> &cage, int nDigits,
CageOperator cageOperator, int cageValue);
// Set all possible values for one operator in a cage (used by the solver).
void setPossibilities (const QVector<int> cage, CageOperator cageOperator,
void setPossibilities (const QVector<int> &cage, CageOperator cageOperator,
int cageValue);
// Set all possible values for a cage that has a multiply or add operator.
void setPossibleAddsOrMultiplies (const QVector<int> cage,
void setPossibleAddsOrMultiplies (const QVector<int> &cage,
CageOperator cageOperator, int cageValue);
// Check if a cage contains duplicate digits (not allowed in Killer Sudoku).
......@@ -178,7 +178,7 @@ private:
// Check if a combo of digits in a cage satisfies Sudoku rules (a Mathdoku
// cage can contain a digit more than once, but not in the same row/column).
bool isSelfConsistent (const QVector<int> cage, int nDigits, int digits[]);
bool isSelfConsistent (const QVector<int> &cage, int nDigits, int digits[]);
// Initialise the cage generator for a particular size and type of puzzle.
void init (SKGraph * graph, bool hiddenOperators);
......
......@@ -48,7 +48,7 @@ const SudokuType types[] = {Plain, XSudoku, Jigsaw, Aztec,
Samurai, TinySamurai, Roxdoku,
Mathdoku, KillerSudoku};
Game Serializer::deserializeGame(QDomElement element) {
Game Serializer::deserializeGame(const QDomElement &element) {
bool hasPuzzle = false;
Puzzle* puzzle = 0;
bool hasHistory = false;
......@@ -95,7 +95,7 @@ Game Serializer::deserializeGame(QDomElement element) {
return game;
}
Puzzle* Serializer::deserializePuzzle(QDomElement element) {
Puzzle* Serializer::deserializePuzzle(const QDomElement &element) {
bool hasGraph = false;
SKGraph* graph = 0;
bool hasValues = false;
......@@ -169,7 +169,7 @@ Puzzle* Serializer::deserializePuzzle(QDomElement element) {
return puzzle;
}
static int readInt(QDomElement element, const QString& name, int* err)
static int readInt(const QDomElement &element, const QString& name, int* err)
{ //out of class, cannot be static
*err = 1;
QString Str = element.attribute(name);
......@@ -183,7 +183,7 @@ static int readInt(QDomElement element, const QString& name, int* err)
return num;
}
SKGraph* Serializer::deserializeGraph(QDomElement element) {
SKGraph* Serializer::deserializeGraph(const QDomElement &element) {
bool noFailure = true;
QString orderStr = element.attribute("order");
......@@ -339,7 +339,7 @@ bool Serializer::deserializeCage(SKGraph * graph, const QDomElement & e) {
return true;
}
QList<HistoryEvent> Serializer::deserializeHistory(QDomElement element) {
QList<HistoryEvent> Serializer::deserializeHistory(const QDomElement &element) {
QList<HistoryEvent> history;
QDomNode child = element.firstChild();
......@@ -356,7 +356,7 @@ QList<HistoryEvent> Serializer::deserializeHistory(QDomElement element) {
return history;
}
HistoryEvent Serializer::deserializeSimpleHistoryEvent(QDomElement element) {
HistoryEvent Serializer::deserializeSimpleHistoryEvent(const QDomElement &element) {
QString indexStr = element.attribute("index");
QString markerStr = element.attribute("markers");
QString valueStr = element.attribute("value");
......@@ -393,7 +393,7 @@ HistoryEvent Serializer::deserializeSimpleHistoryEvent(QDomElement element) {
return HistoryEvent();
}
HistoryEvent Serializer::deserializeComplexHistoryEvent(QDomElement /*element*/) {
HistoryEvent Serializer::deserializeComplexHistoryEvent(const QDomElement /*element*/&) {
// TODO implement this
return HistoryEvent();
}
......
......@@ -48,15 +48,15 @@ public:
private:
// TODO - IDW. Maybe there should be shared methods for file handling.
// And do all these methods need to be static?
static Game deserializeGame(QDomElement element);
static Puzzle* deserializePuzzle(QDomElement element) ;
static SKGraph* deserializeGraph(QDomElement element);
static Game deserializeGame(const QDomElement &element);
static Puzzle* deserializePuzzle(const QDomElement &element) ;
static SKGraph* deserializeGraph(const QDomElement &element);
static bool deserializeClique(SKGraph * graph, const QString & size,
const QString & text);
static bool deserializeCage(SKGraph * graph, const QDomElement & e);
static QList<HistoryEvent> deserializeHistory(QDomElement element);
static HistoryEvent deserializeSimpleHistoryEvent(QDomElement element);
static HistoryEvent deserializeComplexHistoryEvent(QDomElement element);
static QList<HistoryEvent> deserializeHistory(const QDomElement &element);
static HistoryEvent deserializeSimpleHistoryEvent(const QDomElement &element);
static HistoryEvent deserializeComplexHistoryEvent(const QDomElement &element);
......
......@@ -62,7 +62,7 @@ Matrix3fT ThisRot = {{ {1.0f}, {0.0f}, {0.0f}, // NEW: This Rota
{0.0f}, {0.0f}, {1.0f} }};
RoxdokuView::RoxdokuView(ksudoku::Game game, GameActions * gameActions,
RoxdokuView::RoxdokuView(const ksudoku::Game &game, GameActions * gameActions,
QWidget * parent)
: QGLWidget(parent)
{
......
......@@ -51,7 +51,7 @@ class RoxdokuView : public QGLWidget, public ViewInterface
{
Q_OBJECT
public:
RoxdokuView(ksudoku::Game game, GameActions * gameActions, QWidget * parent = 0);
RoxdokuView(const ksudoku::Game &game, GameActions * gameActions, QWidget * parent = 0);
~RoxdokuView();
virtual QString status() const;
......
......@@ -49,9 +49,9 @@ public:
QPoint pos() const { return m_pos; }
void showCursor(QGraphicsItem* cursor);
void setType(SpecialType type);
void setCageLabel (const QString cageLabel);
void setCageLabel (const QString &cageLabel);
void setValues(QVector<ColoredValue> values);
void setValues(const QVector<ColoredValue> &values);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
......@@ -116,13 +116,13 @@ void CellGraphicsItem::setType(SpecialType type) {
updatePixmap();
}
void CellGraphicsItem::setValues(QVector<ColoredValue> values) {
void CellGraphicsItem::setValues(const QVector<ColoredValue> &values) {
m_values = values;
updatePixmap();
}
void CellGraphicsItem::setCageLabel(const QString cageLabel) {
void CellGraphicsItem::setCageLabel(const QString &cageLabel) {
m_cageLabel = cageLabel;
}
......@@ -169,7 +169,7 @@ struct GroupGraphicItemSegment {
class GroupGraphicsItem : public QGraphicsItemGroup {
public:
GroupGraphicsItem(QVector<QPoint> cells, bool isCage = false);
GroupGraphicsItem(const QVector<QPoint> &cells, bool isCage = false);
~GroupGraphicsItem();
void hideBlockBorder (bool visible);
public:
......@@ -190,7 +190,7 @@ private:
};
GroupGraphicsItem::GroupGraphicsItem(QVector<QPoint> cells, bool isCage) {
GroupGraphicsItem::GroupGraphicsItem(const QVector<QPoint> &cells, bool isCage) {
m_cells = cells;
m_isCage = isCage;
m_borderVisible = true;
......
......@@ -131,14 +131,14 @@ void SKGraph::initRoxdokuGroups(int pos)
}
}
void SKGraph::addCliqueStructure(QVector<int> data) {
void SKGraph::addCliqueStructure(const QVector<int> &data) {
m_structures << Clique << m_cliques.count() << 0;
addClique(data);
}
void SKGraph::addClique(QVector<int> data) {
void SKGraph::addClique(const QVector<int> &data) {
// Add to the cliques (groups) list.
m_cliques << data;
for (int n = 0; n < data.size(); n++) {
......@@ -147,7 +147,7 @@ void SKGraph::addClique(QVector<int> data) {
}
}
void SKGraph::addCage(const QVector<int> cage, CageOperator cageOperator,
void SKGraph::addCage(const QVector<int> &cage, CageOperator cageOperator,
int cageValue)
{
// Add to the cages list.
......
......@@ -168,10 +168,10 @@ public:
{ return m_structures.at(n*3 + 2); }
// Add a special or irregularly-shaped group to the list of structures.
void addCliqueStructure(QVector<int> data);
void addCliqueStructure(const QVector<int> &data);
// Add a cage (applicable to Mathdoku or Killer Sudoku puzzles only).
void addCage(const QVector<int> cage, CageOperator cageOperator,
void addCage(const QVector<int> &cage, CageOperator cageOperator,
int cageValue);
// Remove a cage (when keying in a Mathdoku or Killer Sudoku puzzle).
......@@ -243,7 +243,7 @@ protected:
BoardContents m_emptyBoard;
private:
void addClique(QVector<int> data);
void addClique(const QVector<int> &data);
// For efficiency, make an index from cells to the groups (cliques)
// where they belong.
......
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