libkdegames
KCardDialog Class Reference
#include <kcarddialog.h>

Detailed Description
A carddeck selection dialog for card games.The KCardDialog provides a dialog for interactive carddeck selection. It gives cardgames an easy to use interface to select front and back of the card sets. As card sets the KDE default cardsets are offered as well as used specified ones.
In most cases, the simplest use of this class is the static method KCardDialog::getCardDeck, which pops up the dialog, allows the user to select a carddeck, and returns when the dialog is closed. Only if you really need some specific behaviour or if you overwrite the dialog you need all the other access functions.
Card sets (front and back) are identified by their (translated) names. Access to further properties of the sets like their filenames or directories is achieved by querying the dialog using static functions where as argument the card deck or set name is given as argument.
Example:
QString front,back; int result = KCardDialog::getCardDeck(front, back); if ( result == KCardDialog::Accepted ) ...
Retrieve the filename and information for the card back (deck):
QString front,back; int result = KCardDialog::getCardDeck(front, back); ... QString deckFile = KCardDialog::deckSVGFilePath(back); bool isSVG = KCardDialog::isSVGDeck(back); ...
Retrieve the SVG information for the card set (front):
QString front,back; int result = KCardDialog::getCardDeck(front, back); ... QString cardFile = KCardDialog::cardSVGFilePath(front); bool isSVG = KCardDialog::isSVGCards(front); ...
Here you can see a card dialog in action
KCarddialog
KCardDialog::getCardDeck takes additionalparameters for custumization. You can e.g. retrieve a random card deck, limit the choice to scalable or fixed size decks, or lock the front and backside together.
You can also provide a KConfigGroup reference to the dialog. This is used to store information about the dialog.
Definition at line 92 of file kcarddialog.h.
Public Member Functions | |
| KCardDialog (QWidget *parent=NULL, bool pAllowSVG=true, bool pAllowPNG=true, bool pLock=true, QString defFront=QString(), QString defBack=QString()) | |
| KCardDialog (KConfigGroup &group, QWidget *parent=NULL) | |
| ~KCardDialog () | |
| void | saveSettings (KConfigGroup &group) |
| QString | deckName () const |
| QString | cardName () const |
Static Public Member Functions | |
| static int | getCardDeck (QString &pFrontName, QString &pBackName, QWidget *pParent=NULL, bool pAllowSVG=true, bool pAllowPNG=true, bool pLock=true, bool pRandom=false) |
| static QString | deckSVGFilePath (const QString &name) |
| static QString | cardSVGFilePath (const QString &name) |
| static bool | isSVGCard (const QString &name) |
| static bool | isSVGDeck (const QString &name) |
| static QString | defaultCardName (bool pAllowSVG=true, bool pAllowPNG=true) |
| static QString | defaultDeckName (bool pAllowSVG=true, bool pAllowPNG=true) |
| static QString | randomCardName (bool pAllowSVG=true, bool pAllowPNG=true) |
| static QString | randomDeckName (bool pAllowSVG=true, bool pAllowPNG=true) |
| static QString | cardDir (const QString &name) |
| static QString | deckFilename (const QString &name) |
| static void | reset () |
| static QString | getDefaultCardDir (bool pAllowSVG=true, bool pAllowPNG=true) |
| static QString | getDefaultDeck (bool pAllowSVG=true, bool pAllowPNG=true) |
Protected Slots | |
| void | updateFront () |
| void | updateBack () |
| void | updateLocking (int state) |
| void | updateSVG (int state) |
| void | updatePNG (int state) |
Protected Member Functions | |
| void | insertCardIcons () |
| void | insertDeckIcons () |
| void | updateBack (QString item) |
| void | updateFront (QString item) |
| void | setupGUI () |
Static Protected Member Functions | |
| static void | readFronts () |
| static void | readBacks () |
| static QString | findi18nBack (QString &name) |
| static QString | getDeckFileNameFromIndex (const QString &desktop) |
| static QString | group () |
Constructor & Destructor Documentation
| KCardDialog::KCardDialog | ( | QWidget * | parent = NULL, |
|
| bool | pAllowSVG = true, |
|||
| bool | pAllowPNG = true, |
|||
| bool | pLock = true, |
|||
| QString | defFront = QString(), |
|||
| QString | defBack = QString() | |||
| ) | [explicit] |
Constructs a card deck selection dialog.
- Parameters:
-
parent The parent widget of the dialog, if any. pAllowSVG Allow selection of scalable cards sets. pAllowPNG Allow selection of fixed size cards sets. pLock Back side is set to match the front side of cards. defFront Default front side name. defBack Default back side name.
Definition at line 189 of file kcarddialog.cpp.
| KCardDialog::KCardDialog | ( | KConfigGroup & | group, | |
| QWidget * | parent = NULL | |||
| ) | [explicit] |
Constructs a card deck selection dialog.
- Parameters:
-
group The configuration group for dialog parent The parent widget of the dialog, if any.
Definition at line 206 of file kcarddialog.cpp.
| KCardDialog::~KCardDialog | ( | ) |
Member Function Documentation
| int KCardDialog::getCardDeck | ( | QString & | pFrontName, | |
| QString & | pBackName, | |||
| QWidget * | pParent = NULL, |
|||
| bool | pAllowSVG = true, |
|||
| bool | pAllowPNG = true, |
|||
| bool | pLock = true, |
|||
| bool | pRandom = false | |||
| ) | [static] |
Creates a modal carddeck dialog, lets the user choose a deck, and returns when the dialog is closed.
- Parameters:
-
pFrontName A reference to the card front side name. Holds the result of the user choice. pBackName A reference to the card back side name. Holds the result of the user choice. pParent Pointer to the parent window of the dialog pAllowSVG Allow selection of scalable cards sets. pAllowPNG Allow selection of fixed size cards sets. pLock Back side is set to match the front side of cards. pRandom Return a random selection for front and back side.
- Returns:
- QDialog::result().
Definition at line 336 of file kcarddialog.cpp.
| void KCardDialog::saveSettings | ( | KConfigGroup & | group | ) |
Saves the KCardDialog config into a config file.
These settings are used by KCardDialog.
Definition at line 225 of file kcarddialog.cpp.
Retrieve the SVG file belonging to the given card deck (back side).
- Parameters:
-
name The name of the back deck.
- Returns:
- The file name and path to the SVG file or QString() if not available.
Definition at line 859 of file kcarddialog.cpp.
Retrieve the SVG file belonging to the given card set (front side).
The SVG IDs used for the card back is '1_club' for Ace of clubs, '10_spade' for 10 of spades, 'queen_heart' for Queen of Hearts, '2_diamond' for 2 of diamonds and so on.
- Parameters:
-
name The name of the card set.
- Returns:
- The file name and path to the SVG file or QString() if not available.
Definition at line 869 of file kcarddialog.cpp.
| bool KCardDialog::isSVGCard | ( | const QString & | name | ) | [static] |
Check whether the card set is SVG or not.
- Parameters:
-
name The name of the card set.
- Returns:
- True if SVG data is available.
Definition at line 899 of file kcarddialog.cpp.
| bool KCardDialog::isSVGDeck | ( | const QString & | name | ) | [static] |
Check whether the card back deck contains also an SVG file.
- Parameters:
-
name The name of the card deck.
- Returns:
- True if SVG data is available.
Definition at line 909 of file kcarddialog.cpp.
| QString KCardDialog::defaultCardName | ( | bool | pAllowSVG = true, |
|
| bool | pAllowPNG = true | |||
| ) | [static] |
Retrieve the name of the default card set (front side).
- Parameters:
-
pAllowSVG Allow selection of scalable cards sets. pAllowPNG Allow selection of fixed size cards sets.
- Returns:
- The default card set name.
Definition at line 569 of file kcarddialog.cpp.
| QString KCardDialog::defaultDeckName | ( | bool | pAllowSVG = true, |
|
| bool | pAllowPNG = true | |||
| ) | [static] |
Retrieve the name of the default card deck (back side).
- Parameters:
-
pAllowSVG Allow selection of scalable cards sets. pAllowPNG Allow selection of fixed size cards sets.
- Returns:
- The default card deck name.
Definition at line 591 of file kcarddialog.cpp.
| QString KCardDialog::randomCardName | ( | bool | pAllowSVG = true, |
|
| bool | pAllowPNG = true | |||
| ) | [static] |
Retrieve a random card set (front side).
- Parameters:
-
pAllowSVG Allow selection of scalable cards sets. pAllowPNG Allow selection of fixed size cards sets.
- Returns:
- A radnom card set name.
Definition at line 616 of file kcarddialog.cpp.
| QString KCardDialog::randomDeckName | ( | bool | pAllowSVG = true, |
|
| bool | pAllowPNG = true | |||
| ) | [static] |
Retrieve a random card deck (back side).
- Parameters:
-
pAllowSVG Allow selection of scalable cards sets. pAllowPNG Allow selection of fixed size cards sets.
- Returns:
- A radnom card deck name.
Definition at line 640 of file kcarddialog.cpp.
Retrieve the directory where the card front sides are stored.
The cards are named 1.png, 2.png, etc. For SVG card decks use cardSVGFilePath.
- Parameters:
-
name The name of the card set.
- Returns:
- The directory.
Definition at line 889 of file kcarddialog.cpp.
Retrieve the filename of the card back side.
For SVG decks use deckSVGFilePath.
- Parameters:
-
name The name of the card deck.
- Returns:
- The filename.
Definition at line 879 of file kcarddialog.cpp.
| QString KCardDialog::deckName | ( | ) | const |
Retrieve the name of the card deck (back side) from the dialog.
- Returns:
- The deck name.
Definition at line 370 of file kcarddialog.cpp.
| QString KCardDialog::cardName | ( | ) | const |
Retrieve the name of the card set (front side) from the dialog.
- Returns:
- The card set name.
Definition at line 377 of file kcarddialog.cpp.
| void KCardDialog::reset | ( | ) | [static] |
Reset the static information of the dialog.
In particular reread the card information. Only necessary to call if something changed there, like installing new card decks.
Definition at line 327 of file kcarddialog.cpp.
| QString KCardDialog::getDefaultCardDir | ( | bool | pAllowSVG = true, |
|
| bool | pAllowPNG = true | |||
| ) | [static] |
Retreive the default card directory.
- Deprecated:
- KDE 3.x compatibilty
Definition at line 551 of file kcarddialog.cpp.
| QString KCardDialog::getDefaultDeck | ( | bool | pAllowSVG = true, |
|
| bool | pAllowPNG = true | |||
| ) | [static] |
Retrieve the default deck filename.
- Deprecated:
- KDE 3.x compatibilty
Definition at line 560 of file kcarddialog.cpp.
| void KCardDialog::readFronts | ( | ) | [static, protected] |
| void KCardDialog::readBacks | ( | ) | [static, protected] |
| void KCardDialog::insertCardIcons | ( | ) | [protected] |
| void KCardDialog::insertDeckIcons | ( | ) | [protected] |
| void KCardDialog::updateBack | ( | QString | item | ) | [protected] |
Update the back side preview image.
- Parameters:
-
item The name of the deck.
Definition at line 734 of file kcarddialog.cpp.
| void KCardDialog::updateFront | ( | QString | item | ) | [protected] |
Update the front side preview image.
- Parameters:
-
item The name of the card set.
Definition at line 503 of file kcarddialog.cpp.
| void KCardDialog::setupGUI | ( | ) | [protected] |
Find the translated name for the card back side given the non translated one.
Necessary for card back side locking.
- Parameters:
-
name The untranslated back side name.
- Returns:
- The translated back side name.
Definition at line 439 of file kcarddialog.cpp.
Retrieve the filename of the PNG file for the backside of a deck.
diven the index.desktop filename.
- Parameters:
-
desktop The name of the index.desktop file.
- Returns:
- The name of the PNG file.
Definition at line 844 of file kcarddialog.cpp.
| static QString KCardDialog::group | ( | ) | [static, protected] |
- Returns:
- the groupname.
| void KCardDialog::updateFront | ( | ) | [protected, slot] |
Called by the card set list view when a new item was selected.
Definition at line 493 of file kcarddialog.cpp.
| void KCardDialog::updateBack | ( | ) | [protected, slot] |
Called by the card deck list view when a new item was selected.
- Parameters:
-
current The newly selected item. last The previously selected item.
Definition at line 725 of file kcarddialog.cpp.
| void KCardDialog::updateLocking | ( | int | state | ) | [protected, slot] |
Called by the checkboxes when the state of the locking changed.
- Parameters:
-
state The new locking state.
Definition at line 664 of file kcarddialog.cpp.
| void KCardDialog::updateSVG | ( | int | state | ) | [protected, slot] |
Called by the checkboxes when the state of the SVG filter changed.
- Parameters:
-
state The new SVG filter state.
Definition at line 681 of file kcarddialog.cpp.
| void KCardDialog::updatePNG | ( | int | state | ) | [protected, slot] |
Called by the checkboxes when the state of the PNG filter changed.
- Parameters:
-
state The new PNG filter state.
Definition at line 703 of file kcarddialog.cpp.
The documentation for this class was generated from the following files:
KDE 4.0 API Reference