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
5d40996c
Commit
5d40996c
authored
Jun 27, 2009
by
Max-Wilhelm Bruker
Browse files
nice decklist printing
parent
c9f680f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/decklistmodel.cpp
View file @
5d40996c
...
@@ -289,23 +289,60 @@ void DeckListModel::cleanList()
...
@@ -289,23 +289,60 @@ void DeckListModel::cleanList()
void
DeckListModel
::
printDeckListNode
(
QTextCursor
*
cursor
,
InnerDecklistNode
*
node
)
void
DeckListModel
::
printDeckListNode
(
QTextCursor
*
cursor
,
InnerDecklistNode
*
node
)
{
{
cursor
->
insertBlock
()
;
static
const
int
totalColumns
=
3
;
cursor
->
insertText
(
node
->
getVisibleName
());
if
(
node
->
height
()
==
1
)
{
if
(
node
->
height
()
==
1
)
{
QTextBlockFormat
blockFormat
;
QTextCharFormat
charFormat
;
charFormat
.
setFontPointSize
(
11
);
charFormat
.
setFontWeight
(
QFont
::
Bold
);
cursor
->
insertBlock
(
blockFormat
,
charFormat
);
cursor
->
insertText
(
QString
(
"%1: %2"
).
arg
(
node
->
getVisibleName
()).
arg
(
node
->
recursiveCount
(
true
)));
QTextTableFormat
tableFormat
;
QTextTableFormat
tableFormat
;
// XXX
tableFormat
.
setCellPadding
(
0
);
QTextTable
*
table
=
cursor
->
insertTable
(
node
->
size
(),
2
,
tableFormat
);
tableFormat
.
setCellSpacing
(
0
);
tableFormat
.
setBorder
(
0
);
QTextTable
*
table
=
cursor
->
insertTable
(
node
->
size
()
+
1
,
2
,
tableFormat
);
for
(
int
i
=
0
;
i
<
node
->
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
node
->
size
();
i
++
)
{
AbstractDecklistCardNode
*
card
=
dynamic_cast
<
AbstractDecklistCardNode
*>
(
node
->
at
(
i
));
AbstractDecklistCardNode
*
card
=
dynamic_cast
<
AbstractDecklistCardNode
*>
(
node
->
at
(
i
));
QTextCursor
cellCursor
=
table
->
cellAt
(
i
,
0
).
firstCursorPosition
();
QTextCharFormat
cellCharFormat
;
cellCursor
.
insertText
(
QString
::
number
(
card
->
getNumber
()));
cellCharFormat
.
setFontPointSize
(
9
);
cellCursor
=
table
->
cellAt
(
i
,
1
).
firstCursorPosition
();
QTextTableCell
cell
=
table
->
cellAt
(
i
,
0
);
cell
.
setFormat
(
cellCharFormat
);
QTextCursor
cellCursor
=
cell
.
firstCursorPosition
();
cellCursor
.
insertText
(
QString
(
"%1 "
).
arg
(
card
->
getNumber
()));
cell
=
table
->
cellAt
(
i
,
1
);
cell
.
setFormat
(
cellCharFormat
);
cellCursor
=
cell
.
firstCursorPosition
();
cellCursor
.
insertText
(
card
->
getName
());
cellCursor
.
insertText
(
card
->
getName
());
}
}
}
else
{
}
else
if
(
node
->
height
()
==
2
)
{
for
(
int
i
=
0
;
i
<
node
->
size
();
i
++
)
QTextBlockFormat
blockFormat
;
printDeckListNode
(
cursor
,
dynamic_cast
<
InnerDecklistNode
*>
(
node
->
at
(
i
)));
QTextCharFormat
charFormat
;
charFormat
.
setFontPointSize
(
14
);
charFormat
.
setFontWeight
(
QFont
::
Bold
);
cursor
->
insertBlock
(
blockFormat
,
charFormat
);
cursor
->
insertText
(
QString
(
"%1: %2"
).
arg
(
node
->
getVisibleName
()).
arg
(
node
->
recursiveCount
(
true
)));
QTextTableFormat
tableFormat
;
tableFormat
.
setCellPadding
(
10
);
tableFormat
.
setCellSpacing
(
0
);
tableFormat
.
setBorder
(
0
);
QVector
<
QTextLength
>
constraints
;
for
(
int
i
=
0
;
i
<
totalColumns
;
i
++
)
constraints
<<
QTextLength
(
QTextLength
::
PercentageLength
,
100.0
/
totalColumns
);
tableFormat
.
setColumnWidthConstraints
(
constraints
);
QTextTable
*
table
=
cursor
->
insertTable
(
1
,
totalColumns
,
tableFormat
);
for
(
int
i
=
0
;
i
<
node
->
size
();
i
++
)
{
QTextCursor
cellCursor
=
table
->
cellAt
(
0
,
(
i
*
totalColumns
)
/
node
->
size
()).
lastCursorPosition
();
printDeckListNode
(
&
cellCursor
,
dynamic_cast
<
InnerDecklistNode
*>
(
node
->
at
(
i
)));
}
}
}
cursor
->
movePosition
(
QTextCursor
::
End
);
cursor
->
movePosition
(
QTextCursor
::
End
);
}
}
...
@@ -313,16 +350,32 @@ void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *no
...
@@ -313,16 +350,32 @@ void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *no
void
DeckListModel
::
printDeckList
(
QPrinter
*
printer
)
void
DeckListModel
::
printDeckList
(
QPrinter
*
printer
)
{
{
QTextDocument
doc
;
QTextDocument
doc
;
/* QFont font("Times");
font.setStyleHint(QFont::Serif);
doc.setDefaultFont(font);
*/
QTextCursor
cursor
(
&
doc
);
QTextCursor
cursor
(
&
doc
);
cursor
.
insertBlock
();
QTextBlockFormat
headerBlockFormat
;
QTextCharFormat
headerCharFormat
;
headerCharFormat
.
setFontPointSize
(
16
);
headerCharFormat
.
setFontWeight
(
QFont
::
Bold
);
cursor
.
insertBlock
(
headerBlockFormat
,
headerCharFormat
);
cursor
.
insertText
(
deckList
->
getName
());
cursor
.
insertText
(
deckList
->
getName
());
cursor
.
insertBlock
();
headerCharFormat
.
setFontPointSize
(
12
);
cursor
.
insertBlock
(
headerBlockFormat
,
headerCharFormat
);
cursor
.
insertText
(
deckList
->
getComments
());
cursor
.
insertText
(
deckList
->
getComments
());
cursor
.
insertBlock
(
headerBlockFormat
,
headerCharFormat
);
for
(
int
i
=
0
;
i
<
root
->
size
();
i
++
)
for
(
int
i
=
0
;
i
<
root
->
size
();
i
++
)
{
cursor
.
insertHtml
(
"<hr>"
);
cursor
.
insertBlock
(
headerBlockFormat
,
headerCharFormat
);
printDeckListNode
(
&
cursor
,
dynamic_cast
<
InnerDecklistNode
*>
(
root
->
at
(
i
)));
printDeckListNode
(
&
cursor
,
dynamic_cast
<
InnerDecklistNode
*>
(
root
->
at
(
i
)));
}
doc
.
print
(
printer
);
doc
.
print
(
printer
);
}
}
cockatrice/src/window_deckeditor.cpp
View file @
5d40996c
...
@@ -58,9 +58,10 @@ WndDeckEditor::WndDeckEditor(CardDatabase *_db, QWidget *parent)
...
@@ -58,9 +58,10 @@ WndDeckEditor::WndDeckEditor(CardDatabase *_db, QWidget *parent)
nameLabel
->
setBuddy
(
nameEdit
);
nameLabel
->
setBuddy
(
nameEdit
);
connect
(
nameEdit
,
SIGNAL
(
textChanged
(
const
QString
&
)),
deckModel
->
getDeckList
(),
SLOT
(
setName
(
const
QString
&
)));
connect
(
nameEdit
,
SIGNAL
(
textChanged
(
const
QString
&
)),
deckModel
->
getDeckList
(),
SLOT
(
setName
(
const
QString
&
)));
QLabel
*
commentsLabel
=
new
QLabel
(
tr
(
"&Comments:"
));
QLabel
*
commentsLabel
=
new
QLabel
(
tr
(
"&Comments:"
));
commentsEdit
=
new
QLineEdit
;
commentsEdit
=
new
QTextEdit
;
commentsEdit
->
setMaximumHeight
(
70
);
commentsLabel
->
setBuddy
(
commentsEdit
);
commentsLabel
->
setBuddy
(
commentsEdit
);
connect
(
commentsEdit
,
SIGNAL
(
textChanged
(
const
QString
&
)),
deckModel
->
getDeckList
()
,
SLOT
(
set
Comments
(
const
QString
&
)));
connect
(
commentsEdit
,
SIGNAL
(
textChanged
(
)),
this
,
SLOT
(
update
Comments
()));
QGridLayout
*
grid
=
new
QGridLayout
;
QGridLayout
*
grid
=
new
QGridLayout
;
grid
->
addWidget
(
nameLabel
,
0
,
0
);
grid
->
addWidget
(
nameLabel
,
0
,
0
);
grid
->
addWidget
(
nameEdit
,
0
,
1
);
grid
->
addWidget
(
nameEdit
,
0
,
1
);
...
@@ -145,6 +146,11 @@ WndDeckEditor::~WndDeckEditor()
...
@@ -145,6 +146,11 @@ WndDeckEditor::~WndDeckEditor()
}
}
void
WndDeckEditor
::
updateComments
()
{
deckModel
->
getDeckList
()
->
setComments
(
commentsEdit
->
toPlainText
());
}
void
WndDeckEditor
::
updateCardInfoLeft
(
const
QModelIndex
&
current
,
const
QModelIndex
&
/*previous*/
)
void
WndDeckEditor
::
updateCardInfoLeft
(
const
QModelIndex
&
current
,
const
QModelIndex
&
/*previous*/
)
{
{
cardInfo
->
setCard
(
current
.
sibling
(
current
.
row
(),
0
).
data
().
toString
());
cardInfo
->
setCard
(
current
.
sibling
(
current
.
row
(),
0
).
data
().
toString
());
...
...
cockatrice/src/window_deckeditor.h
View file @
5d40996c
...
@@ -12,10 +12,12 @@ class QTreeView;
...
@@ -12,10 +12,12 @@ class QTreeView;
class
QTableView
;
class
QTableView
;
class
CardInfoWidget
;
class
CardInfoWidget
;
class
QLineEdit
;
class
QLineEdit
;
class
QTextEdit
;
class
WndDeckEditor
:
public
QMainWindow
{
class
WndDeckEditor
:
public
QMainWindow
{
Q_OBJECT
Q_OBJECT
private
slots
:
private
slots
:
void
updateComments
();
void
updateCardInfoLeft
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateCardInfoLeft
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateCardInfoRight
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateCardInfoRight
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateSearch
(
const
QString
&
search
);
void
updateSearch
(
const
QString
&
search
);
...
@@ -47,7 +49,8 @@ private:
...
@@ -47,7 +49,8 @@ private:
QTreeView
*
databaseView
;
QTreeView
*
databaseView
;
QTreeView
*
deckView
;
QTreeView
*
deckView
;
CardInfoWidget
*
cardInfo
;
CardInfoWidget
*
cardInfo
;
QLineEdit
*
searchEdit
,
*
nameEdit
,
*
commentsEdit
;
QLineEdit
*
searchEdit
,
*
nameEdit
;
QTextEdit
*
commentsEdit
;
QMenu
*
deckMenu
,
*
setsMenu
;
QMenu
*
deckMenu
,
*
setsMenu
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aPrintDeck
,
*
aClose
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aPrintDeck
,
*
aClose
;
...
...
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