mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 20:33:58 -07:00
Small fixes.
Took 12 minutes
This commit is contained in:
parent
fc5ec370e3
commit
18d9992dc5
3 changed files with 22 additions and 9 deletions
|
|
@ -283,7 +283,11 @@ void DeckEditorDeckDockWidget::updateName(const QString &name)
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::updateComments()
|
void DeckEditorDeckDockWidget::updateComments()
|
||||||
{
|
{
|
||||||
historyManager->save(deckLoader->getDeckList()->createMemento("Comments changed"));
|
historyManager->save(
|
||||||
|
deckLoader->getDeckList()->createMemento(QString("Updated comments (was %1 chars, now %2 chars)")
|
||||||
|
.arg(deckLoader->getDeckList()->getComments().size())
|
||||||
|
.arg(commentsEdit->toPlainText().size())));
|
||||||
|
|
||||||
deckModel->getDeckList()->setComments(commentsEdit->toPlainText());
|
deckModel->getDeckList()->setComments(commentsEdit->toPlainText());
|
||||||
deckEditor->setModified(commentsEdit->toPlainText().isEmpty());
|
deckEditor->setModified(commentsEdit->toPlainText().isEmpty());
|
||||||
emit commentsChanged();
|
emit commentsChanged();
|
||||||
|
|
@ -597,8 +601,6 @@ void DeckEditorDeckDockWidget::actDecrementSelection()
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::actRemoveCard()
|
void DeckEditorDeckDockWidget::actRemoveCard()
|
||||||
{
|
{
|
||||||
historyManager->save(deckLoader->getDeckList()->createMemento("Card removed"));
|
|
||||||
|
|
||||||
auto selectedRows = getSelectedCardNodes();
|
auto selectedRows = getSelectedCardNodes();
|
||||||
|
|
||||||
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
|
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
|
||||||
|
|
@ -613,6 +615,11 @@ void DeckEditorDeckDockWidget::actRemoveCard()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QModelIndex sourceIndex = proxy->mapToSource(index);
|
QModelIndex sourceIndex = proxy->mapToSource(index);
|
||||||
|
QString cardName = sourceIndex.sibling(sourceIndex.row(), 1).data().toString();
|
||||||
|
|
||||||
|
historyManager->save(
|
||||||
|
deckLoader->getDeckList()->createMemento(QString("Removed \"%1\" (all copies)").arg(cardName)));
|
||||||
|
|
||||||
deckModel->removeRow(sourceIndex.row(), sourceIndex.parent());
|
deckModel->removeRow(sourceIndex.row(), sourceIndex.parent());
|
||||||
isModified = true;
|
isModified = true;
|
||||||
}
|
}
|
||||||
|
|
@ -639,7 +646,12 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int of
|
||||||
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
||||||
const int new_count = count + offset;
|
const int new_count = count + offset;
|
||||||
|
|
||||||
QString reason = QString("%1 %2 %3").arg(offset > 0 ? "Added" : "Removed").arg(qAbs(offset)).arg(cardName);
|
const auto reason =
|
||||||
|
QString("%1 %2 × \"%3\" (%4)")
|
||||||
|
.arg(offset > 0 ? "Added" : "Removed")
|
||||||
|
.arg(qAbs(offset))
|
||||||
|
.arg(cardName)
|
||||||
|
.arg(deckModel->data(sourceIndex.sibling(sourceIndex.row(), 4), Qt::DisplayRole).toString());
|
||||||
|
|
||||||
historyManager->save(deckLoader->getDeckList()->createMemento(reason));
|
historyManager->save(deckLoader->getDeckList()->createMemento(reason));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ DeckListHistoryManagerWidget::DeckListHistoryManagerWidget(DeckListModel *_deckL
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent), deckListModel(_deckListModel), styleProxy(_styleProxy), historyManager(manager)
|
: QWidget(parent), deckListModel(_deckListModel), styleProxy(_styleProxy), historyManager(manager)
|
||||||
{
|
{
|
||||||
auto *layout = new QHBoxLayout(this);
|
layout = new QHBoxLayout(this);
|
||||||
|
|
||||||
aUndo = new QAction(QString(), this);
|
aUndo = new QAction(QString(), this);
|
||||||
aUndo->setIcon(QPixmap("theme:icons/arrow_undo"));
|
aUndo->setIcon(QPixmap("theme:icons/arrow_undo"));
|
||||||
|
|
@ -38,8 +38,8 @@ DeckListHistoryManagerWidget::DeckListHistoryManagerWidget(DeckListModel *_deckL
|
||||||
|
|
||||||
layout->addWidget(historyButton);
|
layout->addWidget(historyButton);
|
||||||
|
|
||||||
connect(undoButton, &QPushButton::clicked, this, &DeckListHistoryManagerWidget::doUndo);
|
connect(undoButton, &QToolButton::clicked, this, &DeckListHistoryManagerWidget::doUndo);
|
||||||
connect(redoButton, &QPushButton::clicked, this, &DeckListHistoryManagerWidget::doRedo);
|
connect(redoButton, &QToolButton::clicked, this, &DeckListHistoryManagerWidget::doRedo);
|
||||||
|
|
||||||
connect(historyList, &QListWidget::itemClicked, this, &DeckListHistoryManagerWidget::onListClicked);
|
connect(historyList, &QListWidget::itemClicked, this, &DeckListHistoryManagerWidget::onListClicked);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@
|
||||||
#include "../quick_settings/settings_button_widget.h"
|
#include "../quick_settings/settings_button_widget.h"
|
||||||
#include "deck_list_style_proxy.h"
|
#include "deck_list_style_proxy.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <libcockatrice/deck_list/deck_list_history_manager.h>
|
#include <libcockatrice/deck_list/deck_list_history_manager.h>
|
||||||
#include <libcockatrice/models/deck_list/deck_list_model.h>
|
#include <libcockatrice/models/deck_list/deck_list_model.h>
|
||||||
|
|
@ -40,6 +40,7 @@ private:
|
||||||
DeckListStyleProxy *styleProxy;
|
DeckListStyleProxy *styleProxy;
|
||||||
DeckListHistoryManager *historyManager;
|
DeckListHistoryManager *historyManager;
|
||||||
|
|
||||||
|
QHBoxLayout *layout;
|
||||||
QAction *aUndo;
|
QAction *aUndo;
|
||||||
QToolButton *undoButton;
|
QToolButton *undoButton;
|
||||||
QAction *aRedo;
|
QAction *aRedo;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue