save deck to clipboard
This commit is contained in:
parent
37de620e93
commit
579628b4c4
4 changed files with 41 additions and 20 deletions
|
@ -123,14 +123,18 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
aLoadDeck = new QAction(tr("&Load deck..."), this);
|
||||
aLoadDeck->setShortcuts(QKeySequence::Open);
|
||||
connect(aLoadDeck, SIGNAL(triggered()), this, SLOT(actLoadDeck()));
|
||||
aLoadDeckFromClipboard = new QAction(tr("Load deck from cl&ipboard..."), this);
|
||||
connect(aLoadDeckFromClipboard, SIGNAL(triggered()), this, SLOT(actLoadDeckFromClipboard()));
|
||||
aSaveDeck = new QAction(tr("&Save deck"), this);
|
||||
aSaveDeck->setShortcuts(QKeySequence::Save);
|
||||
connect(aSaveDeck, SIGNAL(triggered()), this, SLOT(actSaveDeck()));
|
||||
aSaveDeckAs = new QAction(tr("Save deck &as..."), this);
|
||||
// aSaveDeckAs->setShortcuts(QKeySequence::SaveAs);
|
||||
connect(aSaveDeckAs, SIGNAL(triggered()), this, SLOT(actSaveDeckAs()));
|
||||
aLoadDeckFromClipboard = new QAction(tr("Load deck from cl&ipboard..."), this);
|
||||
connect(aLoadDeckFromClipboard, SIGNAL(triggered()), this, SLOT(actLoadDeckFromClipboard()));
|
||||
aLoadDeckFromClipboard->setShortcuts(QKeySequence::Paste);
|
||||
aSaveDeckToClipboard = new QAction(tr("Save deck to cl&ipboard"), this);
|
||||
connect(aSaveDeckToClipboard, SIGNAL(triggered()), this, SLOT(actSaveDeckToClipboard()));
|
||||
aSaveDeckToClipboard->setShortcuts(QKeySequence::Copy);
|
||||
aPrintDeck = new QAction(tr("&Print deck..."), this);
|
||||
aPrintDeck->setShortcuts(QKeySequence::Print);
|
||||
connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck()));
|
||||
|
@ -144,10 +148,12 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
deckMenu = menuBar()->addMenu(tr("&Deck"));
|
||||
deckMenu->addAction(aNewDeck);
|
||||
deckMenu->addAction(aLoadDeck);
|
||||
deckMenu->addAction(aLoadDeckFromClipboard);
|
||||
deckMenu->addAction(aSaveDeck);
|
||||
deckMenu->addAction(aSaveDeckAs);
|
||||
deckMenu->addSeparator();
|
||||
deckMenu->addAction(aLoadDeckFromClipboard);
|
||||
deckMenu->addAction(aSaveDeckToClipboard);
|
||||
deckMenu->addSeparator();
|
||||
deckMenu->addAction(aPrintDeck);
|
||||
deckMenu->addSeparator();
|
||||
deckMenu->addAction(aClose);
|
||||
|
@ -279,19 +285,6 @@ void WndDeckEditor::actLoadDeck()
|
|||
delete l;
|
||||
}
|
||||
|
||||
void WndDeckEditor::actLoadDeckFromClipboard()
|
||||
{
|
||||
if (!confirmClose())
|
||||
return;
|
||||
|
||||
DlgLoadDeckFromClipboard dlg;
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
setDeck(dlg.getDeckList());
|
||||
setWindowModified(true);
|
||||
}
|
||||
|
||||
bool WndDeckEditor::actSaveDeck()
|
||||
{
|
||||
if (lastFileName.isEmpty())
|
||||
|
@ -327,6 +320,27 @@ bool WndDeckEditor::actSaveDeckAs()
|
|||
return false;
|
||||
}
|
||||
|
||||
void WndDeckEditor::actLoadDeckFromClipboard()
|
||||
{
|
||||
if (!confirmClose())
|
||||
return;
|
||||
|
||||
DlgLoadDeckFromClipboard dlg;
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
setDeck(dlg.getDeckList());
|
||||
setWindowModified(true);
|
||||
}
|
||||
|
||||
void WndDeckEditor::actSaveDeckToClipboard()
|
||||
{
|
||||
QString buffer;
|
||||
QTextStream stream(&buffer);
|
||||
deckModel->getDeckList()->saveToStream_Plain(stream);
|
||||
QApplication::clipboard()->setText(buffer);
|
||||
}
|
||||
|
||||
void WndDeckEditor::actPrintDeck()
|
||||
{
|
||||
QPrintPreviewDialog *dlg = new QPrintPreviewDialog(this);
|
||||
|
|
|
@ -36,9 +36,10 @@ private slots:
|
|||
|
||||
void actNewDeck();
|
||||
void actLoadDeck();
|
||||
void actLoadDeckFromClipboard();
|
||||
bool actSaveDeck();
|
||||
bool actSaveDeckAs();
|
||||
void actLoadDeckFromClipboard();
|
||||
void actSaveDeckToClipboard();
|
||||
void actPrintDeck();
|
||||
|
||||
void actEditSets();
|
||||
|
@ -71,7 +72,7 @@ private:
|
|||
DlgCardSearch *dlgCardSearch;
|
||||
|
||||
QMenu *deckMenu, *dbMenu;
|
||||
QAction *aNewDeck, *aLoadDeck, *aLoadDeckFromClipboard, *aSaveDeck, *aSaveDeckAs, *aPrintDeck, *aClose;
|
||||
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aClose;
|
||||
QAction *aEditSets, *aSearch, *aClearSearch;
|
||||
QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement;
|
||||
public:
|
||||
|
|
|
@ -405,10 +405,9 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
|
|||
return loadFromStream_Plain(in);
|
||||
}
|
||||
|
||||
bool DeckList::saveToFile_Plain(QIODevice *device)
|
||||
bool DeckList::saveToStream_Plain(QTextStream &out)
|
||||
{
|
||||
// Support for this is only possible if the internal structure doesn't get more complicated.
|
||||
QTextStream out(device);
|
||||
for (int i = 0; i < root->size(); i++) {
|
||||
InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
|
||||
for (int j = 0; j < node->size(); j++) {
|
||||
|
@ -419,6 +418,12 @@ bool DeckList::saveToFile_Plain(QIODevice *device)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DeckList::saveToFile_Plain(QIODevice *device)
|
||||
{
|
||||
QTextStream out(device);
|
||||
return saveToStream_Plain(out);
|
||||
}
|
||||
|
||||
bool DeckList::loadFromFile(const QString &fileName, FileFormat fmt)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
|
|
@ -140,6 +140,7 @@ public:
|
|||
bool saveToFile_Native(QIODevice *device);
|
||||
bool loadFromStream_Plain(QTextStream &stream);
|
||||
bool loadFromFile_Plain(QIODevice *device);
|
||||
bool saveToStream_Plain(QTextStream &stream);
|
||||
bool saveToFile_Plain(QIODevice *device);
|
||||
bool loadFromFile(const QString &fileName, FileFormat fmt);
|
||||
bool saveToFile(const QString &fileName, FileFormat fmt);
|
||||
|
|
Loading…
Reference in a new issue