[Kde-games-devel] [libkdegames] /: Move KChat to kbackgammon that is the only one that uses it
Albert Astals Cid
aacid at kde.org
Tue Dec 25 21:58:23 UTC 2012
Git commit 77093fde077a73e2cca4f3a0849996ffb8cbae53 by Albert Astals Cid.
Committed on 25/12/2012 at 22:57.
Pushed by aacid into branch 'master'.
Move KChat to kbackgammon that is the only one that uses it
And libkdegamesprivate is deprecated/unmaintained code
CCMAIL: kde-games-devel at kde.org
M +0 -1 CMakeLists.txt
M +0 -1 libkdegamesprivate/CMakeLists.txt
D +0 -130 libkdegamesprivate/kchat.cpp
D +0 -151 libkdegamesprivate/kchat.h
http://commits.kde.org/libkdegames/77093fde077a73e2cca4f3a0849996ffb8cbae53
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b1a333..67b8b40 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,7 +126,6 @@ set(kdegamesprivate_LIB_SRCS
libkdegamesprivate/kchatbase.cpp
libkdegamesprivate/kchatbaseitemdelegate.cpp
libkdegamesprivate/kchatbasemodel.cpp
- libkdegamesprivate/kchat.cpp
libkdegamesprivate/kgame/kgamechat.cpp
libkdegamesprivate/kgame/kgame.cpp
libkdegamesprivate/kgame/kgameerror.cpp
diff --git a/libkdegamesprivate/CMakeLists.txt b/libkdegamesprivate/CMakeLists.txt
index ccdecfd..abd5df8 100644
--- a/libkdegamesprivate/CMakeLists.txt
+++ b/libkdegamesprivate/CMakeLists.txt
@@ -14,7 +14,6 @@ install(FILES
kchatbase.h
kchatbaseitemdelegate.h
kchatbasemodel.h
- kchat.h
kgamecanvas.h
kgamedifficulty.h
kgamesvgdocument.h
diff --git a/libkdegamesprivate/kchat.cpp b/libkdegamesprivate/kchat.cpp
deleted file mode 100644
index 6c2a625..0000000
--- a/libkdegamesprivate/kchat.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann at gmx.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "kchat.h"
-
-#include <QtCore/QMap>
-
-#include <klocale.h>
-#include <kdebug.h>
-
-#include "kchatbasemodel.h"
-#include "kchatbaseitemdelegate.h"
-
-class KChatPrivate
-{
-public:
- KChatPrivate()
- {
- }
-
- bool mAutoAddMessages;
-
- QMap<int, QString> mPlayerMap;
- int mPlayerId;
- int mFromId;
-};
-
-KChat::KChat(QWidget* parent, bool twoPlayerGame)
- : KChatBase(parent,
- new KChatBaseModel(parent),
- new KChatBaseItemDelegate(parent),twoPlayerGame),
- d( new KChatPrivate )
-{
- init();
-}
-
-KChat::KChat(QWidget* parent, KChatBaseModel* model, KChatBaseItemDelegate* delegate, bool noComboBox)
- : KChatBase(parent, model, delegate, noComboBox),
- d( new KChatPrivate )
-{
- init();
-}
-
-KChat::~KChat()
-{
- kDebug(11000) << "DESTRUCT KChat" << this;
- delete d;
-}
-
-void KChat::init()
-{
- kDebug(11001) << "INIT KChat" << this;
- d->mAutoAddMessages = true;
- d->mPlayerId = 1;
- d->mFromId = 1;
-}
-
-void KChat::setFromNickname(const QString& n)
-{ d->mFromId = addPlayer(n); }
-QString KChat::fromName() const
-{ return player(fromId()); }
-void KChat::setAutoAddMessages(bool add)
-{ d->mAutoAddMessages = add; }
-bool KChat::autoAddMessages() const
-{ return d->mAutoAddMessages; }
-int KChat::uniqueId()
-{ return d->mPlayerId++; }
-int KChat::fromId() const
-{ return d->mFromId; }
-QString KChat::player(int id) const
-{ return d->mPlayerMap[id]; }
-
-void KChat::returnPressed(const QString& text)
-{
- int id = fromId();
- if (id < 0) {
- // don't return - just display "unknown" as name
- kWarning(11000) << "KChat: no fromNickname has been set!";
- }
- emit signalSendMessage(id, text);
- if (autoAddMessages()) {
- QString p = player(id);
- if (p.isNull()) {
- p = i18nc("Unknown player", "Unknown");
- }
- kDebug(11000) << "auto adding message from player" << p << " ;id=" << id;
- addMessage(p, text);
- }
-}
-
-int KChat::addPlayer(const QString& nickname)
-{
- int id = uniqueId();
- d->mPlayerMap.insert(id, nickname);
- return id;
-}
-
-void KChat::removePlayer(int id)
-{
- d->mPlayerMap.remove(id);
-}
-
-void KChat::removePlayer(const QString& nickname)
-{
- QMap<int, QString>::Iterator it;
- for (it = d->mPlayerMap.begin(); it != d->mPlayerMap.end(); ++it) {
- if (it.value() == nickname) {
- d->mPlayerMap.erase(it);
- }
- }
-}
-
-
-#include "kchat.moc"
diff --git a/libkdegamesprivate/kchat.h b/libkdegamesprivate/kchat.h
deleted file mode 100644
index af954dd..0000000
--- a/libkdegamesprivate/kchat.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann at gmx.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-#ifndef __KCHAT_H__
-#define __KCHAT_H__
-
-#include "kchatbase.h"
-#include "libkdegamesprivate_export.h"
-
-class KChatPrivate;
-
-/**
- * \class KChat kchat.h <KChat>
- *
- * @short A chat widget for non-KGame games
- *
- * Docu is TODO
- *
- * @author Andreas Beckermann <b_mann at gmx.de>
- **/
-class KDEGAMESPRIVATE_EXPORT KChat : public KChatBase
-{
- Q_OBJECT
-public:
- /**
- * @param parent The parent widget for this widget.
- * @param twoPlayerGame If true the combo box where the player can
- * choose to send to a single player or to all players will not be added
- * as you will hardly need it in 2-player games.
- **/
- explicit KChat(QWidget* parent, bool twoPlayerGame = false);
-
- KChat(QWidget* parent, KChatBaseModel* model=0,
- KChatBaseItemDelegate* delegate=0,
- bool noComboBox = false);
-
- virtual ~KChat();
-
- /**
- * Equivalent to player(fromId())
- * @return The name that will be shown for messages from this widget.
- * That is the string from @ref setFromNickname
- **/
- virtual QString fromName() const;
-
- /**
- * This sets the name that will be shown on all chat widgets if this
- * widget sends a message. See signalSendMessage
- * @param name The name of the player owning this widget
- **/
- void setFromNickname(const QString& name);
-
-// TODO:
-// void setPlayerList(QIntDict<QString>);// use this for non-KGame use
-
- /**
- * Adds a player nickname.
- * @return The unique ID of the player
- **/
- int addPlayer(const QString& nick);
-
- /**
- * Removes all players with this nickname. Better don't use this as it
- * will remove *all* players with this nickname. Save the id instead and
- * call removePlayer(id)
- * @param nick The nickname of the removed players
- **/
- void removePlayer(const QString& nick);
-
- /**
- * Removes the player with this id, as returned by @ref addPlayer
- * @param id The id of the player to be removed
- **/
- void removePlayer(int id);
-
-
- /**
- * @return true if the messages which will be sent from here will be
- * added automatically using @ref KChatBase::addMessage. See also @ref
- * setAutoAddMessages
- **/
- bool autoAddMessages() const;
-
- /**
- * Usually the messages which will be sent from here (see @ref
- * signalSendMessage) are added autmatically to this widget. But under
- * some circumstances that would be very unhandy. So you can deactivate
- * this behaviour here and call @ref KChatBase::addMessage yourself
- * @param add If true (default) messages sent from here will be added
- * automatically. Otherwise you will have to add them yourself
- **/
- void setAutoAddMessages(bool add);
-
- /**
- * @return The nickname of the player which belongs to this id
- **/
- QString player(int id) const;
-
- /**
- * @return The ID that belongs to the local player.
- * @see setFromNickname
- **/
- int fromId() const;
-
-
-Q_SIGNALS:
- /**
- * This signal is emitted when the player wants to send a message.
- *
- * The message is added automatically using @ref KChatBase::addMessage if @ref
- * autoAddMessages is enabled.
- * @param id The id of the player who sends the message - see
- * setFromNickname and player
- * @param msg The message itself
- **/
- void signalSendMessage(int id, const QString& msg);
-
-protected:
- /**
- * This emits @ref signalSendMessage and, if @ref autoAddMessages is
- * true, calls @ref KChatBase::addMessage
- **/
- virtual void returnPressed(const QString&);
-
- /**
- * The Id of the next player. Incremented after every call.
- **/
- int uniqueId();
-
-private:
- void init();
-
- KChatPrivate* const d;
-};
-
-#endif
More information about the kde-games-devel
mailing list