KgDifficulty

Search for usage in LXR

#include <KgDifficulty>

Inheritance diagram for KgDifficulty:

Properties

const KgDifficultyLevel currentLevel
 
bool editable
 
bool gameRunning
 
const KgDifficultyLevel selectedLevel
 
- Properties inherited from QObject
 objectName
 

Signals

void currentLevelChanged (const KgDifficultyLevel *level)
 
void editableChanged (bool editable)
 
void gameRunningChanged (bool gameRunning)
 
void selectedLevelChanged (const KgDifficultyLevel *level)
 

Public Slots

void select (const KgDifficultyLevel *level)
 

Public Member Functions

 KgDifficulty (QObject *parent=nullptr)
 
 ~KgDifficulty () override
 
void addLevel (KgDifficultyLevel *level)
 
void addStandardLevel (KgDifficultyLevel::StandardLevel level, bool isDefault=false)
 
void addStandardLevelRange (KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to)
 
void addStandardLevelRange (KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to, KgDifficultyLevel::StandardLevel defaultLevel)
 
const KgDifficultyLevelcurrentLevel () const
 
bool isEditable () const
 
bool isGameRunning () const
 
QList< const KgDifficultyLevel * > levels () const
 
void setEditable (bool editable)
 
void setGameRunning (bool running)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

KgDifficulty manages difficulty levels of a game in a standard way.

The difficulty can be a type of game (like in KMines: small or big field) or the AI skills (like in Bovo: how deep should the computer search to find the best move) or a combination of both of them. On the user point of view, it's not really different: either is the game easy or hard to play.

KgDifficulty contains a list of KgDifficultyLevel instances. One of these levels is selected; this selection will be recorded when the application is closed. A set of standard difficulty levels is provided by KgDifficultyLevel, but custom levels can be defined at the same time.

Definition at line 87 of file kgdifficulty.h.

Constructor & Destructor Documentation

◆ ~KgDifficulty()

KgDifficulty::~KgDifficulty ( )
override

Destroys this instance and all DifficultyLevel instances in it.

Definition at line 165 of file kgdifficulty.cpp.

Member Function Documentation

◆ addLevel()

void KgDifficulty::addLevel ( KgDifficultyLevel level)

Adds a difficulty level to this instance.

This will not affect the currentLevel() if there is one.

Definition at line 170 of file kgdifficulty.cpp.

◆ addStandardLevel()

void KgDifficulty::addStandardLevel ( KgDifficultyLevel::StandardLevel  level,
bool  isDefault = false 
)

A shortcut for addLevel(new KgDifficultyLevel(level)).

Definition at line 188 of file kgdifficulty.cpp.

◆ addStandardLevelRange() [1/2]

void KgDifficulty::addStandardLevelRange ( KgDifficultyLevel::StandardLevel  from,
KgDifficultyLevel::StandardLevel  to 
)

This convenience method adds a range of standard levels to this instance (including the boundaries).

For example:

KgDifficultyLevel::Easy,
KgDifficultyLevel::VeryHard
);

This adds the levels "Easy", "Medium", "Hard" and "Very hard".

Definition at line 193 of file kgdifficulty.cpp.

◆ addStandardLevelRange() [2/2]

void KgDifficulty::addStandardLevelRange ( KgDifficultyLevel::StandardLevel  from,
KgDifficultyLevel::StandardLevel  to,
KgDifficultyLevel::StandardLevel  defaultLevel 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload allows to specify a defaultLevel.

Definition at line 199 of file kgdifficulty.cpp.

◆ currentLevel()

const KgDifficultyLevel* KgDifficulty::currentLevel ( ) const
Returns
the current difficulty level

After the KgDifficulty object has been created, the current difficulty level will not be determined until this method is called for the first time. This allows the application developer to set up the difficulty levels before KgDifficulty retrieves the last selected level from the configuration file.

◆ currentLevelChanged

void KgDifficulty::currentLevelChanged ( const KgDifficultyLevel level)
signal

Emitted when a new difficulty level has been selected.

◆ editableChanged

void KgDifficulty::editableChanged ( bool  editable)
signal

Emitted when the editability changes.

See also
setEditable

◆ gameRunningChanged

void KgDifficulty::gameRunningChanged ( bool  gameRunning)
signal

Emitted when a running game has been marked or unmarked.

See also
setGameRunning

◆ isEditable()

bool KgDifficulty::isEditable ( ) const
Returns
whether the difficulty level selection may be edited

Definition at line 252 of file kgdifficulty.cpp.

◆ isGameRunning()

bool KgDifficulty::isGameRunning ( ) const
Returns
whether a running game has been marked
See also
setGameRunning

Definition at line 266 of file kgdifficulty.cpp.

◆ levels()

QList< const KgDifficultyLevel * > KgDifficulty::levels ( ) const
Returns
a list of all difficulty levels, sorted by hardness

Definition at line 223 of file kgdifficulty.cpp.

◆ select

void KgDifficulty::select ( const KgDifficultyLevel level)
slot

Select a new difficulty level.

The given level must already have been added to this instance.

Note
This does nothing if isEditable() is false. If a game is running (according to setGameRunning()), the user will be asked for confirmation before the new difficulty level is selected.

Definition at line 280 of file kgdifficulty.cpp.

◆ selectedLevelChanged

void KgDifficulty::selectedLevelChanged ( const KgDifficultyLevel level)
signal

Emitted after every call to select(), even when the user has rejected the change.

This is useful to reset a difficulty level selection UI after a rejected change.

◆ setEditable()

void KgDifficulty::setEditable ( bool  editable)

Set whether the difficulty level selection may be edited.

The default value is true.

Definition at line 257 of file kgdifficulty.cpp.

◆ setGameRunning()

void KgDifficulty::setGameRunning ( bool  running)

KgDifficulty has optional protection against changing the difficulty level while a game is running.

If setGameRunning(true) has been called, and select() is called to select a new difficulty level, the user will be asked for confirmation.

Definition at line 271 of file kgdifficulty.cpp.


The documentation for this class was generated from the following files:
KgDifficulty * difficulty()
void addStandardLevelRange(KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to)
This convenience method adds a range of standard levels to this instance (including the boundaries).
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Dec 4 2022 03:50:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.