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

...
 
Commits (7)
......@@ -26,7 +26,6 @@ include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(ECMMarkNonGuiExecutable)
add_definitions(-DQT_USE_FAST_CONCATENATION)
add_definitions(-DMAKE_KDEGAMESPRIVATE_LIB)
add_definitions(-DTRANSLATION_DOMAIN="libkdegames5")
......@@ -85,11 +84,24 @@ set(KGAUDIO_BACKEND_OPENAL TRUE) # for configure_file() below
configure_file(libkdegames_capabilities.h.in ${CMAKE_CURRENT_BINARY_DIR}/libkdegames_capabilities.h)
########### next target ###############
#if (${KF5Config_VERSION} STRGREATER "5.56.0")
# add_definitions(-DQT_NO_FOREACH)
# MESSAGE(STATUS "compile without foreach")
#endif()
add_definitions(
-DQT_DEPRECATED_WARNINGS
-DQT_DISABLE_DEPRECATED_BEFORE=0x050900
-DQT_DEPRECATED_WARNINGS_SINCE=0x060000
-DQT_NO_KEYWORDS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_STRICT_ITERATORS
-DQT_USE_QSTRINGBUILDER
-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x052e00
-DKF_DEPRECATED_WARNINGS_SINCE=0x060000
)
if(NOT Qt5_VERSION VERSION_LESS "5.12.0" AND NOT KF5_VERSION VERSION_LESS "5.56.0")
add_definitions(-DQT_NO_FOREACH)
endif()
set(kdegames_LIB_SRCS
audio/kgaudioscene-${KGAUDIO_BACKEND}.cpp
......
......@@ -131,7 +131,7 @@ void KgSound::setPlaybackType(KgSound::PlaybackType type)
if (d->m_type == type)
return;
d->m_type = type;
emit playbackTypeChanged(type);
Q_EMIT playbackTypeChanged(type);
}
QPointF KgSound::pos() const
......@@ -144,7 +144,7 @@ void KgSound::setPos(const QPointF& pos)
if (d->m_pos == pos)
return;
d->m_pos = pos;
emit posChanged(pos);
Q_EMIT posChanged(pos);
}
qreal KgSound::volume() const
......@@ -157,7 +157,7 @@ void KgSound::setVolume(qreal volume)
if (d->m_volume == volume)
return;
d->m_volume = volume;
emit volumeChanged(volume);
Q_EMIT volumeChanged(volume);
}
bool KgSound::hasError() const
......
......@@ -274,10 +274,9 @@ QString KHighscore::highscoreGroup() const
QStringList KHighscore::groupList() const
{
QStringList groupList = config()->groupList();
const QStringList groupList = config()->groupList();
QStringList highscoreGroupList;
foreach (QString group, groupList) //krazy:exclude=foreach
{
for (QString group : groupList) {
if(group.contains( QLatin1String( "KHighscore")) ) //If it's one of _our_ groups (KHighscore or KHighscore_xxx)
{
if(group == QLatin1String( "KHighscore" ))
......
......@@ -188,8 +188,8 @@ void KScoreDialog::initFromDifficulty(const KgDifficulty* diff, bool doSetConfig
{
QMap<QByteArray, QString> localizedLevelStrings;
QMap<int, QByteArray> levelWeights;
foreach (const KgDifficultyLevel* level, diff->levels())
{
const auto levels = diff->levels();
for (const KgDifficultyLevel* level : levels) {
localizedLevelStrings.insert(level->key(), level->title());
levelWeights.insert(level->hardness(), level->key());
}
......@@ -216,7 +216,7 @@ QString KScoreDialog::KScoreDialogPrivate::findTranslatedGroupName(const QByteAr
{
const QString lookupResult = translatedGroupNames.value(name);
//If it wasn't found then just try i18n( to see if it happens to be in the database
return lookupResult.isEmpty() ? i18n(name) : lookupResult; //FIXME?
return lookupResult.isEmpty() ? i18n(name.constData()) : lookupResult; //FIXME?
}
void KScoreDialog::setComment(const QString &comment)
......@@ -259,8 +259,7 @@ void KScoreDialog::KScoreDialogPrivate::setupDialog()
keysToConfigure.removeAt(index);
}
}
foreach(const QByteArray &groupName, keysToConfigure)
{
for (const QByteArray &groupName : qAsConst(keysToConfigure)) {
setupGroup(groupName);
}
}
......@@ -456,8 +455,8 @@ void KScoreDialog::KScoreDialogPrivate::loadScores()
scores.clear();
QList<QByteArray> groupKeyList; //This will be a list of all the groups in the config file
foreach( const QString & groupString, highscoreObject->groupList())
{
const auto groupStrings = highscoreObject->groupList();
for (const QString & groupString : groupStrings) {
groupKeyList << groupString.toUtf8(); //Convert all the QStrings to QByteArrays
}
......@@ -489,8 +488,8 @@ void KScoreDialog::KScoreDialogPrivate::loadScores()
}
}
highscoreObject->setHighscoreGroup(QLatin1String( tempCurrentGroup )); //reset to the user-set group name
foreach(const QByteArray &groupKey, scores.keys())
{
const auto groupKeys = scores.keys();
for (const QByteArray &groupKey : groupKeys) {
if( (scores[groupKey][0].value(Score)==QLatin1String( "-" )) && (scores.size() > 1) && (latest.first != groupKey) )
{
qCDebug(GAMES_HIGHSCORE) << "Removing group " << groupKey << " since it's unused.";
......
......@@ -77,7 +77,7 @@ QString KGameClock::timeString() const
void KGameClock::showTime()
{
emit timeChanged(timeString());
Q_EMIT timeChanged(timeString());
}
void KGameClock::restart()
......
......@@ -82,7 +82,7 @@ void TextItemWithOpacity::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
// NOTE: this item is QGraphicsTextItem which "eats" mouse events
// because of interaction with links. Because of that let's make a
// special signal to indicate mouse click
emit mouseClicked();
Q_EMIT mouseClicked();
QGraphicsTextItem::mouseReleaseEvent(ev);
}
......@@ -244,7 +244,8 @@ void KGamePopupItem::showMessage( const QString& text, Position pos, ReplaceMode
// NOTE: we blindly take first visible view we found. I.e. we don't support
// multiple views. If no visible scene is found, we simply pick the first one.
QGraphicsView *sceneView = nullptr;
foreach (QGraphicsView *view, scene()->views()) {
const auto views = scene()->views();
for (QGraphicsView *view : views) {
if (view->isVisible()) {
sceneView = view;
break;
......@@ -252,7 +253,7 @@ void KGamePopupItem::showMessage( const QString& text, Position pos, ReplaceMode
}
if (!sceneView)
{
sceneView = scene()->views().at(0);
sceneView = views.at(0);
}
QPolygonF poly = sceneView->mapToScene( sceneView->viewport()->contentsRect() );
......@@ -411,7 +412,7 @@ void KGamePopupItem::hideMe()
if( d->m_timeLine.direction() == QTimeLine::Backward )
{
hide();
emit hidden();
Q_EMIT hidden();
}
}
......@@ -454,7 +455,7 @@ void KGamePopupItem::forceHide(HideType howToHide)
d->m_timeLine.stop();
d->m_timer.stop();
hide();
emit hidden();
Q_EMIT hidden();
}
else if(howToHide == AnimatedHide)
{
......@@ -494,7 +495,7 @@ void KGamePopupItem::onLinkHovered(const QString& link)
}
d->m_linkHovered = !link.isEmpty();
emit linkHovered(link);
Q_EMIT linkHovered(link);
}
void KGamePopupItem::setSharpness( Sharpness sharpness )
......
......@@ -181,7 +181,7 @@ void KGameRendererPrivate::_k_setTheme(const KgTheme* theme)
it1.value().clear(); //because the pixmap is outdated
it1.key()->d->fetchPixmap();
}
emit m_parent->themeChanged(m_currentTheme);
Q_EMIT m_parent->themeChanged(m_currentTheme);
}
bool KGameRendererPrivate::setTheme(const KgTheme* theme)
......@@ -526,8 +526,7 @@ void KGameRendererPrivate::jobFinished(KGRInternal::Job* job, bool isSynchronous
}
const QPixmap pixmap = QPixmap::fromImage(result);
m_pixmapCache.insert(cacheKey, pixmap);
foreach (KGameRendererClient* requester, requesters)
{
for (KGameRendererClient* requester : requesters) {
requester->receivePixmap(pixmap);
}
}
......
......@@ -250,16 +250,14 @@ const KgDifficultyLevel* KgDifficulty::currentLevel() const
//check configuration file for saved difficulty level
KConfigGroup cg(KSharedConfig::openConfig(), "KgDifficulty");
const QByteArray key = cg.readEntry("Level", QByteArray());
foreach (const KgDifficultyLevel* level, d->m_levels)
{
for (const KgDifficultyLevel* level : qAsConst(d->m_levels)) {
if (level->key() == key)
{
return d->m_currentLevel = level;
}
}
//no level predefined - look for a default level
foreach (const KgDifficultyLevel* level, d->m_levels)
{
for (const KgDifficultyLevel* level : qAsConst(d->m_levels)) {
if (level->isDefault())
{
return d->m_currentLevel = level;
......@@ -281,7 +279,7 @@ void KgDifficulty::setEditable(bool editable)
return;
}
d->m_editable = editable;
emit editableChanged(editable);
Q_EMIT editableChanged(editable);
}
bool KgDifficulty::isGameRunning() const
......@@ -296,7 +294,7 @@ void KgDifficulty::setGameRunning(bool gameRunning)
return;
}
d->m_gameRunning = gameRunning;
emit gameRunningChanged(gameRunning);
Q_EMIT gameRunningChanged(gameRunning);
}
void KgDifficulty::select(const KgDifficultyLevel* level)
......@@ -315,13 +313,13 @@ void KgDifficulty::select(const KgDifficultyLevel* level)
);
if (result != KMessageBox::Continue)
{
emit selectedLevelChanged(d->m_currentLevel);
Q_EMIT selectedLevelChanged(d->m_currentLevel);
return;
}
}
d->m_currentLevel = level;
emit selectedLevelChanged(level);
emit currentLevelChanged(level);
Q_EMIT selectedLevelChanged(level);
Q_EMIT currentLevelChanged(level);
}
//END KgDifficulty
......@@ -359,7 +357,7 @@ namespace KgDifficultyGUI
}
void slotSelected(const KgDifficultyLevel* level)
{
emit signalSelected(d->levels().indexOf(level));
Q_EMIT signalSelected(d->levels().indexOf(level));
}
};
class Menu : public KSelectAction
......@@ -398,8 +396,8 @@ void KgDifficultyGUI::init(KXmlGuiWindow* window, KgDifficulty* difficulty)
QObject::connect(selector, &Selector::signalSelected, menu, &KSelectAction::setCurrentItem);
//fill menu and selector
foreach (const KgDifficultyLevel* level, difficulty->levels())
{
const auto levels = difficulty->levels();
for (const KgDifficultyLevel* level : levels) {
selector->addItem(icon, level->title());
menu->addAction(level->title());
}
......
......@@ -109,8 +109,7 @@ bool KgTheme::readFromDesktopFile(const QString& path_)
//open file, look for a known config group
KConfig config(path, KConfig::SimpleConfig);
KConfigGroup group;
foreach (const QString& groupName, Private::s_configGroupNames)
{
for (const QString& groupName : qAsConst(Private::s_configGroupNames)) {
if (config.hasGroup(groupName))
{
group = config.group(groupName);
......
......@@ -50,7 +50,7 @@ class KgThemeProvider::Private
void updateThemeName()
{
emit q->currentThemeNameChanged(q->currentThemeName());
Q_EMIT q->currentThemeNameChanged(q->currentThemeName());
}
};
......@@ -141,8 +141,7 @@ const KgTheme* KgThemeProvider::currentTheme() const
KConfigGroup cg(KSharedConfig::openConfig(), "KgTheme");
const QByteArray id = cg.readEntry(d->m_configKey.data(), QByteArray());
//look for a theme with this id
foreach (const KgTheme* theme, d->m_themes)
{
for (const KgTheme* theme : qAsConst(d->m_themes)) {
if (theme->identifier() == id)
{
return d->m_currentTheme = theme;
......@@ -159,7 +158,7 @@ void KgThemeProvider::setCurrentTheme(const KgTheme* theme)
if (d->m_currentTheme != theme)
{
d->m_currentTheme = theme;
emit currentThemeChanged(theme);
Q_EMIT currentThemeChanged(theme);
}
}
......@@ -207,7 +206,7 @@ void KgThemeProvider::rediscoverThemes()
const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.desktop"));
for (const QString &file : fileNames) {
if (!themePaths.contains(file)) {
themePaths.append(dir + '/' + file);
themePaths.append(dir + QLatin1Char('/') + file);
}
}
}
......@@ -215,8 +214,7 @@ void KgThemeProvider::rediscoverThemes()
//create themes from result, order default theme at the front (that's not
//needed by KgThemeProvider, but nice for the theme selector)
QList<KgTheme*> themes;
foreach (const QString& themePath, themePaths)
{
for (const QString& themePath : qAsConst(themePaths)) {
const QFileInfo fi(themePath);
if (d->m_discoveredThemes.contains(fi.fileName()))
{
......
......@@ -104,8 +104,8 @@ KgThemeSelector::~KgThemeSelector()
void KgThemeSelector::Private::fillList()
{
m_list->clear();
foreach (const KgTheme* theme, m_provider->themes())
{
const auto themes = m_provider->themes();
for (const KgTheme* theme : themes) {
QListWidgetItem* item = new QListWidgetItem(theme->name(), m_list);
item->setData(Qt::DecorationRole,
m_provider->generatePreview(theme, Metrics::ThumbnailBaseSize));
......@@ -145,8 +145,8 @@ void KgThemeSelector::Private::_k_updateProviderSelection()
}
const QByteArray selId = selItem->data(KgThemeDelegate::IdRole).toByteArray();
//select the theme with this identifier
foreach (const KgTheme* theme, m_provider->themes())
{
const auto themes = m_provider->themes();
for (const KgTheme* theme : themes) {
if (theme->identifier() == selId)
{
m_provider->setCurrentTheme(theme);
......
......@@ -187,7 +187,7 @@ bool KGame::loadgame(QDataStream &stream, bool network,bool resetgame)
{
qCWarning(GAMES_PRIVATE_KGAME) << "Trying to load different game version we="<<cookie() << "saved=" << c;
bool result=false;
emit signalLoadError(stream,network,(int)c,result);
Q_EMIT signalLoadError(stream,network,(int)c,result);
return result;
}
if (resetgame) reset();
......@@ -225,7 +225,7 @@ bool KGame::loadgame(QDataStream &stream, bool network,bool resetgame)
// If there is additional data to be loaded before players are loaded then do
// this here.
emit signalLoadPrePlayers(stream);
Q_EMIT signalLoadPrePlayers(stream);
// Switch back on the direct emitting of signals and emit the
// queued signals for properties.
......@@ -262,7 +262,7 @@ bool KGame::loadgame(QDataStream &stream, bool network,bool resetgame)
// qCDebug(GAMES_PRIVATE_KGAME) << "Player "<<player->id() << "to direct emit";
}
emit signalLoad(stream);
Q_EMIT signalLoad(stream);
return true;
}
......@@ -305,7 +305,7 @@ bool KGame::savegame(QDataStream &stream,bool /*network*/,bool saveplayers)
dataHandler()->save(stream);
// Save all data that need to be saved *before* the players are saved
emit signalSavePrePlayers(stream);
Q_EMIT signalSavePrePlayers(stream);
if (saveplayers)
{
......@@ -318,7 +318,7 @@ bool KGame::savegame(QDataStream &stream,bool /*network*/,bool saveplayers)
stream << (qint16)KGAME_LOAD_COOKIE;
emit signalSave(stream);
Q_EMIT signalSave(stream);
return true;
}
......@@ -362,7 +362,7 @@ KPlayer *KGame::loadPlayer(QDataStream& stream,bool isvirtual)
{
qCDebug(GAMES_PRIVATE_KGAME) << "Player "<< id << "not found...asking user to create one";
newplayer=createPlayer(rtti,iovalue,isvirtual);
//emit signalCreatePlayer(newplayer,rtti,iovalue,isvirtual,this);
//Q_EMIT signalCreatePlayer(newplayer,rtti,iovalue,isvirtual,this);
}
/*
if (!newplayer)
......@@ -488,7 +488,7 @@ bool KGame::systemAddPlayer(KPlayer* newplayer)
qCDebug(GAMES_PRIVATE_KGAME) << " id=" << newplayer->id() << " #Players="
<< d->mPlayerList.count() << "added" << newplayer
<< " (virtual=" << newplayer->isVirtual() << ")";
emit signalPlayerJoinedGame(newplayer);
Q_EMIT signalPlayerJoinedGame(newplayer);
}
return true;
}
......@@ -572,7 +572,7 @@ bool KGame::systemRemove(KPlayer* p,bool deleteit)
result = d->mPlayerList.removeAll(p);
}
emit signalPlayerLeftGame(p);
Q_EMIT signalPlayerLeftGame(p);
p->setGame(nullptr);
if (deleteit)
......@@ -625,7 +625,7 @@ bool KGame::systemInactivatePlayer(KPlayer* player)
d->mInactivePlayerList.prepend(player);
player->setActive(false);
}
emit signalPlayerLeftGame(player);
Q_EMIT signalPlayerLeftGame(player);
if (isAdmin())
{
d->mInactiveIdList.prepend(pid);
......@@ -782,7 +782,7 @@ KPlayer * KGame::playerInputFinished(KPlayer *player)
{
player->setTurn(false);
setGameStatus(End);
emit signalGameOver(gameOver,player,this);
Q_EMIT signalGameOver(gameOver,player,this);
}
else if (!player->asyncInput())
{
......@@ -860,7 +860,7 @@ void KGame::networkTransmission(QDataStream &stream, int msgid, quint32 receiver
// *first* notice the game that something has changed - so no return prevents
// this
emit signalMessageUpdate(msgid, receiver, sender);
Q_EMIT signalMessageUpdate(msgid, receiver, sender);
if (KGameMessage::isPlayer(receiver))
{
//qCDebug(GAMES_PRIVATE_KGAME) << "message id" << msgid << "seems to be for a player ("<<active=p->isActive()<<" recv="<< receiver;
......@@ -1006,7 +1006,7 @@ void KGame::networkTransmission(QDataStream &stream, int msgid, quint32 receiver
int cid;
stream >> cid;
qCDebug(GAMES_PRIVATE_KGAME) << "====> (ALL) " << ": Got IdGameConnected for client "<< cid << "we are =" << gameId();
emit signalClientJoinedGame(cid,this);
Q_EMIT signalClientJoinedGame(cid,this);
}
break;
......@@ -1041,7 +1041,7 @@ void KGame::networkTransmission(QDataStream &stream, int msgid, quint32 receiver
qCCritical(GAMES_PRIVATE_KGAME) << "incorrect message id" << msgid << " - emit anyway";
}
qCDebug(GAMES_PRIVATE_KGAME) << ": User data msgid" << msgid;
emit signalNetworkData(msgid - KGameMessage::IdUser,((QBuffer*)stream.device())->readAll(),receiver,sender);
Q_EMIT signalNetworkData(msgid - KGameMessage::IdUser,((QBuffer*)stream.device())->readAll(),receiver,sender);
}
break;
}
......@@ -1302,7 +1302,7 @@ void KGame::slotServerDisconnected() // Client side
{
KPlayer* player = *it;
bool remove = true;
emit signalReplacePlayerIO(player, &remove);
Q_EMIT signalReplacePlayerIO(player, &remove);
if (remove)
{
qCDebug(GAMES_PRIVATE_KGAME) << " ---> Removing player" << player->id();
......@@ -1341,7 +1341,7 @@ void KGame::slotServerDisconnected() // Client side
player->Debug();
}
qCDebug(GAMES_PRIVATE_KGAME) << "+++++++++++" << "DONE=";
emit signalClientLeftGame(0,oldgamestatus,this);
Q_EMIT signalClientLeftGame(0,oldgamestatus,this);
}
void KGame::slotClientDisconnected(quint32 clientID,bool /*broken*/) // server side
......@@ -1368,7 +1368,7 @@ void KGame::slotClientDisconnected(quint32 clientID,bool /*broken*/) // server s
KPlayer* player = *it;
// try to replace the KGameIO first
bool remove = true;
emit signalReplacePlayerIO(player, &remove);
Q_EMIT signalReplacePlayerIO(player, &remove);
if (remove) {
// otherwise (no new KGameIO) remove the player
qCDebug(GAMES_PRIVATE_KGAME) << " ---> Removing player" << player->id();
......@@ -1387,7 +1387,7 @@ void KGame::slotClientDisconnected(quint32 clientID,bool /*broken*/) // server s
activatePlayer(player);
}
}
emit signalClientLeftGame(clientID,oldgamestatus,this);
Q_EMIT signalClientLeftGame(clientID,oldgamestatus,this);
}
......@@ -1464,7 +1464,7 @@ void KGame::sendProperty(int msgid, QDataStream& stream, bool* sent)
void KGame::emitSignal(KGamePropertyBase *me)
{
emit signalPropertyChanged(me,this);
Q_EMIT signalPropertyChanged(me,this);
}
KGamePropertyBase* KGame::findProperty(int id) const
......
......@@ -101,7 +101,7 @@ void KGameIO::notifyTurn(bool b)
bool sendit=false;
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
emit signalPrepareTurn(stream, b, this, &sendit);
Q_EMIT signalPrepareTurn(stream, b, this, &sendit);
if (sendit)
{
QDataStream ostream(buffer);
......@@ -180,7 +180,7 @@ bool KGameKeyIO::eventFilter( QObject *o, QEvent *e )
QByteArray buffer;
QDataStream stream(&buffer,QIODevice::WriteOnly);
bool eatevent=false;
emit signalKeyEvent(this,stream,k,&eatevent);
Q_EMIT signalKeyEvent(this,stream,k,&eatevent);
QDataStream msg(buffer);
if (eatevent && sendInput(msg))
......@@ -268,7 +268,7 @@ bool KGameMouseIO::eventFilter( QObject *o, QEvent *e )
QByteArray buffer;
QDataStream stream(&buffer,QIODevice::WriteOnly);
bool eatevent=false;
emit signalMouseEvent(this,stream,k,&eatevent);
Q_EMIT signalMouseEvent(this,stream,k,&eatevent);
// qCDebug(GAMES_PRIVATE_KGAME) << "################# eatevent=" << eatevent;
QDataStream msg(buffer);
if (eatevent && sendInput(msg))
......@@ -356,7 +356,7 @@ void KGameProcessIO::initIO(KPlayer *p)
{
qint16 id = p->userId();
stream << id;
emit signalIOAdded(this,stream,p,&sendit);
Q_EMIT signalIOAdded(this,stream,p,&sendit);
if (sendit )
{
quint32 sender = p->id();
......@@ -377,7 +377,7 @@ void KGameProcessIO::notifyTurn(bool b)
QByteArray buffer;
QDataStream stream(&buffer,QIODevice::WriteOnly);
stream << (qint8)b;
emit signalPrepareTurn(stream,b,this,&sendit);
Q_EMIT signalPrepareTurn(stream,b,this,&sendit);
if (sendit)
{
quint32 sender=player()->id();
......@@ -448,7 +448,7 @@ void KGameProcessIO::receivedMessage(const QByteArray& receiveBuffer)
// This is a dummy message which allows us the process to talk with its owner
if (msgid==KGameMessage::IdProcessQuery)
{
emit signalProcessQuery(ostream,this);
Q_EMIT signalProcessQuery(ostream,this);
}
else if (player())
{
......@@ -574,7 +574,7 @@ void KGameComputerIO::advance()
void KGameComputerIO::reaction()
{
emit signalReaction();
Q_EMIT signalReaction();
}
......@@ -231,7 +231,7 @@ bool KGameNetwork::connectToServer (KMessageIO *connection)
qCDebug(GAMES_PRIVATE_KGAME) << " about to set server";
d->mMessageClient->setServer(connection);
emit signalAdminStatusChanged(false); // as we delete the connection above isAdmin() is always false now!
Q_EMIT signalAdminStatusChanged(false); // as we delete the connection above isAdmin() is always false now!
// OK: We say that we already have connected, but this isn't so yet!
// If the connection cannot be established, it will look as being disconnected
......@@ -488,7 +488,7 @@ void KGameNetwork::receiveNetworkTransmission(const QByteArray& receiveBuffer, q
qCDebug(GAMES_PRIVATE_KGAME) << "Got IdError" << error;
text = KGameError::errorText(error, stream);
qCDebug(GAMES_PRIVATE_KGAME) << "Error text:" << text.toLatin1();
emit signalNetworkErrorMessage((int)error,text);
Q_EMIT signalNetworkErrorMessage((int)error,text);
}
else
{
......@@ -499,7 +499,7 @@ void KGameNetwork::receiveNetworkTransmission(const QByteArray& receiveBuffer, q
// -------------- slots for the signals of the client
void KGameNetwork::slotAdminStatusChanged(bool isAdmin)
{
emit signalAdminStatusChanged(isAdmin);
Q_EMIT signalAdminStatusChanged(isAdmin);
// TODO: I'm pretty sure there are a lot of things that should be done here...
}
......
......@@ -288,7 +288,7 @@ void KGamePropertyHandler::unlockDirectEmit()
{
KGamePropertyBase *prop=d->mSignalQueue.dequeue();
// qDebug() << "emitting signal for" << prop->id();
emit signalPropertyChanged(prop);
Q_EMIT signalPropertyChanged(prop);
}
}
}
......@@ -308,14 +308,14 @@ void KGamePropertyHandler::emitSignal(KGamePropertyBase *prop)
else
{
// directly emit
emit signalPropertyChanged(prop);
Q_EMIT signalPropertyChanged(prop);
}
}
bool KGamePropertyHandler::sendProperty(QDataStream &s)
{
bool sent = false;
emit signalSendMessage(id(), s, &sent);
Q_EMIT signalSendMessage(id(), s, &sent);
return sent;
}
......@@ -374,7 +374,7 @@ QString KGamePropertyHandler::propertyValue(KGamePropertyBase* prop)
} else if (*t == typeid(qint8)) {
value = ((KGamePropertyBool*)prop)->value() ? i18n("True") : i18n("False");
} else {
emit signalRequestValue(prop, value);
Q_EMIT signalRequestValue(prop, value);
}
if (value.isNull()) {
......
......@@ -221,7 +221,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
{
quint32 clientID;
in_stream >> clientID;
emit broadcastReceived (in_buffer.readAll(), clientID);
Q_EMIT broadcastReceived (in_buffer.readAll(), clientID);
}
break;
......@@ -230,7 +230,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
quint32 clientID;
QList <quint32> receivers;
in_stream >> clientID >> receivers;
emit forwardReceived (in_buffer.readAll(), clientID, receivers);
Q_EMIT forwardReceived (in_buffer.readAll(), clientID, receivers);
}
break;
......@@ -241,7 +241,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
in_stream >> clientID;
d->connection->setId (clientID);
if (old_admin != isAdmin())
emit adminStatusChanged (isAdmin());
Q_EMIT adminStatusChanged (isAdmin());
}
break;
......@@ -250,7 +250,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
bool old_admin = isAdmin();
in_stream >> d->adminID;
if (old_admin != isAdmin())
emit adminStatusChanged (isAdmin());
Q_EMIT adminStatusChanged (isAdmin());
}
break;
......@@ -270,7 +270,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
else
d->clientList.append (id);
emit eventClientConnected (id);
Q_EMIT eventClientConnected (id);
}
break;
......@@ -285,7 +285,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
else
d->clientList.removeAll (id);
emit eventClientDisconnected (id, bool (broken));
Q_EMIT eventClientDisconnected (id, bool (broken));
}
break;
......@@ -296,7 +296,7 @@ void KMessageClient::processMessage (const QByteArray &msg)
if (!unknown && !in_buffer.atEnd())
qCWarning(GAMES_PRIVATE_KGAME) << ": Extra data received for message ID" << messageID;
emit serverMessageReceived (msg, unknown);
Q_EMIT serverMessageReceived (msg, unknown);
if (unknown)
qCWarning(GAMES_PRIVATE_KGAME) << ": received unknown message ID" << messageID;
......@@ -331,11 +331,11 @@ void KMessageClient::removeBrokenConnection2 ()
{
qCDebug(GAMES_PRIVATE_KGAME) << ": Broken:Deleting the connection object"<<this;
emit aboutToDisconnect(id());
Q_EMIT aboutToDisconnect(id());
delete d->connection;
d->connection = nullptr;
d->adminID = 0;
emit connectionBroken();
Q_EMIT connectionBroken();
qCDebug(GAMES_PRIVATE_KGAME) << ": Broken:Deleting the connection object DONE";
}
......@@ -343,11 +343,11 @@ void KMessageClient::disconnect ()
{
qCDebug(GAMES_PRIVATE_KGAME) << ": Disconnect:Deleting the connection object";
emit aboutToDisconnect(id());
Q_EMIT aboutToDisconnect(id());
delete d->connection;
d->connection = nullptr;
d->adminID = 0;
emit connectionBroken();
Q_EMIT connectionBroken();
qCDebug(GAMES_PRIVATE_KGAME) << ": Disconnect:Deleting the connection object DONE";
}
......
......@@ -141,7 +141,7 @@ void KMessageSocket::processNewData ()
str.readRawData (msg.data(), mNextBlockLength);
// send the received message
emit received (msg);
Q_EMIT received (msg);
// Waiting for the header of the next message
mAwaitingHeader = true;
......@@ -204,7 +204,7 @@ KMessageDirect::~KMessageDirect ()
if (mPartner)
{
mPartner->mPartner = nullptr;
emit mPartner->connectionBroken();
Q_EMIT mPartner->connectionBroken();
}
}
......@@ -216,7 +216,7 @@ bool KMessageDirect::isConnected () const
void KMessageDirect::send (const QByteArray &msg)
{
if (mPartner)
emit mPartner->received (msg);
Q_EMIT mPartner->received (msg);
else
qCCritical(GAMES_PRIVATE_KGAME) << ": Not yet connected!";
}
......@@ -301,7 +301,7 @@ void KMessageProcess::slotReceivedStderr()
ba.chop( 1 ); // remove QLatin1Char( '\n' )
qCDebug(GAMES_PRIVATE_KGAME) << "KProcess (" << ba.size() << "):" << ba.constData();
emit signalReceivedStderr(QLatin1String( ba ));
Q_EMIT signalReceivedStderr(QLatin1String( ba ));
ba.clear();
};
}
......@@ -345,7 +345,7 @@ void KMessageProcess::slotReceivedStdout()
std::copy(mReceiveBuffer.begin()+2*sizeof(long),mReceiveBuffer.begin()+len, msg.begin());
// msg.duplicate(mReceiveBuffer.data()+2*sizeof(long),len-2*sizeof(long));
emit received(msg);
Q_EMIT received(msg);
// msg.resetRawData(mReceiveBuffer.data()+2*sizeof(long),len-2*sizeof(long));
// Shift buffer
if (len<mReceiveCount)
......@@ -361,7 +361,7 @@ void KMessageProcess::slotReceivedStdout()
void KMessageProcess::slotProcessExited(int exitCode, QProcess::ExitStatus)
{
qCDebug(GAMES_PRIVATE_KGAME) << "Process exited (slot) with code" << exitCode;
emit connectionBroken();
Q_EMIT connectionBroken();
delete mProcess;
mProcess=nullptr;
}
......
......@@ -47,7 +47,7 @@ void KMessageServerSocket::slotNewConnection ()
{
if (hasPendingConnections())
{
emit newClientConnected (new KMessageSocket (nextPendingConnection()));
Q_EMIT newClientConnected (new KMessageSocket (nextPendingConnection()));
}
}
......@@ -224,7 +224,7 @@ void KMessageServer::addClient (KMessageIO* client)
client->send (msg);
}
emit clientConnected (client);
Q_EMIT clientConnected (client);
}
void KMessageServer::removeClient (KMessageIO* client, bool broken)
......@@ -267,7 +267,7 @@ void KMessageServer::removeBrokenClient ()
return;
}
emit connectionLost (client);
Q_EMIT connectionLost (client);
removeClient (client, true);
}
......@@ -499,7 +499,7 @@ void KMessageServer::processOneMessage ()
if (!unknown && !in_buffer.atEnd())
qCWarning(GAMES_PRIVATE_KGAME) << ": Extra data received for message ID" << messageID;
emit messageReceived (msg_buf->data, clientID, unknown);
Q_EMIT messageReceived (msg_buf->data, clientID, unknown);
if (unknown)
qCWarning(GAMES_PRIVATE_KGAME) << ": received unknown message ID" << messageID;
......
......@@ -39,7 +39,7 @@ public:
explicit KMessageServerSocket (quint16 port, QObject *parent = nullptr);
~KMessageServerSocket ();
public slots:
public Q_SLOTS:
void slotNewConnection();
Q_SIGNALS:
......
......@@ -388,7 +388,7 @@ bool KPlayer::load(QDataStream &stream)
qCCritical(GAMES_PRIVATE_KGAME) << " Player loading error. probably format error";
}
// emit signalLoad(stream);
// Q_EMIT signalLoad(stream);
return true;
}
......@@ -400,7 +400,7 @@ bool KPlayer::save(QDataStream &stream)
stream << (qint16)KPLAYER_LOAD_COOKIE;
//emit signalSave(stream);
//Q_EMIT signalSave(stream);
return true;
}
......@@ -432,7 +432,7 @@ void KPlayer::networkTransmission(QDataStream &stream,int msgid,quint32 sender)
}
break;
default:
emit signalNetworkData(msgid - KGameMessage::IdUser,
Q_EMIT signalNetworkData(msgid - KGameMessage::IdUser,
((QBuffer*)stream.device())->readAll(),sender,this);
qCDebug(GAMES_PRIVATE_KGAME) << ": "
<< "User data msgid" << msgid;
......@@ -475,7 +475,7 @@ void KPlayer::emitSignal(KGamePropertyBase *me)
it.next()->notifyTurn(d->mMyTurn.value());
}
}
emit signalPropertyChanged(me,this);
Q_EMIT signalPropertyChanged(me,this);
}
// --------------------- DEBUG --------------------
......
......@@ -981,7 +981,7 @@ QRect KGameCanvasAdapter::childRect()
{
if (!m_child_rect_valid) {
m_child_rect = QRect();
foreach (KGameCanvasItem* el, m_items) {
for (KGameCanvasItem* el : qAsConst(m_items)) {
m_child_rect |= el->rect();
}
m_child_rect_valid = true;
......@@ -992,7 +992,7 @@ QRect KGameCanvasAdapter::childRect()
void KGameCanvasAdapter::render(QPainter *painter)
{
foreach (KGameCanvasItem* el, m_items) {
for (KGameCanvasItem* el : qAsConst(m_items)) {
if (el->m_visible) {
el->m_last_rect = el->rect();
el->paintInternal(painter, childRect(), childRect(), QPoint(), 1.0);
......@@ -1004,7 +1004,7 @@ void KGameCanvasAdapter::ensurePendingUpdate()
{
m_child_rect_valid = false;
foreach (KGameCanvasItem* el, m_items) {
for (KGameCanvasItem* el : qAsConst(m_items)) {
if (el->m_changed) {
el->updateChanges();
}
......
......@@ -183,7 +183,7 @@ void KGameDifficultyPrivate::rebuildActions()
m_comboBox->clear();
std::sort(m_standardLevels.begin(), m_standardLevels.end());
foreach(KGameDifficulty::standardLevel level, m_standardLevels) {
for (KGameDifficulty::standardLevel level : qAsConst(m_standardLevels)) {
if (level!=KGameDifficulty::Configurable) {
m_menu->addAction(standardLevelString(level).second);
m_comboBox->addItem(QIcon::fromTheme( QStringLiteral( "games-difficult" )), standardLevelString(level).second);
......@@ -191,7 +191,7 @@ void KGameDifficultyPrivate::rebuildActions()
}
if (!m_customLevels.isEmpty()) {
foreach(const QString &s, m_customLevels) {
for (const QString &s : qAsConst(m_customLevels)) {
m_menu->addAction(s);
m_comboBox->addItem(QIcon::fromTheme( QStringLiteral( "games-difficult" )), s);
}
......@@ -225,7 +225,7 @@ void KGameDifficultyPrivate::setSelection(int newSelection)
else if(newSelection<countWithoutConfigurable)
KGameDifficulty::setLevel(m_standardLevels[newSelection]);
else
KGameDifficulty::setLevelCustom((m_customLevels.uniqueKeys()).value(newSelection - countWithoutConfigurable));
KGameDifficulty::setLevelCustom((m_customLevels.keys()).value(newSelection - countWithoutConfigurable));
m_oldSelection = newSelection;
}
......@@ -247,7 +247,7 @@ void KGameDifficultyPrivate::setLevel(KGameDifficulty::standardLevel level)
if (level != m_level) {
m_level = level;
emit standardLevelChanged(level);
Q_EMIT standardLevelChanged(level);
}
m_oldSelection = m_menu->currentItem();
......@@ -262,13 +262,13 @@ void KGameDifficultyPrivate::setLevelCustom(int key)
if (m_standardLevels.contains(KGameDifficulty::Configurable))
a -= 1;
int i = (m_customLevels.uniqueKeys()).indexOf(key) + a;
int i = (m_customLevels.keys()).indexOf(key) + a;
m_menu->setCurrentItem(i);
m_comboBox->setCurrentIndex(i);
if (key != m_levelCustom) {
m_levelCustom = key;
emit customLevelChanged(key);
Q_EMIT customLevelChanged(key);
}
m_oldSelection = m_menu->currentItem();
......
......@@ -143,8 +143,7 @@ void KGameThemeSelector::KGameThemeSelectorPrivate::findThemes(const QString &in
{
// TODO change this if we ever change KGameTheme::loadDefault
QString defaultPath = QStringLiteral( "themes/default.desktop" );
foreach(KGameTheme* theme, themeMap)
{
for (KGameTheme* theme : qAsConst(themeMap)) {
if (theme->path().endsWith(defaultPath))
{
const QList<QListWidgetItem *> itemList = ui.themeList->findItems(theme->themeProperty(QStringLiteral( "Name" )), Qt::MatchExactly);
......
......@@ -31,7 +31,7 @@ class tst_KGamePropertyTest : public QObject
Q_OBJECT
// Declare test functions as private slots, or they won't get executed
private slots:
private Q_SLOTS:
/// @brief This function is called first, so you can do init stuff here.
void initTestCase();
......
......@@ -29,7 +29,7 @@ class tst_KGameSvgDocument : public QObject
KGameSvgDocument m_svgDom;
// Declare test functions as private slots, or they won't get executed
private slots:
private Q_SLOTS:
/// @brief This function is called first, so you can do init stuff here.
void initTestCase();
......
......@@ -32,7 +32,7 @@ class KGpiMainWindow : public KXmlGuiWindow
Q_OBJECT
public:
KGpiMainWindow();
private slots:
private Q_SLOTS:
void onPopupTL();
void onPopupTR();
void onPopupBL();
......