Run clang-format
This commit is contained in:
parent
892d6a7fff
commit
1dc80b96d1
11 changed files with 378 additions and 356 deletions
|
@ -15,7 +15,9 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
ArtConfigWindow::ArtConfigWindow(const QString& filename, QWidget* parent) : QDialog(parent) {
|
ArtConfigWindow::ArtConfigWindow(const QString &filename, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
setWindowModality(Qt::WindowModality::WindowModal);
|
setWindowModality(Qt::WindowModality::WindowModal);
|
||||||
setWindowTitle(filename);
|
setWindowTitle(filename);
|
||||||
|
|
||||||
|
@ -56,7 +58,8 @@ ArtConfigWindow::ArtConfigWindow(const QString& filename, QWidget* parent) : QDi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArtConfigWindow::loadData(const QString& filename) {
|
void ArtConfigWindow::loadData(const QString &filename)
|
||||||
|
{
|
||||||
qDebug() << "Loading data from" << filename;
|
qDebug() << "Loading data from" << filename;
|
||||||
|
|
||||||
QFile artFile(filename);
|
QFile artFile(filename);
|
||||||
|
@ -67,7 +70,8 @@ void ArtConfigWindow::loadData(const QString& filename) {
|
||||||
m_commissionsOpen->setChecked(artJson[QStringLiteral("commissions")].toBool());
|
m_commissionsOpen->setChecked(artJson[QStringLiteral("commissions")].toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArtConfigWindow::saveData(const QString& filename) {
|
void ArtConfigWindow::saveData(const QString &filename)
|
||||||
|
{
|
||||||
qDebug() << "Saving data to" << filename;
|
qDebug() << "Saving data to" << filename;
|
||||||
|
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
|
@ -82,4 +86,3 @@ void ArtConfigWindow::saveData(const QString& filename) {
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDateEdit>
|
#include <QDateEdit>
|
||||||
|
#include <QDialog>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class ArtConfigWindow : public QDialog {
|
class ArtConfigWindow : public QDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ArtConfigWindow(const QString &filename, QWidget *parent = nullptr);
|
explicit ArtConfigWindow(const QString &filename, QWidget *parent = nullptr);
|
||||||
|
|
|
@ -176,7 +176,8 @@ ArtDetailWindow::ArtDetailWindow(const QString &filename, const QDir &assetDirec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArtDetailWindow::loadData(const QString& filename) {
|
void ArtDetailWindow::loadData(const QString &filename)
|
||||||
|
{
|
||||||
qDebug() << "Loading data from" << filename;
|
qDebug() << "Loading data from" << filename;
|
||||||
|
|
||||||
QFile artFile(filename);
|
QFile artFile(filename);
|
||||||
|
@ -235,7 +236,8 @@ void ArtDetailWindow::loadData(const QString& filename) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArtDetailWindow::saveData(const QString& filename) {
|
void ArtDetailWindow::saveData(const QString &filename)
|
||||||
|
{
|
||||||
qDebug() << "Saving data to" << filename;
|
qDebug() << "Saving data to" << filename;
|
||||||
|
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
|
@ -287,4 +289,3 @@ void ArtDetailWindow::saveData(const QString& filename) {
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
class ArtDetailWindow : public QDialog {
|
class ArtDetailWindow : public QDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ArtDetailWindow(const QString &filename, const QDir &assetDirectory, QWidget *parent = nullptr);
|
ArtDetailWindow(const QString &filename, const QDir &assetDirectory, QWidget *parent = nullptr);
|
||||||
|
|
|
@ -55,17 +55,20 @@ ArtModel::ArtModel(const QDir &definitionDirectory, const QDir &assetDirectory)
|
||||||
piecesFuture->setFuture(QtConcurrent::mapped(pieceList, loadPiece));
|
piecesFuture->setFuture(QtConcurrent::mapped(pieceList, loadPiece));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ArtModel::rowCount(const QModelIndex &parent) const {
|
int ArtModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return m_artPieces.size();
|
return m_artPieces.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ArtModel::columnCount(const QModelIndex &parent) const {
|
int ArtModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ArtModel::data(const QModelIndex &index, int role) const {
|
QVariant ArtModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -96,7 +99,8 @@ QVariant ArtModel::data(const QModelIndex &index, int role) const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ArtModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
QVariant ArtModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
if (orientation == Qt::Orientation::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Orientation::Horizontal && role == Qt::DisplayRole) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -115,8 +119,8 @@ QVariant ArtModel::headerData(int section, Qt::Orientation orientation, int role
|
||||||
return QAbstractTableModel::headerData(section, orientation, role);
|
return QAbstractTableModel::headerData(section, orientation, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArtModel::loadData(ArtPiece &piece, const QString &filename, const QString &assetFilename)
|
||||||
void ArtModel::loadData(ArtPiece& piece, const QString& filename, const QString& assetFilename) {
|
{
|
||||||
piece.jsonFilename = filename + ".json";
|
piece.jsonFilename = filename + ".json";
|
||||||
piece.filename = assetFilename;
|
piece.filename = assetFilename;
|
||||||
|
|
||||||
|
@ -138,15 +142,16 @@ void ArtModel::loadData(ArtPiece& piece, const QString& filename, const QString&
|
||||||
piece.hasAltText = true;
|
piece.hasAltText = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ArtModel::pieceFinished(int row) {
|
void ArtModel::pieceFinished(int row)
|
||||||
|
{
|
||||||
m_artPieces[row] = piecesFuture->resultAt(row);
|
m_artPieces[row] = piecesFuture->resultAt(row);
|
||||||
|
|
||||||
Q_EMIT dataChanged(index(row, 0), index(row + 1, 0));
|
Q_EMIT dataChanged(index(row, 0), index(row + 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArtModel::finished() {
|
void ArtModel::finished()
|
||||||
std::sort(m_artPieces.begin(), m_artPieces.end(), [](ArtPiece& a, ArtPiece& b)
|
|
||||||
{
|
{
|
||||||
|
std::sort(m_artPieces.begin(), m_artPieces.end(), [](ArtPiece &a, ArtPiece &b) {
|
||||||
return a.date > b.date;
|
return a.date > b.date;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ struct ArtPiece {
|
||||||
bool hasAltText = false;
|
bool hasAltText = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ArtModel : public QAbstractTableModel {
|
class ArtModel : public QAbstractTableModel
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ArtModel(const QDir &definitionDirectory, const QDir &assetDirectory);
|
explicit ArtModel(const QDir &definitionDirectory, const QDir &assetDirectory);
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(const QDir &definitionDirectory, const QDir &assetDirectory, const QDir &dataDirectory);
|
explicit MainWindow(const QDir &definitionDirectory, const QDir &assetDirectory, const QDir &dataDirectory);
|
||||||
|
|
|
@ -4,30 +4,37 @@
|
||||||
|
|
||||||
#include "imagelabel.h"
|
#include "imagelabel.h"
|
||||||
|
|
||||||
ImageLabel::ImageLabel(QWidget *parent) : QLabel(parent) {
|
ImageLabel::ImageLabel(QWidget *parent)
|
||||||
|
: QLabel(parent)
|
||||||
|
{
|
||||||
this->setMinimumSize(1, 1);
|
this->setMinimumSize(1, 1);
|
||||||
setScaledContents(false);
|
setScaledContents(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageLabel::setPixmap(const QPixmap &p) {
|
void ImageLabel::setPixmap(const QPixmap &p)
|
||||||
|
{
|
||||||
pix = p;
|
pix = p;
|
||||||
QLabel::setPixmap(scaledPixmap());
|
QLabel::setPixmap(scaledPixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImageLabel::heightForWidth(int width) const {
|
int ImageLabel::heightForWidth(int width) const
|
||||||
|
{
|
||||||
return pix.isNull() ? this->height() : ((qreal)pix.height() * width) / pix.width();
|
return pix.isNull() ? this->height() : ((qreal)pix.height() * width) / pix.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize ImageLabel::sizeHint() const {
|
QSize ImageLabel::sizeHint() const
|
||||||
|
{
|
||||||
const int w = this->width();
|
const int w = this->width();
|
||||||
return {w, heightForWidth(w)};
|
return {w, heightForWidth(w)};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap ImageLabel::scaledPixmap() const {
|
QPixmap ImageLabel::scaledPixmap() const
|
||||||
|
{
|
||||||
return pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
return pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageLabel::resizeEvent(QResizeEvent *e) {
|
void ImageLabel::resizeEvent(QResizeEvent *e)
|
||||||
|
{
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
if (!pix.isNull()) {
|
if (!pix.isNull()) {
|
||||||
QLabel::setPixmap(scaledPixmap());
|
QLabel::setPixmap(scaledPixmap());
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
class ImageLabel : public QLabel {
|
class ImageLabel : public QLabel
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ImageLabel(QWidget *parent = nullptr);
|
explicit ImageLabel(QWidget *parent = nullptr);
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue