mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 01:23:57 -07:00
Add plate comments and re-order DeckCardZoneDisplay.cpp to be more structured
Took 7 minutes Took 5 seconds
This commit is contained in:
parent
8beedf6a13
commit
aea241291f
2 changed files with 57 additions and 61 deletions
|
|
@ -46,6 +46,20 @@ DeckCardZoneDisplayWidget::DeckCardZoneDisplayWidget(QWidget *parent,
|
||||||
connect(deckListModel, &QAbstractItemModel::rowsRemoved, this, &DeckCardZoneDisplayWidget::onCategoryRemoval);
|
connect(deckListModel, &QAbstractItemModel::rowsRemoved, this, &DeckCardZoneDisplayWidget::onCategoryRemoval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =====================================================================================================================
|
||||||
|
// User Interaction
|
||||||
|
// =====================================================================================================================
|
||||||
|
|
||||||
|
void DeckCardZoneDisplayWidget::onClick(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *card)
|
||||||
|
{
|
||||||
|
emit cardClicked(event, card, zoneName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckCardZoneDisplayWidget::onHover(const ExactCard &card)
|
||||||
|
{
|
||||||
|
emit cardHovered(card);
|
||||||
|
}
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
void DeckCardZoneDisplayWidget::onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
{
|
{
|
||||||
for (auto &range : selected) {
|
for (auto &range : selected) {
|
||||||
|
|
@ -69,17 +83,9 @@ void DeckCardZoneDisplayWidget::onSelectionChanged(const QItemSelection &selecte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::cleanupInvalidCardGroup(CardGroupDisplayWidget *displayWidget)
|
// =====================================================================================================================
|
||||||
{
|
// Display Widget Management
|
||||||
cardGroupLayout->removeWidget(displayWidget);
|
// =====================================================================================================================
|
||||||
displayWidget->setParent(nullptr);
|
|
||||||
for (auto idx : indexToWidgetMap.keys()) {
|
|
||||||
if (!idx.isValid()) {
|
|
||||||
indexToWidgetMap.remove(idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete displayWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::constructAppropriateWidget(QPersistentModelIndex index)
|
void DeckCardZoneDisplayWidget::constructAppropriateWidget(QPersistentModelIndex index)
|
||||||
{
|
{
|
||||||
|
|
@ -140,6 +146,45 @@ void DeckCardZoneDisplayWidget::displayCards()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckCardZoneDisplayWidget::refreshDisplayType(const DisplayType &_displayType)
|
||||||
|
{
|
||||||
|
displayType = _displayType;
|
||||||
|
QLayoutItem *item;
|
||||||
|
while ((item = cardGroupLayout->takeAt(0)) != nullptr) {
|
||||||
|
if (item->widget()) {
|
||||||
|
item->widget()->deleteLater();
|
||||||
|
} else if (item->layout()) {
|
||||||
|
item->layout()->deleteLater();
|
||||||
|
}
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
indexToWidgetMap.clear();
|
||||||
|
|
||||||
|
// We gotta wait for all the deleteLater's to finish so we fire after the next event cycle
|
||||||
|
|
||||||
|
auto timer = new QTimer(this);
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
connect(timer, &QTimer::timeout, this, [this]() { displayCards(); });
|
||||||
|
timer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckCardZoneDisplayWidget::cleanupInvalidCardGroup(CardGroupDisplayWidget *displayWidget)
|
||||||
|
{
|
||||||
|
cardGroupLayout->removeWidget(displayWidget);
|
||||||
|
displayWidget->setParent(nullptr);
|
||||||
|
for (auto idx : indexToWidgetMap.keys()) {
|
||||||
|
if (!idx.isValid()) {
|
||||||
|
indexToWidgetMap.remove(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete displayWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =====================================================================================================================
|
||||||
|
// DeckListModel Signal Responses
|
||||||
|
// =====================================================================================================================
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::onCategoryAddition(const QModelIndex &parent, int first, int last)
|
void DeckCardZoneDisplayWidget::onCategoryAddition(const QModelIndex &parent, int first, int last)
|
||||||
{
|
{
|
||||||
if (!trackedIndex.isValid()) {
|
if (!trackedIndex.isValid()) {
|
||||||
|
|
@ -172,38 +217,6 @@ void DeckCardZoneDisplayWidget::onCategoryRemoval(const QModelIndex &parent, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::onClick(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *card)
|
|
||||||
{
|
|
||||||
emit cardClicked(event, card, zoneName);
|
|
||||||
}
|
|
||||||
void DeckCardZoneDisplayWidget::onHover(const ExactCard &card)
|
|
||||||
{
|
|
||||||
emit cardHovered(card);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::refreshDisplayType(const DisplayType &_displayType)
|
|
||||||
{
|
|
||||||
displayType = _displayType;
|
|
||||||
QLayoutItem *item;
|
|
||||||
while ((item = cardGroupLayout->takeAt(0)) != nullptr) {
|
|
||||||
if (item->widget()) {
|
|
||||||
item->widget()->deleteLater();
|
|
||||||
} else if (item->layout()) {
|
|
||||||
item->layout()->deleteLater();
|
|
||||||
}
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
|
|
||||||
indexToWidgetMap.clear();
|
|
||||||
|
|
||||||
// We gotta wait for all the deleteLater's to finish so we fire after the next event cycle
|
|
||||||
|
|
||||||
auto timer = new QTimer(this);
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
connect(timer, &QTimer::timeout, this, [this]() { displayCards(); });
|
|
||||||
timer->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged(QString _activeGroupCriteria)
|
void DeckCardZoneDisplayWidget::onActiveGroupCriteriaChanged(QString _activeGroupCriteria)
|
||||||
{
|
{
|
||||||
activeGroupCriteria = _activeGroupCriteria;
|
activeGroupCriteria = _activeGroupCriteria;
|
||||||
|
|
@ -214,20 +227,4 @@ void DeckCardZoneDisplayWidget::onActiveSortCriteriaChanged(QStringList _activeS
|
||||||
{
|
{
|
||||||
activeSortCriteria = _activeSortCriteria;
|
activeSortCriteria = _activeSortCriteria;
|
||||||
emit activeSortCriteriaChanged(activeSortCriteria);
|
emit activeSortCriteriaChanged(activeSortCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> DeckCardZoneDisplayWidget::getGroupCriteriaValueList()
|
|
||||||
{
|
|
||||||
QList<QString> groupCriteriaValues;
|
|
||||||
|
|
||||||
QList<ExactCard> cardsInZone = deckListModel->getCardsForZone(zoneName);
|
|
||||||
|
|
||||||
for (const ExactCard &cardInZone : cardsInZone) {
|
|
||||||
groupCriteriaValues.append(cardInZone.getInfo().getProperty(activeGroupCriteria));
|
|
||||||
}
|
|
||||||
|
|
||||||
groupCriteriaValues.removeDuplicates();
|
|
||||||
groupCriteriaValues.sort();
|
|
||||||
|
|
||||||
return groupCriteriaValues;
|
|
||||||
}
|
|
||||||
|
|
@ -50,7 +50,6 @@ public slots:
|
||||||
void refreshDisplayType(const DisplayType &displayType);
|
void refreshDisplayType(const DisplayType &displayType);
|
||||||
void onActiveGroupCriteriaChanged(QString activeGroupCriteria);
|
void onActiveGroupCriteriaChanged(QString activeGroupCriteria);
|
||||||
void onActiveSortCriteriaChanged(QStringList activeSortCriteria);
|
void onActiveSortCriteriaChanged(QStringList activeSortCriteria);
|
||||||
QList<QString> getGroupCriteriaValueList();
|
|
||||||
void onCategoryAddition(const QModelIndex &parent, int first, int last);
|
void onCategoryAddition(const QModelIndex &parent, int first, int last);
|
||||||
void onCategoryRemoval(const QModelIndex &parent, int first, int last);
|
void onCategoryRemoval(const QModelIndex &parent, int first, int last);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue