mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -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()
|
||||
{
|
||||
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());
|
||||
deckEditor->setModified(commentsEdit->toPlainText().isEmpty());
|
||||
emit commentsChanged();
|
||||
|
|
@ -597,8 +601,6 @@ void DeckEditorDeckDockWidget::actDecrementSelection()
|
|||
|
||||
void DeckEditorDeckDockWidget::actRemoveCard()
|
||||
{
|
||||
historyManager->save(deckLoader->getDeckList()->createMemento("Card removed"));
|
||||
|
||||
auto selectedRows = getSelectedCardNodes();
|
||||
|
||||
// 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;
|
||||
}
|
||||
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());
|
||||
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 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));
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ DeckListHistoryManagerWidget::DeckListHistoryManagerWidget(DeckListModel *_deckL
|
|||
QWidget *parent)
|
||||
: QWidget(parent), deckListModel(_deckListModel), styleProxy(_styleProxy), historyManager(manager)
|
||||
{
|
||||
auto *layout = new QHBoxLayout(this);
|
||||
layout = new QHBoxLayout(this);
|
||||
|
||||
aUndo = new QAction(QString(), this);
|
||||
aUndo->setIcon(QPixmap("theme:icons/arrow_undo"));
|
||||
|
|
@ -38,8 +38,8 @@ DeckListHistoryManagerWidget::DeckListHistoryManagerWidget(DeckListModel *_deckL
|
|||
|
||||
layout->addWidget(historyButton);
|
||||
|
||||
connect(undoButton, &QPushButton::clicked, this, &DeckListHistoryManagerWidget::doUndo);
|
||||
connect(redoButton, &QPushButton::clicked, this, &DeckListHistoryManagerWidget::doRedo);
|
||||
connect(undoButton, &QToolButton::clicked, this, &DeckListHistoryManagerWidget::doUndo);
|
||||
connect(redoButton, &QToolButton::clicked, this, &DeckListHistoryManagerWidget::doRedo);
|
||||
|
||||
connect(historyList, &QListWidget::itemClicked, this, &DeckListHistoryManagerWidget::onListClicked);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
#include "../quick_settings/settings_button_widget.h"
|
||||
#include "deck_list_style_proxy.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QHBoxLayout>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/deck_list/deck_list_history_manager.h>
|
||||
#include <libcockatrice/models/deck_list/deck_list_model.h>
|
||||
|
|
@ -40,6 +40,7 @@ private:
|
|||
DeckListStyleProxy *styleProxy;
|
||||
DeckListHistoryManager *historyManager;
|
||||
|
||||
QHBoxLayout *layout;
|
||||
QAction *aUndo;
|
||||
QToolButton *undoButton;
|
||||
QAction *aRedo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue