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
3af58040
Commit
3af58040
authored
Jun 13, 2015
by
Fabio Bas
Browse files
Reworked deck editor
parent
50b908c7
Changes
13
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
3af58040
...
@@ -587,7 +587,7 @@ void CardInfo::imageLoaded(const QImage &image)
...
@@ -587,7 +587,7 @@ void CardInfo::imageLoaded(const QImage &image)
void
CardInfo
::
getPixmap
(
QSize
size
,
QPixmap
&
pixmap
)
void
CardInfo
::
getPixmap
(
QSize
size
,
QPixmap
&
pixmap
)
{
{
QString
key
=
QLatin1String
(
"card_"
)
+
name
+
QLatin1Char
(
'_'
)
+
QString
::
number
(
size
.
width
());
QString
key
=
QLatin1String
(
"card_"
)
+
name
+
QLatin1Char
(
'_'
)
+
QString
::
number
(
size
.
width
())
+
QString
::
number
(
size
.
height
())
;
if
(
QPixmapCache
::
find
(
key
,
&
pixmap
))
if
(
QPixmapCache
::
find
(
key
,
&
pixmap
))
return
;
return
;
...
@@ -598,15 +598,15 @@ void CardInfo::getPixmap(QSize size, QPixmap &pixmap)
...
@@ -598,15 +598,15 @@ void CardInfo::getPixmap(QSize size, QPixmap &pixmap)
pixmap
=
QPixmap
();
// null
pixmap
=
QPixmap
();
// null
return
;
return
;
}
else
{
}
else
{
pixmap
=
QPixmap
(
size
);
pixmap
.
fill
(
Qt
::
transparent
);
QSvgRenderer
svg
(
QString
(
":/back.svg"
));
QSvgRenderer
svg
(
QString
(
":/back.svg"
));
QPainter
painter
(
&
pixmap
);
bigPixmap
=
QPixmap
(
svg
.
defaultSize
());
svg
.
render
(
&
painter
,
QRectF
(
0
,
0
,
size
.
width
(),
size
.
height
()));
bigPixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
bigPixmap
);
svg
.
render
(
&
painter
);
}
}
}
else
{
pixmap
=
bigPixmap
.
scaled
(
size
,
Qt
::
IgnoreAspectRatio
,
Qt
::
SmoothTransformation
);
}
}
pixmap
=
bigPixmap
.
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
QPixmapCache
::
insert
(
key
,
pixmap
);
QPixmapCache
::
insert
(
key
,
pixmap
);
}
}
...
...
cockatrice/src/carddatabasemodel.cpp
View file @
3af58040
...
@@ -183,7 +183,7 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
...
@@ -183,7 +183,7 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
return
true
;
return
true
;
}
}
void
CardDatabaseDisplayModel
::
clear
Search
()
void
CardDatabaseDisplayModel
::
clear
FilterAll
()
{
{
cardName
.
clear
();
cardName
.
clear
();
cardText
.
clear
();
cardText
.
clear
();
...
...
cockatrice/src/carddatabasemodel.h
View file @
3af58040
...
@@ -53,7 +53,7 @@ public:
...
@@ -53,7 +53,7 @@ public:
void
setCardText
(
const
QString
&
_cardText
)
{
cardText
=
_cardText
;
invalidate
();
}
void
setCardText
(
const
QString
&
_cardText
)
{
cardText
=
_cardText
;
invalidate
();
}
void
setCardTypes
(
const
QSet
<
QString
>
&
_cardTypes
)
{
cardTypes
=
_cardTypes
;
invalidate
();
}
void
setCardTypes
(
const
QSet
<
QString
>
&
_cardTypes
)
{
cardTypes
=
_cardTypes
;
invalidate
();
}
void
setCardColors
(
const
QSet
<
QString
>
&
_cardColors
)
{
cardColors
=
_cardColors
;
invalidate
();
}
void
setCardColors
(
const
QSet
<
QString
>
&
_cardColors
)
{
cardColors
=
_cardColors
;
invalidate
();
}
void
clear
Search
();
void
clear
FilterAll
();
protected:
protected:
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
;
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
;
...
...
cockatrice/src/cardframe.cpp
View file @
3af58040
...
@@ -5,26 +5,76 @@
...
@@ -5,26 +5,76 @@
#include
"main.h"
#include
"main.h"
#include
"cardinfopicture.h"
#include
"cardinfopicture.h"
#include
"cardinfotext.h"
#include
"cardinfotext.h"
#include
"settingscache.h"
#include
<QVBoxLayout>
#include
<QTabBar>
CardFrame
::
CardFrame
(
int
width
,
int
height
,
CardFrame
::
CardFrame
(
int
width
,
int
height
,
const
QString
&
cardName
,
QWidget
*
parent
)
const
QString
&
cardName
,
QWidget
*
parent
)
:
Q
StackedWidget
(
parent
)
:
Q
Frame
(
parent
)
,
info
(
0
)
,
info
(
0
)
,
cardTextOnly
(
false
)
,
cardTextOnly
(
false
)
{
{
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
setMaximumWidth
(
width
);
setMaximumWidth
(
width
);
setMinimumWidth
(
width
);
setMinimumWidth
(
width
);
setMaximumHeight
(
height
);
setMinimumHeight
(
height
);
setMinimumHeight
(
height
);
pic
=
new
CardInfoPicture
(
width
);
pic
=
new
CardInfoPicture
(
width
);
addWidget
(
pic
);
text
=
new
CardInfoText
();
text
=
new
CardInfoText
();
addWidget
(
text
);
connect
(
pic
,
SIGNAL
(
hasPictureChanged
()),
this
,
SLOT
(
hasPictureChanged
()));
tabBar
=
new
QTabBar
(
this
);
tabBar
->
setDrawBase
(
false
);
tabBar
->
insertTab
(
ImageOnlyView
,
QString
());
tabBar
->
insertTab
(
TextOnlyView
,
QString
());
tabBar
->
insertTab
(
ImageAndTextView
,
QString
());
connect
(
tabBar
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
setViewMode
(
int
)));
QVBoxLayout
*
layout
=
new
QVBoxLayout
();
layout
->
addWidget
(
tabBar
);
layout
->
addWidget
(
pic
);
layout
->
addWidget
(
text
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
setSpacing
(
0
);
setLayout
(
layout
);
setViewMode
(
settingsCache
->
getCardInfoViewMode
());
setCard
(
db
->
getCard
(
cardName
));
setCard
(
db
->
getCard
(
cardName
));
}
}
void
CardFrame
::
retranslateUi
()
{
tabBar
->
setTabText
(
ImageOnlyView
,
tr
(
"Image"
));
tabBar
->
setTabText
(
TextOnlyView
,
tr
(
"Description"
));
tabBar
->
setTabText
(
ImageAndTextView
,
tr
(
"Both"
));
}
void
CardFrame
::
setViewMode
(
int
mode
)
{
if
(
tabBar
->
currentIndex
()
!=
mode
)
tabBar
->
setCurrentIndex
(
mode
);
switch
(
mode
)
{
case
ImageOnlyView
:
pic
->
setVisible
(
true
);
text
->
setVisible
(
false
);
break
;
case
TextOnlyView
:
pic
->
setVisible
(
false
);
text
->
setVisible
(
true
);
break
;
case
ImageAndTextView
:
pic
->
setVisible
(
true
);
text
->
setVisible
(
true
);
break
;
}
settingsCache
->
setCardInfoViewMode
(
mode
);
}
void
CardFrame
::
setCard
(
CardInfo
*
card
)
void
CardFrame
::
setCard
(
CardInfo
*
card
)
{
{
if
(
info
)
if
(
info
)
...
@@ -49,11 +99,3 @@ void CardFrame::clear()
...
@@ -49,11 +99,3 @@ void CardFrame::clear()
{
{
setCard
(
db
->
getCard
());
setCard
(
db
->
getCard
());
}
}
void
CardFrame
::
hasPictureChanged
()
{
if
(
pic
->
hasPicture
()
&&
!
cardTextOnly
)
setCurrentWidget
(
pic
);
else
setCurrentWidget
(
text
);
}
cockatrice/src/cardframe.h
View file @
3af58040
#ifndef CARDFRAME_H
#ifndef CARDFRAME_H
#define CARDFRAME_H
#define CARDFRAME_H
#include
<Q
StackedWidget
>
#include
<Q
Frame
>
class
AbstractCardItem
;
class
AbstractCardItem
;
class
CardInfo
;
class
CardInfo
;
class
CardInfoPicture
;
class
CardInfoPicture
;
class
CardInfoText
;
class
CardInfoText
;
class
QTabBar
;
class
CardFrame
:
public
Q
StackedWidget
{
class
CardFrame
:
public
Q
Frame
{
Q_OBJECT
Q_OBJECT
private:
private:
QTabBar
*
tabBar
;
CardInfo
*
info
;
CardInfo
*
info
;
CardInfoPicture
*
pic
;
CardInfoPicture
*
pic
;
CardInfoText
*
text
;
CardInfoText
*
text
;
bool
cardTextOnly
;
bool
cardTextOnly
;
public:
public:
enum
ViewMode
{
ImageOnlyView
,
TextOnlyView
,
ImageAndTextView
};
CardFrame
(
int
width
,
int
height
,
const
QString
&
cardName
=
QString
(),
CardFrame
(
int
width
,
int
height
,
const
QString
&
cardName
=
QString
(),
QWidget
*
parent
=
0
);
QWidget
*
parent
=
0
);
void
setCardTextOnly
(
bool
status
)
{
cardTextOnly
=
status
;
hasPictureChanged
();
}
void
retranslateUi
();
public
slots
:
public
slots
:
void
setCard
(
CardInfo
*
card
);
void
setCard
(
CardInfo
*
card
);
void
setCard
(
const
QString
&
cardName
);
void
setCard
(
const
QString
&
cardName
);
void
setCard
(
AbstractCardItem
*
card
);
void
setCard
(
AbstractCardItem
*
card
);
void
clear
();
void
clear
();
void
setViewMode
(
int
mode
);
private
slots
:
void
hasPictureChanged
();
void
toggleCardTextOnly
()
{
setCardTextOnly
(
!
cardTextOnly
);
}
};
};
#endif
#endif
cockatrice/src/cardinfopicture.cpp
View file @
3af58040
...
@@ -10,6 +10,7 @@ CardInfoPicture::CardInfoPicture(int maximumWidth, QWidget *parent)
...
@@ -10,6 +10,7 @@ CardInfoPicture::CardInfoPicture(int maximumWidth, QWidget *parent)
,
info
(
0
)
,
info
(
0
)
,
noPicture
(
true
)
,
noPicture
(
true
)
{
{
setAlignment
(
Qt
::
AlignCenter
);
setMaximumWidth
(
maximumWidth
);
setMaximumWidth
(
maximumWidth
);
}
}
...
@@ -31,22 +32,24 @@ void CardInfoPicture::setCard(CardInfo *card)
...
@@ -31,22 +32,24 @@ void CardInfoPicture::setCard(CardInfo *card)
updatePixmap
();
updatePixmap
();
}
}
void
CardInfoPicture
::
updatePixmap
(
)
void
CardInfoPicture
::
resizeEvent
(
QResizeEvent
*
/* e */
)
{
{
qreal
aspectRatio
=
(
qreal
)
CARD_HEIGHT
/
(
qreal
)
CARD_WIDTH
;
updatePixmap
()
;
qreal
pixmapWidth
=
this
->
width
();
}
if
(
pixmapWidth
==
0
)
{
void
CardInfoPicture
::
updatePixmap
()
{
if
(
info
==
0
||
width
()
==
0
||
height
()
==
0
)
{
setNoPicture
(
true
);
setNoPicture
(
true
);
return
;
return
;
}
}
QPixmap
resizedPixmap
;
QPixmap
resizedPixmap
;
info
->
getPixmap
(
QS
ize
(
pixmapWidth
,
pixmapWidth
*
aspectRatio
),
resizedPixmap
);
info
->
getPixmap
(
s
ize
(),
resizedPixmap
);
if
(
resizedPixmap
.
isNull
())
{
if
(
resizedPixmap
.
isNull
())
{
setNoPicture
(
true
);
setNoPicture
(
true
);
db
->
getCard
()
->
getPixmap
(
QS
ize
(
pixmapWidth
,
pixmapWidth
*
aspectRatio
),
resizedPixmap
);
db
->
getCard
()
->
getPixmap
(
s
ize
(),
resizedPixmap
);
}
else
{
}
else
{
setNoPicture
(
false
);
setNoPicture
(
false
);
}
}
...
...
cockatrice/src/cardinfopicture.h
View file @
3af58040
...
@@ -19,16 +19,14 @@ private:
...
@@ -19,16 +19,14 @@ private:
public:
public:
CardInfoPicture
(
int
maximumWidth
,
QWidget
*
parent
=
0
);
CardInfoPicture
(
int
maximumWidth
,
QWidget
*
parent
=
0
);
bool
hasPicture
()
const
{
return
!
noPicture
;
}
bool
hasPicture
()
const
{
return
!
noPicture
;
}
private:
private:
void
setNoPicture
(
bool
status
);
void
setNoPicture
(
bool
status
);
protected:
void
resizeEvent
(
QResizeEvent
*
event
);
public
slots
:
public
slots
:
void
setCard
(
CardInfo
*
card
);
void
setCard
(
CardInfo
*
card
);
private
slots
:
void
updatePixmap
();
void
updatePixmap
();
};
};
#endif
#endif
cockatrice/src/filterbuilder.cpp
View file @
3af58040
#include
"filterbuilder.h"
#include
"filterbuilder.h"
#include
<Q
HBox
Layout>
#include
<Q
Grid
Layout>
#include
<QComboBox>
#include
<QComboBox>
#include
<QPushButton>
#include
<QPushButton>
#include
<QLineEdit>
#include
<QLineEdit>
...
@@ -8,41 +8,36 @@
...
@@ -8,41 +8,36 @@
#include
"cardfilter.h"
#include
"cardfilter.h"
FilterBuilder
::
FilterBuilder
(
QWidget
*
parent
)
FilterBuilder
::
FilterBuilder
(
QWidget
*
parent
)
:
Q
Frame
(
parent
)
:
Q
Widget
(
parent
)
{
{
int
i
;
QVBoxLayout
*
layout
=
new
QVBoxLayout
;
QHBoxLayout
*
addFilter
=
new
QHBoxLayout
;
filterCombo
=
new
QComboBox
;
filterCombo
=
new
QComboBox
;
for
(
i
=
0
;
i
<
CardFilter
::
AttrEnd
;
i
++
)
for
(
int
i
=
0
;
i
<
CardFilter
::
AttrEnd
;
i
++
)
filterCombo
->
addItem
(
filterCombo
->
addItem
(
tr
(
CardFilter
::
attrName
(
static_cast
<
CardFilter
::
Attr
>
(
i
))),
tr
(
CardFilter
::
attrName
(
static_cast
<
CardFilter
::
Attr
>
(
i
))),
QVariant
(
i
)
QVariant
(
i
)
);
);
typeCombo
=
new
QComboBox
;
typeCombo
=
new
QComboBox
;
for
(
i
=
0
;
i
<
CardFilter
::
TypeEnd
;
i
++
)
for
(
int
i
=
0
;
i
<
CardFilter
::
TypeEnd
;
i
++
)
typeCombo
->
addItem
(
typeCombo
->
addItem
(
tr
(
CardFilter
::
typeName
(
static_cast
<
CardFilter
::
Type
>
(
i
))),
tr
(
CardFilter
::
typeName
(
static_cast
<
CardFilter
::
Type
>
(
i
))),
QVariant
(
i
)
QVariant
(
i
)
);
);
QPushButton
*
ok
=
new
QPushButton
(
"+"
);
QPushButton
*
ok
=
new
QPushButton
(
QIcon
(
":/resources/increment.svg"
),
QString
()
);
ok
->
setMaximumSize
(
20
,
20
);
ok
->
setMaximumSize
(
20
,
20
);
addFilter
->
addWidget
(
ok
);
addFilter
->
addWidget
(
typeCombo
);
addFilter
->
addWidget
(
filterCombo
,
Qt
::
AlignLeft
);
edit
=
new
QLineEdit
;
edit
=
new
QLineEdit
;
edit
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
);
edit
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
);
layout
->
addLayout
(
addFilter
);
layout
->
addWidget
(
edit
);
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
QGridLayout
*
layout
=
new
QGridLayout
;
layout
->
setAlignment
(
Qt
::
AlignTop
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
addWidget
(
typeCombo
,
0
,
0
,
1
,
2
);
layout
->
addWidget
(
filterCombo
,
0
,
2
,
1
,
2
);
layout
->
addWidget
(
edit
,
1
,
0
,
1
,
3
);
layout
->
addWidget
(
ok
,
1
,
3
);
setLayout
(
layout
);
setLayout
(
layout
);
connect
(
edit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
emit_add
()));
connect
(
edit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
emit_add
()));
...
...
cockatrice/src/filterbuilder.h
View file @
3af58040
#ifndef FILTERBUILDER_H
#ifndef FILTERBUILDER_H
#define FILTERBUILDER_H
#define FILTERBUILDER_H
#include
<Q
Frame
>
#include
<Q
Widget
>
class
QCheckBox
;
class
QCheckBox
;
class
QComboBox
;
class
QComboBox
;
class
QLineEdit
;
class
QLineEdit
;
class
CardFilter
;
class
CardFilter
;
class
FilterBuilder
:
public
Q
Frame
{
class
FilterBuilder
:
public
Q
Widget
{
Q_OBJECT
Q_OBJECT
private:
private:
...
...
cockatrice/src/settingscache.cpp
View file @
3af58040
...
@@ -79,6 +79,13 @@ SettingsCache::SettingsCache()
...
@@ -79,6 +79,13 @@ SettingsCache::SettingsCache()
leftJustified
=
settings
->
value
(
"interface/leftjustified"
,
false
).
toBool
();
leftJustified
=
settings
->
value
(
"interface/leftjustified"
,
false
).
toBool
();
masterVolume
=
settings
->
value
(
"sound/mastervolume"
,
100
).
toInt
();
masterVolume
=
settings
->
value
(
"sound/mastervolume"
,
100
).
toInt
();
cardInfoViewMode
=
settings
->
value
(
"cards/cardinfoviewmode"
,
0
).
toInt
();
}
void
SettingsCache
::
setCardInfoViewMode
(
const
int
_viewMode
)
{
cardInfoViewMode
=
_viewMode
;
settings
->
setValue
(
"cards/cardinfoviewmode"
,
cardInfoViewMode
);
}
}
void
SettingsCache
::
setMasterVolume
(
int
_masterVolume
)
{
void
SettingsCache
::
setMasterVolume
(
int
_masterVolume
)
{
...
...
cockatrice/src/settingscache.h
View file @
3af58040
...
@@ -81,6 +81,7 @@ private:
...
@@ -81,6 +81,7 @@ private:
bool
showMentionPopups
;
bool
showMentionPopups
;
bool
leftJustified
;
bool
leftJustified
;
int
masterVolume
;
int
masterVolume
;
int
cardInfoViewMode
;
public:
public:
SettingsCache
();
SettingsCache
();
const
QByteArray
&
getMainWindowGeometry
()
const
{
return
mainWindowGeometry
;
}
const
QByteArray
&
getMainWindowGeometry
()
const
{
return
mainWindowGeometry
;
}
...
@@ -136,6 +137,7 @@ public:
...
@@ -136,6 +137,7 @@ public:
bool
getShowMentionPopup
()
const
{
return
showMentionPopups
;
}
bool
getShowMentionPopup
()
const
{
return
showMentionPopups
;
}
bool
getLeftJustified
()
const
{
return
leftJustified
;
}
bool
getLeftJustified
()
const
{
return
leftJustified
;
}
int
getMasterVolume
()
const
{
return
masterVolume
;
}
int
getMasterVolume
()
const
{
return
masterVolume
;
}
int
getCardInfoViewMode
()
const
{
return
cardInfoViewMode
;
}
public
slots
:
public
slots
:
void
setMainWindowGeometry
(
const
QByteArray
&
_mainWindowGeometry
);
void
setMainWindowGeometry
(
const
QByteArray
&
_mainWindowGeometry
);
void
setLang
(
const
QString
&
_lang
);
void
setLang
(
const
QString
&
_lang
);
...
@@ -185,6 +187,7 @@ public slots:
...
@@ -185,6 +187,7 @@ public slots:
void
setShowMentionPopups
(
const
int
_showMentionPopups
);
void
setShowMentionPopups
(
const
int
_showMentionPopups
);
void
setLeftJustified
(
const
int
_leftJustified
);
void
setLeftJustified
(
const
int
_leftJustified
);
void
setMasterVolume
(
const
int
_masterVolume
);
void
setMasterVolume
(
const
int
_masterVolume
);
void
setCardInfoViewMode
(
const
int
_viewMode
);
};
};
extern
SettingsCache
*
settingsCache
;
extern
SettingsCache
*
settingsCache
;
...
...
cockatrice/src/tab_deck_editor.cpp
View file @
3af58040
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#include
<QAction>
#include
<QAction>
#include
<QCloseEvent>
#include
<QCloseEvent>
#include
<QFileDialog>
#include
<QFileDialog>
#include
<QGroupBox>
#include
<QMenuBar>
#include
<QMenuBar>
#include
<QMessageBox>
#include
<QMessageBox>
#include
<QPrintPreviewDialog>
#include
<QPrintPreviewDialog>
...
@@ -49,9 +50,14 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
...
@@ -49,9 +50,14 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
TabDeckEditor
::
TabDeckEditor
(
TabSupervisor
*
_tabSupervisor
,
QWidget
*
parent
)
TabDeckEditor
::
TabDeckEditor
(
TabSupervisor
*
_tabSupervisor
,
QWidget
*
parent
)
:
Tab
(
_tabSupervisor
,
parent
),
modified
(
false
)
:
Tab
(
_tabSupervisor
,
parent
),
modified
(
false
)
{
{
aClearSearch
=
new
QAction
(
QString
(),
this
);
aClearFilterAll
=
new
QAction
(
QString
(),
this
);
aClearSearch
->
setIcon
(
QIcon
(
":/resources/icon_clearsearch.svg"
));
aClearFilterAll
->
setIcon
(
QIcon
(
":/resources/icon_clearsearch.svg"
));
connect
(
aClearSearch
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actClearSearch
()));
connect
(
aClearFilterAll
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actClearFilterAll
()));
aClearFilterOne
=
new
QAction
(
QString
(),
this
);
aClearFilterOne
->
setIcon
(
QIcon
(
":/resources/decrement.svg"
));
connect
(
aClearFilterOne
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actClearFilterOne
()));
searchEdit
=
new
SearchLineEdit
;
searchEdit
=
new
SearchLineEdit
;
#if QT_VERSION >= 0x050300
#if QT_VERSION >= 0x050300
searchEdit
->
addAction
(
QIcon
(
":/resources/icon_search_black.svg"
),
QLineEdit
::
LeadingPosition
);
searchEdit
->
addAction
(
QIcon
(
":/resources/icon_search_black.svg"
),
QLineEdit
::
LeadingPosition
);
...
@@ -103,9 +109,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
...
@@ -103,9 +109,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
leftFrame
->
addWidget
(
databaseView
);
leftFrame
->
addWidget
(
databaseView
);
cardInfo
=
new
CardFrame
(
250
,
356
);
cardInfo
=
new
CardFrame
(
250
,
356
);
aCardTextOnly
=
new
QAction
(
QString
(),
this
);
aCardTextOnly
->
setCheckable
(
true
);
connect
(
aCardTextOnly
,
SIGNAL
(
triggered
()),
cardInfo
,
SLOT
(
toggleCardTextOnly
()));
filterModel
=
new
FilterTreeModel
();
filterModel
=
new
FilterTreeModel
();
databaseDisplayModel
->
setFilterTree
(
filterModel
->
filterTree
());
databaseDisplayModel
->
setFilterTree
(
filterModel
->
filterTree
());
...
@@ -119,16 +122,29 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
...
@@ -119,16 +122,29 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
connect
(
filterView
,
SIGNAL
(
customContextMenuRequested
(
const
QPoint
&
)),
connect
(
filterView
,
SIGNAL
(
customContextMenuRequested
(
const
QPoint
&
)),
this
,
SLOT
(
filterViewCustomContextMenu
(
const
QPoint
&
)));
this
,
SLOT
(
filterViewCustomContextMenu
(
const
QPoint
&
)));
FilterBuilder
*
filterBuilder
=
new
FilterBuilder
;
FilterBuilder
*
filterBuilder
=
new
FilterBuilder
;
filterBuilder
->
setMaximumWidth
(
250
);
connect
(
filterBuilder
,
SIGNAL
(
add
(
const
CardFilter
*
)),
filterModel
,
SLOT
(
addFilter
(
const
CardFilter
*
)));
connect
(
filterBuilder
,
SIGNAL
(
add
(
const
CardFilter
*
)),
filterModel
,
SLOT
(
addFilter
(
const
CardFilter
*
)));
QVBoxLayout
*
filter
=
new
QVBoxLayout
;
QToolButton
*
filterDelOne
=
new
QToolButton
();
filter
->
addWidget
(
filterBuilder
,
0
,
Qt
::
AlignTop
);
filterDelOne
->
setDefaultAction
(
aClearFilterOne
);
filter
->
addWidget
(
filterView
,
10
);
filterDelOne
->
setToolButtonStyle
(
Qt
::
ToolButtonTextBesideIcon
);
QToolButton
*
filterDelAll
=
new
QToolButton
();
filterDelAll
->
setDefaultAction
(
aClearFilterAll
);
filterDelAll
->
setToolButtonStyle
(
Qt
::
ToolButtonTextBesideIcon
);
QGridLayout
*
filterLayout
=
new
QGridLayout
;
filterLayout
->
addWidget
(
filterBuilder
,
0
,
0
,
1
,
2
);
filterLayout
->
addWidget
(
filterView
,
1
,
0
,
1
,
2
);
filterLayout
->
addWidget
(
filterDelOne
,
2
,
0
);
filterLayout
->
addWidget
(
filterDelAll
,
2
,
1
);
filterBox
=
new
QGroupBox
();
filterBox
->
setMaximumWidth
(
250
);
filterBox
->
setLayout
(
filterLayout
);
QVBoxLayout
*
middleFrame
=
new
QVBoxLayout
;
QVBoxLayout
*
middleFrame
=
new
QVBoxLayout
;
middleFrame
->
addWidget
(
cardInfo
,
0
,
Qt
::
AlignTop
);
middleFrame
->
addWidget
(
cardInfo
,
0
,
Qt
::
AlignTop
);
middleFrame
->
add
Layou
t
(
filter
,
1
0
);
middleFrame
->
add
Widge
t
(
filter
Box
,
0
);
deckModel
=
new
DeckListModel
(
this
);
deckModel
=
new
DeckListModel
(
this
);
connect
(
deckModel
,
SIGNAL
(
deckHashChanged
()),
this
,
SLOT
(
updateHash
()));
connect
(
deckModel
,
SIGNAL
(
deckHashChanged
()),
this
,
SLOT
(
updateHash
()));
...
@@ -258,8 +274,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
...
@@ -258,8 +274,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
dbMenu
->
addAction
(
aEditSets
);
dbMenu
->
addAction
(
aEditSets
);
dbMenu
->
addAction
(
aEditTokens
);
dbMenu
->
addAction
(
aEditTokens
);
dbMenu
->
addSeparator
();
dbMenu
->
addSeparator
();
dbMenu
->
addAction
(
aClearSearch
);
dbMenu
->
addAction
(
aClearFilterAll
);
dbMenu
->
addAction
(
aCardTextOnly
);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
dbMenu
->
addSeparator
();
dbMenu
->
addSeparator
();
dbMenu
->
addAction
(
aOpenCustomFolder
);
dbMenu
->
addAction
(
aOpenCustomFolder
);
...
@@ -303,8 +318,11 @@ TabDeckEditor::~TabDeckEditor()
...
@@ -303,8 +318,11 @@ TabDeckEditor::~TabDeckEditor()
void
TabDeckEditor
::
retranslateUi
()
void
TabDeckEditor
::
retranslateUi
()
{
{
aCardTextOnly
->
setText
(
tr
(
"Show card text only"
));
cardInfo
->
retranslateUi
();
aClearSearch
->
setText
(
tr
(
"&Clear search"
));
filterBox
->
setTitle
(
tr
(
"Filters"
));
aClearFilterAll
->
setText
(
tr
(
"&Clear all filters"
));
aClearFilterOne
->
setText
(
tr
(
"Delete selected"
));
nameLabel
->
setText
(
tr
(
"Deck &name:"
));
nameLabel
->
setText
(
tr
(
"Deck &name:"
));
commentsLabel
->
setText
(
tr
(
"&Comments:"
));
commentsLabel
->
setText
(
tr
(
"&Comments:"
));
...
@@ -570,9 +588,16 @@ void TabDeckEditor::actEditTokens()
...
@@ -570,9 +588,16 @@ void TabDeckEditor::actEditTokens()
db
->
saveToFile
(
settingsCache
->
getTokenDatabasePath
(),
true
);
db
->
saveToFile
(
settingsCache
->
getTokenDatabasePath
(),
true
);
}
}
void
TabDeckEditor
::
actClear
Search
()
void
TabDeckEditor
::
actClear
FilterAll
()
{
{
databaseDisplayModel
->
clearSearch
();
databaseDisplayModel
->
clearFilterAll
();
}
void
TabDeckEditor
::
actClearFilterOne
()
{
QModelIndexList
selIndexes
=
filterView
->
selectionModel
()
->
selectedIndexes
();
foreach
(
QModelIndex
idx
,
selIndexes
)
filterModel
->
removeRow
(
idx
.
row
(),
idx
.
parent
());
}
}
void
TabDeckEditor
::
recursiveExpand
(
const
QModelIndex
&
index
)
void
TabDeckEditor
::
recursiveExpand
(
const
QModelIndex
&
index
)
...
...
cockatrice/src/tab_deck_editor.h
View file @
3af58040
...
@@ -17,7 +17,9 @@ class QLabel;
...
@@ -17,7 +17,9 @@ class QLabel;
class
DeckLoader
;
class
DeckLoader
;
class
Response
;
class
Response
;
class
FilterTreeModel
;
class
FilterTreeModel
;
class
FilterBuilder
;
class
CardInfo
;
class
CardInfo
;
class
QGroupBox
;
class
SearchLineEdit
:
public
QLineEdit
{
class
SearchLineEdit
:
public
QLineEdit
{
private:
private:
...
@@ -52,7 +54,8 @@ class TabDeckEditor : public Tab {
...
@@ -52,7 +54,8 @@ class TabDeckEditor : public Tab {
void
actEditSets
();
void
actEditSets
();
void
actEditTokens
();
void
actEditTokens
();
void
actClearSearch
();
void
actClearFilterAll
();
void
actClearFilterOne
();
void
actSwapCard
();
void
actSwapCard
();
void
actAddCard
();
void
actAddCard
();
...
@@ -96,10 +99,11 @@ private:
...
@@ -96,10 +99,11 @@ private:
QLabel
*
hashLabel
;
QLabel
*
hashLabel
;
FilterTreeModel
*
filterModel
;
FilterTreeModel
*
filterModel
;
QTreeView
*
filterView
;
QTreeView
*
filterView
;
QGroupBox
*
filterBox
;
QMenu
*
deckMenu
,
*
dbMenu
;
QMenu
*
deckMenu
,
*
dbMenu
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aLoadDeckFromClipboard
,
*
aSaveDeckToClipboard
,
*
aPrintDeck
,
*
aAnalyzeDeck
,
*
aClose
,
*
aOpenCustomFolder
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aLoadDeckFromClipboard
,
*
aSaveDeckToClipboard
,
*
aPrintDeck
,
*
aAnalyzeDeck
,
*
aClose
,
*
aOpenCustomFolder
;
QAction
*
aEditSets
,
*
aEditTokens
,
*
aClear
Search
,
*
aCardTextOnly
;
QAction
*
aEditSets
,
*
aEditTokens
,
*
aClear
FilterAll
,
*
aClearFilterOne
;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
;
// *aUpdatePrices;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
;
// *aUpdatePrices;
bool
modified
;
bool
modified
;
...
...
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