Commit e274ebdb authored by Johannes Bergmeier's avatar Johannes Bergmeier

resolved warnings (not completed yet):

- changed uint to ints where they are not used for flags
- removed some unnescessary static_casts
- solved some other warnings

svn path=/trunk/playground/games/ksudoku/; revision=649084
parent 7007c52a
......@@ -15,7 +15,7 @@
namespace ksudoku {
GameOptionsDialog::GameOptionsDialog(QWidget* parent, bool dub, int type, int order)
GameOptionsDialog::GameOptionsDialog(QWidget* parent, bool /*dub*/, int type, int order)
: QWidget(parent)
, m_config(*KApplication::kApplication()->sessionConfig())
{
......
......@@ -7,7 +7,7 @@ HistoryEvent::HistoryEvent()
{
}
HistoryEvent::HistoryEvent(uint index, const CellInfo& changeCell)
HistoryEvent::HistoryEvent(int index, const CellInfo& changeCell)
: m_cellsIndex(1, index), m_cellsBefore(), m_cellsAfter(1, changeCell)
{
}
......@@ -15,13 +15,13 @@ HistoryEvent::HistoryEvent(uint index, const CellInfo& changeCell)
HistoryEvent::HistoryEvent(const PuzzleState& puzzleChange)
: m_cellsIndex(puzzleChange.size()), m_cellsBefore(), m_cellsAfter(puzzleChange.size())
{
for(uint i = 0; i < puzzleChange.size(); i++) {
for(int i = 0; i < puzzleChange.size(); i++) {
m_cellsIndex[i] = i;
m_cellsAfter[i] = getPuzzleCell(puzzleChange, i);
}
}
void HistoryEvent::setPuzzleCell(PuzzleState& puzzle, uint index, const CellInfo& cell) const {
void HistoryEvent::setPuzzleCell(PuzzleState& puzzle, int index, const CellInfo& cell) const {
switch(cell.state()) {
case GivenValue:
puzzle.setGiven(index, true);
......@@ -43,7 +43,7 @@ void HistoryEvent::setPuzzleCell(PuzzleState& puzzle, uint index, const CellInfo
}
}
CellInfo HistoryEvent::getPuzzleCell(const PuzzleState& puzzle, uint index) const {
CellInfo HistoryEvent::getPuzzleCell(const PuzzleState& puzzle, int index) const {
if(puzzle.given(index)) {
return CellInfo(GivenValue, puzzle.value(index));
} else if(puzzle.value(index) == 0) {
......@@ -59,7 +59,7 @@ bool HistoryEvent::applyTo(PuzzleState& puzzle) {
return false;
m_cellsBefore = QVector<CellInfo>(m_cellsIndex.count());
for(uint i = 0; i < m_cellsIndex.count(); ++i) {
for(int i = 0; i < m_cellsIndex.count(); ++i) {
m_cellsBefore[i] = getPuzzleCell(puzzle, m_cellsIndex[i]);
setPuzzleCell(puzzle, m_cellsIndex[i], m_cellsAfter[i]);
}
......@@ -70,7 +70,7 @@ bool HistoryEvent::undoOn(PuzzleState& puzzle) const {
if(m_cellsBefore.size() == 0 || m_cellsBefore.size() != m_cellsIndex.size())
return false;
for(uint i = 0; i < m_cellsIndex.count(); ++i) {
for(int i = 0; i < m_cellsIndex.count(); ++i) {
setPuzzleCell(puzzle, m_cellsIndex[i], m_cellsBefore[i]);
}
return true;
......@@ -80,7 +80,7 @@ bool HistoryEvent::redoOn(PuzzleState& puzzle) const {
if(m_cellsBefore.size() == 0 || m_cellsBefore.size() != m_cellsIndex.size())
return false;
for(uint i = 0; i < m_cellsIndex.count(); ++i) {
for(int i = 0; i < m_cellsIndex.count(); ++i) {
setPuzzleCell(puzzle, m_cellsIndex[i], m_cellsAfter[i]);
}
return true;
......
......@@ -16,7 +16,7 @@ class CellInfo {
inline CellInfo()
: m_state(Marker), m_value(0), m_markers()
{ }
inline CellInfo(ButtonState state, uint value)
inline CellInfo(ButtonState state, int value)
: m_state(state), m_value(value), m_markers()
{ }
inline CellInfo(const QBitArray& markers)
......@@ -26,9 +26,9 @@ class CellInfo {
: m_state(info.m_state), m_value(info.m_value), m_markers(info.m_markers)
{ }
inline ButtonState state() const { return m_state; }
inline uint value() const { return m_value; }
inline int value() const { return m_value; }
inline const QBitArray markers() const { return m_markers; }
inline bool marker(uint value) const {
inline bool marker(int value) const {
if(value > m_markers.size() || value == 0) return false;
return m_markers[value-1];
}
......@@ -40,7 +40,7 @@ class CellInfo {
}
private:
ButtonState m_state;
uint m_value;
int m_value;
QBitArray m_markers;
};
......@@ -48,11 +48,11 @@ class PuzzleState {
public:
PuzzleState() {
}
PuzzleState(uint size, uint values)
PuzzleState(int size, int values)
: m_markers(values), m_values(size, 0), m_given(size)
{
for(uint i = 0; i < values; i++) {
for(int i = 0; i < values; i++) {
m_markers[i] = QBitArray(size);
}
}
......@@ -68,19 +68,19 @@ public:
m_given.clearBit(i);
}
}
inline void setMarker(uint index, uint value, bool status)
inline void setMarker(int index, int value, bool status)
{
if(value == 0 || value > m_markers.size())
return;
m_markers[value-1].setBit(index, status);
}
inline void resetMarkers(uint index)
inline void resetMarkers(int index)
{
for(int i = 0; i < m_markers.size(); i++) {
m_markers[i].clearBit(index);
}
}
inline void setMarkers(uint index, const QBitArray& values) {
inline void setMarkers(int index, const QBitArray& values) {
if(values.size() == 0) {
resetMarkers(index);
return;
......@@ -89,37 +89,37 @@ public:
m_markers[i].setBit(index, values[i]);
}
}
inline bool marker(uint index, uint value) const
inline bool marker(int index, int value) const
{
if(value == 0 || value > m_markers.size())
return false;
return m_markers[value-1][index];
}
inline QBitArray markers(uint index) const {
inline QBitArray markers(int index) const {
QBitArray array(m_markers.size());
for(int i = 0; i < m_markers.size(); i++) {
array.setBit(i, m_markers[i][index]);
}
return array;
}
inline void setGiven(uint index, bool given)
inline void setGiven(int index, bool given)
{
m_given.setBit(index, given);
}
inline void setValue(uint index, int value)
inline void setValue(int index, int value)
{
m_values[index] = value;
}
inline void setValue(uint index, uint value, bool given)
inline void setValue(int index, int value, bool given)
{
m_given.setBit(index, given);
m_values[index] = value;
};
inline bool given(uint index) const
inline bool given(int index) const
{
return m_given[index];
}
inline uint value(uint index) const
inline int value(int index) const
{
return m_values[index];
}
......@@ -129,7 +129,7 @@ public:
// m_given = state.m_given;
// }
inline void detach() {
for(uint i = 0; i < m_markers.size(); ++i) {
for(int i = 0; i < m_markers.size(); ++i) {
// Detach m_markers
// This actually is only needed once and not every loop
// However this way it's more secure (m_markers.size() might be 0)
......@@ -148,7 +148,7 @@ public:
*@note Use this method only to get size of puzzle when operating
* directly on the puzzle state.
*/
inline uint size() const {
inline int size() const {
return m_values.size();
}
......@@ -162,22 +162,22 @@ private:
class HistoryEvent {
public:
HistoryEvent();
HistoryEvent(uint index, const CellInfo& changedCell);
HistoryEvent(int index, const CellInfo& changedCell);
HistoryEvent(const PuzzleState& newState);
bool applyTo(PuzzleState& puzzle);
bool undoOn(PuzzleState& puzzle) const;
bool redoOn(PuzzleState& puzzle) const;
const QVector<uint>& cellIndices() const { return m_cellsIndex; }
const QVector<int>& cellIndices() const { return m_cellsIndex; }
const QVector<CellInfo>& cellChanges() const { return m_cellsAfter; }
private:
void setPuzzleCell(PuzzleState& puzzle, uint index, const CellInfo& cell) const;
CellInfo getPuzzleCell(const PuzzleState& puzzle, uint index) const;
void setPuzzleCell(PuzzleState& puzzle, int index, const CellInfo& cell) const;
CellInfo getPuzzleCell(const PuzzleState& puzzle, int index) const;
private:
QVector<uint> m_cellsIndex;
QVector<int> m_cellsIndex;
QVector<CellInfo> m_cellsBefore;
QVector<CellInfo> m_cellsAfter;
};
......
......@@ -265,7 +265,7 @@ void KSudoku::addGame(const Game& game) {
printf("out\n");
}
void KSudoku::dlgSelectedGame(const QString& name)
void KSudoku::dlgSelectedGame(const QString& /*name*/)
{
// int order = m_gameSelDlg->order;
// int difficulty = m_gameSelDlg->difficulty;
......@@ -942,7 +942,7 @@ void KSudoku::readProperties(KConfig *config)
}
}
void KSudoku::dragEnterEvent(QDragEnterEvent *event)
void KSudoku::dragEnterEvent(QDragEnterEvent */*event*/)
{
// accept uri drops only
......@@ -1044,9 +1044,9 @@ void KSudoku::filePrint()
// button is clicked
// Game* game = currentGame();
ksudoku::KsView* view = currentView();
//TODO PORT
// ksudoku::KsView* view = currentView();
// if(view)
// ksudoku::Print p(*view);// *game, game->solver()->g->sizeZ() > 0);
//else ??? give message noting to print with hint what is printable ??
......@@ -1118,7 +1118,7 @@ void KSudoku::loadCustomShapeFromPath()
}
QString tmpFile;
bool success = false;
// bool success = false;
QDomDocument doc;
if(!KIO::NetAccess::download( Url, tmpFile, this ))
{
......@@ -1173,7 +1173,7 @@ bool KSudokuNewStuff::install( const QString &fileName )
return true;
}
bool KSudokuNewStuff::createUploadFile( const QString &fileName )
bool KSudokuNewStuff::createUploadFile( const QString &/*fileName*/ )
{
return true;
}
......
......@@ -31,7 +31,7 @@ public:
inline void ref() { ++m_refCount; }
inline bool deref() { return !--m_refCount; }
private:
uint m_refCount;
int m_refCount;
public: // The slots of GameIFace
void undo();
......@@ -44,13 +44,13 @@ public:
inline void emitCompleted(bool isCorrect, const QTime& required, bool withHelp) {
emit completed(isCorrect, required, withHelp);
}
inline void emitCellChange(uint index) { emit cellChange(index); }
inline void emitCellChange(int index) { emit cellChange(index); }
inline void emitFullChange() { emit fullChange(); }
public:
//use this to set order (multiple changes)
void setOrder(int o) { order = o; symbols.setOrder(o); }
uint order;
int order;
PuzzleState state;
......@@ -60,7 +60,7 @@ public:
QTime time;
KUrl url;
QList<HistoryEvent> history;
uint historyPos;
int historyPos;
///@todo move this to proper place (or remove this todo)
Symbols symbols;
......@@ -72,11 +72,11 @@ void Game::Private::undo() {
HistoryEvent event(history[--historyPos]);
event.undoOn(state);
const QVector<uint>& indices = event.cellIndices();
const QVector<int>& indices = event.cellIndices();
if(indices.count() > 10) {
emit fullChange();
} else {
for(uint i = 0; i < indices.count(); ++i)
for(int i = 0; i < indices.count(); ++i)
emit cellChange(indices[i]);
}
emit modified(true);
......@@ -88,11 +88,11 @@ void Game::Private::redo() {
HistoryEvent event(history[historyPos++]);
event.redoOn(state);
const QVector<uint>& indices = event.cellIndices();
const QVector<int>& indices = event.cellIndices();
if(indices.count() > 10) {
emit fullChange();
} else {
for(uint i = 0; i < indices.count(); ++i)
for(int i = 0; i < indices.count(); ++i)
emit cellChange(indices[i]);
}
emit modified(true);
......@@ -130,7 +130,7 @@ Game::Game(Puzzle* puzzle)
m_private->state = PuzzleState(size(), m_private->order);
m_private->state.reset();
for(uint i = 0; i < size(); i++) {
for(int i = 0; i < size(); i++) {
m_private->state.setValue(i, m_private->puzzle->value(i));
if(value(i) != 0)
m_private->state.setGiven(i, true);
......@@ -165,13 +165,13 @@ Game& Game::operator=(const Game& game) {
bool Game::simpleCheck() const {
if(!m_private) return false;
for(uint i = 0; i < size(); ++i) {
for(int i = 0; i < size(); ++i) {
if(m_private->puzzle->value(i) == 0)
continue;
for(uint j = 0; j < m_private->puzzle->optimized_d(i); ++j){
for(int j = 0; j < m_private->puzzle->optimized_d(i); ++j){
// set k to the index of the connected field
uint k = m_private->puzzle->optimized(i,j);
int k = m_private->puzzle->optimized(i,j);
if(k == i)
continue;
......@@ -186,17 +186,17 @@ bool Game::simpleCheck() const {
return true;
}
uint Game::order() const {
int Game::order() const {
if(!m_private) return 0;
return m_private->order;
}
uint Game::index(uint x, uint y, uint z) const {
int Game::index(int x, int y, int z) const {
if(!m_private) return 0;
return m_private->puzzle->index(x,y,z);
}
uint Game::size() const {
int Game::size() const {
if(!m_private) return 0;
return m_private->puzzle->size();
}
......@@ -233,21 +233,21 @@ KUrl Game::getUrl() const {
}
QBitArray Game::highlightValueConnections(uint val, bool allValues) const {
QBitArray Game::highlightValueConnections(int val, bool allValues) const {
if(!m_private) return QBitArray();
if(val <= 0 || val > m_private->order)
return QBitArray();
QBitArray array(size());
for(uint i = 0; i < size(); i++)
for(int i = 0; i < size(); i++)
array.clearBit(i);
for(uint i = 0; i < size(); i++) {
for(int i = 0; i < size(); i++) {
if(allValues && value(i))
array.setBit(i);
if(value(i) == val) {
for(uint j = 0; j < (uint)m_private->puzzle->optimized_d(i); j++)
for(int j = 0; j < m_private->puzzle->optimized_d(i); j++)
array.setBit(m_private->puzzle->optimized(i,j));
}
}
......@@ -255,7 +255,7 @@ QBitArray Game::highlightValueConnections(uint val, bool allValues) const {
return array;
}
void Game::setGiven(uint index, bool given) {
void Game::setGiven(int index, bool given) {
if(!m_private) return;
if(given != m_private->state.given(index)) {
......@@ -269,7 +269,7 @@ void Game::setGiven(uint index, bool given) {
}
}
bool Game::setMarker(uint index, uint val, bool state) {
bool Game::setMarker(int index, int val, bool state) {
if(!m_private) return false;
if(val == 0 || val > order())
......@@ -277,7 +277,7 @@ bool Game::setMarker(uint index, uint val, bool state) {
if(m_private->state.given(index))
return false;
uint val2 = value(index);
int val2 = value(index);
if(val == val2) {
doEvent(HistoryEvent(index, CellInfo()));
} else {
......@@ -297,12 +297,12 @@ bool Game::setMarker(uint index, uint val, bool state) {
return true;
}
void Game::setValue(uint index, uint val) {
void Game::setValue(int index, int val) {
if(!m_private) return;
if(m_private->state.given(index)) return;
uint oldvalue = value(index);
int oldvalue = value(index);
doEvent(HistoryEvent(index, CellInfo(CorrectValue, val)));
m_private->emitCellChange(index);
......@@ -315,11 +315,11 @@ void Game::setValue(uint index, uint val) {
void Game::checkCompleted() {
if(!m_private || !m_private->puzzle->hasSolution()) return;
for(uint i = 0; i < size(); i++)
for(int i = 0; i < size(); i++)
if(value(i) == 0)
return;
for(uint i = 0; i < size(); i++) {
for(int i = 0; i < size(); i++) {
if(value(i) != m_private->puzzle->solution(i)) {
m_private->emitCompleted(false, time(), m_private->hadHelp);
return;
......@@ -344,8 +344,8 @@ bool Game::giveHint() {
// i = RANDOM(size());
// } while (m_private->isGiven(i));
uint start = RANDOM(size());
uint i;
int start = RANDOM(size());
int i;
for(i = start; i < size(); ++i)
if(!given(i))
break;
......@@ -356,7 +356,7 @@ bool Game::giveHint() {
if(i == start) return false;
}
uint val = m_private->puzzle->solution(i);
int val = m_private->puzzle->solution(i);
doEvent(HistoryEvent(i, CellInfo(GivenValue, val)));
m_private->emitCellChange(i);
......@@ -375,8 +375,8 @@ bool Game::autoSolve() {
PuzzleState newState(size(), order());
newState.reset();
for(uint i = 0; i < size(); ++i) {
uint val = m_private->puzzle->solution(i);
for(int i = 0; i < size(); ++i) {
int val = m_private->puzzle->solution(i);
newState.setValue(i, val);
newState.setGiven(i, true);
}
......@@ -392,22 +392,22 @@ bool Game::autoSolve() {
}
uint Game::value(uint index) const {
int Game::value(int index) const {
if(!m_private) return 0;
return m_private->state.value(index);
}
bool Game::given(uint index) const {
bool Game::given(int index) const {
if(!m_private) return false;
return m_private->state.given(index);
}
bool Game::marker(uint index, uint val) const {
bool Game::marker(int index, int val) const {
if(!m_private) return false;
return m_private->state.marker(index, val);
}
ksudoku::ButtonState Game::buttonState(uint index) const {
ksudoku::ButtonState Game::buttonState(int index) const {
if(!m_private) return WrongValue;
if(given(index))
......@@ -419,7 +419,7 @@ ksudoku::ButtonState Game::buttonState(uint index) const {
return CorrectValue;
}
CellInfo Game::cellInfo(uint index) const {
CellInfo Game::cellInfo(int index) const {
if(!m_private)
return CellInfo(WrongValue, 0);
......@@ -438,7 +438,7 @@ const QByteArray Game::allValues() const {
return m_private->state.allValues();
}
QChar Game::value2Char(uint value) const {
QChar Game::value2Char(int value) const {
if(!m_private || value == 0) return QChar('\0');
//return m_private->puzzle->value2Char(value);
......@@ -475,13 +475,13 @@ void Game::doEvent(const HistoryEvent& event) {
m_private->historyPos++;
}
uint Game::historyLength() const {
int Game::historyLength() const {
if(!m_private) return 0;
return m_private->history.count();
}
HistoryEvent Game::historyEvent(uint i) const {
HistoryEvent Game::historyEvent(int i) const {
if(!m_private || i >= m_private->history.count())
return HistoryEvent();
......
......@@ -32,7 +32,7 @@ public slots:
signals:
void modified(bool isModified);
void completed(bool isCorrect, const QTime& required, bool withHelp);
void cellChange(uint index);
void cellChange(int index);
void fullChange();
};
......@@ -70,12 +70,12 @@ public:
///convert coordinates in a puzzle to one index value
///no bound checks are performed for performance reason
uint index(uint x, uint y, uint z = 0) const;
int index(int x, int y, int z = 0) const;
/**
* The nubmer of cells of the puzzle
*/
uint size() const;
int size() const;
/**
* Checks wheter a set contains obvious errors
......@@ -91,7 +91,7 @@ public:
* @param[in] allValues Whether cells which allready have a value should also be hightlighted
* @return A array of bools for each cell. True when the cell might not be used otherwise false.
*/
QBitArray highlightValueConnections(uint val, bool allValues = false) const;
QBitArray highlightValueConnections(int val, bool allValues = false) const;
///@return pointer to current puzzle
Puzzle* puzzle() const;
......@@ -110,23 +110,23 @@ public:
bool hasSolver();
uint order() const;
int order() const;
bool marker(uint index, uint value) const;
inline bool marker(uint value, uint x, uint y, uint z = 0) const;
uint value(uint index) const;
inline uint value(uint x, uint y, uint z = 0) const;
bool given(uint index) const;
inline bool given(uint x, uint y, uint z = 0) const;
bool marker(int index, int value) const;
inline bool marker(int value, int x, int y, int z = 0) const;
int value(int index) const;
inline int value(int x, int y, int z = 0) const;
bool given(int index) const;
inline bool given(int x, int y, int z = 0) const;
/**
* Returns the state of a cell
* @param[in] index The index of the cell
*/
ksudoku::ButtonState buttonState(uint index) const;
inline ksudoku::ButtonState buttonState(uint x, uint y, uint z = 0) const;
CellInfo cellInfo(uint index) const;
inline CellInfo cellInfo(uint x, uint y, uint z = 0) const;
ksudoku::ButtonState buttonState(int index) const;
inline ksudoku::ButtonState buttonState(int x, int y, int z = 0) const;
CellInfo cellInfo(int index) const;
inline CellInfo cellInfo(int x, int y, int z = 0) const;
/**
* Sets one marker in a cell
......@@ -135,24 +135,24 @@ public:
* @param[in] state Whether the marker shoudl be set or unset
* @return Whether this function was executed succesfully
*/
bool setMarker(uint index, uint val, bool state);
inline bool setMarker(uint val, bool state, uint x, uint y, uint z = 0);
inline bool flipMarker(uint index, uint val);
inline bool flipMarker(uint val, uint x, uint y, uint z = 0);
bool setMarker(int index, int val, bool state);
inline bool setMarker(int val, bool state, int x, int y, int z = 0);
inline bool flipMarker(int index, int val);
inline bool flipMarker(int val, int x, int y, int z = 0);
/**
* @brief Sets the value of a cell
* @param[in] index The index of the cell
* @param[in] val The new value of the cell
*/
void setValue(uint index, uint val);
inline void setValue(uint val, uint x, uint y, uint z = 0);