fixed issue #37: add option to manually add token cards to the database
This commit is contained in:
parent
d5a1032cf3
commit
3ba3952604
15 changed files with 434 additions and 93 deletions
|
@ -9,6 +9,7 @@ SET(cockatrice_SOURCES
|
||||||
src/dlg_filter_games.cpp
|
src/dlg_filter_games.cpp
|
||||||
src/dlg_connect.cpp
|
src/dlg_connect.cpp
|
||||||
src/dlg_create_token.cpp
|
src/dlg_create_token.cpp
|
||||||
|
src/dlg_edit_tokens.cpp
|
||||||
src/abstractclient.cpp
|
src/abstractclient.cpp
|
||||||
src/remoteclient.cpp
|
src/remoteclient.cpp
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
|
@ -85,6 +86,7 @@ SET(cockatrice_HEADERS
|
||||||
src/dlg_filter_games.h
|
src/dlg_filter_games.h
|
||||||
src/dlg_connect.h
|
src/dlg_connect.h
|
||||||
src/dlg_create_token.h
|
src/dlg_create_token.h
|
||||||
|
src/dlg_edit_tokens.h
|
||||||
src/gamesmodel.h
|
src/gamesmodel.h
|
||||||
src/abstractclient.h
|
src/abstractclient.h
|
||||||
src/remoteclient.h
|
src/remoteclient.h
|
||||||
|
|
|
@ -440,9 +440,11 @@ CardDatabase::CardDatabase(QObject *parent)
|
||||||
{
|
{
|
||||||
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(picsPathChanged()));
|
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(picsPathChanged()));
|
||||||
connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase()));
|
connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase()));
|
||||||
|
connect(settingsCache, SIGNAL(tokenDatabasePathChanged()), this, SLOT(loadTokenDatabase()));
|
||||||
connect(settingsCache, SIGNAL(picDownloadChanged()), this, SLOT(picDownloadChanged()));
|
connect(settingsCache, SIGNAL(picDownloadChanged()), this, SLOT(picDownloadChanged()));
|
||||||
|
|
||||||
loadCardDatabase();
|
loadCardDatabase();
|
||||||
|
loadTokenDatabase();
|
||||||
|
|
||||||
pictureLoaderThread = new QThread;
|
pictureLoaderThread = new QThread;
|
||||||
pictureLoader = new PictureLoader(settingsCache->getPicsPath(), settingsCache->getPicDownload());
|
pictureLoader = new PictureLoader(settingsCache->getPicsPath(), settingsCache->getPicDownload());
|
||||||
|
@ -482,18 +484,31 @@ void CardDatabase::clear()
|
||||||
cardHash.clear();
|
cardHash.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfo *CardDatabase::getCard(const QString &cardName)
|
void CardDatabase::addCard(CardInfo *card)
|
||||||
|
{
|
||||||
|
cardHash.insert(card->getName(), card);
|
||||||
|
emit cardAdded(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabase::removeCard(CardInfo *card)
|
||||||
|
{
|
||||||
|
cardHash.remove(card->getName());
|
||||||
|
emit cardRemoved(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
CardInfo *CardDatabase::getCard(const QString &cardName, bool createIfNotFound)
|
||||||
{
|
{
|
||||||
if (cardName.isEmpty())
|
if (cardName.isEmpty())
|
||||||
return noCard;
|
return noCard;
|
||||||
else if (cardHash.contains(cardName))
|
else if (cardHash.contains(cardName))
|
||||||
return cardHash.value(cardName);
|
return cardHash.value(cardName);
|
||||||
else {
|
else if (createIfNotFound) {
|
||||||
CardInfo *newCard = new CardInfo(this, cardName, true);
|
CardInfo *newCard = new CardInfo(this, cardName, true);
|
||||||
newCard->addToSet(getSet("TK"));
|
newCard->addToSet(getSet("TK"));
|
||||||
cardHash.insert(cardName, newCard);
|
cardHash.insert(cardName, newCard);
|
||||||
return newCard;
|
return newCard;
|
||||||
}
|
} else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardSet *CardDatabase::getSet(const QString &setName)
|
CardSet *CardDatabase::getSet(const QString &setName)
|
||||||
|
@ -601,14 +616,42 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardDatabase::loadFromFile(const QString &fileName)
|
bool CardDatabase::loadFromFile(const QString &fileName, bool tokens)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
if (!file.isOpen())
|
if (!file.isOpen())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (tokens) {
|
||||||
|
QMutableHashIterator<QString, CardInfo *> i(cardHash);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
if (i.value()->getIsToken()) {
|
||||||
|
delete i.value();
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QHashIterator<QString, CardSet *> setIt(setHash);
|
||||||
|
while (setIt.hasNext()) {
|
||||||
|
setIt.next();
|
||||||
|
delete setIt.value();
|
||||||
|
}
|
||||||
|
setHash.clear();
|
||||||
|
|
||||||
|
QMutableHashIterator<QString, CardInfo *> i(cardHash);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
if (!i.value()->getIsToken()) {
|
||||||
|
delete i.value();
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cardHash.clear();
|
||||||
|
}
|
||||||
|
|
||||||
QXmlStreamReader xml(&file);
|
QXmlStreamReader xml(&file);
|
||||||
clear();
|
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
if (xml.readNext() == QXmlStreamReader::StartElement) {
|
if (xml.readNext() == QXmlStreamReader::StartElement) {
|
||||||
if (xml.name() != "cockatrice_carddatabase")
|
if (xml.name() != "cockatrice_carddatabase")
|
||||||
|
@ -629,7 +672,7 @@ bool CardDatabase::loadFromFile(const QString &fileName)
|
||||||
return !cardHash.isEmpty();
|
return !cardHash.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardDatabase::saveToFile(const QString &fileName)
|
bool CardDatabase::saveToFile(const QString &fileName, bool tokens)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::WriteOnly))
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
@ -641,16 +684,21 @@ bool CardDatabase::saveToFile(const QString &fileName)
|
||||||
xml.writeStartElement("cockatrice_carddatabase");
|
xml.writeStartElement("cockatrice_carddatabase");
|
||||||
xml.writeAttribute("version", QString::number(versionNeeded));
|
xml.writeAttribute("version", QString::number(versionNeeded));
|
||||||
|
|
||||||
|
if (!tokens) {
|
||||||
xml.writeStartElement("sets");
|
xml.writeStartElement("sets");
|
||||||
QHashIterator<QString, CardSet *> setIterator(setHash);
|
QHashIterator<QString, CardSet *> setIterator(setHash);
|
||||||
while (setIterator.hasNext())
|
while (setIterator.hasNext())
|
||||||
xml << setIterator.next().value();
|
xml << setIterator.next().value();
|
||||||
xml.writeEndElement(); // sets
|
xml.writeEndElement(); // sets
|
||||||
|
}
|
||||||
|
|
||||||
xml.writeStartElement("cards");
|
xml.writeStartElement("cards");
|
||||||
QHashIterator<QString, CardInfo *> cardIterator(cardHash);
|
QHashIterator<QString, CardInfo *> cardIterator(cardHash);
|
||||||
while (cardIterator.hasNext())
|
while (cardIterator.hasNext()) {
|
||||||
xml << cardIterator.next().value();
|
CardInfo *card = cardIterator.next().value();
|
||||||
|
if (card->getIsToken() == tokens)
|
||||||
|
xml << card;
|
||||||
|
}
|
||||||
xml.writeEndElement(); // cards
|
xml.writeEndElement(); // cards
|
||||||
|
|
||||||
xml.writeEndElement(); // cockatrice_carddatabase
|
xml.writeEndElement(); // cockatrice_carddatabase
|
||||||
|
@ -669,13 +717,13 @@ void CardDatabase::picDownloadChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardDatabase::loadCardDatabase(const QString &path)
|
bool CardDatabase::loadCardDatabase(const QString &path, bool tokens)
|
||||||
{
|
{
|
||||||
|
bool tempLoadSuccess = false;
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
loadSuccess = loadFromFile(path);
|
tempLoadSuccess = loadFromFile(path, tokens);
|
||||||
else loadSuccess = false;
|
|
||||||
|
|
||||||
if (loadSuccess) {
|
if (tempLoadSuccess) {
|
||||||
SetList allSets;
|
SetList allSets;
|
||||||
QHashIterator<QString, CardSet *> setsIterator(setHash);
|
QHashIterator<QString, CardSet *> setsIterator(setHash);
|
||||||
while (setsIterator.hasNext())
|
while (setsIterator.hasNext())
|
||||||
|
@ -687,12 +735,20 @@ bool CardDatabase::loadCardDatabase(const QString &path)
|
||||||
emit cardListChanged();
|
emit cardListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadSuccess;
|
if (!tokens)
|
||||||
|
loadSuccess = tempLoadSuccess;
|
||||||
|
|
||||||
|
return tempLoadSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardDatabase::loadCardDatabase()
|
void CardDatabase::loadCardDatabase()
|
||||||
{
|
{
|
||||||
return loadCardDatabase(settingsCache->getCardDatabasePath());
|
loadCardDatabase(settingsCache->getCardDatabasePath(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabase::loadTokenDatabase()
|
||||||
|
{
|
||||||
|
loadCardDatabase(settingsCache->getTokenDatabasePath(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CardDatabase::getAllColors() const
|
QStringList CardDatabase::getAllColors() const
|
||||||
|
|
|
@ -130,7 +130,11 @@ public:
|
||||||
const QString &getText() const { return text; }
|
const QString &getText() const { return text; }
|
||||||
const int &getLoyalty() const { return loyalty; }
|
const int &getLoyalty() const { return loyalty; }
|
||||||
bool getCipt() const { return cipt; }
|
bool getCipt() const { return cipt; }
|
||||||
void setText(const QString &_text) { text = _text; }
|
void setManaCost(const QString &_manaCost) { manacost = _manaCost; emit cardInfoChanged(this); }
|
||||||
|
void setCardType(const QString &_cardType) { cardtype = _cardType; emit cardInfoChanged(this); }
|
||||||
|
void setPowTough(const QString &_powTough) { powtough = _powTough; emit cardInfoChanged(this); }
|
||||||
|
void setText(const QString &_text) { text = _text; emit cardInfoChanged(this); }
|
||||||
|
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
|
||||||
const QStringList &getColors() const { return colors; }
|
const QStringList &getColors() const { return colors; }
|
||||||
QString getPicURL(const QString &set) const { return picURLs.value(set); }
|
QString getPicURL(const QString &set) const { return picURLs.value(set); }
|
||||||
QString getPicURLHq(const QString &set) const { return picURLsHq.value(set); }
|
QString getPicURLHq(const QString &set) const { return picURLsHq.value(set); }
|
||||||
|
@ -141,7 +145,7 @@ public:
|
||||||
QString getCorrectedName() const;
|
QString getCorrectedName() const;
|
||||||
int getTableRow() const { return tableRow; }
|
int getTableRow() const { return tableRow; }
|
||||||
void setTableRow(int _tableRow) { tableRow = _tableRow; }
|
void setTableRow(int _tableRow) { tableRow = _tableRow; }
|
||||||
void setLoyalty(int _loyalty) { loyalty = _loyalty; }
|
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
|
||||||
void setPicURL(const QString &_set, const QString &_picURL) { picURLs.insert(_set, _picURL); }
|
void setPicURL(const QString &_set, const QString &_picURL) { picURLs.insert(_set, _picURL); }
|
||||||
void setPicURLHq(const QString &_set, const QString &_picURL) { picURLsHq.insert(_set, _picURL); }
|
void setPicURLHq(const QString &_set, const QString &_picURL) { picURLsHq.insert(_set, _picURL); }
|
||||||
void setPicURLSt(const QString &_set, const QString &_picURL) { picURLsSt.insert(_set, _picURL); }
|
void setPicURLSt(const QString &_set, const QString &_picURL) { picURLsSt.insert(_set, _picURL); }
|
||||||
|
@ -155,6 +159,7 @@ public slots:
|
||||||
void updatePixmapCache();
|
void updatePixmapCache();
|
||||||
signals:
|
signals:
|
||||||
void pixmapUpdated();
|
void pixmapUpdated();
|
||||||
|
void cardInfoChanged(CardInfo *card);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CardDatabase : public QObject {
|
class CardDatabase : public QObject {
|
||||||
|
@ -175,12 +180,14 @@ public:
|
||||||
CardDatabase(QObject *parent = 0);
|
CardDatabase(QObject *parent = 0);
|
||||||
~CardDatabase();
|
~CardDatabase();
|
||||||
void clear();
|
void clear();
|
||||||
CardInfo *getCard(const QString &cardName = QString());
|
void addCard(CardInfo *card);
|
||||||
|
void removeCard(CardInfo *card);
|
||||||
|
CardInfo *getCard(const QString &cardName = QString(), bool createIfNotFound = true);
|
||||||
CardSet *getSet(const QString &setName);
|
CardSet *getSet(const QString &setName);
|
||||||
QList<CardInfo *> getCardList() const { return cardHash.values(); }
|
QList<CardInfo *> getCardList() const { return cardHash.values(); }
|
||||||
SetList getSetList() const;
|
SetList getSetList() const;
|
||||||
bool loadFromFile(const QString &fileName);
|
bool loadFromFile(const QString &fileName, bool tokens = false);
|
||||||
bool saveToFile(const QString &fileName);
|
bool saveToFile(const QString &fileName, bool tokens = false);
|
||||||
QStringList getAllColors() const;
|
QStringList getAllColors() const;
|
||||||
QStringList getAllMainCardTypes() const;
|
QStringList getAllMainCardTypes() const;
|
||||||
bool getLoadSuccess() const { return loadSuccess; }
|
bool getLoadSuccess() const { return loadSuccess; }
|
||||||
|
@ -188,14 +195,18 @@ public:
|
||||||
void loadImage(CardInfo *card);
|
void loadImage(CardInfo *card);
|
||||||
public slots:
|
public slots:
|
||||||
void clearPixmapCache();
|
void clearPixmapCache();
|
||||||
bool loadCardDatabase(const QString &path);
|
bool loadCardDatabase(const QString &path, bool tokens = false);
|
||||||
bool loadCardDatabase();
|
|
||||||
private slots:
|
private slots:
|
||||||
void imageLoaded(CardInfo *card, QImage image);
|
void imageLoaded(CardInfo *card, QImage image);
|
||||||
void picDownloadChanged();
|
void picDownloadChanged();
|
||||||
void picsPathChanged();
|
void picsPathChanged();
|
||||||
|
|
||||||
|
void loadCardDatabase();
|
||||||
|
void loadTokenDatabase();
|
||||||
signals:
|
signals:
|
||||||
void cardListChanged();
|
void cardListChanged();
|
||||||
|
void cardAdded(CardInfo *card);
|
||||||
|
void cardRemoved(CardInfo *card);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,12 +4,13 @@ CardDatabaseModel::CardDatabaseModel(CardDatabase *_db, QObject *parent)
|
||||||
: QAbstractListModel(parent), db(_db)
|
: QAbstractListModel(parent), db(_db)
|
||||||
{
|
{
|
||||||
connect(db, SIGNAL(cardListChanged()), this, SLOT(updateCardList()));
|
connect(db, SIGNAL(cardListChanged()), this, SLOT(updateCardList()));
|
||||||
cardList = db->getCardList();
|
connect(db, SIGNAL(cardAdded(CardInfo *)), this, SLOT(cardAdded(CardInfo *)));
|
||||||
|
connect(db, SIGNAL(cardRemoved(CardInfo *)), this, SLOT(cardRemoved(CardInfo *)));
|
||||||
|
updateCardList();
|
||||||
}
|
}
|
||||||
|
|
||||||
CardDatabaseModel::~CardDatabaseModel()
|
CardDatabaseModel::~CardDatabaseModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardDatabaseModel::rowCount(const QModelIndex &/*parent*/) const
|
int CardDatabaseModel::rowCount(const QModelIndex &/*parent*/) const
|
||||||
|
@ -66,10 +67,44 @@ QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation,
|
||||||
|
|
||||||
void CardDatabaseModel::updateCardList()
|
void CardDatabaseModel::updateCardList()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < cardList.size(); ++i)
|
||||||
|
disconnect(cardList[i], 0, this, 0);
|
||||||
|
|
||||||
cardList = db->getCardList();
|
cardList = db->getCardList();
|
||||||
|
for (int i = 0; i < cardList.size(); ++i)
|
||||||
|
connect(cardList[i], SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardDatabaseModel::cardInfoChanged(CardInfo *card)
|
||||||
|
{
|
||||||
|
const int row = cardList.indexOf(card);
|
||||||
|
if (row == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit dataChanged(index(row, 0), index(row, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabaseModel::cardAdded(CardInfo *card)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(), cardList.size(), cardList.size());
|
||||||
|
cardList.append(card);
|
||||||
|
connect(card, SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabaseModel::cardRemoved(CardInfo *card)
|
||||||
|
{
|
||||||
|
const int row = cardList.indexOf(card);
|
||||||
|
if (row == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beginRemoveRows(QModelIndex(), row, row);
|
||||||
|
cardList.removeAt(row);
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent),
|
: QSortFilterProxyModel(parent),
|
||||||
isToken(ShowAll)
|
isToken(ShowAll)
|
||||||
|
|
|
@ -16,12 +16,15 @@ public:
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
CardInfo const *getCard(int index) const { return cardList[index]; }
|
CardInfo *getCard(int index) const { return cardList[index]; }
|
||||||
private:
|
private:
|
||||||
QList<CardInfo *> cardList;
|
QList<CardInfo *> cardList;
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
private slots:
|
private slots:
|
||||||
void updateCardList();
|
void updateCardList();
|
||||||
|
void cardAdded(CardInfo *card);
|
||||||
|
void cardRemoved(CardInfo *card);
|
||||||
|
void cardInfoChanged(CardInfo *card);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CardDatabaseDisplayModel : public QSortFilterProxyModel {
|
class CardDatabaseDisplayModel : public QSortFilterProxyModel {
|
||||||
|
|
|
@ -123,7 +123,7 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
|
||||||
void DlgCreateToken::tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
void DlgCreateToken::tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
||||||
{
|
{
|
||||||
const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
|
const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
|
||||||
const CardInfo *cardInfo = cardDatabaseModel->getCard(realIndex.row());
|
const CardInfo *cardInfo = current.row() >= 0 ? cardDatabaseModel->getCard(realIndex.row()) : db->getCard();
|
||||||
|
|
||||||
nameEdit->setText(cardInfo->getName());
|
nameEdit->setText(cardInfo->getName());
|
||||||
const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
|
const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
|
||||||
|
|
176
cockatrice/src/dlg_edit_tokens.cpp
Normal file
176
cockatrice/src/dlg_edit_tokens.cpp
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
#include "dlg_edit_tokens.h"
|
||||||
|
#include "carddatabasemodel.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
DlgEditTokens::DlgEditTokens(QWidget *parent)
|
||||||
|
: QDialog(parent), currentCard(0)
|
||||||
|
{
|
||||||
|
nameLabel = new QLabel(tr("&Name:"));
|
||||||
|
nameEdit = new QLineEdit;
|
||||||
|
nameEdit->setEnabled(false);
|
||||||
|
nameLabel->setBuddy(nameEdit);
|
||||||
|
|
||||||
|
colorLabel = new QLabel(tr("C&olor:"));
|
||||||
|
colorEdit = new QComboBox;
|
||||||
|
colorEdit->addItem(tr("white"), "w");
|
||||||
|
colorEdit->addItem(tr("blue"), "u");
|
||||||
|
colorEdit->addItem(tr("black"), "b");
|
||||||
|
colorEdit->addItem(tr("red"), "r");
|
||||||
|
colorEdit->addItem(tr("green"), "g");
|
||||||
|
colorEdit->addItem(tr("multicolor"), "m");
|
||||||
|
colorEdit->addItem(tr("colorless"), QString());
|
||||||
|
colorLabel->setBuddy(colorEdit);
|
||||||
|
connect(colorEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(colorChanged(int)));
|
||||||
|
|
||||||
|
ptLabel = new QLabel(tr("&P/T:"));
|
||||||
|
ptEdit = new QLineEdit;
|
||||||
|
ptLabel->setBuddy(ptEdit);
|
||||||
|
connect(ptEdit, SIGNAL(textChanged(QString)), this, SLOT(ptChanged(QString)));
|
||||||
|
|
||||||
|
annotationLabel = new QLabel(tr("&Annotation:"));
|
||||||
|
annotationEdit = new QLineEdit;
|
||||||
|
annotationLabel->setBuddy(annotationEdit);
|
||||||
|
connect(annotationEdit, SIGNAL(textChanged(QString)), this, SLOT(annotationChanged(QString)));
|
||||||
|
|
||||||
|
QGridLayout *grid = new QGridLayout;
|
||||||
|
grid->addWidget(nameLabel, 0, 0);
|
||||||
|
grid->addWidget(nameEdit, 0, 1);
|
||||||
|
grid->addWidget(colorLabel, 1, 0);
|
||||||
|
grid->addWidget(colorEdit, 1, 1);
|
||||||
|
grid->addWidget(ptLabel, 2, 0);
|
||||||
|
grid->addWidget(ptEdit, 2, 1);
|
||||||
|
grid->addWidget(annotationLabel, 3, 0);
|
||||||
|
grid->addWidget(annotationEdit, 3, 1);
|
||||||
|
|
||||||
|
QGroupBox *tokenDataGroupBox = new QGroupBox(tr("Token data"));
|
||||||
|
tokenDataGroupBox->setLayout(grid);
|
||||||
|
|
||||||
|
cardDatabaseModel = new CardDatabaseModel(db, this);
|
||||||
|
cardDatabaseDisplayModel = new CardDatabaseDisplayModel(this);
|
||||||
|
cardDatabaseDisplayModel->setSourceModel(cardDatabaseModel);
|
||||||
|
cardDatabaseDisplayModel->setIsToken(CardDatabaseDisplayModel::ShowTrue);
|
||||||
|
|
||||||
|
chooseTokenView = new QTreeView;
|
||||||
|
chooseTokenView->setModel(cardDatabaseDisplayModel);
|
||||||
|
chooseTokenView->setUniformRowHeights(true);
|
||||||
|
chooseTokenView->setRootIsDecorated(false);
|
||||||
|
chooseTokenView->setAlternatingRowColors(true);
|
||||||
|
chooseTokenView->setSortingEnabled(true);
|
||||||
|
chooseTokenView->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
chooseTokenView->resizeColumnToContents(0);
|
||||||
|
chooseTokenView->header()->setStretchLastSection(false);
|
||||||
|
chooseTokenView->header()->hideSection(1);
|
||||||
|
chooseTokenView->header()->hideSection(2);
|
||||||
|
chooseTokenView->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
||||||
|
chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents);
|
||||||
|
connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex)));
|
||||||
|
|
||||||
|
QAction *aAddToken = new QAction(tr("Add token"), this);
|
||||||
|
aAddToken->setIcon(QIcon(":/resources/increment.svg"));
|
||||||
|
connect(aAddToken, SIGNAL(triggered()), this, SLOT(actAddToken()));
|
||||||
|
QAction *aRemoveToken = new QAction(tr("Remove token"), this);
|
||||||
|
aRemoveToken->setIcon(QIcon(":/resources/decrement.svg"));
|
||||||
|
connect(aRemoveToken, SIGNAL(triggered()), this, SLOT(actRemoveToken()));
|
||||||
|
|
||||||
|
QToolBar *databaseToolBar = new QToolBar;
|
||||||
|
databaseToolBar->addAction(aAddToken);
|
||||||
|
databaseToolBar->addAction(aRemoveToken);
|
||||||
|
|
||||||
|
QVBoxLayout *leftVBox = new QVBoxLayout;
|
||||||
|
leftVBox->addWidget(chooseTokenView);
|
||||||
|
leftVBox->addWidget(databaseToolBar);
|
||||||
|
|
||||||
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
|
hbox->addLayout(leftVBox);
|
||||||
|
hbox->addWidget(tokenDataGroupBox);
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||||
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
|
mainLayout->addLayout(hbox);
|
||||||
|
mainLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
|
setLayout(mainLayout);
|
||||||
|
setWindowTitle(tr("Edit tokens"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgEditTokens::tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
|
{
|
||||||
|
const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
|
||||||
|
CardInfo *cardInfo = current.row() >= 0 ? cardDatabaseModel->getCard(realIndex.row()) : db->getCard();
|
||||||
|
if (!cardInfo->getName().isEmpty())
|
||||||
|
currentCard = cardInfo;
|
||||||
|
else
|
||||||
|
currentCard = 0;
|
||||||
|
|
||||||
|
nameEdit->setText(cardInfo->getName());
|
||||||
|
const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
|
||||||
|
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
|
||||||
|
ptEdit->setText(cardInfo->getPowTough());
|
||||||
|
annotationEdit->setText(cardInfo->getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgEditTokens::actAddToken()
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
bool askAgain;
|
||||||
|
do {
|
||||||
|
name = QInputDialog::getText(this, tr("Add token"), tr("Please enter the name of the token:"));
|
||||||
|
if (!name.isEmpty() && db->getCard(name, false)) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("The chosen name conflicts with an existing card or token."));
|
||||||
|
askAgain = true;
|
||||||
|
} else
|
||||||
|
askAgain = false;
|
||||||
|
} while (askAgain);
|
||||||
|
|
||||||
|
if (name.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CardInfo *card = new CardInfo(db, name, true);
|
||||||
|
card->addToSet(db->getSet("TK"));
|
||||||
|
card->setCardType("Token");
|
||||||
|
db->addCard(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgEditTokens::actRemoveToken()
|
||||||
|
{
|
||||||
|
if (currentCard) {
|
||||||
|
db->removeCard(currentCard);
|
||||||
|
delete currentCard;
|
||||||
|
currentCard = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgEditTokens::colorChanged(int colorIndex)
|
||||||
|
{
|
||||||
|
if (currentCard)
|
||||||
|
currentCard->setColors(QStringList() << colorEdit->itemData(colorIndex).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgEditTokens::ptChanged(const QString &_pt)
|
||||||
|
{
|
||||||
|
if (currentCard)
|
||||||
|
currentCard->setPowTough(_pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgEditTokens::annotationChanged(const QString &_annotation)
|
||||||
|
{
|
||||||
|
if (currentCard)
|
||||||
|
currentCard->setText(_annotation);
|
||||||
|
}
|
38
cockatrice/src/dlg_edit_tokens.h
Normal file
38
cockatrice/src/dlg_edit_tokens.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef DLG_EDIT_TOKENS_H
|
||||||
|
#define DLG_EDIT_TOKENS_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class QModelIndex;
|
||||||
|
class CardDatabaseModel;
|
||||||
|
class CardDatabaseDisplayModel;
|
||||||
|
class QLabel;
|
||||||
|
class QComboBox;
|
||||||
|
class QLineEdit;
|
||||||
|
class QTreeView;
|
||||||
|
class CardInfo;
|
||||||
|
|
||||||
|
class DlgEditTokens : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
void colorChanged(int _colorIndex);
|
||||||
|
void ptChanged(const QString &_pt);
|
||||||
|
void annotationChanged(const QString &_annotation);
|
||||||
|
|
||||||
|
void actAddToken();
|
||||||
|
void actRemoveToken();
|
||||||
|
private:
|
||||||
|
CardInfo *currentCard;
|
||||||
|
CardDatabaseModel *cardDatabaseModel;
|
||||||
|
CardDatabaseDisplayModel *cardDatabaseDisplayModel;
|
||||||
|
QStringList predefinedTokens;
|
||||||
|
QLabel *nameLabel, *colorLabel, *ptLabel, *annotationLabel;
|
||||||
|
QComboBox *colorEdit;
|
||||||
|
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
||||||
|
QTreeView *chooseTokenView;
|
||||||
|
public:
|
||||||
|
DlgEditTokens(QWidget *parent = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -27,8 +27,6 @@ GeneralSettingsPage::GeneralSettingsPage()
|
||||||
{
|
{
|
||||||
languageLabel = new QLabel;
|
languageLabel = new QLabel;
|
||||||
languageBox = new QComboBox;
|
languageBox = new QComboBox;
|
||||||
customTranslationButton = new QPushButton("...");
|
|
||||||
customTranslationButton->setMaximumWidth(50);
|
|
||||||
|
|
||||||
QString setLanguage = settingsCache->getLang();
|
QString setLanguage = settingsCache->getLang();
|
||||||
QStringList qmFiles = findQmFiles();
|
QStringList qmFiles = findQmFiles();
|
||||||
|
@ -43,14 +41,12 @@ GeneralSettingsPage::GeneralSettingsPage()
|
||||||
picDownloadCheckBox->setChecked(settingsCache->getPicDownload());
|
picDownloadCheckBox->setChecked(settingsCache->getPicDownload());
|
||||||
|
|
||||||
connect(languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
|
connect(languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
|
||||||
connect(customTranslationButton, SIGNAL(clicked()), this, SLOT(customTranslationButtonClicked()));
|
|
||||||
connect(picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int)));
|
connect(picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int)));
|
||||||
|
|
||||||
QGridLayout *personalGrid = new QGridLayout;
|
QGridLayout *personalGrid = new QGridLayout;
|
||||||
personalGrid->addWidget(languageLabel, 0, 0);
|
personalGrid->addWidget(languageLabel, 0, 0);
|
||||||
personalGrid->addWidget(languageBox, 0, 1);
|
personalGrid->addWidget(languageBox, 0, 1);
|
||||||
personalGrid->addWidget(customTranslationButton, 0, 2);
|
personalGrid->addWidget(picDownloadCheckBox, 1, 0, 1, 2);
|
||||||
personalGrid->addWidget(picDownloadCheckBox, 1, 0, 1, 3);
|
|
||||||
|
|
||||||
personalGroupBox = new QGroupBox;
|
personalGroupBox = new QGroupBox;
|
||||||
personalGroupBox->setLayout(personalGrid);
|
personalGroupBox->setLayout(personalGrid);
|
||||||
|
@ -79,6 +75,12 @@ GeneralSettingsPage::GeneralSettingsPage()
|
||||||
QPushButton *cardDatabasePathButton = new QPushButton("...");
|
QPushButton *cardDatabasePathButton = new QPushButton("...");
|
||||||
connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked()));
|
connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked()));
|
||||||
|
|
||||||
|
tokenDatabasePathLabel = new QLabel;
|
||||||
|
tokenDatabasePathEdit = new QLineEdit(settingsCache->getTokenDatabasePath());
|
||||||
|
tokenDatabasePathEdit->setReadOnly(true);
|
||||||
|
QPushButton *tokenDatabasePathButton = new QPushButton("...");
|
||||||
|
connect(tokenDatabasePathButton, SIGNAL(clicked()), this, SLOT(tokenDatabasePathButtonClicked()));
|
||||||
|
|
||||||
QGridLayout *pathsGrid = new QGridLayout;
|
QGridLayout *pathsGrid = new QGridLayout;
|
||||||
pathsGrid->addWidget(deckPathLabel, 0, 0);
|
pathsGrid->addWidget(deckPathLabel, 0, 0);
|
||||||
pathsGrid->addWidget(deckPathEdit, 0, 1);
|
pathsGrid->addWidget(deckPathEdit, 0, 1);
|
||||||
|
@ -92,6 +94,9 @@ GeneralSettingsPage::GeneralSettingsPage()
|
||||||
pathsGrid->addWidget(cardDatabasePathLabel, 3, 0);
|
pathsGrid->addWidget(cardDatabasePathLabel, 3, 0);
|
||||||
pathsGrid->addWidget(cardDatabasePathEdit, 3, 1);
|
pathsGrid->addWidget(cardDatabasePathEdit, 3, 1);
|
||||||
pathsGrid->addWidget(cardDatabasePathButton, 3, 2);
|
pathsGrid->addWidget(cardDatabasePathButton, 3, 2);
|
||||||
|
pathsGrid->addWidget(tokenDatabasePathLabel, 4, 0);
|
||||||
|
pathsGrid->addWidget(tokenDatabasePathEdit, 4, 1);
|
||||||
|
pathsGrid->addWidget(tokenDatabasePathButton, 4, 2);
|
||||||
pathsGroupBox = new QGroupBox;
|
pathsGroupBox = new QGroupBox;
|
||||||
pathsGroupBox->setLayout(pathsGrid);
|
pathsGroupBox->setLayout(pathsGrid);
|
||||||
|
|
||||||
|
@ -158,19 +163,19 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked()
|
||||||
settingsCache->setCardDatabasePath(path);
|
settingsCache->setCardDatabasePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettingsPage::languageBoxChanged(int index)
|
void GeneralSettingsPage::tokenDatabasePathButtonClicked()
|
||||||
{
|
|
||||||
settingsCache->setCustomTranslationFile(QString());
|
|
||||||
settingsCache->setLang(languageBox->itemData(index).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralSettingsPage::customTranslationButtonClicked()
|
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
settingsCache->setCustomTranslationFile(path);
|
tokenDatabasePathEdit->setText(path);
|
||||||
|
settingsCache->setTokenDatabasePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralSettingsPage::languageBoxChanged(int index)
|
||||||
|
{
|
||||||
|
settingsCache->setLang(languageBox->itemData(index).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettingsPage::retranslateUi()
|
void GeneralSettingsPage::retranslateUi()
|
||||||
|
@ -183,6 +188,7 @@ void GeneralSettingsPage::retranslateUi()
|
||||||
replaysPathLabel->setText(tr("Replays directory:"));
|
replaysPathLabel->setText(tr("Replays directory:"));
|
||||||
picsPathLabel->setText(tr("Pictures directory:"));
|
picsPathLabel->setText(tr("Pictures directory:"));
|
||||||
cardDatabasePathLabel->setText(tr("Path to card database:"));
|
cardDatabasePathLabel->setText(tr("Path to card database:"));
|
||||||
|
tokenDatabasePathLabel->setText(tr("Path to token database:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
AppearanceSettingsPage::AppearanceSettingsPage()
|
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
|
@ -590,7 +596,6 @@ DlgSettings::DlgSettings(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
connect(settingsCache, SIGNAL(langChanged()), this, SLOT(updateLanguage()));
|
connect(settingsCache, SIGNAL(langChanged()), this, SLOT(updateLanguage()));
|
||||||
connect(settingsCache, SIGNAL(customTranslationFileChanged()), this, SLOT(updateLanguage()));
|
|
||||||
|
|
||||||
contentsWidget = new QListWidget;
|
contentsWidget = new QListWidget;
|
||||||
contentsWidget->setViewMode(QListView::IconMode);
|
contentsWidget->setViewMode(QListView::IconMode);
|
||||||
|
|
|
@ -27,21 +27,20 @@ public:
|
||||||
GeneralSettingsPage();
|
GeneralSettingsPage();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
private slots:
|
private slots:
|
||||||
void customTranslationButtonClicked();
|
|
||||||
void deckPathButtonClicked();
|
void deckPathButtonClicked();
|
||||||
void replaysPathButtonClicked();
|
void replaysPathButtonClicked();
|
||||||
void picsPathButtonClicked();
|
void picsPathButtonClicked();
|
||||||
void cardDatabasePathButtonClicked();
|
void cardDatabasePathButtonClicked();
|
||||||
|
void tokenDatabasePathButtonClicked();
|
||||||
void languageBoxChanged(int index);
|
void languageBoxChanged(int index);
|
||||||
private:
|
private:
|
||||||
QStringList findQmFiles();
|
QStringList findQmFiles();
|
||||||
QString languageName(const QString &qmFile);
|
QString languageName(const QString &qmFile);
|
||||||
QPushButton *customTranslationButton;
|
QLineEdit *deckPathEdit, *replaysPathEdit, *picsPathEdit, *cardDatabasePathEdit, *tokenDatabasePathEdit;
|
||||||
QLineEdit *deckPathEdit, *replaysPathEdit, *picsPathEdit, *cardDatabasePathEdit;
|
|
||||||
QGroupBox *personalGroupBox, *pathsGroupBox;
|
QGroupBox *personalGroupBox, *pathsGroupBox;
|
||||||
QComboBox *languageBox;
|
QComboBox *languageBox;
|
||||||
QCheckBox *picDownloadCheckBox;
|
QCheckBox *picDownloadCheckBox;
|
||||||
QLabel *languageLabel, *deckPathLabel, *replaysPathLabel, *picsPathLabel, *cardDatabasePathLabel;
|
QLabel *languageLabel, *deckPathLabel, *replaysPathLabel, *picsPathLabel, *cardDatabasePathLabel, *tokenDatabasePathLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppearanceSettingsPage : public AbstractSettingsPage {
|
class AppearanceSettingsPage : public AbstractSettingsPage {
|
||||||
|
|
|
@ -71,9 +71,6 @@ void installNewTranslator()
|
||||||
qApp->installTranslator(qtTranslator);
|
qApp->installTranslator(qtTranslator);
|
||||||
if (!translationPath.startsWith("/"))
|
if (!translationPath.startsWith("/"))
|
||||||
translationPath.prepend(qApp->applicationDirPath() + "/");
|
translationPath.prepend(qApp->applicationDirPath() + "/");
|
||||||
if (!settingsCache->getCustomTranslationFile().isEmpty())
|
|
||||||
translator->load(settingsCache->getCustomTranslationFile());
|
|
||||||
else
|
|
||||||
translator->load(translationPrefix + "_" + lang, translationPath);
|
translator->load(translationPrefix + "_" + lang, translationPath);
|
||||||
qApp->installTranslator(translator);
|
qApp->installTranslator(translator);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +114,8 @@ int main(int argc, char *argv[])
|
||||||
if (!db->getLoadSuccess())
|
if (!db->getLoadSuccess())
|
||||||
if (db->loadCardDatabase(dataDir + "/cards.xml"))
|
if (db->loadCardDatabase(dataDir + "/cards.xml"))
|
||||||
settingsCache->setCardDatabasePath(dataDir + "/cards.xml");
|
settingsCache->setCardDatabasePath(dataDir + "/cards.xml");
|
||||||
|
if (settingsCache->getTokenDatabasePath().isEmpty())
|
||||||
|
settingsCache->setTokenDatabasePath(dataDir + "/tokens.xml");
|
||||||
if (!QDir(settingsCache->getDeckPath()).exists() || settingsCache->getDeckPath().isEmpty()) {
|
if (!QDir(settingsCache->getDeckPath()).exists() || settingsCache->getDeckPath().isEmpty()) {
|
||||||
QDir().mkpath(dataDir + "/decks");
|
QDir().mkpath(dataDir + "/decks");
|
||||||
settingsCache->setDeckPath(dataDir + "/decks");
|
settingsCache->setDeckPath(dataDir + "/decks");
|
||||||
|
|
|
@ -5,13 +5,13 @@ SettingsCache::SettingsCache()
|
||||||
{
|
{
|
||||||
settings = new QSettings(this);
|
settings = new QSettings(this);
|
||||||
|
|
||||||
customTranslationFile = settings->value("personal/custom_translation").toString();
|
|
||||||
lang = settings->value("personal/lang").toString();
|
lang = settings->value("personal/lang").toString();
|
||||||
|
|
||||||
deckPath = settings->value("paths/decks").toString();
|
deckPath = settings->value("paths/decks").toString();
|
||||||
replaysPath = settings->value("paths/replays").toString();
|
replaysPath = settings->value("paths/replays").toString();
|
||||||
picsPath = settings->value("paths/pics").toString();
|
picsPath = settings->value("paths/pics").toString();
|
||||||
cardDatabasePath = settings->value("paths/carddatabase").toString();
|
cardDatabasePath = settings->value("paths/carddatabase").toString();
|
||||||
|
tokenDatabasePath = settings->value("paths/tokendatabase").toString();
|
||||||
|
|
||||||
handBgPath = settings->value("zonebg/hand").toString();
|
handBgPath = settings->value("zonebg/hand").toString();
|
||||||
stackBgPath = settings->value("zonebg/stack").toString();
|
stackBgPath = settings->value("zonebg/stack").toString();
|
||||||
|
@ -41,13 +41,6 @@ SettingsCache::SettingsCache()
|
||||||
ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool();
|
ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setCustomTranslationFile(const QString &_customTranslationFile)
|
|
||||||
{
|
|
||||||
customTranslationFile = _customTranslationFile;
|
|
||||||
settings->setValue("personal/custom_translation", customTranslationFile);
|
|
||||||
emit customTranslationFileChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCache::setLang(const QString &_lang)
|
void SettingsCache::setLang(const QString &_lang)
|
||||||
{
|
{
|
||||||
lang = _lang;
|
lang = _lang;
|
||||||
|
@ -81,6 +74,13 @@ void SettingsCache::setCardDatabasePath(const QString &_cardDatabasePath)
|
||||||
emit cardDatabasePathChanged();
|
emit cardDatabasePathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setTokenDatabasePath(const QString &_tokenDatabasePath)
|
||||||
|
{
|
||||||
|
tokenDatabasePath = _tokenDatabasePath;
|
||||||
|
settings->setValue("paths/tokendatabase", tokenDatabasePath);
|
||||||
|
emit tokenDatabasePathChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setHandBgPath(const QString &_handBgPath)
|
void SettingsCache::setHandBgPath(const QString &_handBgPath)
|
||||||
{
|
{
|
||||||
handBgPath = _handBgPath;
|
handBgPath = _handBgPath;
|
||||||
|
|
|
@ -8,10 +8,10 @@ class QSettings;
|
||||||
class SettingsCache : public QObject {
|
class SettingsCache : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void customTranslationFileChanged();
|
|
||||||
void langChanged();
|
void langChanged();
|
||||||
void picsPathChanged();
|
void picsPathChanged();
|
||||||
void cardDatabasePathChanged();
|
void cardDatabasePathChanged();
|
||||||
|
void tokenDatabasePathChanged();
|
||||||
void handBgPathChanged();
|
void handBgPathChanged();
|
||||||
void stackBgPathChanged();
|
void stackBgPathChanged();
|
||||||
void tableBgPathChanged();
|
void tableBgPathChanged();
|
||||||
|
@ -29,8 +29,8 @@ private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
|
||||||
QByteArray mainWindowGeometry;
|
QByteArray mainWindowGeometry;
|
||||||
QString customTranslationFile, lang;
|
QString lang;
|
||||||
QString deckPath, replaysPath, picsPath, cardDatabasePath;
|
QString deckPath, replaysPath, picsPath, cardDatabasePath, tokenDatabasePath;
|
||||||
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
||||||
bool picDownload;
|
bool picDownload;
|
||||||
bool doubleClickToPlay;
|
bool doubleClickToPlay;
|
||||||
|
@ -49,12 +49,12 @@ private:
|
||||||
public:
|
public:
|
||||||
SettingsCache();
|
SettingsCache();
|
||||||
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
|
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
|
||||||
QString getCustomTranslationFile() const { return customTranslationFile; }
|
|
||||||
QString getLang() const { return lang; }
|
QString getLang() const { return lang; }
|
||||||
QString getDeckPath() const { return deckPath; }
|
QString getDeckPath() const { return deckPath; }
|
||||||
QString getReplaysPath() const { return replaysPath; }
|
QString getReplaysPath() const { return replaysPath; }
|
||||||
QString getPicsPath() const { return picsPath; }
|
QString getPicsPath() const { return picsPath; }
|
||||||
QString getCardDatabasePath() const { return cardDatabasePath; }
|
QString getCardDatabasePath() const { return cardDatabasePath; }
|
||||||
|
QString getTokenDatabasePath() const { return tokenDatabasePath; }
|
||||||
QString getHandBgPath() const { return handBgPath; }
|
QString getHandBgPath() const { return handBgPath; }
|
||||||
QString getStackBgPath() const { return stackBgPath; }
|
QString getStackBgPath() const { return stackBgPath; }
|
||||||
QString getTableBgPath() const { return tableBgPath; }
|
QString getTableBgPath() const { return tableBgPath; }
|
||||||
|
@ -77,12 +77,12 @@ public:
|
||||||
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
|
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
|
||||||
public slots:
|
public slots:
|
||||||
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
||||||
void setCustomTranslationFile(const QString &_customTranslationFile);
|
|
||||||
void setLang(const QString &_lang);
|
void setLang(const QString &_lang);
|
||||||
void setDeckPath(const QString &_deckPath);
|
void setDeckPath(const QString &_deckPath);
|
||||||
void setReplaysPath(const QString &_replaysPath);
|
void setReplaysPath(const QString &_replaysPath);
|
||||||
void setPicsPath(const QString &_picsPath);
|
void setPicsPath(const QString &_picsPath);
|
||||||
void setCardDatabasePath(const QString &_cardDatabasePath);
|
void setCardDatabasePath(const QString &_cardDatabasePath);
|
||||||
|
void setTokenDatabasePath(const QString &_tokenDatabasePath);
|
||||||
void setHandBgPath(const QString &_handBgPath);
|
void setHandBgPath(const QString &_handBgPath);
|
||||||
void setStackBgPath(const QString &_stackBgPath);
|
void setStackBgPath(const QString &_stackBgPath);
|
||||||
void setTableBgPath(const QString &_tableBgPath);
|
void setTableBgPath(const QString &_tableBgPath);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "cardinfowidget.h"
|
#include "cardinfowidget.h"
|
||||||
#include "dlg_cardsearch.h"
|
#include "dlg_cardsearch.h"
|
||||||
#include "dlg_load_deck_from_clipboard.h"
|
#include "dlg_load_deck_from_clipboard.h"
|
||||||
|
#include "dlg_edit_tokens.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "priceupdater.h"
|
#include "priceupdater.h"
|
||||||
|
@ -41,7 +42,7 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||||
: Tab(_tabSupervisor, parent)
|
: Tab(_tabSupervisor, parent), modified(false)
|
||||||
{
|
{
|
||||||
aSearch = new QAction(QString(), this);
|
aSearch = new QAction(QString(), this);
|
||||||
aSearch->setIcon(QIcon(":/resources/icon_search.svg"));
|
aSearch->setIcon(QIcon(":/resources/icon_search.svg"));
|
||||||
|
@ -161,8 +162,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||||
mainLayout->addLayout(rightFrame, 10);
|
mainLayout->addLayout(rightFrame, 10);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
setWindowTitle(tr("Deck editor [*]"));
|
|
||||||
|
|
||||||
aNewDeck = new QAction(QString(), this);
|
aNewDeck = new QAction(QString(), this);
|
||||||
aNewDeck->setShortcuts(QKeySequence::New);
|
aNewDeck->setShortcuts(QKeySequence::New);
|
||||||
connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck()));
|
connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck()));
|
||||||
|
@ -181,15 +180,16 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||||
aSaveDeckToClipboard = new QAction(QString(), this);
|
aSaveDeckToClipboard = new QAction(QString(), this);
|
||||||
connect(aSaveDeckToClipboard, SIGNAL(triggered()), this, SLOT(actSaveDeckToClipboard()));
|
connect(aSaveDeckToClipboard, SIGNAL(triggered()), this, SLOT(actSaveDeckToClipboard()));
|
||||||
aSaveDeckToClipboard->setShortcuts(QKeySequence::Copy);
|
aSaveDeckToClipboard->setShortcuts(QKeySequence::Copy);
|
||||||
aPrintDeck = new QAction(tr("&Print deck..."), this);
|
aPrintDeck = new QAction(QString(), this);
|
||||||
aPrintDeck->setShortcuts(QKeySequence::Print);
|
aPrintDeck->setShortcuts(QKeySequence::Print);
|
||||||
connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck()));
|
connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck()));
|
||||||
aClose = new QAction(tr("&Close"), this);
|
aClose = new QAction(QString(), this);
|
||||||
aClose->setShortcut(tr("Ctrl+Q"));
|
|
||||||
connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest()));
|
connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest()));
|
||||||
|
|
||||||
aEditSets = new QAction(tr("&Edit sets..."), this);
|
aEditSets = new QAction(QString(), this);
|
||||||
connect(aEditSets, SIGNAL(triggered()), this, SLOT(actEditSets()));
|
connect(aEditSets, SIGNAL(triggered()), this, SLOT(actEditSets()));
|
||||||
|
aEditTokens = new QAction(QString(), this);
|
||||||
|
connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens()));
|
||||||
|
|
||||||
deckMenu = new QMenu(this);
|
deckMenu = new QMenu(this);
|
||||||
deckMenu->addAction(aNewDeck);
|
deckMenu->addAction(aNewDeck);
|
||||||
|
@ -207,6 +207,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||||
|
|
||||||
dbMenu = new QMenu(this);
|
dbMenu = new QMenu(this);
|
||||||
dbMenu->addAction(aEditSets);
|
dbMenu->addAction(aEditSets);
|
||||||
|
dbMenu->addAction(aEditTokens);
|
||||||
dbMenu->addSeparator();
|
dbMenu->addSeparator();
|
||||||
dbMenu->addAction(aSearch);
|
dbMenu->addAction(aSearch);
|
||||||
dbMenu->addAction(aClearSearch);
|
dbMenu->addAction(aClearSearch);
|
||||||
|
@ -266,6 +267,9 @@ void TabDeckEditor::retranslateUi()
|
||||||
aSaveDeckAs->setText(tr("Save deck &as..."));
|
aSaveDeckAs->setText(tr("Save deck &as..."));
|
||||||
aLoadDeckFromClipboard->setText(tr("Load deck from cl&ipboard..."));
|
aLoadDeckFromClipboard->setText(tr("Load deck from cl&ipboard..."));
|
||||||
aSaveDeckToClipboard->setText(tr("Save deck to clip&board"));
|
aSaveDeckToClipboard->setText(tr("Save deck to clip&board"));
|
||||||
|
aPrintDeck->setText(tr("&Print deck..."));
|
||||||
|
aClose->setText(tr("&Close"));
|
||||||
|
aClose->setShortcut(tr("Ctrl+Q"));
|
||||||
|
|
||||||
aAddCard->setText(tr("Add card to &maindeck"));
|
aAddCard->setText(tr("Add card to &maindeck"));
|
||||||
aAddCard->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Return")) << QKeySequence(tr("Enter")));
|
aAddCard->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Return")) << QKeySequence(tr("Enter")));
|
||||||
|
@ -280,12 +284,15 @@ void TabDeckEditor::retranslateUi()
|
||||||
|
|
||||||
deckMenu->setTitle(tr("&Deck editor"));
|
deckMenu->setTitle(tr("&Deck editor"));
|
||||||
dbMenu->setTitle(tr("C&ard database"));
|
dbMenu->setTitle(tr("C&ard database"));
|
||||||
|
|
||||||
|
aEditSets->setText(tr("&Edit sets..."));
|
||||||
|
aEditTokens->setText(tr("Edit &tokens..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TabDeckEditor::getTabText() const
|
QString TabDeckEditor::getTabText() const
|
||||||
{
|
{
|
||||||
QString result = tr("Deck: %1").arg(nameEdit->text());
|
QString result = tr("Deck: %1").arg(nameEdit->text());
|
||||||
if (isWindowModified())
|
if (modified)
|
||||||
result.prepend("* ");
|
result.prepend("* ");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -293,13 +300,13 @@ QString TabDeckEditor::getTabText() const
|
||||||
void TabDeckEditor::updateName(const QString &name)
|
void TabDeckEditor::updateName(const QString &name)
|
||||||
{
|
{
|
||||||
deckModel->getDeckList()->setName(name);
|
deckModel->getDeckList()->setName(name);
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::updateComments()
|
void TabDeckEditor::updateComments()
|
||||||
{
|
{
|
||||||
deckModel->getDeckList()->setComments(commentsEdit->toPlainText());
|
deckModel->getDeckList()->setComments(commentsEdit->toPlainText());
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::updateCardInfoLeft(const QModelIndex ¤t, const QModelIndex &/*previous*/)
|
void TabDeckEditor::updateCardInfoLeft(const QModelIndex ¤t, const QModelIndex &/*previous*/)
|
||||||
|
@ -330,7 +337,7 @@ void TabDeckEditor::updateHash()
|
||||||
|
|
||||||
bool TabDeckEditor::confirmClose()
|
bool TabDeckEditor::confirmClose()
|
||||||
{
|
{
|
||||||
if (isWindowModified()) {
|
if (modified) {
|
||||||
QMessageBox::StandardButton ret = QMessageBox::warning(this, tr("Are you sure?"),
|
QMessageBox::StandardButton ret = QMessageBox::warning(this, tr("Are you sure?"),
|
||||||
tr("The decklist has been modified.\nDo you want to save the changes?"),
|
tr("The decklist has been modified.\nDo you want to save the changes?"),
|
||||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||||
|
@ -357,7 +364,7 @@ void TabDeckEditor::actNewDeck()
|
||||||
nameEdit->setText(QString());
|
nameEdit->setText(QString());
|
||||||
commentsEdit->setText(QString());
|
commentsEdit->setText(QString());
|
||||||
hashLabel->setText(QString());
|
hashLabel->setText(QString());
|
||||||
setWindowModified(false);
|
setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actLoadDeck()
|
void TabDeckEditor::actLoadDeck()
|
||||||
|
@ -386,7 +393,7 @@ void TabDeckEditor::saveDeckRemoteFinished(const Response &response)
|
||||||
if (response.response_code() != Response::RespOk)
|
if (response.response_code() != Response::RespOk)
|
||||||
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved."));
|
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved."));
|
||||||
else
|
else
|
||||||
setWindowModified(false);
|
setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabDeckEditor::actSaveDeck()
|
bool TabDeckEditor::actSaveDeck()
|
||||||
|
@ -405,7 +412,7 @@ bool TabDeckEditor::actSaveDeck()
|
||||||
} else if (deck->getLastFileName().isEmpty())
|
} else if (deck->getLastFileName().isEmpty())
|
||||||
return actSaveDeckAs();
|
return actSaveDeckAs();
|
||||||
else if (deck->saveToFile(deck->getLastFileName(), deck->getLastFileFormat())) {
|
else if (deck->saveToFile(deck->getLastFileName(), deck->getLastFileFormat())) {
|
||||||
setWindowModified(false);
|
setModified(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved.\nPlease check that the directory is writable and try again."));
|
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved.\nPlease check that the directory is writable and try again."));
|
||||||
|
@ -431,7 +438,7 @@ bool TabDeckEditor::actSaveDeckAs()
|
||||||
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved.\nPlease check that the directory is writable and try again."));
|
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved.\nPlease check that the directory is writable and try again."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setWindowModified(false);
|
setModified(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +452,7 @@ void TabDeckEditor::actLoadDeckFromClipboard()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setDeck(dlg.getDeckList());
|
setDeck(dlg.getDeckList());
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actSaveDeckToClipboard()
|
void TabDeckEditor::actSaveDeckToClipboard()
|
||||||
|
@ -471,6 +478,13 @@ void TabDeckEditor::actEditSets()
|
||||||
w->show();
|
w->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabDeckEditor::actEditTokens()
|
||||||
|
{
|
||||||
|
DlgEditTokens dlg;
|
||||||
|
dlg.exec();
|
||||||
|
db->saveToFile(settingsCache->getTokenDatabasePath(), true);
|
||||||
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actSearch()
|
void TabDeckEditor::actSearch()
|
||||||
{
|
{
|
||||||
if (dlgCardSearch->exec()) {
|
if (dlgCardSearch->exec()) {
|
||||||
|
@ -509,7 +523,7 @@ void TabDeckEditor::addCardHelper(QString zoneName)
|
||||||
recursiveExpand(newCardIndex);
|
recursiveExpand(newCardIndex);
|
||||||
deckView->setCurrentIndex(newCardIndex);
|
deckView->setCurrentIndex(newCardIndex);
|
||||||
|
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actAddCard()
|
void TabDeckEditor::actAddCard()
|
||||||
|
@ -528,7 +542,7 @@ void TabDeckEditor::actRemoveCard()
|
||||||
if (!currentIndex.isValid() || deckModel->hasChildren(currentIndex))
|
if (!currentIndex.isValid() || deckModel->hasChildren(currentIndex))
|
||||||
return;
|
return;
|
||||||
deckModel->removeRow(currentIndex.row(), currentIndex.parent());
|
deckModel->removeRow(currentIndex.row(), currentIndex.parent());
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actIncrement()
|
void TabDeckEditor::actIncrement()
|
||||||
|
@ -540,7 +554,7 @@ void TabDeckEditor::actIncrement()
|
||||||
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
||||||
deckView->setCurrentIndex(numberIndex);
|
deckView->setCurrentIndex(numberIndex);
|
||||||
deckModel->setData(numberIndex, count + 1, Qt::EditRole);
|
deckModel->setData(numberIndex, count + 1, Qt::EditRole);
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actDecrement()
|
void TabDeckEditor::actDecrement()
|
||||||
|
@ -555,7 +569,7 @@ void TabDeckEditor::actDecrement()
|
||||||
deckModel->removeRow(currentIndex.row(), currentIndex.parent());
|
deckModel->removeRow(currentIndex.row(), currentIndex.parent());
|
||||||
else
|
else
|
||||||
deckModel->setData(numberIndex, count - 1, Qt::EditRole);
|
deckModel->setData(numberIndex, count - 1, Qt::EditRole);
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actUpdatePrices()
|
void TabDeckEditor::actUpdatePrices()
|
||||||
|
@ -569,7 +583,7 @@ void TabDeckEditor::actUpdatePrices()
|
||||||
void TabDeckEditor::finishedUpdatingPrices()
|
void TabDeckEditor::finishedUpdatingPrices()
|
||||||
{
|
{
|
||||||
deckModel->pricesUpdated();
|
deckModel->pricesUpdated();
|
||||||
setWindowModified(true);
|
setModified(true);
|
||||||
aUpdatePrices->setDisabled(false);
|
aUpdatePrices->setDisabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,15 +596,15 @@ void TabDeckEditor::setDeck(DeckLoader *_deck)
|
||||||
updateHash();
|
updateHash();
|
||||||
deckModel->sort(1);
|
deckModel->sort(1);
|
||||||
deckView->expandAll();
|
deckView->expandAll();
|
||||||
setWindowModified(false);
|
setModified(false);
|
||||||
|
|
||||||
db->cacheCardPixmaps(deckModel->getDeckList()->getCardList());
|
db->cacheCardPixmaps(deckModel->getDeckList()->getCardList());
|
||||||
deckView->expandAll();
|
deckView->expandAll();
|
||||||
setWindowModified(false);
|
setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::setWindowModified(bool _windowModified)
|
void TabDeckEditor::setModified(bool _modified)
|
||||||
{
|
{
|
||||||
Tab::setWindowModified(_windowModified);
|
modified = _modified;
|
||||||
emit tabTextChanged(this, getTabText());
|
emit tabTextChanged(this, getTabText());
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ private slots:
|
||||||
void actPrintDeck();
|
void actPrintDeck();
|
||||||
|
|
||||||
void actEditSets();
|
void actEditSets();
|
||||||
|
void actEditTokens();
|
||||||
|
|
||||||
void actSearch();
|
void actSearch();
|
||||||
void actClearSearch();
|
void actClearSearch();
|
||||||
|
@ -82,15 +83,17 @@ private:
|
||||||
|
|
||||||
QMenu *deckMenu, *dbMenu;
|
QMenu *deckMenu, *dbMenu;
|
||||||
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aClose;
|
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aClose;
|
||||||
QAction *aEditSets, *aSearch, *aClearSearch;
|
QAction *aEditSets, *aEditTokens, *aSearch, *aClearSearch;
|
||||||
QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement, *aUpdatePrices;
|
QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement, *aUpdatePrices;
|
||||||
|
|
||||||
|
bool modified;
|
||||||
public:
|
public:
|
||||||
TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = 0);
|
TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = 0);
|
||||||
~TabDeckEditor();
|
~TabDeckEditor();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
QString getTabText() const;
|
QString getTabText() const;
|
||||||
void setDeck(DeckLoader *_deckLoader);
|
void setDeck(DeckLoader *_deckLoader);
|
||||||
void setWindowModified(bool _windowModified);
|
void setModified(bool _windowModified);
|
||||||
public slots:
|
public slots:
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in a new issue