Add const, remove unreachable code, and more clang tidy fixes
This commit is contained in:
parent
6d92853f05
commit
cab88bf23f
8 changed files with 24 additions and 25 deletions
|
@ -14,8 +14,9 @@
|
|||
#include <QDialog>
|
||||
|
||||
class ArtConfigWindow : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ArtConfigWindow(const QString& filename, QWidget* parent = nullptr);
|
||||
explicit ArtConfigWindow(const QString& filename, QWidget* parent = nullptr);
|
||||
|
||||
private:
|
||||
void loadData(const QString& filename);
|
||||
|
|
|
@ -52,7 +52,7 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
formLayout->addRow(QStringLiteral("Title"), m_titleEdit);
|
||||
|
||||
m_knowExactDateBox = new QCheckBox();
|
||||
connect(m_knowExactDateBox, &QCheckBox::toggled, this, [=](bool checked) {
|
||||
connect(m_knowExactDateBox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
if (checked) {
|
||||
m_dateEdit->setDisplayFormat(QStringLiteral("yyyy-MM-dd"));
|
||||
} else {
|
||||
|
@ -100,7 +100,7 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
charactersLayout->addLayout(characterButtonLayout);
|
||||
|
||||
auto addCharacterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), QStringLiteral("Add"));
|
||||
connect(addCharacterButton, &QPushButton::clicked, this, [=] {
|
||||
connect(addCharacterButton, &QPushButton::clicked, this, [this] {
|
||||
auto tmp = m_characterListModel->stringList();;
|
||||
tmp.push_back(QStringLiteral("New Character"));
|
||||
m_characterListModel->setStringList(tmp);
|
||||
|
@ -109,9 +109,9 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
characterButtonLayout->addStretch(1);
|
||||
|
||||
auto removeCharacterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), QStringLiteral("Remove"));
|
||||
connect(removeCharacterButton, &QPushButton::clicked, this, [=] {
|
||||
connect(removeCharacterButton, &QPushButton::clicked, this, [this, characterList] {
|
||||
if(characterList->selectionModel()->hasSelection()) {
|
||||
QString toRemove = characterList->selectionModel()->selectedRows()[0].data().toString();
|
||||
const QString toRemove = characterList->selectionModel()->selectedRows()[0].data().toString();
|
||||
|
||||
auto tmp = m_characterListModel->stringList();
|
||||
tmp.removeOne(toRemove);
|
||||
|
@ -132,7 +132,7 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
tagLayout->addLayout(tagButtonLayout);
|
||||
|
||||
auto addTagButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), QStringLiteral("Add"));
|
||||
connect(addTagButton, &QPushButton::clicked, this, [=] {
|
||||
connect(addTagButton, &QPushButton::clicked, this, [this] {
|
||||
auto tmp = m_tagsListModel->stringList();;
|
||||
tmp.push_back(QStringLiteral("New Tag"));
|
||||
m_tagsListModel->setStringList(tmp);
|
||||
|
@ -141,9 +141,9 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
tagButtonLayout->addStretch(1);
|
||||
|
||||
auto removeTagButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), QStringLiteral("Remove"));
|
||||
connect(removeTagButton, &QPushButton::clicked, this, [=] {
|
||||
connect(removeTagButton, &QPushButton::clicked, this, [this, tagsList] {
|
||||
if(tagsList->selectionModel()->hasSelection()) {
|
||||
QString toRemove = tagsList->selectionModel()->selectedRows()[0].data().toString();
|
||||
const QString toRemove = tagsList->selectionModel()->selectedRows()[0].data().toString();
|
||||
|
||||
auto tmp = m_tagsListModel->stringList();
|
||||
tmp.removeOne(toRemove);
|
||||
|
@ -156,14 +156,12 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
formLayout->addRow(bottomButtonLayout);
|
||||
|
||||
auto cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-close")), QStringLiteral("Cancel"));
|
||||
connect(cancelButton, &QPushButton::clicked, this, [=] {
|
||||
close();
|
||||
});
|
||||
connect(cancelButton, &QPushButton::clicked, this, &ArtDetailWindow::close);
|
||||
bottomButtonLayout->addWidget(cancelButton);
|
||||
bottomButtonLayout->addStretch(1);
|
||||
|
||||
auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok")), QStringLiteral("Save"));
|
||||
connect(saveButton, &QPushButton::clicked, this, [=] {
|
||||
connect(saveButton, &QPushButton::clicked, this, [this, filename] {
|
||||
saveData(filename);
|
||||
});
|
||||
bottomButtonLayout->addWidget(saveButton);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QDialog>
|
||||
|
||||
class ArtDetailWindow : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ArtDetailWindow(const QString& filename, const QString& assetDirectory, QWidget* parent = nullptr);
|
||||
|
||||
|
|
|
@ -80,10 +80,7 @@ QVariant ArtModel::data(const QModelIndex &index, int role) const {
|
|||
} else if (role == Qt::DecorationRole) {
|
||||
switch(index.column()) {
|
||||
case 1:
|
||||
{
|
||||
return m_artPieces[index.row()].thumbnail;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
return m_artPieces[index.row()].hasAltText ? QIcon::fromTheme(QStringLiteral("emblem-checked")) : QIcon::fromTheme(QStringLiteral("emblem-error"));
|
||||
}
|
||||
|
|
|
@ -21,14 +21,15 @@ struct ArtPiece {
|
|||
};
|
||||
|
||||
class ArtModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ArtModel(const QString& definitionDirectory, const QString& assetDirectory);
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
private:
|
||||
void loadData(ArtPiece& piece, const QString& filename, const QString& assetFilename);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QMainWindow>
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(const QString& definitionDirectory, const QString& assetDirectory, const QString& dataDirectory);
|
||||
};
|
||||
|
|
|
@ -19,8 +19,8 @@ int ImageLabel::heightForWidth(int width) const {
|
|||
}
|
||||
|
||||
QSize ImageLabel::sizeHint() const {
|
||||
int w = this->width();
|
||||
return QSize(w, heightForWidth(w));
|
||||
const int w = this->width();
|
||||
return {w, heightForWidth(w)};
|
||||
}
|
||||
|
||||
QPixmap ImageLabel::scaledPixmap() const {
|
||||
|
|
|
@ -11,11 +11,11 @@ class ImageLabel : public QLabel {
|
|||
public:
|
||||
explicit ImageLabel(QWidget *parent = nullptr);
|
||||
|
||||
int heightForWidth(int width) const override;
|
||||
QSize sizeHint() const override;
|
||||
QPixmap scaledPixmap() const;
|
||||
[[nodiscard]] int heightForWidth(int width) const override;
|
||||
[[nodiscard]] QSize sizeHint() const override;
|
||||
[[nodiscard]] QPixmap scaledPixmap() const;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void setPixmap(const QPixmap &);
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue