mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Performance stuffs.
This commit is contained in:
parent
a688a5fe72
commit
2dab9a7db2
8 changed files with 171 additions and 99 deletions
|
|
@ -5,14 +5,14 @@
|
||||||
# Uncomment a rule to disable logging for that category,
|
# Uncomment a rule to disable logging for that category,
|
||||||
# or set .debug = true for that category to see debug level logs
|
# or set .debug = true for that category to see debug level logs
|
||||||
|
|
||||||
# main = false
|
main = false
|
||||||
# qt_translator = false
|
qt_translator = false
|
||||||
# window_main.* = false
|
window_main = false
|
||||||
# release_channel = false
|
release_channel = false
|
||||||
# spoiler_background_updater = false
|
spoiler_background_updater = false
|
||||||
# theme_manager = false
|
theme_manager = false
|
||||||
# sound_engine = false
|
sound_engine = false
|
||||||
# tapped_out_interface = false
|
tapped_out_interface = false
|
||||||
|
|
||||||
# tab_game = false
|
# tab_game = false
|
||||||
# tab_message = false
|
# tab_message = false
|
||||||
|
|
@ -38,17 +38,17 @@
|
||||||
|
|
||||||
# user_info_connection = false
|
# user_info_connection = false
|
||||||
|
|
||||||
# picture_loader = false
|
picture_loader = false
|
||||||
# picture_loader.worker = false
|
picture_loader.worker = false
|
||||||
# picture_loader.card_back_cache_fail = false
|
picture_loader.card_back_cache_fail = false
|
||||||
# picture_loader.picture_to_load = false
|
picture_loader.picture_to_load = false
|
||||||
# deck_loader = false
|
# deck_loader = false
|
||||||
# card_database = false
|
card_database = false
|
||||||
# card_database.loading = false
|
card_database.loading = false
|
||||||
# card_database.loading.success_or_failure = false
|
card_database.loading.success_or_failure = true
|
||||||
# cockatrice_xml.* = false
|
cockatrice_xml.* = false
|
||||||
# cockatrice_xml.xml_3_parser = false
|
cockatrice_xml.xml_3_parser = false
|
||||||
# cockatrice_xml.xml_4_parser = false
|
cockatrice_xml.xml_4_parser = false
|
||||||
# card_info = false
|
# card_info = false
|
||||||
# card_list = false
|
# card_list = false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ void TabDeckEditorVisual::createCentralFrame()
|
||||||
void TabDeckEditorVisual::onDeckChanged()
|
void TabDeckEditorVisual::onDeckChanged()
|
||||||
{
|
{
|
||||||
AbstractTabDeckEditor::onDeckModified();
|
AbstractTabDeckEditor::onDeckModified();
|
||||||
tabContainer->visualDeckView->decklistDataChanged(QModelIndex(), QModelIndex());
|
tabContainer->visualDeckView->constructZoneWidgetsFromDeckListModel();
|
||||||
tabContainer->deckAnalytics->refreshDisplays(deckDockWidget->deckModel);
|
tabContainer->deckAnalytics->refreshDisplays(deckDockWidget->deckModel);
|
||||||
tabContainer->sampleHandWidget->setDeckModel(deckDockWidget->deckModel);
|
tabContainer->sampleHandWidget->setDeckModel(deckDockWidget->deckModel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
DeckCardZoneDisplayWidget::DeckCardZoneDisplayWidget(QWidget *parent,
|
DeckCardZoneDisplayWidget::DeckCardZoneDisplayWidget(QWidget *parent,
|
||||||
DeckListModel *_deckListModel,
|
DeckListModel *_deckListModel,
|
||||||
|
QPersistentModelIndex _trackedIndex,
|
||||||
QString _zoneName,
|
QString _zoneName,
|
||||||
QString _activeGroupCriteria,
|
QString _activeGroupCriteria,
|
||||||
QStringList _activeSortCriteria,
|
QStringList _activeSortCriteria,
|
||||||
|
|
@ -16,7 +17,7 @@ DeckCardZoneDisplayWidget::DeckCardZoneDisplayWidget(QWidget *parent,
|
||||||
int bannerOpacity,
|
int bannerOpacity,
|
||||||
int subBannerOpacity,
|
int subBannerOpacity,
|
||||||
CardSizeWidget *_cardSizeWidget)
|
CardSizeWidget *_cardSizeWidget)
|
||||||
: QWidget(parent), deckListModel(_deckListModel), zoneName(_zoneName), activeGroupCriteria(_activeGroupCriteria),
|
: QWidget(parent), deckListModel(_deckListModel), trackedIndex(_trackedIndex), zoneName(_zoneName), activeGroupCriteria(_activeGroupCriteria),
|
||||||
activeSortCriteria(_activeSortCriteria), displayType(_displayType), bannerOpacity(bannerOpacity),
|
activeSortCriteria(_activeSortCriteria), displayType(_displayType), bannerOpacity(bannerOpacity),
|
||||||
subBannerOpacity(subBannerOpacity), cardSizeWidget(_cardSizeWidget)
|
subBannerOpacity(subBannerOpacity), cardSizeWidget(_cardSizeWidget)
|
||||||
{
|
{
|
||||||
|
|
@ -34,8 +35,65 @@ DeckCardZoneDisplayWidget::DeckCardZoneDisplayWidget(QWidget *parent,
|
||||||
banner->setBuddy(cardGroupContainer);
|
banner->setBuddy(cardGroupContainer);
|
||||||
|
|
||||||
displayCards();
|
displayCards();
|
||||||
connect(deckListModel, &DeckListModel::dataChanged, this, &DeckCardZoneDisplayWidget::displayCards);
|
//connect(deckListModel, &DeckListModel::dataChanged, this, &DeckCardZoneDisplayWidget::displayCards);
|
||||||
|
//connect(deckListModel, &DeckListModel::dataChanged, this, &DeckCardZoneDisplayWidget::decklistDataChanged);
|
||||||
|
connect(deckListModel, &QAbstractItemModel::rowsInserted, this, &DeckCardZoneDisplayWidget::onCategoryAddition);
|
||||||
|
connect(deckListModel, &QAbstractItemModel::rowsRemoved, this, &DeckCardZoneDisplayWidget::onCategoryRemoval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckCardZoneDisplayWidget::onCategoryAddition(const QModelIndex &parent, int first, int last)
|
||||||
|
{
|
||||||
|
if (parent == trackedIndex) {
|
||||||
|
for (int i = first; i <= last; i++) {
|
||||||
|
QPersistentModelIndex index = QPersistentModelIndex(deckListModel->index(i, 1, trackedIndex));
|
||||||
|
|
||||||
|
if (indexToWidgetMap.contains(index)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qInfo() << deckListModel->data(index, Qt::EditRole).toString();
|
||||||
|
|
||||||
|
if (displayType == "overlap") {
|
||||||
|
auto *display_widget = new OverlappedCardGroupDisplayWidget(
|
||||||
|
cardGroupContainer, deckListModel, zoneName, deckListModel->data(index, Qt::EditRole).toString(), activeGroupCriteria, activeSortCriteria,
|
||||||
|
subBannerOpacity, cardSizeWidget);
|
||||||
|
connect(display_widget, SIGNAL(cardClicked(QMouseEvent *, CardInfoPictureWithTextOverlayWidget *)), this,
|
||||||
|
SLOT(onClick(QMouseEvent *, CardInfoPictureWithTextOverlayWidget *)));
|
||||||
|
connect(display_widget, SIGNAL(cardHovered(CardInfoPtr)), this, SLOT(onHover(CardInfoPtr)));
|
||||||
|
connect(this, &DeckCardZoneDisplayWidget::activeSortCriteriaChanged, display_widget,
|
||||||
|
&CardGroupDisplayWidget::onActiveSortCriteriaChanged);
|
||||||
|
cardGroupLayout->addWidget(display_widget);
|
||||||
|
indexToWidgetMap.insert(index, display_widget);
|
||||||
|
} else if (displayType == "flat") {
|
||||||
|
auto *display_widget = new FlatCardGroupDisplayWidget(cardGroupContainer, deckListModel, zoneName,
|
||||||
|
deckListModel->data(index, Qt::EditRole).toString(), activeGroupCriteria, activeSortCriteria,
|
||||||
|
subBannerOpacity, cardSizeWidget);
|
||||||
|
connect(display_widget, SIGNAL(cardClicked(QMouseEvent *, CardInfoPictureWithTextOverlayWidget *)), this,
|
||||||
|
SLOT(onClick(QMouseEvent *, CardInfoPictureWithTextOverlayWidget *)));
|
||||||
|
connect(display_widget, SIGNAL(cardHovered(CardInfoPtr)), this, SLOT(onHover(CardInfoPtr)));
|
||||||
|
connect(this, &DeckCardZoneDisplayWidget::activeSortCriteriaChanged, display_widget,
|
||||||
|
&CardGroupDisplayWidget::onActiveSortCriteriaChanged);
|
||||||
|
cardGroupLayout->addWidget(display_widget);
|
||||||
|
indexToWidgetMap.insert(index, display_widget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckCardZoneDisplayWidget::onCategoryRemoval(const QModelIndex &parent, int first, int last)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
Q_UNUSED(first);
|
||||||
|
Q_UNUSED(last);
|
||||||
|
for (const QPersistentModelIndex &idx : indexToWidgetMap.keys()) {
|
||||||
|
if (!idx.isValid()) {
|
||||||
|
cardGroupLayout->removeWidget(indexToWidgetMap.value(idx));
|
||||||
|
indexToWidgetMap.value(idx)->deleteLater();
|
||||||
|
indexToWidgetMap.remove(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::resizeEvent(QResizeEvent *event)
|
void DeckCardZoneDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
|
|
@ -57,8 +115,6 @@ void DeckCardZoneDisplayWidget::onHover(CardInfoPtr card)
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::displayCards()
|
void DeckCardZoneDisplayWidget::displayCards()
|
||||||
{
|
{
|
||||||
addCardGroupIfItDoesNotExist();
|
|
||||||
deleteCardGroupIfItDoesNotExist();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::refreshDisplayType(const DisplayType &_displayType)
|
void DeckCardZoneDisplayWidget::refreshDisplayType(const DisplayType &_displayType)
|
||||||
|
|
@ -127,21 +183,6 @@ void DeckCardZoneDisplayWidget::addCardGroupIfItDoesNotExist()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::deleteCardGroupIfItDoesNotExist()
|
|
||||||
{
|
|
||||||
QList<CardGroupDisplayWidget *> cardGroupsDisplayWidgets =
|
|
||||||
cardGroupContainer->findChildren<CardGroupDisplayWidget *>();
|
|
||||||
|
|
||||||
QList<QString> validGroups = getGroupCriteriaValueList();
|
|
||||||
|
|
||||||
for (CardGroupDisplayWidget *cardGroupDisplayWidget : cardGroupsDisplayWidgets) {
|
|
||||||
if (!validGroups.contains(cardGroupDisplayWidget->cardGroupCategory)) {
|
|
||||||
cardGroupLayout->removeWidget(cardGroupDisplayWidget);
|
|
||||||
cardGroupDisplayWidget->deleteLater(); // Properly delete the widget after the event loop cycles
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged(QString _activeGroupCriteria)
|
void DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged(QString _activeGroupCriteria)
|
||||||
{
|
{
|
||||||
activeGroupCriteria = _activeGroupCriteria;
|
activeGroupCriteria = _activeGroupCriteria;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ class DeckCardZoneDisplayWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
DeckCardZoneDisplayWidget(QWidget *parent,
|
DeckCardZoneDisplayWidget(QWidget *parent,
|
||||||
DeckListModel *deckListModel,
|
DeckListModel *deckListModel,
|
||||||
|
QPersistentModelIndex trackedIndex,
|
||||||
QString zoneName,
|
QString zoneName,
|
||||||
QString activeGroupCriteria,
|
QString activeGroupCriteria,
|
||||||
QStringList activeSortCriteria,
|
QStringList activeSortCriteria,
|
||||||
|
|
@ -27,6 +28,7 @@ public:
|
||||||
int subBannerOpacity,
|
int subBannerOpacity,
|
||||||
CardSizeWidget *_cardSizeWidget);
|
CardSizeWidget *_cardSizeWidget);
|
||||||
DeckListModel *deckListModel;
|
DeckListModel *deckListModel;
|
||||||
|
QPersistentModelIndex trackedIndex;
|
||||||
QString zoneName;
|
QString zoneName;
|
||||||
void addCardsToOverlapWidget();
|
void addCardsToOverlapWidget();
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
@ -37,10 +39,11 @@ public slots:
|
||||||
void displayCards();
|
void displayCards();
|
||||||
void refreshDisplayType(const DisplayType &displayType);
|
void refreshDisplayType(const DisplayType &displayType);
|
||||||
void addCardGroupIfItDoesNotExist();
|
void addCardGroupIfItDoesNotExist();
|
||||||
void deleteCardGroupIfItDoesNotExist();
|
|
||||||
void onActiveGroupCriteriaChanged(QString activeGroupCriteria);
|
void onActiveGroupCriteriaChanged(QString activeGroupCriteria);
|
||||||
void onActiveSortCriteriaChanged(QStringList activeSortCriteria);
|
void onActiveSortCriteriaChanged(QStringList activeSortCriteria);
|
||||||
QList<QString> getGroupCriteriaValueList();
|
QList<QString> getGroupCriteriaValueList();
|
||||||
|
void onCategoryAddition(const QModelIndex &parent, int first, int last);
|
||||||
|
void onCategoryRemoval(const QModelIndex &parent, int first, int last);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void cardClicked(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *card, QString zoneName);
|
void cardClicked(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *card, QString zoneName);
|
||||||
|
|
@ -59,6 +62,7 @@ private:
|
||||||
QWidget *cardGroupContainer;
|
QWidget *cardGroupContainer;
|
||||||
QVBoxLayout *cardGroupLayout;
|
QVBoxLayout *cardGroupLayout;
|
||||||
OverlapWidget *overlapWidget;
|
OverlapWidget *overlapWidget;
|
||||||
|
QHash<QPersistentModelIndex, QWidget*> indexToWidgetMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECK_CARD_ZONE_DISPLAY_WIDGET_H
|
#endif // DECK_CARD_ZONE_DISPLAY_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@
|
||||||
VisualDeckEditorWidget::VisualDeckEditorWidget(QWidget *parent, DeckListModel *_deckListModel)
|
VisualDeckEditorWidget::VisualDeckEditorWidget(QWidget *parent, DeckListModel *_deckListModel)
|
||||||
: QWidget(parent), deckListModel(_deckListModel)
|
: QWidget(parent), deckListModel(_deckListModel)
|
||||||
{
|
{
|
||||||
connect(deckListModel, &DeckListModel::dataChanged, this, &VisualDeckEditorWidget::decklistDataChanged);
|
|
||||||
|
|
||||||
// The Main Widget and Main Layout, which contain a single Widget: The Scroll Area
|
// The Main Widget and Main Layout, which contain a single Widget: The Scroll Area
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
mainLayout = new QVBoxLayout(this);
|
mainLayout = new QVBoxLayout(this);
|
||||||
|
|
@ -175,14 +173,17 @@ VisualDeckEditorWidget::VisualDeckEditorWidget(QWidget *parent, DeckListModel *_
|
||||||
scrollArea->addScrollBarWidget(zoneContainer, Qt::AlignHCenter);
|
scrollArea->addScrollBarWidget(zoneContainer, Qt::AlignHCenter);
|
||||||
scrollArea->setWidget(zoneContainer);
|
scrollArea->setWidget(zoneContainer);
|
||||||
|
|
||||||
updateZoneWidgets();
|
|
||||||
|
|
||||||
cardSizeWidget = new CardSizeWidget(this);
|
cardSizeWidget = new CardSizeWidget(this);
|
||||||
|
|
||||||
mainLayout->addWidget(groupAndSortContainer);
|
mainLayout->addWidget(groupAndSortContainer);
|
||||||
mainLayout->addWidget(scrollArea);
|
mainLayout->addWidget(scrollArea);
|
||||||
mainLayout->addWidget(cardSizeWidget);
|
mainLayout->addWidget(cardSizeWidget);
|
||||||
|
|
||||||
|
connect(deckListModel, &DeckListModel::dataChanged, this, &VisualDeckEditorWidget::decklistDataChanged);
|
||||||
|
connect(deckListModel, &QAbstractItemModel::rowsInserted, this, &VisualDeckEditorWidget::onCardAddition);
|
||||||
|
connect(deckListModel, &QAbstractItemModel::rowsRemoved, this, &VisualDeckEditorWidget::onCardRemoval);
|
||||||
|
constructZoneWidgetsFromDeckListModel();
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,10 +199,81 @@ void VisualDeckEditorWidget::retranslateUi()
|
||||||
tr("Change how cards are displayed within zones (i.e. overlapped or fully visible.)"));
|
tr("Change how cards are displayed within zones (i.e. overlapped or fully visible.)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VisualDeckEditorWidget::onCardAddition(const QModelIndex &parent, int first, int last)
|
||||||
|
{
|
||||||
|
if (parent == deckListModel->getRoot()) {
|
||||||
|
for (int i = first; i <= last; i++) {
|
||||||
|
QPersistentModelIndex index = QPersistentModelIndex(deckListModel->index(i, 1, deckListModel->getRoot()));
|
||||||
|
|
||||||
|
if (indexToWidgetMap.contains(index)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qInfo() << deckListModel->data(index, Qt::EditRole).toString();
|
||||||
|
|
||||||
|
DeckCardZoneDisplayWidget *zoneDisplayWidget = new DeckCardZoneDisplayWidget(
|
||||||
|
zoneContainer, deckListModel, index, deckListModel->data(index, Qt::EditRole).toString(), activeGroupCriteria,
|
||||||
|
activeSortCriteria, 20, 10, cardSizeWidget);
|
||||||
|
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardHovered, this, &VisualDeckEditorWidget::onHover);
|
||||||
|
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardClicked, this, &VisualDeckEditorWidget::onCardClick);
|
||||||
|
connect(this, &VisualDeckEditorWidget::activeSortCriteriaChanged, zoneDisplayWidget,
|
||||||
|
&DeckCardZoneDisplayWidget::onActiveSortCriteriaChanged);
|
||||||
|
connect(this, &VisualDeckEditorWidget::activeGroupCriteriaChanged, zoneDisplayWidget,
|
||||||
|
&DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged);
|
||||||
|
connect(this, &VisualDeckEditorWidget::displayTypeChanged, zoneDisplayWidget,
|
||||||
|
&DeckCardZoneDisplayWidget::refreshDisplayType);
|
||||||
|
zoneContainerLayout->addWidget(zoneDisplayWidget);
|
||||||
|
|
||||||
|
indexToWidgetMap.insert(index, zoneDisplayWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisualDeckEditorWidget::onCardRemoval(const QModelIndex &parent, int first, int last)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
Q_UNUSED(first);
|
||||||
|
Q_UNUSED(last);
|
||||||
|
for (const QPersistentModelIndex &idx : indexToWidgetMap.keys()) {
|
||||||
|
if (!idx.isValid()) {
|
||||||
|
zoneContainerLayout->removeWidget(indexToWidgetMap.value(idx));
|
||||||
|
indexToWidgetMap.value(idx)->deleteLater();
|
||||||
|
indexToWidgetMap.remove(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisualDeckEditorWidget::constructZoneWidgetsFromDeckListModel()
|
||||||
|
{
|
||||||
|
qInfo() << "Constructing zone widgets";
|
||||||
|
for (int i = 0; i < deckListModel->rowCount(deckListModel->parent(QModelIndex())); ++i) {
|
||||||
|
QPersistentModelIndex index = QPersistentModelIndex(deckListModel->index(i, 1, deckListModel->getRoot()));
|
||||||
|
|
||||||
|
if (indexToWidgetMap.contains(index)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qInfo() << deckListModel->data(index, Qt::EditRole).toString();
|
||||||
|
|
||||||
|
DeckCardZoneDisplayWidget *zoneDisplayWidget = new DeckCardZoneDisplayWidget(
|
||||||
|
zoneContainer, deckListModel, index, deckListModel->data(index, Qt::EditRole).toString(), activeGroupCriteria,
|
||||||
|
activeSortCriteria, 20, 10, cardSizeWidget);
|
||||||
|
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardHovered, this, &VisualDeckEditorWidget::onHover);
|
||||||
|
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardClicked, this, &VisualDeckEditorWidget::onCardClick);
|
||||||
|
connect(this, &VisualDeckEditorWidget::activeSortCriteriaChanged, zoneDisplayWidget,
|
||||||
|
&DeckCardZoneDisplayWidget::onActiveSortCriteriaChanged);
|
||||||
|
connect(this, &VisualDeckEditorWidget::activeGroupCriteriaChanged, zoneDisplayWidget,
|
||||||
|
&DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged);
|
||||||
|
connect(this, &VisualDeckEditorWidget::displayTypeChanged, zoneDisplayWidget,
|
||||||
|
&DeckCardZoneDisplayWidget::refreshDisplayType);
|
||||||
|
zoneContainerLayout->addWidget(zoneDisplayWidget);
|
||||||
|
|
||||||
|
indexToWidgetMap.insert(index, zoneDisplayWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VisualDeckEditorWidget::updateZoneWidgets()
|
void VisualDeckEditorWidget::updateZoneWidgets()
|
||||||
{
|
{
|
||||||
addZoneIfDoesNotExist();
|
|
||||||
deleteZoneIfDoesNotExist();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDeckEditorWidget::updateDisplayType()
|
void VisualDeckEditorWidget::updateDisplayType()
|
||||||
|
|
@ -221,57 +293,6 @@ void VisualDeckEditorWidget::updateDisplayType()
|
||||||
emit displayTypeChanged(currentDisplayType);
|
emit displayTypeChanged(currentDisplayType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDeckEditorWidget::addZoneIfDoesNotExist()
|
|
||||||
{
|
|
||||||
QList<DeckCardZoneDisplayWidget *> cardZoneDisplayWidgets =
|
|
||||||
zoneContainer->findChildren<DeckCardZoneDisplayWidget *>();
|
|
||||||
for (const QString &zone : *deckListModel->getZones()) {
|
|
||||||
bool found = false;
|
|
||||||
for (DeckCardZoneDisplayWidget *displayWidget : cardZoneDisplayWidgets) {
|
|
||||||
if (displayWidget->zoneName == zone) {
|
|
||||||
found = true;
|
|
||||||
displayWidget->displayCards();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DeckCardZoneDisplayWidget *zoneDisplayWidget =
|
|
||||||
new DeckCardZoneDisplayWidget(zoneContainer, deckListModel, zone, activeGroupCriteria, activeSortCriteria,
|
|
||||||
currentDisplayType, 20, 10, cardSizeWidget);
|
|
||||||
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardHovered, this, &VisualDeckEditorWidget::onHover);
|
|
||||||
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardClicked, this, &VisualDeckEditorWidget::onCardClick);
|
|
||||||
connect(this, &VisualDeckEditorWidget::activeSortCriteriaChanged, zoneDisplayWidget,
|
|
||||||
&DeckCardZoneDisplayWidget::onActiveSortCriteriaChanged);
|
|
||||||
connect(this, &VisualDeckEditorWidget::activeGroupCriteriaChanged, zoneDisplayWidget,
|
|
||||||
&DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged);
|
|
||||||
connect(this, &VisualDeckEditorWidget::displayTypeChanged, zoneDisplayWidget,
|
|
||||||
&DeckCardZoneDisplayWidget::refreshDisplayType);
|
|
||||||
zoneContainerLayout->addWidget(zoneDisplayWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VisualDeckEditorWidget::deleteZoneIfDoesNotExist()
|
|
||||||
{
|
|
||||||
QList<DeckCardZoneDisplayWidget *> cardZoneDisplayWidgets =
|
|
||||||
zoneContainer->findChildren<DeckCardZoneDisplayWidget *>();
|
|
||||||
for (DeckCardZoneDisplayWidget *displayWidget : cardZoneDisplayWidgets) {
|
|
||||||
bool found = false;
|
|
||||||
for (const QString &zone : *deckListModel->getZones()) {
|
|
||||||
if (displayWidget->zoneName == zone) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
zoneContainerLayout->removeWidget(displayWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VisualDeckEditorWidget::resizeEvent(QResizeEvent *event)
|
void VisualDeckEditorWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,9 @@ public slots:
|
||||||
void decklistDataChanged(QModelIndex topLeft, QModelIndex bottomRight);
|
void decklistDataChanged(QModelIndex topLeft, QModelIndex bottomRight);
|
||||||
void updateZoneWidgets();
|
void updateZoneWidgets();
|
||||||
void updateDisplayType();
|
void updateDisplayType();
|
||||||
void addZoneIfDoesNotExist();
|
void onCardAddition(const QModelIndex &parent, int first, int last);
|
||||||
void deleteZoneIfDoesNotExist();
|
void onCardRemoval(const QModelIndex &parent, int first, int last);
|
||||||
|
void constructZoneWidgetsFromDeckListModel();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activeCardChanged(CardInfoPtr activeCard);
|
void activeCardChanged(CardInfoPtr activeCard);
|
||||||
|
|
@ -83,6 +84,7 @@ private:
|
||||||
QVBoxLayout *zoneContainerLayout;
|
QVBoxLayout *zoneContainerLayout;
|
||||||
// OverlapControlWidget *overlapControlWidget;
|
// OverlapControlWidget *overlapControlWidget;
|
||||||
QWidget *container;
|
QWidget *container;
|
||||||
|
QHash<QPersistentModelIndex, QWidget*> indexToWidgetMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISUAL_DECK_EDITOR_H
|
#endif // VISUAL_DECK_EDITOR_H
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ bool DeckListModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
} else {
|
} else {
|
||||||
emitRecursiveUpdates(parent);
|
emitRecursiveUpdates(parent);
|
||||||
}
|
}
|
||||||
emit dataChanged(parent, parent);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,10 @@ signals:
|
||||||
public:
|
public:
|
||||||
explicit DeckListModel(QObject *parent = nullptr);
|
explicit DeckListModel(QObject *parent = nullptr);
|
||||||
~DeckListModel() override;
|
~DeckListModel() override;
|
||||||
|
QModelIndex getRoot() const
|
||||||
|
{
|
||||||
|
return nodeToIndex(root);
|
||||||
|
};
|
||||||
QString getSortCriteriaForCard(CardInfoPtr info);
|
QString getSortCriteriaForCard(CardInfoPtr info);
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue