mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
New layout updating?
This commit is contained in:
parent
3b3ba55bcb
commit
5a8dc3ec66
2 changed files with 16 additions and 7 deletions
|
|
@ -109,8 +109,10 @@ DlgSelectSetForCards::DlgSelectSetForCards(QWidget *parent, DeckListModel *_mode
|
||||||
|
|
||||||
bottomSplitter->setStretchFactor(0, 1); // Left and right equally split
|
bottomSplitter->setStretchFactor(0, 1); // Left and right equally split
|
||||||
bottomSplitter->setStretchFactor(1, 1);
|
bottomSplitter->setStretchFactor(1, 1);
|
||||||
}
|
|
||||||
|
|
||||||
|
connect(this, &DlgSelectSetForCards::orderChanged, this, &DlgSelectSetForCards::updateLayoutOrder);
|
||||||
|
connect(this, &DlgSelectSetForCards::widgetOrderChanged, this, &DlgSelectSetForCards::updateCardLists);
|
||||||
|
}
|
||||||
|
|
||||||
void DlgSelectSetForCards::actOK()
|
void DlgSelectSetForCards::actOK()
|
||||||
{
|
{
|
||||||
|
|
@ -194,7 +196,6 @@ QMap<QString, int> DlgSelectSetForCards::getSetsForCards()
|
||||||
|
|
||||||
void DlgSelectSetForCards::updateCardLists()
|
void DlgSelectSetForCards::updateCardLists()
|
||||||
{
|
{
|
||||||
updateLayoutOrder();
|
|
||||||
for (SetEntryWidget *entryWidget : entry_widgets) {
|
for (SetEntryWidget *entryWidget : entry_widgets) {
|
||||||
entryWidget->populateCardList();
|
entryWidget->populateCardList();
|
||||||
if (entryWidget->expanded) {
|
if (entryWidget->expanded) {
|
||||||
|
|
@ -259,13 +260,12 @@ void DlgSelectSetForCards::updateCardLists()
|
||||||
.getProperty("uuid"));
|
.getProperty("uuid"));
|
||||||
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(modifiedCardsFlowWidget);
|
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(modifiedCardsFlowWidget);
|
||||||
picture_widget->setCard(infoPtr);
|
picture_widget->setCard(infoPtr);
|
||||||
modifiedCardsFlowWidget->addWidget(picture_widget);}
|
modifiedCardsFlowWidget->addWidget(picture_widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DlgSelectSetForCards::dragEnterEvent(QDragEnterEvent *event)
|
void DlgSelectSetForCards::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasFormat("application/x-setentrywidget")) {
|
if (event->mimeData()->hasFormat("application/x-setentrywidget")) {
|
||||||
|
|
@ -302,6 +302,9 @@ void DlgSelectSetForCards::dropEvent(QDropEvent *event)
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
// Reset cursor after drop
|
// Reset cursor after drop
|
||||||
unsetCursor();
|
unsetCursor();
|
||||||
|
|
||||||
|
// We need to execute this AFTER the current event-cycle so we use a timer.
|
||||||
|
QTimer::singleShot(10, this, [this]() { emit orderChanged(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
|
QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
|
||||||
|
|
@ -376,6 +379,8 @@ void DlgSelectSetForCards::updateLayoutOrder()
|
||||||
entry_widgets.append(entry);
|
entry_widgets.append(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit widgetOrderChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEntryWidget::SetEntryWidget(DlgSelectSetForCards *_parent, const QString &_setName, int count)
|
SetEntryWidget::SetEntryWidget(DlgSelectSetForCards *_parent, const QString &_setName, int count)
|
||||||
|
|
@ -387,7 +392,7 @@ SetEntryWidget::SetEntryWidget(DlgSelectSetForCards *_parent, const QString &_se
|
||||||
QHBoxLayout *headerLayout = new QHBoxLayout();
|
QHBoxLayout *headerLayout = new QHBoxLayout();
|
||||||
CardSetPtr set = CardDatabaseManager::getInstance()->getSet(setName);
|
CardSetPtr set = CardDatabaseManager::getInstance()->getSet(setName);
|
||||||
checkBox = new QCheckBox("(" + set->getShortName() + ") - " + set->getLongName(), this);
|
checkBox = new QCheckBox("(" + set->getShortName() + ") - " + set->getLongName(), this);
|
||||||
connect(checkBox, &QCheckBox::checkStateChanged, parent, &DlgSelectSetForCards::updateCardLists);
|
connect(checkBox, &QCheckBox::checkStateChanged, parent, &DlgSelectSetForCards::updateLayoutOrder);
|
||||||
expandButton = new QPushButton("+", this);
|
expandButton = new QPushButton("+", this);
|
||||||
countLabel = new QLabel(QString::number(count), this);
|
countLabel = new QLabel(QString::number(count), this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,17 @@ public:
|
||||||
void sortSetsByCount();
|
void sortSetsByCount();
|
||||||
QMap<QString, QStringList> getCardsForSets();
|
QMap<QString, QStringList> getCardsForSets();
|
||||||
QMap<QString, QStringList> getModifiedCards();
|
QMap<QString, QStringList> getModifiedCards();
|
||||||
void updateLayoutOrder();
|
|
||||||
QVBoxLayout *listLayout;
|
QVBoxLayout *listLayout;
|
||||||
QList<SetEntryWidget *> entry_widgets;
|
QList<SetEntryWidget *> entry_widgets;
|
||||||
QMap<QString, QStringList> cardsForSets;
|
QMap<QString, QStringList> cardsForSets;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void widgetOrderChanged();
|
||||||
|
void orderChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void actOK();
|
void actOK();
|
||||||
|
void updateLayoutOrder();
|
||||||
void updateCardLists();
|
void updateCardLists();
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue