[nostalgia/core/studio] Fix memory leaks
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include <QSettings>
|
||||
#include <QSpinBox>
|
||||
#include <QSplitter>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QUndoCommand>
|
||||
#include <QTableWidget>
|
||||
#include <QToolBar>
|
||||
@@ -55,20 +54,6 @@ struct LabeledSpinner: public QWidget {
|
||||
|
||||
};
|
||||
|
||||
struct TileSheetEditorColorTableDelegate: public QStyledItemDelegate {
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const {
|
||||
if (idx.column() != 1) {
|
||||
QStyledItemDelegate::paint(painter, opt, idx);
|
||||
} else {
|
||||
auto color = idx.model()->data(idx, Qt::DisplayRole).toString();
|
||||
painter->fillRect(opt.rect, QColor(color));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class UpdateDimensionsCommand: public QUndoCommand {
|
||||
public:
|
||||
enum class Dimension {
|
||||
@@ -236,6 +221,16 @@ class InsertTileCommand: public QUndoCommand {
|
||||
};
|
||||
|
||||
|
||||
void TileSheetEditorColorTableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const {
|
||||
if (idx.column() != 1) {
|
||||
QStyledItemDelegate::paint(painter, opt, idx);
|
||||
} else {
|
||||
auto color = idx.model()->data(idx, Qt::DisplayRole).toString();
|
||||
painter->fillRect(opt.rect, QColor(color));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SheetData::SheetData(QUndoStack *undoStack): m_cmdStack(undoStack) {
|
||||
}
|
||||
|
||||
@@ -506,7 +501,7 @@ QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) {
|
||||
auto lyt = new QVBoxLayout(colorPicker);
|
||||
m_colorPicker.palette = new QComboBox(colorPicker);
|
||||
m_colorPicker.colorTable = new QTableWidget(colorPicker);
|
||||
m_colorPicker.colorTable->setItemDelegate(new TileSheetEditorColorTableDelegate);
|
||||
m_colorPicker.colorTable->setItemDelegate(&m_colorTableDelegate);
|
||||
m_colorPicker.colorTable->setColumnCount(2);
|
||||
m_colorPicker.colorTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_colorPicker.colorTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
Reference in New Issue
Block a user