From b5abb15c8ef49830a54b33eccc4db4e1e4fe3b9f Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Mon, 11 Feb 2008 20:33:42 +0100 Subject: [PATCH] push 3d4e9e0832507dc01d09c79a6b95c4d44c86028c --- src/animation.cpp | 18 ++--- src/board.cpp | 9 +-- src/chesstable.cpp | 20 +++--- src/common.cpp | 46 +------------ src/common.h | 35 +--------- src/connection.cpp | 10 +-- src/console.cpp | 26 ++++---- src/controllers/editgame.cpp | 23 ++++--- src/controllers/editposition.cpp | 18 ++--- src/engine.cpp | 15 ++--- src/engineinfo.cpp | 4 +- src/entities/engineentity.cpp | 12 ++-- src/entities/icsentity.cpp | 17 +++-- src/game.cpp | 46 ++++++------- src/gnushogiengine.cpp | 5 +- src/graphicalgame.cpp | 7 +- src/hline.cpp | 8 +-- src/hlvariant/animator.h | 5 +- src/hlvariant/chess/san.cpp | 11 ++-- src/hlvariant/chess/san.h | 4 +- src/hlvariant/shogi/legalitycheck.h | 4 +- src/hlvariant/shogi/serializer.h | 7 +- src/hlvariant/tagua_wrapped.h | 8 +-- src/hlvariant/tori-shogi/legalitycheck.h | 1 - src/icsconnection.cpp | 41 ++++++------ src/icsgamedata.cpp | 5 +- src/index.cpp | 5 +- src/loader/context.cpp | 14 +--- src/loader/context.h | 7 +- src/loader/image.cpp | 4 +- src/loader/theme.cpp | 23 ++++--- src/luaapi/genericwrapper.h | 8 +-- src/luaapi/luahl.cpp | 16 ++--- src/luaapi/luavalue.cpp | 9 +-- src/luaapi/options.cpp | 5 +- src/mainwindow.cpp | 51 ++++++-------- src/mastersettings.cpp | 18 ++--- src/movelist.cpp | 35 ++++------ src/movelist_textual.cpp | 24 +++---- src/option.cpp | 110 +++++++++++++++---------------- src/pgnparser.cpp | 7 +- src/piecepool.cpp | 18 ++--- src/point.cpp | 46 +++++-------- src/point.h | 2 +- src/positioninfo.cpp | 3 +- src/pref_movelist.cpp | 1 - src/pref_theme.cpp | 13 ++-- src/qconnect.cpp | 2 +- src/settings.cpp | 4 +- src/sprite.cpp | 3 +- src/tabwidget.cpp | 4 +- src/ui.cpp | 8 ++- src/ui.h | 2 + src/weakset.h | 14 ++-- src/xboardengine.cpp | 4 +- tests/luaimage/test.cpp | 2 +- tests/options/main.cpp | 2 +- tests/test_weakset.cpp | 2 +- tests/weak_set/test_weakset.cpp | 2 +- 59 files changed, 378 insertions(+), 495 deletions(-) diff --git a/src/animation.cpp b/src/animation.cpp index 2e4d757..bbcb62e 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -45,15 +45,15 @@ MovementAnimation::MovementAnimation(const SpritePtr& piece, , m_state(Inactive) , m_rotate(rotate) { #ifdef ANIMATION_DEBUG - cout << "creating animation " << this << " for piece " << piece.get() << endl; + kDebug() << "creating animation " << this << " for piece " << piece.get() << endl; #endif } MovementAnimation::~MovementAnimation() { #ifdef ANIMATION_DEBUG - cout << "destroying animation " << this << " for piece " << m_piece.get() << endl; + kDebug() << "destroying animation " << this << " for piece " << m_piece.get() << endl; if (m_piece->movementAnimation().lock()) - cout << " *********** BUG **************" << endl; + kDebug() << " *********** BUG **************" << endl; #endif // m_piece->setMovementAnimation(0); } @@ -73,14 +73,14 @@ MovementAnimation::createMovement(const QPoint& from, const QPoint& to) const { void MovementAnimation::start() { #ifdef ANIMATION_DEBUG - cout << "starting movement animation " << this + kDebug() << "starting movement animation " << this << " on piece " << m_piece.get() << endl; #endif { if (shared_ptr animation = m_source->movementAnimation().lock()) { #ifdef ANIMATION_DEBUG - cout << "aborting movement animation " << animation + kDebug() << "aborting movement animation " << animation << " on piece " << m_source.get() << endl; #endif animation->abort(); @@ -119,7 +119,7 @@ Animation::State MovementAnimation::animationAdvance(int msec) { Q_ASSERT(t >= 0); #ifdef ANIMATION_DEBUG - cout << "active: t = " << t << endl; + kDebug() << "active: t = " << t << endl; #endif if (t >= 1) @@ -135,14 +135,14 @@ Animation::State MovementAnimation::animationAdvance(int msec) { } #ifdef ANIMATION_DEBUG - cout << "advance (" << this << ") state = " << m_state << endl; + kDebug() << "advance (" << this << ") state = " << m_state << endl; #endif return m_state; } void MovementAnimation::stop() { #ifdef ANIMATION_DEBUG - cout << "stopping animation " << this + kDebug() << "stopping animation " << this << " on piece " << m_piece.get() << endl; #endif m_piece->moveTo(m_destination); @@ -153,7 +153,7 @@ void MovementAnimation::stop() { void MovementAnimation::abort() { #ifdef ANIMATION_DEBUG - cout << "aborting animation " << this + kDebug() << "aborting animation " << this << " on piece " << m_piece.get() << endl; #endif m_state = Aborted; diff --git a/src/board.cpp b/src/board.cpp index 3853767..1ee0afd 100644 --- a/src/board.cpp +++ b/src/board.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include "mastersettings.h" #include "board.h" @@ -111,7 +112,7 @@ void Board::updateBackground() { } } else - ERROR("Board::updateBackground(): unexpected type in boost::variant!"); + kError() << "Board::updateBackground(): unexpected type in boost::variant!"; } void Board::enqueue(const shared_ptr& anim) { @@ -257,7 +258,7 @@ void Board::updateBorder() { } } else - ERROR("Board::updateBorder(): unexpected type in boost::variant!"); + kError() << "Board::updateBorder(): unexpected type in boost::variant!"; } void Board::createGrid(Point p, const QStringList& border_coords) { @@ -355,7 +356,7 @@ bool Board::doMove(const NormalUserMove& m) { } } - std::cout << "invalid move" << std::endl; + kDebug() << "invalid move"; error(InvalidMove); return false; @@ -726,7 +727,7 @@ bool Board::dropOn(int pool, int index, const QPoint& point) { break; } - std::cout << "invalid move" << std::endl; + kDebug() << "invalid move"; error(InvalidMove); return false; } diff --git a/src/chesstable.cpp b/src/chesstable.cpp index c7f13aa..b0a0641 100644 --- a/src/chesstable.cpp +++ b/src/chesstable.cpp @@ -8,10 +8,10 @@ (at your option) any later version. */ -#include #include #include #include +#include #include "chesstable.h" #include "game.h" #include "gameinfo.h" @@ -139,12 +139,12 @@ void ChessTable::layout(bool force_reload) { #if 0 for(::LuaApi::LuaValueMap::iterator it = lvals.begin(); it != lvals.end(); ++it) if(double* val = boost::get(&it.value())) - std::cout << "lvals[" << it.key() << "] = " << *val << std::endl; + kDebug() << "lvals[" << it.key() << "] = " << *val; else if(QPointF* val = boost::get(&it.value())) - std::cout << "lvals[" << it.key() << "] = Point(" << val->x() << "," << val->y() << ")" << std::endl; + kDebug() << "lvals[" << it.key() << "] = Point(" << val->x() << "," << val->y() << ")"; else if(QRectF* val = boost::get(&it.value())) - std::cout << "lvals[" << it.key() << "] = Rect(" << val->x() << "," << val->y() - << "," << val->width() << "," << val->height() << ")" << std::endl; + kDebug() << "lvals[" << it.key() << "] = Rect(" << val->x() << "," << val->y() + << "," << val->width() << "," << val->height() << ")"; #endif #define GET_INT(name) \ @@ -153,7 +153,7 @@ void ChessTable::layout(bool force_reload) { if(double* val = (it==lvals.end()) ? 0 : boost::get(&lvals[#name]) ) \ name = (int)*val; \ else \ - ERROR("Hey Jack, please set "<<#name<<" to a number in the layout!");} + kError() << "Theme error:" << #name << "should be set to a number in the layout";} #define GET_POINT(name) \ QPoint name; \ @@ -161,7 +161,7 @@ void ChessTable::layout(bool force_reload) { if(QPointF* val = (it==lvals.end()) ? 0 : boost::get(&lvals[#name]) ) \ name = val->toPoint(); \ else \ - ERROR("Hey Jack, please set "<<#name<<" to a point in the layout!");} + kError() << "Theme error:" << #name << "should be set to a point in the layout";} GET_POINT(board_position); GET_INT(square_size); @@ -183,11 +183,11 @@ void ChessTable::layout(bool force_reload) { m_clocks[x]->resize(clock_size); m_clocks[x]->moveTo(clock0_position.x(), clock0_position.y()); -// std::cout << "moving clock " << x << " to " << clock0_position.y() << std::endl; +// kDebug() << "moving clock " << x << " to " << clock0_position.y(); m_clocks[!x]->resize(clock_size); m_clocks[!x]->moveTo(clock1_position.x(), clock1_position.y()); -// std::cout << "moving clock " << !x << " to " << clock1_position.y() << std::endl; +// kDebug() << "moving clock " << !x << " to " << clock1_position.y(); m_pools[x]->m_flipped = false; m_pools[x]->onResize(pool_piece_size, force_reload); @@ -335,7 +335,7 @@ void ChessTable::run() { } void ChessTable::displayMessage(const QString& msg) { - std::cout << msg << std::endl; + kDebug() << msg; message(msg); } diff --git a/src/common.cpp b/src/common.cpp index 85425e2..1b0333d 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -8,54 +8,14 @@ (at your option) any later version. */ -// throw exception: used by boost - -#include -#include -#include -#include -#include #include "common.h" +#include namespace boost { - +// throw exception: used by boost void throw_exception(std::exception const &) { - std::cout << "[bug] boost exception" << std::endl; -} - -} - -std::ostream &operator <<(std::ostream &os, const QString& s) { - os << s.toAscii().constData(); - return os; + kError() << "[bug] boost exception"; } - -#ifdef Q_CC_GNU - void __attribute__ ((used)) -#else - void -#endif -pstr(const QString& s) { - std::cout << "\"" << s << "\"" << std::endl; -} - -QString qPrintf(const char* fmt, ...) { - va_list ap; - - va_start(ap, fmt); - int l = vsnprintf(NULL, 0, fmt, ap)+1; - va_end(ap); - - char *str = (char*)alloca(l); - //char *str = (char*)malloc(l); - va_start(ap, fmt); - vsnprintf(str, l, fmt, ap); - va_end(ap); - - QString retv(str); - - //free(str); - return retv; } #ifdef Q_CC_GNU diff --git a/src/common.h b/src/common.h index 1357fa4..e68ce42 100644 --- a/src/common.h +++ b/src/common.h @@ -11,9 +11,8 @@ #ifndef COMMON_H #define COMMON_H -#include #include "export.h" - +#include class QString; @@ -21,41 +20,11 @@ enum ErrorCode { InvalidMove }; -struct null_deleter { - void operator()(void const *) const { } -}; - -//class ChessPiece; - -template class Grid; -template class PointerGrid; -//typedef PointerGrid PieceGrid; - - -TAGUA_EXPORT std::ostream &operator <<(std::ostream &os, const QString& s); - -inline const char* wrap_cptr(const char* ptr) { - return ptr ? ptr : "[NULL]"; -} - -QString qPrintf(const char* fmt, ...); - -TAGUA_EXPORT QString prettyTypeName(const char* name); - -inline void TRAP() { -#if defined(Q_CC_GNU) - __asm__ __volatile__("int $3\n\t"); -#endif -} +QString prettyTypeName(const char* name); #ifndef M_PI #define M_PI 3.1415926 #endif -#define DEBUG_MSG(header, msg) (std::cerr << header << msg << "\n" \ - << " in " << __PRETTY_FUNCTION__ << ", line " << __LINE__ << " of " << __FILE__ << std::endl) -#define ERROR(x) DEBUG_MSG("Error: ", x) -#define WARNING(x) DEBUG_MSG("Warning: ", x) - #endif // COMMON_H diff --git a/src/connection.cpp b/src/connection.cpp index 0dec27c..54313bd 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -9,17 +9,13 @@ */ #include "connection.h" - -#include - #include #include #include #include #include - +#include #include - #include "common.h" #include "settings.h" @@ -119,7 +115,7 @@ void Connection::lookedUp(const QHostInfo &hi) { void Connection::processLine() { if(!m_device) { - ERROR("No m_device"); + kError() << "No device"; return; } @@ -152,7 +148,7 @@ void Connection::sendText(const QString& text) { } if(!m_device) { - ERROR("No m_device"); + kDebug() << "No device"; return; } diff --git a/src/console.cpp b/src/console.cpp index 32d1e46..51f7fce 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -20,10 +20,10 @@ #include #include -#include #include -#include -#include +#include +#include +#include #include "common.h" #include "foreach.h" @@ -72,12 +72,12 @@ LuaConsoleHighlighter::LuaConsoleHighlighter() KStandardDirs* dirs = KGlobal::dirs(); QString luaHighlightingLibrary = dirs->locate("appdata", "scripts/hllib.lua"); - std::cout << "lua lib: " << luaHighlightingLibrary << std::endl; + kDebug() << "lua lib: " << luaHighlightingLibrary; m_api.runFile(qPrintable(luaHighlightingLibrary)); QStringList highlighting = dirs->findAllResources("appdata", "highlighting/*.lua", KStandardDirs::Recursive); foreach (QString f, highlighting) { - std::cout << "lua highlighting file: " << f << std::endl; + kDebug() << "lua highlighting file: " << f; m_api.runFile(qPrintable(f)); } } @@ -156,22 +156,22 @@ void ConsoleHighlighter::operator()(const QString& text, ConsoleOutput& output) if (best >= 0) { // output the portion of the text before the matching // substring -// std::cout << "outputting plain: " << text.mid(offset, best_offset - offset) << std::endl; -// std::cout << "weight = " << m_display->currentCharFormat().fontWeight() << std::endl; +// kDebug() << "outputting plain: " << text.mid(offset, best_offset - offset); +// kDebug() << "weight = " << m_display->currentCharFormat().fontWeight(); output(text.mid(offset, best_offset - offset)); // change format m_display->setCurrentCharFormat(m_patterns[best].format); // output the matching substring -// std::cout << "outputting formatted: " << text.mid(best_offset, best_length) << std::endl; -// std::cout << "weight = " << m_display->currentCharFormat().fontWeight() << std::endl; +// kDebug() << "outputting formatted: " << text.mid(best_offset, best_length); +// kDebug() << "weight = " << m_display->currentCharFormat().fontWeight(); output(text.mid(best_offset, best_length)); // restore basic format m_display->setCurrentCharFormat(m_basic_format); -// std::cout << "restored" << std::endl; -// std::cout << "weight = " << m_display->currentCharFormat().fontWeight() << std::endl; +// kDebug() << "restored"; +// kDebug() << "weight = " << m_display->currentCharFormat().fontWeight(); // update offset offset = best_offset + best_length; @@ -180,9 +180,9 @@ void ConsoleHighlighter::operator()(const QString& text, ConsoleOutput& output) } // output the last portion of the text -// std::cout << "outputting plain: " << text.mid(offset) << std::endl; +// kDebug() << "outputting plain: " << text.mid(offset); output(text.mid(offset)); -// std::cout << "weight = " << m_display->currentCharFormat().fontWeight() << std::endl; +// kDebug() << "weight = " << m_display->currentCharFormat().fontWeight(); } #endif diff --git a/src/controllers/editgame.cpp b/src/controllers/editgame.cpp index 45b4174..cddedcc 100644 --- a/src/controllers/editgame.cpp +++ b/src/controllers/editgame.cpp @@ -9,7 +9,7 @@ */ #include "editgame.h" - +#include #include "graphicalgame.h" #include "graphicalsystem.h" #include "xboardengine.h" @@ -24,7 +24,6 @@ #include "foreach.h" #include "actioncollection.h" #include "ui.h" -#include using namespace boost; @@ -153,7 +152,7 @@ EntityToken EditGameController::addPlayingEngine(int side, const shared_ptr& connection) { @@ -200,7 +199,7 @@ bool EditGameController::addICSPlayer(int side, int game_number, const shared_pt side, game_number, connection, &m_agents)); if (entity->attach()) { - std::cout << "added ICS agent " << entity.get() << std::endl; + kDebug() << "added ICS agent " << entity.get(); m_agents.addAgent(entity); m_players[side] = entity; @@ -212,12 +211,12 @@ bool EditGameController::addICSPlayer(int side, int game_number, const shared_pt m_agents.addAgent(m_clock_agent); } else { - std::cout << "** could not attach ics entity **" << std::endl; + kDebug() << "** could not attach ics entity **"; return false; } } else { - std::cout << "** could not detach entity playing " << side << "**" << std::endl; + kDebug() << "** could not detach entity playing " << side << "**"; return false; } @@ -225,7 +224,7 @@ bool EditGameController::addICSPlayer(int side, int game_number, const shared_pt } bool EditGameController::setExaminationMode(int game_number, const shared_ptr& connection) { - std::cout << "[controller " << this << "] setting examination mode" << std::endl; + kDebug() << "[controller " << this << "] setting examination mode"; if (m_players[0]->canDetach() && m_players[1]->canDetach()) { shared_ptr entity(new ExaminationEntity(m_variant, m_game, @@ -244,10 +243,10 @@ bool EditGameController::setExaminationMode(int game_number, const shared_ptrfen(0, 0) << std::endl; - std::cout << "to" << std::endl; - std::cout << action.m_to->fen(0, 0) << std::endl; + kDebug() << "undo warp from:"; + kDebug() << action.m_from->fen(0, 0); + kDebug() << "to"; + kDebug() << action.m_to->fen(0, 0); m_data.m_graphical->warp(AbstractMove::Ptr(), action.m_from); } }; @@ -319,9 +319,9 @@ bool EditPositionController::clearBoard() { bool EditPositionController::setStartingPosition() { AbstractPosition::Ptr startingPosition = m_variant->createPosition(); startingPosition->setup(); - std::cout << "adding warp to undo history:" << std::endl; - std::cout << m_graphical->position()->fen(0, 0) << std::endl; - std::cout << startingPosition->fen(0, 0) << std::endl; + kDebug() << "adding warp to undo history:"; + kDebug() << m_graphical->position()->fen(0, 0); + kDebug() << startingPosition->fen(0, 0); m_undo_history.add(WarpAction(m_graphical->position()->clone(), startingPosition)); m_graphical->warp(AbstractMove::Ptr(), startingPosition); return true; @@ -334,13 +334,13 @@ QString EditPositionController::fen() { bool EditPositionController::setFEN(const QString& fen) { AbstractPosition::Ptr pos = m_variant->createPositionFromFEN(fen); if (pos) { - std::cout << "warping to fen " << fen << std::endl; + kDebug() << "warping to fen " << fen; m_undo_history.add(WarpAction(m_graphical->position()->clone(), pos)); m_graphical->warp(AbstractMove::Ptr(), pos); return true; } else { - std::cout << "invalid fen" << std::endl; + kDebug() << "invalid fen"; return false; } } diff --git a/src/engine.cpp b/src/engine.cpp index 26096b2..59bdad5 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -14,8 +14,7 @@ #define ENGINE_DEBUG #ifdef ENGINE_DEBUG - #include - #include "common.h" + #include #endif using namespace boost; @@ -59,10 +58,10 @@ void Engine::sendCommand(const QString& command, bool echo) { os << command << "\n"; #ifdef ENGINE_DEBUG if (m_side == -1) - std::cout << "?"; + kDebug() << "?"; else - std::cout << m_side; - std::cout << "> " << command << std::endl; + kDebug() << m_side; + kDebug() << "> " << command; #endif } else { @@ -77,10 +76,10 @@ void Engine::processInput() { line.remove("\n").remove("\r"); #ifdef ENGINE_DEBUG if (m_side == -1) - std::cout << "?"; + kDebug() << "?"; else - std::cout << m_side; - std::cout << "< " << line << std::endl; + kDebug() << m_side; + kDebug() << "< " << line; #endif if (m_console) m_console->displayText(line + "\n", 0); diff --git a/src/engineinfo.cpp b/src/engineinfo.cpp index 49281c5..a7aefee 100644 --- a/src/engineinfo.cpp +++ b/src/engineinfo.cpp @@ -12,7 +12,7 @@ #include "xboardengine.h" #include "gnushogiengine.h" #include "ui.h" -#include +#include using namespace boost; @@ -70,7 +70,7 @@ shared_ptr EngineInfo::engine(int player) { else if (m_details.type == EngineDetails::GNUShogi) res = shared_ptr(new GNUShogiEngine(m_details.path, QStringList())); else { - ERROR("Unimplemented engine type " << EngineDetails::typeName(m_details.type)); + kError() << "Unimplemented engine type" << EngineDetails::typeName(m_details.type); return shared_ptr(); } diff --git a/src/entities/engineentity.cpp b/src/entities/engineentity.cpp index f468a00..83db000 100644 --- a/src/entities/engineentity.cpp +++ b/src/entities/engineentity.cpp @@ -9,10 +9,10 @@ */ #include "engineentity.h" +#include #include "game.h" #include "engine.h" -#include #include using namespace boost; @@ -38,7 +38,7 @@ void EngineEntity::setup() { Index index = m_game->index(); while (index != 0) { m_indexes.push(index); - std::cout << "pushed index " << index << std::endl; + kDebug() << "pushed index " << index; index = index.prev(); } @@ -46,14 +46,14 @@ void EngineEntity::setup() { // in the current variation while (!m_indexes.empty()) { PositionPtr pos = m_game->position(index); - std::cout << "REF:" << std::endl; + kDebug() << "REF:"; pos->dump(); index = m_indexes.top(); m_indexes.pop(); MovePtr move = m_game->move(index); - std::cout << "move = " << move->toString("simple", pos) << std::endl; + kDebug() << "move = " << move->toString("simple", pos); m_engine->sendMove(move, pos); } @@ -74,7 +74,7 @@ void EngineEntity::notifyEngineMove(const QString& move_str) { m_dispatcher.move(m_game->index()); } else - ERROR("Engine attempted to execute an invalid move: " << move_str); + kError() << "Engine attempted to execute an invalid move:" << move_str; } void EngineEntity::checkPlaying() { @@ -97,7 +97,7 @@ void EngineEntity::notifyMove(const Index& index) { } else { // TODO: handle move notification in arbitrary indexes - WARNING("engine entity can't handle index " << index << " (m_last_index = " << m_last_index << ")"); + kWarning() << "engine entity can't handle index" << index << "(m_last_index =" << m_last_index << ")"; } } diff --git a/src/entities/icsentity.cpp b/src/entities/icsentity.cpp index b48d103..4a8582a 100644 --- a/src/entities/icsentity.cpp +++ b/src/entities/icsentity.cpp @@ -9,16 +9,15 @@ */ #include "icsentity.h" +#include #include "game.h" #include "icsconnection.h" #include "positioninfo.h" #include "poolinfo.h" #include "icsapi.h" -#include using namespace boost; - class ICSTurnPolicy : public TurnPolicy::Abstract { const ICSEntity* m_entity; public: @@ -82,10 +81,10 @@ void ICSEntity::updateGame(const Index& index, AbstractMove::Ptr icsMove, icsPos->copyPoolFrom(position); if (!position->equals(icsPos)) - std::cout << "[inconsistency] computed position differs from expected!" << std::endl; + kDebug() << "[inconsistency] computed position differs from expected!"; } else - std::cout << "[inconsistency] invalid move from server!" << std::endl; + kDebug() << "[inconsistency] invalid move from server!"; } } @@ -126,9 +125,9 @@ void ICSEntity::notifyStyle12(const PositionInfo& style12, bool is_starting) { if (position) { AbstractMove::Ptr mv = position->getMove(style12.lastMoveSAN); if (!mv || !mv->equals(last_move)) { - std::cout << + kDebug() << "[server inconsistency] SAN for last move is different from verbose notation" - << std::endl; + ; } } } @@ -157,8 +156,8 @@ void ICSEntity::notifyMoveList(int num, AbstractPosition::Ptr pos, const PGN& pg if (m_game_number != num) return; if(pos->variant() != m_variant->name()) { - std::cout << "Mismatch for move list, this variant is \"" << m_variant->name() << "\",\n" - " got move list for \"" << pos->variant() << "\"" << std::endl; + kDebug() << "Mismatch for move list, this variant is \"" << m_variant->name() << "\",\n" + " got move list for \"" << pos->variant() << "\""; return; } @@ -180,7 +179,7 @@ bool ICSEntity::canDetach() const { bool ICSEntity::attach() { // an ICS player can attach only if no move for that side has been made - //std::cout << "[ICS attach] index = " << m_game->lastMainlineIndex() << std::endl; + //kDebug() << "[ICS attach] index = " << m_game->lastMainlineIndex(); if (m_game->lastMainlineIndex() == 0) return true; if (m_game->lastMainlineIndex() == 1 && m_side == 1) { // white already played, inform black diff --git a/src/game.cpp b/src/game.cpp index 946fe4b..e70fb38 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -8,8 +8,8 @@ (at your option) any later version. */ -#include #include +#include #ifdef Q_CC_MSVC #pragma warning( push ) #pragma warning( disable : 4100 ) @@ -108,7 +108,7 @@ void Game::testMove(const Index& ix) { return; if (!e1->position->testMove(e2->move)) - ERROR("invalid move added to game history!"); + kError() << "invalid move added to game history"; } } @@ -150,7 +150,7 @@ MovePtr Game::move() const { MovePtr Game::move(const Index& index) const { Entry *e = (Entry*)fetch(index); if(!e) { - ERROR("Index out of range!"); + kError() << "Index out of range"; return MovePtr(); } return e->move; @@ -163,7 +163,7 @@ PositionPtr Game::position() const { PositionPtr Game::position(const Index& index) const { Entry *e = (Entry*)fetch(index); if(!e) { - ERROR("Index " << index << " out of range!"); + kError() << "Index" << index << "out of range"; return PositionPtr(); } return e->position; @@ -176,7 +176,7 @@ QString Game::comment() const { QString Game::comment(const Index& index) const { const Entry *e = fetch(index); if(!e) { - ERROR("Index out of range!"); + kError() << "Index out of range"; return QString(); } return e->comment; @@ -195,7 +195,7 @@ void Game::reset(PositionPtr pos) { void Game::undo() { if(undo_pos <= 0) { - ERROR("Cannot undo at the beginning of the undo history!"); + kError() << "Nothing to undo"; return; } @@ -317,7 +317,7 @@ void Game::undo() { } } else - ERROR("Game::undo(): unexpected type in boost::variant!"); + kError() << "Unexpected type in boost::variant"; if(last_undo) onAvailableUndo(false); @@ -327,7 +327,7 @@ void Game::undo() { void Game::redo() { if(undo_pos >= (int)undo_history.size()) { - ERROR("Cannot redo at the end of the undo history!"); + kError() << "Nothing to redo"; return; } @@ -361,6 +361,8 @@ void Game::redo() { } onAdded(a->index); + current = a->index; + onCurrentIndexChanged(); } else if(boost::get(op)) { UndoPromote *p = boost::get(op); @@ -442,7 +444,7 @@ void Game::redo() { } } else - ERROR("Game::redo(): unexpected type in boost::variant!"); + kError() << "Unexpected type in boost::variant"; if(now_undo) onAvailableUndo(true); @@ -457,7 +459,7 @@ void Game::setComment(const QString& c) { void Game::setComment(const Index& ix, const QString& c) { Entry* e = fetch(ix); if(!e) { - ERROR("Invalid index!"); + kError() << "Invalid index"; return; } if(e->comment == c) @@ -471,7 +473,7 @@ void Game::setComment(const Index& ix, const QString& c) { void Game::setVComment(const Index& ix, int v, const QString& c) { Entry* e = fetch(ix); if(!e) { - ERROR("Invalid index!"); + kError() << "Invalid index"; return; } QString oc = e->vcomments.count(v) ? e->vcomments[v] : QString(); @@ -492,7 +494,7 @@ void Game::promoteVariation() { void Game::promoteVariation(const Index& _ix) { if(_ix.nested.size()==0) { - ERROR("Cannot promote main line!"); + kError() << "Cannot promote main line"; return; } Index ix = _ix; @@ -530,7 +532,7 @@ void Game::removeVariation(int v) { void Game::removeVariation(const Index& _ix) { if(_ix.nested.size()==0) { - ERROR("Cannot remove main line!"); + kError() << "Cannot remove main line"; return; } Index ix = _ix; @@ -583,7 +585,7 @@ void Game::truncate(const Index& ix) { int at; History* vec = fetchRef(ix, &at); if(!vec) { - ERROR("Truncating at an unexisting index!"); + kError() << "Truncating at an unexisting index"; return; } @@ -676,7 +678,7 @@ bool Game::insert(MovePtr m, PositionPtr pos, const Index& at) { return true; } else { - ERROR("Index out if range!"); + kError() << "Index out if range"; return false; } } @@ -811,7 +813,7 @@ void Game::load(const PGN& pgn) { vi = Variants::instance().get("chess"); } else if (!(vi = Variants::instance().get(var->second))) { - ERROR("No such variant " << var->second); + kError() << "No such variant" << var->second; return; } @@ -824,7 +826,7 @@ void Game::load(const PGN& pgn) { //} #if 0 // BROKEN else if( !(pos = vi->createPositionFromFEN(fen->second))) { - ERROR("Wrong fen " << fen->second); + kError() << "Wrong fen " << fen->second; return; } #endif @@ -887,7 +889,7 @@ void Game::load(PositionPtr pos, const PGN& pgn) { } else if(boost::get(pgn[i])) { if(var_stack.size() == 0) { - ERROR("Unexpected end variation!"); + kError() << "Unexpected end variation"; break; } current = var_stack.back(); @@ -901,15 +903,15 @@ void Game::load(PositionPtr pos, const PGN& pgn) { if(!pm->m_number) // not all moves get numbered in PGN, usually only 1st player ones current = current.prev(); else if(pm->m_number>n+1) - ERROR("Too far variation!"); + kError() << "Too far variation"; else { if(pm->m_numberm_number); } } else if(pm->m_number && pm->m_number!=n+1) - ERROR("Move number mismatch!"); + kError() << "Move number mismatch"; PositionPtr pos = position(); MovePtr m = pos->getMove(pm->m_move); @@ -951,7 +953,7 @@ void Game::load(PositionPtr pos, const PGN& pgn) { var_start = false; } else - ERROR("Game::load: unexpected type in boost::variant!"); + kError() << "Unexpected type in boost::variant"; } if(history.size()>1) diff --git a/src/gnushogiengine.cpp b/src/gnushogiengine.cpp index 2bc1282..1483195 100644 --- a/src/gnushogiengine.cpp +++ b/src/gnushogiengine.cpp @@ -12,8 +12,7 @@ #include #include -#include - +#include #include "enginenotifier.h" #include "foreach.h" @@ -48,7 +47,7 @@ GNUShogiEngine::GNUShogiEngine(const QString& path, const QStringList& arguments } GNUShogiEngine::~GNUShogiEngine() { - std::cout << "[debug] destroying engine" << std::endl; + kDebug() << "[debug] destroying engine"; stop(); m_engine.kill(); } diff --git a/src/graphicalgame.cpp b/src/graphicalgame.cpp index fe76aed..22e4c75 100644 --- a/src/graphicalgame.cpp +++ b/src/graphicalgame.cpp @@ -8,8 +8,10 @@ (at your option) any later version. */ -#include #include "graphicalgame.h" + +#include + #include "game.h" #include "game_p.h" #include "mastersettings.h" @@ -17,7 +19,6 @@ #include "movelist_table.h" #include "decoratedmove.h" #include "entities/userentity.h" -#include using namespace GamePrivate; // is this ok? @@ -91,7 +92,7 @@ void GraphicalGame::onAddedInternal(const Index& ix, bool confirm_promotion) { int at; History *vec = fetchRef(ix, &at); if(!vec) { - ERROR("invalid index " << ix); + kError() << "invalid index " << ix; return; } diff --git a/src/hline.cpp b/src/hline.cpp index 602411d..94565ea 100644 --- a/src/hline.cpp +++ b/src/hline.cpp @@ -9,18 +9,16 @@ */ #include "hline.h" - -#include "common.h" -#include +#include class TrivialExecutor : public HLineExecutor { public: virtual ~TrivialExecutor() { - std::cout << std::endl; + kDebug(); } virtual void writeChunk(const QString& text) { - std::cout << text << "|"; + kDebug() << text << "|"; } virtual void setFormat(const QTextCharFormat&) { } diff --git a/src/hlvariant/animator.h b/src/hlvariant/animator.h index f5d2635..218e0dc 100644 --- a/src/hlvariant/animator.h +++ b/src/hlvariant/animator.h @@ -12,6 +12,7 @@ #define HLVARIANT__ANIMATOR_H #include "animation.h" +#include #include "fwd.h" #include "variantdata.h" #include "namedsprite.h" @@ -149,7 +150,7 @@ AnimationGroupPtr SimpleAnimator::forward(const GameState& final, const if (piece) res.addPreAnimation(*movement(piece, move.from(), move.to())); else - ERROR("Bug!!!"); + kError() << "Scheduling movement animation for a null piece"; if (captured) res.addPostAnimation(Animate::destroy(captured)); @@ -165,7 +166,7 @@ AnimationGroupPtr SimpleAnimator::forward(const GameState& final, const res.addPostAnimation(Animate::morph(old_sprite, new_sprite)); } else - ERROR("Bug!!!"); + kError() << "Scheduling morph animation for a null piece"; } else if (move.kingSideCastling()) { Point rookSquare = move.to() + Point(1,0); diff --git a/src/hlvariant/chess/san.cpp b/src/hlvariant/chess/san.cpp index 767713e..13e3c03 100644 --- a/src/hlvariant/chess/san.cpp +++ b/src/hlvariant/chess/san.cpp @@ -82,7 +82,7 @@ void SAN::load(const QString& str, int& offset, int ysize) { offset += kingCastlingPattern.matchedLength(); } else { - //std::cout << "error!!!! " << str.mid(offset) << std::endl; + //kDebug() << "error!!!! " << str.mid(offset); to = Point::invalid(); } } @@ -92,13 +92,14 @@ void SAN::load(const QString& str, int ysize) { load(str, offset, ysize); } -std::ostream& operator<<(std::ostream& os, const SAN& move) { +QDebug operator<<(QDebug os, const SAN& move) { if (move.castling == SAN::KingSide) - return os << "O-O"; + os << "O-O"; else if (move.castling == SAN::QueenSide) - return os << "O-O-O"; + os << "O-O-O"; else - return os << move.type << ": " << move.from << " -> " << move.to; + os << move.type << ": " << move.from << " -> " << move.to; + return os; } diff --git a/src/hlvariant/chess/san.h b/src/hlvariant/chess/san.h index 6951da5..0ded863 100644 --- a/src/hlvariant/chess/san.h +++ b/src/hlvariant/chess/san.h @@ -14,7 +14,7 @@ #include #include - +#include #include "export.h" #include "point.h" @@ -22,7 +22,7 @@ namespace HLVariant { namespace Chess { class TAGUA_EXPORT SAN { - friend std::ostream& operator<<(std::ostream& os, const SAN& move); + friend QDebug operator<<(QDebug os, const SAN& move); static QRegExp pattern; static QRegExp kingCastlingPattern; diff --git a/src/hlvariant/shogi/legalitycheck.h b/src/hlvariant/shogi/legalitycheck.h index a8cdff9..c42e6e6 100644 --- a/src/hlvariant/shogi/legalitycheck.h +++ b/src/hlvariant/shogi/legalitycheck.h @@ -12,6 +12,7 @@ #define HLVARIANT__SHOGI__LEGALITYCHECK_H #include "interactiontype.h" +#include #include "turnpolicy.h" namespace HLVariant { @@ -173,7 +174,6 @@ bool LegalityCheck::pseudolegal(Move& move) const { return true; } else { - //std::cerr << "CANNOT MOVE: piece type cannot go there" << std::endl; return false; } } @@ -188,7 +188,7 @@ template Piece piece = state.board().get(p); LegalityCheck check(state); if (piece.color() == state.turn() && check.getMoveType(piece, Move(p, point))) { - std::cerr << state.board().get(point).name() << " can be captured" << std::endl; + kDebug() << state.board().get(point).name() << " can be captured"; return true; } } diff --git a/src/hlvariant/shogi/serializer.h b/src/hlvariant/shogi/serializer.h index 9b2c7b5..5d73ca6 100644 --- a/src/hlvariant/shogi/serializer.h +++ b/src/hlvariant/shogi/serializer.h @@ -13,6 +13,7 @@ #include #include +#include namespace HLVariant { namespace Shogi { @@ -244,7 +245,7 @@ Serializer::parse(const QString& str, int& offset, if (check.legal(mv)) { if (candidate.valid()) { // ambiguous! - std::cerr << "ambiguous !" << std::endl; + kDebug() << "ambiguous"; return Move(); } else { @@ -258,13 +259,13 @@ Serializer::parse(const QString& str, int& offset, } if (!candidate.valid()) - std::cerr << "error - piece not found" << std::endl; + kError() << "Piece not found"; offset += pattern.matchedLength(); return candidate; } else { - std::cout << "error!!!! " << qPrintable(str.mid(offset)) << std::endl; + kDebug() << "error!!!! " << qPrintable(str.mid(offset)); return Move(Point::invalid(),Point::invalid()); } } diff --git a/src/hlvariant/tagua_wrapped.h b/src/hlvariant/tagua_wrapped.h index 375eabe..3323d84 100644 --- a/src/hlvariant/tagua_wrapped.h +++ b/src/hlvariant/tagua_wrapped.h @@ -23,10 +23,10 @@ #define __FUNC__ __FUNCTION__ #endif -#define MISMATCH(x,y) (std::cout << " --> Error in "<<__FUNC__<<", MISMATCH!" << std::endl \ - << " got type " << prettyTypeName(typeid(x).name()) << std::endl \ - << " instead of " << prettyTypeName(typeid(y).name()) << std::endl \ - << " this is " << prettyTypeName(typeid(*this).name()) << std::endl) +#define MISMATCH(x,y) (kDebug() << " --> Error in "<<__FUNC__<<", MISMATCH!" \ + << " got type " << prettyTypeName(typeid(x).name()) \ + << " instead of " << prettyTypeName(typeid(y).name()) \ + << " this is " << prettyTypeName(typeid(*this).name()) ) #define DEFINE_VARIANT_FACTORY() \ VariantFactory* createFactory() { \ diff --git a/src/hlvariant/tori-shogi/legalitycheck.h b/src/hlvariant/tori-shogi/legalitycheck.h index 21d62ce..92e5ad2 100644 --- a/src/hlvariant/tori-shogi/legalitycheck.h +++ b/src/hlvariant/tori-shogi/legalitycheck.h @@ -157,7 +157,6 @@ bool LegalityCheck::pseudolegal(Move& move) const { return true; } else { - //std::cerr << "CANNOT MOVE: piece type cannot go there" << std::endl; return false; } } diff --git a/src/icsconnection.cpp b/src/icsconnection.cpp index 7d2f8d1..0db46b2 100644 --- a/src/icsconnection.cpp +++ b/src/icsconnection.cpp @@ -8,11 +8,10 @@ (at your option) any later version. */ -#include +#include "icsconnection.h" #include #include - -#include "icsconnection.h" +#include #include "poolinfo.h" #include "positioninfo.h" #include "player.h" @@ -88,9 +87,9 @@ bool ICSConnection::test(const QRegExp& pattern, const QString& str) { } void ICSConnection::processPartialLine(QString str) { -// std::cout << "processing (partial) " << str << std::endl; +// kDebug() << "processing (partial) " << str; if (test(fics, str)) { -// std::cout << "matched prompt" << std::endl; +// kDebug() << "matched prompt"; prompt(); } else if (test(beep, str)) { @@ -128,10 +127,10 @@ void ICSConnection::process(QString str) { int number = observed_game.cap(1).toInt(); incomingGameInfo->setGameNumber(number); m_games[number] = ICSGameData(-1, incomingGameInfo->type()); - //std::cout << "ok, obs " << number << " of type " << incomingGameInfo->type() << std::endl; + //kDebug() << "ok, obs " << number << " of type " << incomingGameInfo->type(); } else if (test(game, str)) { - //std::cout << "matched game. incomingGameInfo = " << incomingGameInfo << std::endl; + //kDebug() << "matched game. incomingGameInfo = " << incomingGameInfo; if(game.cap(4).startsWith("Creating") || game.cap(4).startsWith("Continuing") ) { if (!incomingGameInfo) { //this should really never happen, but anyway... @@ -150,7 +149,7 @@ void ICSConnection::process(QString str) { else { if (!incomingGameInfo) { int number = game.cap(1).toInt(); - //std::cout << "matching game " << number << " end" << std::endl; + //kDebug() << "matching game " << number << " end"; m_games.erase(number); QString what = game.cap(4); QString result = game.cap(5); @@ -159,7 +158,7 @@ void ICSConnection::process(QString str) { } } else if (test(unexamine, str)) { - //std::cout << "matching examined game end" << std::endl; + //kDebug() << "matching examined game end"; int gameNumber = unexamine.cap(1).toInt(); m_games.erase(gameNumber); endingExaminedGame(gameNumber); @@ -170,7 +169,7 @@ void ICSConnection::process(QString str) { endingObservedGame(gameNumber); } else if (test(move_list_start, str)) { - //std::cout << "entering move list state" << std::endl; + //kDebug() << "entering move list state"; m_move_list_game_num = move_list_start.cap(1).toInt(); state = MoveListHeader; } @@ -198,7 +197,7 @@ void ICSConnection::process(QString str) { // no info on this game if (!incomingGameInfo) { - WARNING("unexpected style 12 for game " << gameNumber); + kWarning() << "unexpected style 12 for game" << gameNumber; incomingGameInfo = new GameInfo(Player(positionInfo.whitePlayer, 0), Player(positionInfo.blackPlayer, 0), "rated", "", 0, 0); @@ -207,16 +206,16 @@ void ICSConnection::process(QString str) { switch (positionInfo.relation) { case PositionInfo::NotMyMove: case PositionInfo::MyMove: - //std::cout << "creating game" << std::endl; + //kDebug() << "creating game"; creatingGame(incomingGameInfo, positionInfo); break; case PositionInfo::Examining: - //std::cout << "creating examination" << std::endl; + //kDebug() << "creating examination"; creatingExaminedGame(incomingGameInfo, positionInfo); break; case PositionInfo::ObservingPlayed: case PositionInfo::ObservingExamined: - //std::cout << "creating obs " << gameNumber << " " << incomingGameInfo->type() << std::endl; + //kDebug() << "creating obs " << gameNumber << " " << incomingGameInfo->type(); creatingObservedGame(incomingGameInfo, positionInfo); break; default: @@ -250,11 +249,11 @@ void ICSConnection::process(QString str) { case MoveListHeader: if (test(move_list_players, str)){ - //std::cout << "move list players: " << str << std::endl; + //kDebug() << "move list players: " << str; m_move_list_players = move_list_players.capturedTexts(); } else if (test(move_list_game, str)){ - //std::cout << "move list game: " << str << std::endl; + //kDebug() << "move list game: " << str; if (m_move_list_game_info) delete m_move_list_game_info; @@ -276,13 +275,13 @@ void ICSConnection::process(QString str) { m_games[m_move_list_game_num].setType(move_list_game.cap(2)); } else if (test(move_list_terminator, str)) { - //std::cout << "move list ign3: " << str << std::endl; + //kDebug() << "move list ign3: " << str; } else if (test(move_list_ignore1, str)){ - //std::cout << "move list ign1: " << str << std::endl; + //kDebug() << "move list ign1: " << str; } else if (test(move_list_ignore2, str)) { - //std::cout << "move list ign2: " << str << std::endl; + //kDebug() << "move list ign2: " << str; state = MoveListMoves; } else { @@ -306,7 +305,7 @@ void ICSConnection::process(QString str) { else { std::map::const_iterator gi = m_games.find(m_move_list_game_num); if (gi == m_games.end()) { - ERROR("BUG: Received move list for unknown game " << m_move_list_game_num); + kError() << "Received move list for unknown game " << m_move_list_game_num; } else { VariantPtr variant = gi->second.variant; @@ -323,7 +322,7 @@ void ICSConnection::process(QString str) { PGN pgn(m_move_list); if (!pgn.valid()) - std::cout << "parse error on move list" << std::endl; + kDebug() << "parse error on move list"; else listener->notifyMoveList(m_move_list_game_num, p, pgn); } diff --git a/src/icsgamedata.cpp b/src/icsgamedata.cpp index 2f5fb09..b735bda 100644 --- a/src/icsgamedata.cpp +++ b/src/icsgamedata.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006-2007 Paolo Capriotti + Copyright (c) 2006-2008 Paolo Capriotti (c) 2006-2007 Maurizio Monge This program is free software; you can redistribute it and/or modify @@ -9,6 +9,7 @@ */ #include "icsgamedata.h" +#include #include "tagua.h" #include "gameinfo.h" #include "variants.h" @@ -26,7 +27,7 @@ ICSGameData::ICSGameData(int index, const QString& type) void ICSGameData::setType(const QString& type) { variant = Variants::instance().get(GameInfo::variantCode(type)); if (!variant) { - ERROR("BUG: No variant corresponding to " << type); + kError() << "No variant corresponding to " << type; } else if (!(icsapi = variant->icsAPI())) { // There's no ICSAPI in this variant. diff --git a/src/index.cpp b/src/index.cpp index d1b2ea9..f4d5a11 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -9,8 +9,8 @@ (at your option) any later version. */ -#include #include +#include #include "index.h" Index::operator QString() const { @@ -124,8 +124,7 @@ Index Index::prev(int _num) const { while(num) { if(retv.nested.size() == 0) { if(retv.num_moves < num) { - ERROR("Cannot rewind index " << *this << - " by " << _num << "!"); + kError() << "Cannot rewind index" << *this << "by" << _num; return Index(-1); } retv.num_moves -= num; diff --git a/src/loader/context.cpp b/src/loader/context.cpp index 2e72d29..0d836e3 100644 --- a/src/loader/context.cpp +++ b/src/loader/context.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006 Paolo Capriotti + Copyright (c) 2006-2008 Paolo Capriotti (c) 2006 Maurizio Monge This program is free software; you can redistribute it and/or modify @@ -8,9 +8,8 @@ (at your option) any later version. */ -#include -#include #include "common.h" +#include #include "loader/context.h" namespace Loader { @@ -39,14 +38,5 @@ Context::~Context() { Q_ASSERT(m_references.empty()); } -void Context::dump() { - for(Cache::iterator c = s_cache.begin(); c != s_cache.end(); ++c) - std::cout << "*"<< std::setiosflags(std::ios::left) - << std::setw(2) << c->second.m_ref_count - << std::setiosflags(std::ios::left) - << std::setw(50) << prettyTypeName(c->first.m_type) - << " \"" << c->first.m_name << "\"" << std::endl; -} - } //end namespace Loader diff --git a/src/loader/context.h b/src/loader/context.h index c1ce00b..9aec748 100644 --- a/src/loader/context.h +++ b/src/loader/context.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2006 Paolo Capriotti + Copyright (c) 2006-2008 Paolo Capriotti (c) 2006 Maurizio Monge This program is free software; you can redistribute it and/or modify @@ -106,11 +106,6 @@ public: s_cache[key] = Resource(data); m_references.insert(key); } - - /** - * For debugging - */ - static void dump(); }; } //end namespace Loader diff --git a/src/loader/image.cpp b/src/loader/image.cpp index a871e67..97bd014 100644 --- a/src/loader/image.cpp +++ b/src/loader/image.cpp @@ -29,7 +29,7 @@ Font::Font(int id, int size) , m_families(QFontDatabase::applicationFontFamilies(id)) , m_font(m_families.empty()?QString():m_families[0], size) { //for(int i=0;iget(k)) font_glyph = *f; else { diff --git a/src/loader/theme.cpp b/src/loader/theme.cpp index 3ead808..0c0b883 100644 --- a/src/loader/theme.cpp +++ b/src/loader/theme.cpp @@ -9,11 +9,11 @@ */ -#include +#include "theme.h" #include +#include #include "common.h" #include "mastersettings.h" -#include "loader/theme.h" namespace Loader { @@ -36,10 +36,9 @@ Theme::Theme(const ThemeInfo& theme) : m_theme(theme) , m_context() , m_lua_loader(&m_context, theme) { - //std::cout << "loading theme " << theme.file_name << std::endl; m_lua_loader.runFile(m_theme.file_name); if(m_lua_loader.error()) - ERROR("Script load error: " << std::endl << m_lua_loader.errorString()); + kError() << "Script load error:" << m_lua_loader.errorString(); settings().onChange(this, "onSettingsChanged"); onSettingsChanged(); @@ -47,7 +46,7 @@ Theme::Theme(const ThemeInfo& theme) Theme::~Theme() { if(!m_cache.empty()) - ERROR("Sizes still referenced."); + kError() << "Sizes still referenced."; } void Theme::onSettingsChanged() { @@ -71,7 +70,7 @@ void Theme::refSize(int size) { void Theme::unrefSize(int size) { Cache::iterator it = m_cache.find(size); if(it == m_cache.end()) { - ERROR("Size " << size << " not referenced."); + kError() << "Size" << size << "not referenced."; return; } @@ -86,14 +85,14 @@ T Theme::getValue(const QString& key, int size, const ::LuaApi::LuaValueMap* arg Cache::iterator it = m_cache.find(size); if(it == m_cache.end()) { - ERROR("Size " << size << " not referenced."); + kError() << "Size" << size << "not referenced."; return T(); } T retv = m_lua_loader.getValue(key, size, args, allow_nil); if(m_lua_loader.error()) { - ERROR("Script run error: " << std::endl << m_lua_loader.errorString()); + kError() << "Script run error:" << m_lua_loader.errorString(); m_lua_loader.clearError(); } @@ -107,7 +106,7 @@ PixmapOrMap Theme::getValue(const QString& key, int size, const ::L Cache::iterator it = m_cache.find(size); if(it == m_cache.end()) { - ERROR("Size " << size << " not referenced."); + kError() << "Size" << size << "not referenced."; return PixmapOrMap(); } @@ -119,7 +118,7 @@ PixmapOrMap Theme::getValue(const QString& key, int size, const ::L PixmapOrMap retv = to_pixmap_map(m_lua_loader.getValue< ::LuaApi::ImageOrMap>(key, size, args, allow_nil)); if(m_lua_loader.error()) { - ERROR("Script run error: " << std::endl << m_lua_loader.errorString()); + kError() << "Script run error:" << m_lua_loader.errorString(); m_lua_loader.clearError(); } @@ -143,7 +142,7 @@ Glyph Theme::getValue(const QString& key, int size, const ::LuaApi::LuaVa Cache::iterator it = m_cache.find(size); if(it == m_cache.end()) { - ERROR("Size " << size << " not referenced."); + kError() << "Size" << size << "not referenced."; return Glyph(); } @@ -156,7 +155,7 @@ Glyph Theme::getValue(const QString& key, int size, const ::LuaApi::LuaVa Glyph retv = m_lua_loader.getValue(key, size, args, allow_nil); if(m_lua_loader.error()) { - ERROR("Script run error: " << std::endl << m_lua_loader.errorString()); + kError() << "Script run error:" << m_lua_loader.errorString(); m_lua_loader.clearError(); } diff --git a/src/luaapi/genericwrapper.h b/src/luaapi/genericwrapper.h index c98b055..5763b8b 100644 --- a/src/luaapi/genericwrapper.h +++ b/src/luaapi/genericwrapper.h @@ -17,8 +17,8 @@ extern "C" { #include #include "lfunclib.h" } -#include #include +#include #include "common.h" namespace Loader { class Context; } @@ -129,9 +129,9 @@ public: ~StackCheck() { if (lua_gettop(l) != top) { - std::cout << "Wrong lua stack size!\n" + kDebug() << "Wrong lua stack size!\n" " expected = " << top << "\n" - " actual = " << lua_gettop(l) << std::endl; + " actual = " << lua_gettop(l); } } }; @@ -217,7 +217,7 @@ public: lua_getfield(l, -2, ".type"); if(lua_isstring(l, -1)) luaL_error(l, "Mismatch, got object of type %s expecting %s", - wrap_cptr(lua_tostring(l,-1)), Wrapper::class_name()); + lua_tostring(l,-1), Wrapper::class_name()); } lua_pop(l,2); luaL_error(l, "Mismatch, got object of unknown type expecting %s", diff --git a/src/luaapi/luahl.cpp b/src/luaapi/luahl.cpp index 5b49248..24fc536 100644 --- a/src/luaapi/luahl.cpp +++ b/src/luaapi/luahl.cpp @@ -212,17 +212,17 @@ void Api::runFile(const char* file) { if(luaL_loadfile(m_state, file) == 0) pcall(0, LUA_MULTRET); else { - std::cout << "LOADFILE FOR " << wrap_cptr(file) << " FAILED" << std::endl; - std::cout << wrap_cptr(lua_tostring(m_state, -1)) << std::endl; + kDebug() << "LOADFILE FOR " << file << " FAILED"; + kDebug() << lua_tostring(m_state, -1); } } else - std::cout << "FILE " << wrap_cptr(file) << " DOES NOT EXIST" << std::endl; + kDebug() << "FILE " << file << " DOES NOT EXIST"; } void Api::pcall(int nArgs, int nResults) { if (lua_pcall(m_state, nArgs, nResults, 0) != 0) { - std::cout << "RUNTIME ERROR: " << wrap_cptr(lua_tostring(m_state, -1)) << std::endl; + kDebug() << "RUNTIME ERROR: " << lua_tostring(m_state, -1); } } @@ -234,7 +234,7 @@ int Api::create_line(lua_State* l) { Wrapper::allocate(l, new HLine(line, QTextCharFormat())); if (lua_pcall(l, 1, 1, 0) != 0) - std::cout << "ERROR INSIDE create_line" << std::endl; + kDebug() << "ERROR INSIDE create_line"; return 1; } @@ -292,8 +292,8 @@ std::pair Api::runEvent(const QString& text, int eventIndex, QRegE lua_getglobal(m_state, "__run_event__"); if (!lua_isfunction(m_state, -1)) { - std::cout << "** ERROR: __run_event__ is corrupted (type = " << - lua_typename(m_state, lua_type(m_state, -1)) << ") **" << std::endl; + kDebug() << "** ERROR: __run_event__ is corrupted (type = " << + lua_typename(m_state, lua_type(m_state, -1)) << ") **"; lua_pop(m_state, 1); return std::pair(false, 0); } @@ -301,7 +301,7 @@ std::pair Api::runEvent(const QString& text, int eventIndex, QRegE // event lua_getglobal(m_state, "__patterns__"); if (!lua_istable(m_state, -1)) { - std::cout << "** ERROR: __patterns__ is corrupted **" << std::endl; + kDebug() << "** ERROR: __patterns__ is corrupted **"; lua_pop(m_state, 2); return std::pair(false, 0); } diff --git a/src/luaapi/luavalue.cpp b/src/luaapi/luavalue.cpp index a75de28..77f6bb4 100644 --- a/src/luaapi/luavalue.cpp +++ b/src/luaapi/luavalue.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2006 Paolo Capriotti + Copyright (c) 2006-2008 Paolo Capriotti (c) 2006 Maurizio Monge This program is free software; you can redistribute it and/or modify @@ -8,8 +8,9 @@ (at your option) any later version. */ -#include "luaapi/luavalue.h" -#include "luaapi/imaging.h" +#include "luavalue.h" +#include +#include "imaging.h" namespace LuaApi { @@ -21,7 +22,7 @@ void lua_pushvalue(lua_State* l, const LuaValue& value) { else if(const QRectF* v = boost::get(&value)) Wrapper::create(l, *v); else - ERROR("Unknown variant type!"); + kError() << "Unknown variant type!"; } void lua_pushvaluemap(lua_State* l, const LuaValueMap* valuemap) { diff --git a/src/luaapi/options.cpp b/src/luaapi/options.cpp index 622ba16..459412b 100644 --- a/src/luaapi/options.cpp +++ b/src/luaapi/options.cpp @@ -9,6 +9,7 @@ */ #include "options.h" +#include #include "luaapi/loader.h" namespace LuaApi { @@ -107,7 +108,7 @@ int Wrapper::constructor(lua_State* l) { lua_pop(l, n); // for(int i=0;i + Copyright (c) 2006-2008 Paolo Capriotti (c) 2006-2007 Maurizio Monge This program is free software; you can redistribute it and/or modify @@ -19,14 +19,15 @@ #include #include -#include #include +#include +#include #include #include -#include #include #include #include +#include #include #include "actioncollection.h" @@ -204,7 +205,7 @@ void MainWindow::updateVariantActions(bool unplug) { plugActionList("variantActions", variant_actions->actions()); } else { - WARNING("No variant actions"); + kWarning() << "No variant actions"; } } @@ -307,7 +308,7 @@ bool MainWindow::newGame(const QString& variantName, AbstractPosition::Ptr start bool newTab) { VariantPtr variant = Variants::instance().get(variantName); if (!variant) { - WARNING("no variant " << variantName << " found"); + kWarning() << "no variant" << variantName << "found"; variant = Variants::instance().get("chess"); } @@ -330,7 +331,7 @@ bool MainWindow::newGame(const QString& variantName, AbstractPosition::Ptr start return true; } else { - ERROR("Could not find the chess variant"); + kError() << "Could not find the chess variant"; exit(1); return false; } @@ -389,7 +390,7 @@ void MainWindow::setupObservedGame(const GameInfo* g, const PositionInfo& style1 board->setPlayers(Player(style12.whitePlayer, -1), Player(style12.blackPlayer, -1)); // ui().setController(controller); - //std::cout << "adding tab" << std::endl; + //kDebug() << "adding tab"; createTab(board.get(), controller, QString("Observing - %1 vs %2").arg(style12.whitePlayer) .arg(style12.blackPlayer)); @@ -401,25 +402,15 @@ void MainWindow::setupPGN(const QString& s) { PGN pgn(s); std::map::const_iterator var = pgn.m_tags.find("Variant"); - VariantPtr variant; - - if (var == pgn.m_tags.end()) { - variant = Variants::instance().get("chess"); - } - else if (!(variant = Variants::instance().get(var->second))) { - std::cout << " --> MainWindow::setupPGN: Error, no such variant " << var->second << std::endl; - return; - } + QString variant; - shared_ptr controller(new EditGameController( - table(), variant)); - ui().setController(controller); - controller->loadPGN(pgn); - -// table()->setPlayers(gameInfo->white(), gameInfo->black()); -// m_main->setTabText(m_main->currentIndex(), -// QString("FICS Game - %1 vs %2").arg(style12.whitePlayer) -// .arg(style12.blackPlayer)); + if (var == pgn.m_tags.end()) + variant = "chess"; + else + variant = var->second; + + newGame(variant, PositionPtr(), false); + ui().pgnPaste(pgn); } bool MainWindow::openFile(const QString& filename) { @@ -616,24 +607,24 @@ void MainWindow::testConnect() { void MainWindow::onEstablishConnection() { -// std::cout << "connection established" << std::endl; +// kDebug() << "connection established"; } void MainWindow::onConnectionError(int ) { -// std::cout << "connection error (" << code << ")" << std::endl; +// kDebug() << "connection error (" << code << ")"; } void MainWindow::onHostLookup() { -// std::cout << "hostLookup..." << std::flush; +// kDebug() << "hostLookup..." << std::flush; } void MainWindow::onHostFound() { -// std::cout << "found" << std::endl; +// kDebug() << "found"; } void MainWindow::sendLogin() { -// std::cout << "sending username" << std::endl; +// kDebug() << "sending username"; // connection->sendText(connection->username()); } diff --git a/src/mastersettings.cpp b/src/mastersettings.cpp index c5dbcbd..0fa34bd 100644 --- a/src/mastersettings.cpp +++ b/src/mastersettings.cpp @@ -11,7 +11,7 @@ #include "mastersettings.h" #include - +#include #include #include "common.h" @@ -22,13 +22,13 @@ QDomElement MasterSettings::node() const { if (m_node.isNull()) { QFile f(m_filename); if (!f.open(QFile::ReadOnly | QFile::Text) || !m_doc.setContent(&f)) { - WARNING("Unable to open configuration file for reading."); + kWarning() << "Unable to open configuration file for reading."; // // create a stub configuration file // { // QFile stub(m_filename); // if (!stub.open(QFile::WriteOnly | QFile::Text)) { -// std::cout << "Unable to write to configuration file." << std::endl; +// kDebug() << "Unable to write to configuration file."; // exit(1); // } // QTextStream stream(&stub); @@ -42,7 +42,7 @@ QDomElement MasterSettings::node() const { // exit(1); m_doc.appendChild(m_doc.createElement("configuration")); -// std::cout << m_doc.toString() << std::endl; +// kDebug() << m_doc.toString(); } @@ -97,10 +97,10 @@ void MasterSettings::onChange(QObject* obj, const char* method, const char* depe if (it2->dependency && strcmp(it2->dependency, this_class) == 0) { // something which is notified before has us a dependency // this means that there is a cyclic dependency it2 -> us -> it. - WARNING("Removing a cyclic dependency: " << - it2->object->metaObject()->className() << " -> " << - this_class << " -> " << - observer_class); + kWarning() << "Removing a cyclic dependency:" << + it2->object->metaObject()->className() << "->" << + this_class << "->" << + observer_class; // remove the cycle it2->dependency = 0; @@ -121,7 +121,7 @@ void MasterSettings::sync() { // store to file QFile f(m_filename); if (!f.open(QFile::WriteOnly | QFile::Text)) - ERROR("Cannot open configuration file for writing"); + kError() << "Cannot open configuration file for writing"; else { QTextStream stream(&f); stream << node().ownerDocument().toString(); diff --git a/src/movelist.cpp b/src/movelist.cpp index 054ed92..5eca3ea 100644 --- a/src/movelist.cpp +++ b/src/movelist.cpp @@ -7,8 +7,6 @@ the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ - -#include #include #include #include @@ -22,14 +20,15 @@ #include #include #include -#include -#include -#include "mastersettings.h" -#include "pref_theme.h" +#include +#include + #include "movelist_widget.h" #include "movelist_table.h" #include "movelist_notifier.h" #include "movelist_p.h" +#include "mastersettings.h" +#include "pref_theme.h" namespace MoveList { @@ -99,8 +98,6 @@ void FancyItem::goTo(QPoint p) { old_pos = pos(); target_pos = p; time_pos = m->layout_time; - /*std::cout << m->layout_time << " start " << this << " " - << prettyTypeName(typeid(*this).name()) << std::endl;*/ setAnimated(true); } } @@ -126,8 +123,6 @@ void FancyItem::setHighlight(bool h) { void FancyItem::advance(int time) { Widget *m = dynamic_cast(topLevelCanvas()); - /*std::cout << time << " anim " << this << " " - << prettyTypeName(typeid(*this).name()) << std::endl;*/ if(time_highlight != -1) { float fact = (time - time_highlight) / m->m_settings->anim_time; if(fact >= 1.0) { @@ -153,21 +148,15 @@ void FancyItem::advance(int time) { if(time_pos != -1) { float fact = (time - time_pos) / m->m_settings->anim_time; if(fact >= 1.0) { - /*std::cout << time << " done " << this << " " - << prettyTypeName(typeid(*this).name()) << std::endl;*/ moveTo(target_pos); time_pos = -1; } else { - /*std::cout << time << " move " << this << " " - << prettyTypeName(typeid(*this).name()) << std::endl;*/ moveTo( int(target_pos.x()*fact + old_pos.x()*(1-fact)+0.5), int(target_pos.y()*fact + old_pos.y()*(1-fact)+0.5)); } } if(canStop()) { - /*std::cout << time << " stop " << this << " " - << prettyTypeName(typeid(*this).name()) << std::endl;*/ setAnimated(false); } } @@ -607,7 +596,7 @@ void Widget::startEditing(const Index& i, int v) { EntryPtr e = fetch(i); if(!e) { - ERROR("Invalid index " << i); + kError() << "Invalid index " << i; return; } @@ -795,7 +784,7 @@ void Widget::doLayout() { layout_time = mSecs(); layout_pending = false; layout_max_width = 0; - //std::cout << "layout_must_relayout = " << layout_must_relayout << std::endl; + //kDebug() << "layout_must_relayout = " << layout_must_relayout; int h = layoutHistory(history, BORDER_LEFT, BORDER_TOP, -1, 0, 0, true); QSize s(std::max(entry_size*7, layout_max_width+BORDER_RIGHT), @@ -1124,7 +1113,7 @@ void Widget::setComment(EntryPtr e, int v, const QString& comment) { void Widget::setComment(const Index& index, const QString& comment) { EntryPtr e = fetch(index); if(!e) { - ERROR("Invalid index " << index); + kError() << "Invalid index" << index; return; } setComment(e, -1, comment); @@ -1133,7 +1122,7 @@ void Widget::setComment(const Index& index, const QString& comment) { void Widget::setVComment(const Index& index, int v, const QString& comment) { EntryPtr e = fetch(index); if(!e || !e->variations.count(v)) { - ERROR("Invalid index " << index); + kError() << "Invalid index" << index; return; } setComment(e, v, comment); @@ -1175,7 +1164,7 @@ void Widget::setMove(const Index& index, int at; History *vec = fetchRef(index.prev(), &at); if(!vec) { - ERROR("Invalid index " << index); + kError() << "Invalid index" << index; return; } @@ -1225,7 +1214,7 @@ void Widget::fixIndices(const Index& ix) { int at; History *vec = fetchRef(ix, &at); if(!vec) { - ERROR("Invalid index " << ix); + kError() << "Invalid index" << ix; return; } Index index = ix; @@ -1244,7 +1233,7 @@ void Widget::promoteVariation(const Index& ix, int v) { int at; History *vec = fetchRef(ix, &at); if(!vec) { - ERROR("Invalid index " << ix); + kError() << "Invalid index" << ix; return; } diff --git a/src/movelist_textual.cpp b/src/movelist_textual.cpp index 7c40c3c..b485769 100644 --- a/src/movelist_textual.cpp +++ b/src/movelist_textual.cpp @@ -43,12 +43,12 @@ Textual::Textual(QWidget *parent) setPluginsEnabled(false); QString fpath = KStandardDirs::locate("appdata", "scripts/movelist_textual.html"); - //std::cout << "HTML file is:"<< fpath < Error in Textual::onURL, what should i do with url \""<< u <<"\"?" << std::endl; + kDebug() << " --> Error in Textual::onURL, what should i do with url \""<< u <<"\"?"; return; } QString p = u.mid(8); Index ix = Index::fromString(p); - std::cout << "Open Link \"" << p << "\" = \"" << ix << "\"" << std::endl; + kDebug() << "Open Link \"" << p << "\" = \"" << ix << "\""; m_notifier->onUserSelectMove(ix); } @@ -93,7 +93,7 @@ void Textual::setComment(const Index& index, const QString& comment) { DOM::HTMLDocument document = htmlDocument(); DOM::Element this_cm = document.getElementById("cm_"+index); if(this_cm.isNull()) { - std::cout << " --> Error in Textual::setComment, invalid index!" << std::endl; + kDebug() << " --> Error in Textual::setComment, invalid index!"; return; } @@ -108,7 +108,7 @@ void Textual::setVComment(const Index& index, int v, const QString& comment) { DOM::HTMLDocument document = htmlDocument(); DOM::Element this_cm = document.getElementById("vk_"+index.next(v)); if(this_cm.isNull()) { - std::cout << " --> Error in Textual::setVComment, invalid index!" << std::endl; + kDebug() << " --> Error in Textual::setVComment, invalid index!"; return; } @@ -178,7 +178,7 @@ void Textual::setMove(const Index& index, int turn, const QString& move, void Textual::setMove(const Index& index, int turn, const DecoratedMove& move, const QString& comment) { - //std::cout << "i= " << index << std::endl; + //kDebug() << "i= " << index; DOM::HTMLDocument document = htmlDocument(); QString istr = (QString)index; @@ -207,7 +207,7 @@ void Textual::setMove(const Index& index, int turn, const DecoratedMove& move, prev_cm = document.getElementById("cm_"+index.prev()); prev_mv = document.getElementById("mv_"+index.prev()); if(prev_cm.isNull() || prev_mv.isNull()) { - std::cout << " --> Error in Textual::setMove, no previous move!" << std::endl; + kDebug() << " --> Error in Textual::setMove, no previous move!"; return; } } @@ -229,7 +229,7 @@ void Textual::setMove(const Index& index, int turn, const DecoratedMove& move, if(!index.nested.size()) { parent = document.body(); if(parent.isNull()) { - std::cout << "QUEEEEEEEEE!!!!!!!" << std::endl; + kDebug() << "QUEEEEEEEEE!!!!!!!"; return; } } @@ -291,7 +291,7 @@ void Textual::setMove(const Index& index, int turn, const DecoratedMove& move, Index pi = index.prev(index.nested.back().num_moves); parent = document.getElementById("vr_"+pi); if(parent.isNull()) { - std::cout << " --> Error in Textual::setMove, no variation?!?!?" << std::endl; + kDebug() << " --> Error in Textual::setMove, no variation?!?!?"; return; } } @@ -329,11 +329,11 @@ void Textual::setMove(const Index& index, int turn, const DecoratedMove& move, ::Loader::Glyph g = m_loader.getValue< ::Loader::Glyph>(move[i].m_string); DOM::Element el = document.createElement("span"); #if 1 - std::cout << "size = " << QString("%1%").arg(g.m_font.pointSize()*100/12) << std::endl; + kDebug() << "size = " << QString("%1%").arg(g.m_font.pointSize()*100/12); el.style().setProperty("font-size", QString("%1%").arg(g.m_font.pointSize()*100/12), "important"); el.style().setProperty("line-height", QString("%1%").arg(g.m_font.pointSize()*100/12), "important"); #endif - std::cout << "familiy = " << g.m_font.family() << std::endl; + kDebug() << "familiy = " << g.m_font.family(); el.style().setProperty("font-weight", "normal", "important"); el.style().setProperty("font-family", g.m_font.family(), "important"); DOM::Text t = document.createTextNode(QString(g.m_char)); diff --git a/src/option.cpp b/src/option.cpp index da66931..6e8e918 100644 --- a/src/option.cpp +++ b/src/option.cpp @@ -8,12 +8,12 @@ (at your option) any later version. */ -#include #include #include #include #include #include +#include #include "settings.h" #include "common.h" #include "option.h" @@ -59,11 +59,11 @@ void OptionWidget::setupOptionWidget(QWidget* widget, OptList& options, bool ind if(BoolOptPtr o = boost::dynamic_pointer_cast(_o)) { OptCheckBox *cb = new OptCheckBox(o, this, widget); - cb->setObjectName(qPrintf("%02d_check",i)); + cb->setObjectName(QString("%02d_check").arg(i)); layout->addWidget(cb, lpos++, left, 1, 2); if(o->m_sub_options.size()) { QWidget *w = new QWidget(widget); - w->setObjectName(qPrintf("%02d_check_sub",i)); + w->setObjectName(QString("%02d_check_sub").arg(i)); setupOptionWidget(w, o->m_sub_options, true); w->setEnabled(o->value()); QObject::connect(cb, SIGNAL(toggled(bool)), w, SLOT(setEnabled(bool))); @@ -73,17 +73,17 @@ void OptionWidget::setupOptionWidget(QWidget* widget, OptList& options, bool ind else if(SelectOptPtr o = boost::dynamic_pointer_cast(_o)) { QGroupBox *gb = new QGroupBox(o->label(), widget); - gb->setObjectName(qPrintf("%02d_group",i)); + gb->setObjectName(QString("%02d_group").arg(i)); QVBoxLayout *vbox = new QVBoxLayout(gb); //vbox->setMargin(0); for(int j=0;jm_options.size();j++) { BoolOptPtr so = o->m_options[j]; OptRadioButton *rb = new OptRadioButton(o, j, this, gb); - rb->setObjectName(qPrintf("%02d_radio_%02d",i,j)); + rb->setObjectName(QString("%02d_radio_%02d").arg(i).arg(j)); vbox->addWidget(rb); if(so->m_sub_options.size()) { QWidget *w = new QWidget(widget); - w->setObjectName(qPrintf("%02d_radio_%02d_sub",i,j)); + w->setObjectName(QString("%02d_radio_%02d_sub").arg(i).arg(j)); setupOptionWidget(w, so->m_sub_options, true); w->setEnabled(so->value()); QObject::connect(rb, SIGNAL(toggled(bool)), w, SLOT(setEnabled(bool))); @@ -99,14 +99,14 @@ void OptionWidget::setupOptionWidget(QWidget* widget, OptList& options, bool ind case IntOpt::SpinBox: { OptSpinBox *sb = new OptSpinBox(o, this, widget); - sb->setObjectName(qPrintf("%02d_spin",i)); + sb->setObjectName(QString("%02d_spin").arg(i)); layout->addWidget(sb, lpos++, right); break; } case IntOpt::Slider: { OptSlider *sl = new OptSlider(o, this, widget); - sl->setObjectName(qPrintf("%02d_slid",i)); + sl->setObjectName(QString("%02d_slid").arg(i)); layout->addWidget(sl, lpos++, right); break; } @@ -116,39 +116,39 @@ void OptionWidget::setupOptionWidget(QWidget* widget, OptList& options, bool ind boost::dynamic_pointer_cast(_o)) { layout->addWidget(new QLabel(o->label()), lpos, left); OptLineEdit *ow = new OptLineEdit(o, this, widget); - ow->setObjectName(qPrintf("%02d_line",i)); + ow->setObjectName(QString("%02d_line").arg(i)); layout->addWidget(ow, lpos++, right); } else if(UrlOptPtr o = boost::dynamic_pointer_cast(_o)) { layout->addWidget(new QLabel(o->label()), lpos, left); OptUrlRequester *ow = new OptUrlRequester(o, this, widget); - ow->setObjectName(qPrintf("%02d_url",i)); + ow->setObjectName(QString("%02d_url").arg(i)); layout->addWidget(ow, lpos++, right); } else if(ComboOptPtr o = boost::dynamic_pointer_cast(_o)) { layout->addWidget(new QLabel(o->label()), lpos, left); OptComboBox *ow = new OptComboBox(o, this, widget); - ow->setObjectName(qPrintf("%02d_combo",i)); + ow->setObjectName(QString("%02d_combo").arg(i)); layout->addWidget(ow, lpos++, right); } else if(ColorOptPtr o = boost::dynamic_pointer_cast(_o)) { layout->addWidget(new QLabel(o->label()), lpos, left); OptColorButton *ow = new OptColorButton(o, this, widget); - ow->setObjectName(qPrintf("%02d_color",i)); + ow->setObjectName(QString("%02d_color").arg(i)); layout->addWidget(ow, lpos++, right); } else if(FontOptPtr o = boost::dynamic_pointer_cast(_o)) { layout->addWidget(new QLabel(o->label()), lpos, left); OptFontRequester *ow = new OptFontRequester(o,this, widget); - ow->setObjectName(qPrintf("%02d_font",i)); + ow->setObjectName(QString("%02d_font").arg(i)); layout->addWidget(ow, lpos++, right); } else - ERROR("Unknown option of type " << prettyTypeName(typeid(*_o).name())); + kError() << "Unknown option of type" << prettyTypeName(typeid(*_o).name()); } if(indent) @@ -161,29 +161,29 @@ void OptionWidget::setOptionWidgetValues(QWidget* widget, OptList& newopts) { OptPtr _o = newopts[i]; if(BoolOptPtr o = boost::dynamic_pointer_cast(_o)) { - OptCheckBox *cb = widget->findChild(qPrintf("%02d_check",i)); + OptCheckBox *cb = widget->findChild(QString("%02d_check").arg(i)); if(!cb) goto fail; cb->setChecked(o->value()); if(o->m_sub_options.size()) { - QWidget *w = widget->findChild(qPrintf("%02d_check_sub",i)); + QWidget *w = widget->findChild(QString("%02d_check_sub").arg(i)); if(!w) goto fail; setOptionWidgetValues(w, o->m_sub_options); } } else if(SelectOptPtr o = boost::dynamic_pointer_cast(_o)) { - QGroupBox *gb = widget->findChild(qPrintf("%02d_group",i)); + QGroupBox *gb = widget->findChild(QString("%02d_group").arg(i)); if(!gb) goto fail; for(int j=0;jm_options.size();j++) { BoolOptPtr so = o->m_options[j]; - OptRadioButton *rb = gb->findChild(qPrintf("%02d_radio_%02d",i,j)); + OptRadioButton *rb = gb->findChild(QString("%02d_radio_%02d").arg(i).arg(j)); if(!rb) goto fail; rb->setChecked(so->value()); if(so->m_sub_options.size()) { - QWidget *w = widget->findChild(qPrintf("%02d_radio_%02d_sub",i,j)); + QWidget *w = widget->findChild(QString("%02d_radio_%02d_sub").arg(i).arg(j)); if(!w) goto fail; setOptionWidgetValues(w, so->m_sub_options); } @@ -194,14 +194,14 @@ void OptionWidget::setOptionWidgetValues(QWidget* widget, OptList& newopts) { switch (o->visualization()) { case IntOpt::SpinBox: { - OptSpinBox *sb = widget->findChild(qPrintf("%02d_spin",i)); + OptSpinBox *sb = widget->findChild(QString("%02d_spin").arg(i)); if(!sb) goto fail; sb->setValue(o->value()); break; } case IntOpt::Slider: { - OptSlider *sl = widget->findChild(qPrintf("%02d_slid",i)); + OptSlider *sl = widget->findChild(QString("%02d_slid").arg(i)); if(!sl) goto fail; sl->setValue(o->value()); break; @@ -210,107 +210,107 @@ void OptionWidget::setOptionWidgetValues(QWidget* widget, OptList& newopts) { } else if(StringOptPtr o = boost::dynamic_pointer_cast(_o)) { - OptLineEdit *ow = widget->findChild(qPrintf("%02d_line",i)); + OptLineEdit *ow = widget->findChild(QString("%02d_line").arg(i)); if(!ow) goto fail; ow->setText(o->value()); } else if(UrlOptPtr o = boost::dynamic_pointer_cast(_o)) { - OptUrlRequester *ow = widget->findChild(qPrintf("%02d_url",i)); + OptUrlRequester *ow = widget->findChild(QString("%02d_url").arg(i)); if(!ow) goto fail; ow->setUrl(o->value()); } else if(ComboOptPtr o = boost::dynamic_pointer_cast(_o)) { - OptComboBox *ow = widget->findChild(qPrintf("%02d_combo",i)); + OptComboBox *ow = widget->findChild(QString("%02d_combo").arg(i)); if(!ow) goto fail; ow->setCurrentIndex(o->selected()); } else if(ColorOptPtr o = boost::dynamic_pointer_cast(_o)) { - OptColorButton *ow = widget->findChild(qPrintf("%02d_color",i)); + OptColorButton *ow = widget->findChild(QString("%02d_color").arg(i)); if(!ow) goto fail; ow->setColor(o->value()); } else if(FontOptPtr o = boost::dynamic_pointer_cast(_o)) { - OptFontRequester *ow = widget->findChild(qPrintf("%02d_font",i)); + OptFontRequester *ow = widget->findChild(QString("%02d_font").arg(i)); if(!ow) goto fail; ow->setFont(o->value()); } else - ERROR("Unknown option of type " << prettyTypeName(typeid(*_o).name())); + kError() << "Unknown option of type" << prettyTypeName(typeid(*_o).name()); } return; fail: - ERROR("Options/Widget mismatch!"); + kError() << "Options/Widget mismatch!"; } void dump_options_list(const OptList& options, int indent) { - if(!indent)std::cout << "---- begin dump ----" << std::endl; + if(!indent)kDebug() << "---- begin dump ----"; for(int i=0;i(_o)) { - for(int j=0;jvalue()?"[X]":"[ ]") << " " << o->label() << std::endl; + for(int j=0;jvalue()?"[X]":"[ ]") << " " << o->label(); dump_options_list(o->subOptions(), indent+1); } else if(IntOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << " |" << o->value() << "|" << std::endl; + for(int j=0;jlabel() << " |" << o->value() << "|"; } else if(StringOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << " [" << o->value() << "]" << std::endl; + for(int j=0;jlabel() << " [" << o->value() << "]"; } else if(UrlOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << " {" << o->value() << "}" << std::endl; + for(int j=0;jlabel() << " {" << o->value() << "}"; } else if(ColorOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << " {" << o->value().name() << "}" << std::endl; + for(int j=0;jlabel() << " {" << o->value().name() << "}"; } else if(FontOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << " {" << o->value().toString() << "}" << std::endl; + for(int j=0;jlabel() << " {" << o->value().toString() << "}"; } else if(ComboOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << std::endl; + for(int j=0;jlabel(); for(int k=0;kvalues().size();k++) { - for(int j=0;jselected()) - std::cout << " *<" << o->values()[k] << ">*" << std::endl; + kDebug() << " *<" << o->values()[k] << ">*"; else - std::cout << " <" << o->values()[k] << ">" << std::endl; + kDebug() << " <" << o->values()[k] << ">"; } } else if(SelectOptPtr o = boost::dynamic_pointer_cast(_o)) { - for(int j=0;jlabel() << std::endl; + for(int j=0;jlabel(); for(int j=0;joptions().size();j++) { BoolOptPtr so = o->options()[j]; - for(int j=0;jvalue()?"(*)":"( )") << " " << so->label() << std::endl; + for(int j=0;jvalue()?"(*)":"( )") << " " << so->label(); if(so->subOptions().size()) dump_options_list(so->subOptions(), indent+2); } } else { - std::cout << "dump_options_list: Error, unknown option of type " - << prettyTypeName(typeid(*_o).name()) << std::endl; + kDebug() << "dump_options_list: Error, unknown option of type " + << prettyTypeName(typeid(*_o).name()); } } - if(!indent)std::cout << "---- end dump ----" << std::endl; + if(!indent)kDebug() << "---- end dump ----"; } bool options_list_load_from_settings(OptList& options, const Settings& s) { @@ -373,7 +373,7 @@ bool options_list_load_from_settings(OptList& options, const Settings& s) { o->setSelected( newval ); } else - ERROR("option of type " << prettyTypeName(typeid(*_o).name()) ); + kError() << "option of type" << prettyTypeName(typeid(*_o).name()); } return retv; } @@ -421,6 +421,6 @@ void options_list_save_to_settings(const OptList& options, Settings s) { sel_group["value"] = o->value(); } else - ERROR("option of type " << prettyTypeName(typeid(*_o).name()) ); + kError() << "option of type" << prettyTypeName(typeid(*_o).name()); } } diff --git a/src/pgnparser.cpp b/src/pgnparser.cpp index 5f062c3..d2f3fa9 100644 --- a/src/pgnparser.cpp +++ b/src/pgnparser.cpp @@ -8,10 +8,9 @@ (at your option) any later version. */ -#include -#include #include "pgnparser.h" -#include "common.h" +#include +#include QRegExp PGN::number("^(\\d+)(?:(?:\\.\\s+)?(\\.\\.\\.)|\\.?)?"); QRegExp PGN::begin_var("^\\("); @@ -102,7 +101,7 @@ bool PGN::parse(const QString& pgn) { } // parse error! - std::cout << "pgn parse error! at" << pgn.mid(offset, 100) << std::endl; + kDebug() << "pgn parse error! at" << pgn.mid(offset, 100); return false; } diff --git a/src/piecepool.cpp b/src/piecepool.cpp index 43952fa..4017d17 100644 --- a/src/piecepool.cpp +++ b/src/piecepool.cpp @@ -9,9 +9,9 @@ */ -#include "board.h" #include "piecepool.h" - +#include "board.h" +#include PiecePool::PiecePool(int num, Board* b, const AnimationSettings& animSettings, KGameCanvasAbstract* parent) : ClickableCanvas(parent) @@ -102,7 +102,7 @@ void PiecePool::insertSprite(int index, const NamedSprite& nsprite) { index--; if(index < 0 || index > fill() ) { - ERROR("invalid index " << index); + kError() << "invalid index" << index; return; } @@ -128,7 +128,7 @@ NamedSprite PiecePool::getSprite(int index) { index--; if(index < 0 || index >= (int)m_sprites.size() ) { - ERROR("invalid index " << index); + kError() << "invalid index" << index; return NamedSprite(); } @@ -147,7 +147,7 @@ void PiecePool::removeSprite(int index) { index--; if(index < 0 || index >= (int)m_sprites.size() ) { - ERROR("invalid index " << index); + kError() << "invalid index" << index; return; } @@ -164,14 +164,14 @@ NamedSprite PiecePool::takeSprite(int index) { return retv; } - ERROR("Only the sprite being dropped can be taken from the pool."); + kError() << "Only the sprite being dropped can be taken from the pool."; return NamedSprite(); #if 0 if(m_dragged && index > m_dragged_index) index--; if(index < 0 || index >= (int)m_sprites.size() ) { - ERROR("invalid index " << index); + kError() << "invalid index" << index; return NamedSprite(); } @@ -182,7 +182,7 @@ NamedSprite PiecePool::takeSprite(int index) { NamedSprite PiecePool::takeSpriteAt(int index) { if(index < 0 || index >= (int)m_sprites.size() ) { - ERROR("invalid index " << index); + kError() << "invalid index" << index; return NamedSprite(); } @@ -270,7 +270,7 @@ void PiecePool::onMousePress(const QPoint& pos, int button) { return; if(m_dragged) { - ERROR("Eh? We are already dragging?"); + kError() << "Eh? We are already dragging?"; cancelDragging(); //never remove implicitly a piece from the pool } diff --git a/src/point.cpp b/src/point.cpp index 16260a0..da2535a 100644 --- a/src/point.cpp +++ b/src/point.cpp @@ -9,25 +9,22 @@ */ #include -#include +#include #include #include "common.h" #include "point.h" Point::Point(int x, int y) - : x(x), y(y) -{ + : x(x), y(y) { } Point::Point(const QPoint& p) - : x(p.x()), y(p.y()) -{ + : x(p.x()), y(p.y()) { } -Point::Point() -{ +Point::Point() { } @@ -120,58 +117,47 @@ bool Point::operator==(const Point& other) const { return x == other.x && y == other.y; } -bool Point::operator!=(const Point& other) const -{ +bool Point::operator!=(const Point& other) const { return !(*this == other); } -bool Point::operator<(const Point& other) const -{ +bool Point::operator<(const Point& other) const { return y < other.y || (y == other.y && x < other.x); } -bool Point::operator<=(const Point& other) const -{ +bool Point::operator<=(const Point& other) const { return y <= other.y || (y == other.y && x <= other.x); } -bool Point::resembles(const Point& other) const -{ +bool Point::resembles(const Point& other) const { return (other.x == -1 || x == other.x) && (other.y == -1 || y == other.y); } -Point::operator QPoint() const -{ +Point::operator QPoint() const { return QPoint(x,y); } -Point Point::normalizeInfinity() const -{ +Point Point::normalizeInfinity() const { return Point( normalizeInfinityHelper(x), normalizeInfinityHelper(y) ); } -double Point::norm() const -{ +double Point::norm() const { return sqrt((double)(x*x + y*y)); } -int Point::normalizeInfinityHelper(int n) const -{ +int Point::normalizeInfinityHelper(int n) const { if (n == 0) return 0; else return n > 0 ? 1 : -1; } -std::ostream& operator<<(std::ostream& os, const Point& p) -{ - return os << "(" << (p.x == -1 ? QString("?") : QString::number(p.x)) - << ", " << (p.y == -1 ? QString("?") : QString::number(p.y)) << ")"; +QDebug operator<<(QDebug dbg, const Point& p) { + dbg << "(" << (p.x == -1 ? QString("?") : QString::number(p.x)) + << ", " << (p.y == -1 ? QString("?") : QString::number(p.y)) << ")"; + return dbg; } - - - diff --git a/src/point.h b/src/point.h index 958b8c0..e53c4f6 100644 --- a/src/point.h +++ b/src/point.h @@ -60,6 +60,6 @@ private: int normalizeInfinityHelper(int n) const; }; -TAGUA_EXPORT std::ostream& operator<<(std::ostream&, const Point&); +TAGUA_EXPORT QDebug operator<<(QDebug dbg, const Point& c); #endif // POINT_H diff --git a/src/positioninfo.cpp b/src/positioninfo.cpp index a881802..e2b6e92 100644 --- a/src/positioninfo.cpp +++ b/src/positioninfo.cpp @@ -9,6 +9,7 @@ */ #include "positioninfo.h" +#include #include "variants.h" #include "gameinfo.h" #include "icsapi.h" @@ -88,7 +89,7 @@ bool PositionInfo::load(std::map& games, const QString& str) { ICSAPIPtr icsapi; if (gi == games.end()) { - WARNING("Received style12 for unknown game " << gn); + kWarning() << "Received style12 for unknown game" << gn; // create a gameinfo of type "dummy" gi = games.insert(std::make_pair(gn, ICSGameData(gn, ""))).first; new_game = true; diff --git a/src/pref_movelist.cpp b/src/pref_movelist.cpp index b916418..c805699 100644 --- a/src/pref_movelist.cpp +++ b/src/pref_movelist.cpp @@ -13,7 +13,6 @@ #include "movelist_p.h" #include "pref_movelist.h" - PrefMoveList::PrefMoveList(const QString&, QWidget *parent) : QWidget(parent) { diff --git a/src/pref_theme.cpp b/src/pref_theme.cpp index 93c0fa3..e824a37 100644 --- a/src/pref_theme.cpp +++ b/src/pref_theme.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "foreach.h" @@ -23,7 +24,7 @@ PrefTheme::ThemeInfoList PrefTheme::to_theme_info_list(const QStringList& files, const Settings& s) { - //std::cout << "about to examine " << files.size() << " desktop files" << std::endl; + //kDebug() << "about to examine " << files.size() << " desktop files"; std::map cached_info; SettingArray themes = s.group("themes").array("theme"); @@ -52,7 +53,7 @@ PrefTheme::ThemeInfoList PrefTheme::to_theme_info_list(const QStringList& files, all_themes << theme_info; if (theme_info.name.isEmpty()) { - ERROR("No name property in " << files[i]); + kError() << "No name property in" << files[i]; } } } @@ -75,7 +76,7 @@ PrefTheme::ThemeInfoList PrefTheme::to_theme_info_list(const QStringList& files, OptList PrefTheme::get_file_options(const QString& f, bool reload_defaults) { - //std::cout << "get file options for " << f << std::endl; + //kDebug() << "get file options for " << f; if(!reload_defaults) { std::map::iterator it = m_new_theme_options.find(f); @@ -88,7 +89,7 @@ OptList PrefTheme::get_file_options(const QString& f, bool reload_defaults) { lua_context.runFile(f); if(lua_context.error()) { - ERROR(lua_context.errorString()); + kError() << lua_context.errorString(); lua_context.clearError(); m_new_theme_options[f] = OptList(); @@ -97,7 +98,7 @@ OptList PrefTheme::get_file_options(const QString& f, bool reload_defaults) { OptList o = lua_context.getValue("options", 0, NULL, true); if(lua_context.error()) { - ERROR(lua_context.errorString()); + kError() << lua_context.errorString(); lua_context.clearError(); } @@ -162,7 +163,7 @@ PrefTheme::PrefTheme(const QString& currentVariant, QWidget *parent) cached_theme_info.group(cit->first) ); - //std::cout << "loaded " << c->m_themes.size() << " themes" << std::endl; + //kDebug() << "loaded " << c->m_themes.size() << " themes"; } QStringList all = Variants::instance().all(); diff --git a/src/qconnect.cpp b/src/qconnect.cpp index 680c025..7ee180b 100644 --- a/src/qconnect.cpp +++ b/src/qconnect.cpp @@ -34,7 +34,7 @@ QConnect::QConnect(QWidget *parent, const char *name) connect(buttonTimesealPath, SIGNAL(clicked()), this, SLOT(setTimesealPath())); chkTimesealCmd->setToolTip(timeseal_cmd_tool_tip); editTimesealCmd->setToolTip(timeseal_cmd_tool_tip); - //std::cout << "initializing dialog" << std::endl; + //kDebug() << "initializing dialog"; Settings s_ics = settings().group("ics"); if (s_ics["username"]) diff --git a/src/settings.cpp b/src/settings.cpp index 5196183..d38f00b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -103,8 +103,8 @@ void Settings::ensureExistence(QDomElement& node, QDomElement parent, const QStr } bool Settings::flag(const QString& attr, bool def) const { - //std::cout << "get flag " << node().isNull() << " " << attr << " = " - //<< node().attribute(attr, def ? "true" : "false") << std::endl; + //kDebug() << "get flag " << node().isNull() << " " << attr << " = " + //<< node().attribute(attr, def ? "true" : "false"); return node().attribute(attr, def ? "true" : "false") == "true"; } diff --git a/src/sprite.cpp b/src/sprite.cpp index 4e1c41d..fc007eb 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -64,7 +65,7 @@ Sprite* Sprite::duplicate() const { } void Sprite::setThumb(const QImage& thumb) { - std::cout << "setting thumb" << std::endl; + kDebug() << "setting thumb"; QPixmap pix = m_pixmap; int width = pix.width() / 2; int height = pix.height() / 2; diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index bf553cf..32b39df 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -33,14 +33,14 @@ TabWidget::TabWidget(QWidget* parent) // void TabWidget::insertTab(int index, QWidget* widget, const QString& caption) { // KTabWidget::insertTab(index, widget, caption); -// std::cout << "showing" << std::endl; +// kDebug() << "showing"; // if (count() > 1) // setTabBarHidden(false); // } // // void TabWidget::removeTab(int index) { // KTabWidget::removeTab(index); -// std::cout << "hiding" << std::endl; +// kDebug() << "hiding"; // if (count() <= 1) // setTabBarHidden(true); // } diff --git a/src/ui.cpp b/src/ui.cpp index e9aa536..0f13e52 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -8,11 +8,11 @@ (at your option) any later version. */ -#include #include #include #include #include +#include #include "ui.h" #include "controllers/abstract.h" #include "graphicalgame.h" @@ -78,7 +78,7 @@ void UI::setController(const shared_ptr& controller) { void UI::removeController(QWidget* w) { controller()->end(); - std::cout << "removing controller " << w << std::endl; + kDebug() << "removing controller " << w; m_controller.erase(w); } @@ -141,6 +141,10 @@ void UI::pgnPaste(const QString&) { //controller()->loadPGN(pgn); } +void UI::pgnPaste(const PGN& pgn) { + controller()->loadPGN(pgn); +} + void UI::clearBoard() { controller()->clearBoard(); } diff --git a/src/ui.h b/src/ui.h index a635b52..93d7022 100644 --- a/src/ui.h +++ b/src/ui.h @@ -24,6 +24,7 @@ class Engine; class ActionCollection; class KActionCollection; class ActionStateObserver; +class PGN; /** * @brief Utility class to handle GUI actions. @@ -110,6 +111,7 @@ public Q_SLOTS: void pgnCopy(); void pgnPaste(); void pgnPaste(const QString&); + void pgnPaste(const PGN& pgn); QString currentPGN(); // editing diff --git a/src/weakset.h b/src/weakset.h index 34f3faa..70a6b0c 100644 --- a/src/weakset.h +++ b/src/weakset.h @@ -46,7 +46,7 @@ public: void skip_garbage() { #ifdef WEAK_SET_DEBUG - cout << "skipping garbage" << endl; + kDebug() << "skipping garbage" << endl; uint c = 0; #endif // WEAK_SET_DEBUG while (true) { @@ -56,13 +56,13 @@ public: // while (m_it != m_parent.m_set.end() && !(obj = (*m_it).lock())) { #ifdef WEAK_SET_DEBUG - cout << "iteration " << c++ << endl; + kDebug() << "iteration " << c++ << endl; #endif // WEAK_SET_DEBUG // the current reference is dangling: // remove it from the list and get the next one #ifdef WEAK_SET_DEBUG - cout << "dangling reference! removing it" << endl; + kDebug() << "dangling reference! removing it" << endl; #endif // WEAK_SET_DEBUG m_it = m_parent.m_set.erase(m_it); } @@ -72,9 +72,9 @@ public: // m_it == m_parent.m_set.end() #ifdef WEAK_SET_DEBUG if (obj) - cout << "no iteration done: uses = " << obj.use_count() << ", obj = " << *obj << endl; + kDebug() << "no iteration done: uses = " << obj.use_count() << ", obj = " << *obj << endl; else - cout << "we're at the end" << endl; + kDebug() << "we're at the end" << endl; #endif // WEAK_SET_DEBUG } public: @@ -95,13 +95,13 @@ public: */ iterator& operator++() { #ifdef WEAK_SET_DEBUG - cout << "incrementing" << endl; + kDebug() << "incrementing" << endl; #endif // WEAK_SET_DEBUG ++m_it; obj.reset(); skip_garbage(); #ifdef WEAK_SET_DEBUG - cout << "done incrementing" << endl; + kDebug() << "done incrementing" << endl; #endif // WEAK_SET_DEBUG return *this; } diff --git a/src/xboardengine.cpp b/src/xboardengine.cpp index 0319d62..1e415f0 100644 --- a/src/xboardengine.cpp +++ b/src/xboardengine.cpp @@ -10,9 +10,9 @@ #include "xboardengine.h" +#include #include #include -#include #include "enginenotifier.h" #include "foreach.h" @@ -48,7 +48,7 @@ XBoardEngine::XBoardEngine(const QString& path, const QStringList& arguments) } XBoardEngine::~XBoardEngine() { - std::cout << "[debug] destroying engine" << std::endl; + kDebug() << "[debug] destroying engine"; stop(); m_engine.kill(); } diff --git a/tests/luaimage/test.cpp b/tests/luaimage/test.cpp index 1064a1e..04dab03 100644 --- a/tests/luaimage/test.cpp +++ b/tests/luaimage/test.cpp @@ -57,7 +57,7 @@ void mkWidget(QImage img) int main(int argc, char *argv[]) { QApplication app(argc, argv); - //std::cout << "Va a cagare " << QDir::cleanPath("pqr/abc/../xyz") << std::endl; + //kDebug()()() << "Va a cagare " << QDir::cleanPath("pqr/abc/../xyz") << std::endl; #if 0 LoadingContext* x = new LoadingContext; diff --git a/tests/options/main.cpp b/tests/options/main.cpp index 39a70be..7b61910 100644 --- a/tests/options/main.cpp +++ b/tests/options/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { ja.runFile("test.lua"); OptList opts2 = ja.getOptList("options"); if(ja.error()) - std::cout << ja.errorString() << std::endl; + kDebug()()() << ja.errorString() << std::endl; else { /*sets.qSettings()->beginGroup("o2"); options_list_load_from_settings(opts2, sets); diff --git a/tests/test_weakset.cpp b/tests/test_weakset.cpp index 7a7e632..cc43d11 100644 --- a/tests/test_weakset.cpp +++ b/tests/test_weakset.cpp @@ -25,7 +25,7 @@ void test_insertion() { void test_garbage_collection() { #ifdef WEAK_SET_DEBUG - cout << "\n\ntesting garbage collection\n\n" << endl; + kDebug()() << "\n\ntesting garbage collection\n\n" << endl; #endif // WEAK_SET_DEBUG weak_set s; diff --git a/tests/weak_set/test_weakset.cpp b/tests/weak_set/test_weakset.cpp index dd1b704..7c11dfc 100644 --- a/tests/weak_set/test_weakset.cpp +++ b/tests/weak_set/test_weakset.cpp @@ -24,7 +24,7 @@ void test_insertion() { void test_garbage_collection() { #ifdef WEAK_SET_DEBUG - cout << "\n\ntesting garbage collection\n\n" << endl; + kDebug()() << "\n\ntesting garbage collection\n\n" << endl; #endif // WEAK_SET_DEBUG weak_set s; -- 2.11.4.GIT