Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
579628b4
Commit
579628b4
authored
Jun 06, 2010
by
Max-Wilhelm Bruker
Browse files
save deck to clipboard
parent
37de620e
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/window_deckeditor.cpp
View file @
579628b4
...
...
@@ -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
);
...
...
cockatrice/src/window_deckeditor.h
View file @
579628b4
...
...
@@ -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
,
*
aSaveDeck
ToClipboard
,
*
aPrintDeck
,
*
aClose
;
QAction
*
aEditSets
,
*
aSearch
,
*
aClearSearch
;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
;
public:
...
...
common/decklist.cpp
View file @
579628b4
...
...
@@ -405,10 +405,9 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
return
loadFromStream_Plain
(
in
);
}
bool
DeckList
::
saveTo
File
_Plain
(
Q
IODevice
*
device
)
bool
DeckList
::
saveTo
Stream
_Plain
(
Q
TextStream
&
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
);
...
...
common/decklist.h
View file @
579628b4
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment