mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
almost finished pre-game deck loading
This commit is contained in:
parent
8dcf81654e
commit
cf21528a69
16 changed files with 140 additions and 64 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include "carddatabasemodel.h"
|
||||
#include "decklistmodel.h"
|
||||
#include "cardinfowidget.h"
|
||||
#include "deck_picturecacher.h"
|
||||
#include "main.h"
|
||||
|
||||
void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
||||
|
|
@ -14,11 +15,6 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
|||
QLineEdit::keyPressEvent(event);
|
||||
}
|
||||
|
||||
const QStringList WndDeckEditor::fileNameFilters = QStringList()
|
||||
<< QObject::tr("Cockatrice decks (*.cod)")
|
||||
<< QObject::tr("Plain text decks (*.dec *.mwDeck)")
|
||||
<< QObject::tr("All files (*.*)");
|
||||
|
||||
WndDeckEditor::WndDeckEditor(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
|
|
@ -245,18 +241,12 @@ void WndDeckEditor::actLoadDeck()
|
|||
QFileDialog dialog(this, tr("Load deck"));
|
||||
QSettings settings;
|
||||
dialog.setDirectory(settings.value("paths/decks").toString());
|
||||
dialog.setNameFilters(fileNameFilters);
|
||||
dialog.setNameFilters(DeckList::fileNameFilters);
|
||||
if (!dialog.exec())
|
||||
return;
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
DeckList::FileFormat fmt;
|
||||
switch (fileNameFilters.indexOf(dialog.selectedNameFilter())) {
|
||||
case 0: fmt = DeckList::CockatriceFormat; break;
|
||||
case 1: fmt = DeckList::PlainTextFormat; break;
|
||||
default: fmt = DeckList::PlainTextFormat; break;
|
||||
}
|
||||
|
||||
DeckList::FileFormat fmt = DeckList::getFormatFromNameFilter(dialog.selectedNameFilter());
|
||||
DeckList *l = deckModel->getDeckList();
|
||||
if (l->loadFromFile(fileName, fmt)) {
|
||||
lastFileName = fileName;
|
||||
|
|
@ -268,7 +258,7 @@ void WndDeckEditor::actLoadDeck()
|
|||
deckView->resizeColumnToContents(0);
|
||||
setWindowModified(false);
|
||||
|
||||
deckModel->cacheCardPictures(this);
|
||||
Deck_PictureCacher::cachePictures(l, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -291,17 +281,12 @@ bool WndDeckEditor::actSaveDeckAs()
|
|||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setConfirmOverwrite(true);
|
||||
dialog.setDefaultSuffix("cod");
|
||||
dialog.setNameFilters(fileNameFilters);
|
||||
dialog.setNameFilters(DeckList::fileNameFilters);
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
DeckList::FileFormat fmt;
|
||||
switch (fileNameFilters.indexOf(dialog.selectedNameFilter())) {
|
||||
case 0: fmt = DeckList::CockatriceFormat; break;
|
||||
case 1: fmt = DeckList::PlainTextFormat; break;
|
||||
default: fmt = DeckList::PlainTextFormat; break;
|
||||
}
|
||||
DeckList::FileFormat fmt = DeckList::getFormatFromNameFilter(dialog.selectedNameFilter());
|
||||
|
||||
if (deckModel->getDeckList()->saveToFile(fileName, fmt)) {
|
||||
lastFileName = fileName;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue