1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 11:45:33 +00:00

components/contentselector cleanup; case-insensative functions marked as [[maybe_unused]] as they are only used on windows and it is better to be explicit than implicit

This commit is contained in:
Bret Curtis 2020-10-24 21:23:55 +02:00
parent ba3aad31c1
commit f062dcdc70
11 changed files with 26 additions and 49 deletions

View file

@ -84,7 +84,7 @@ namespace Bsa
Files::IStreamPtr getFile(const FileRecord& fileRecord);
public:
CompressedBSAFile();
virtual ~CompressedBSAFile();
~CompressedBSAFile() override;
//checks version of BSA from file header
static BsaVersion detectVersion(std::string filePath);

View file

@ -20,7 +20,7 @@ namespace Config
class GameSettings
{
public:
GameSettings(Files::ConfigurationManager &cfg);
explicit GameSettings(Files::ConfigurationManager &cfg);
~GameSettings();
inline QString value(const QString &key, const QString &defaultValue = QString())

View file

@ -8,10 +8,11 @@
#include <QDebug>
#include <components/esm/esmreader.hpp>
#include <utility>
ContentSelectorModel::ContentModel::ContentModel(QObject *parent, QIcon warningIcon) :
QAbstractTableModel(parent),
mWarningIcon(warningIcon),
mWarningIcon(std::move(warningIcon)),
mMimeType ("application/omwcontent"),
mMimeTypes (QStringList() << mMimeType),
mColumnCount (1),
@ -81,7 +82,7 @@ const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(co
QModelIndex ContentSelectorModel::ContentModel::indexFromItem(const EsmFile *item) const
{
//workaround: non-const pointer cast for calls from outside contentmodel/contentselector
EsmFile *non_const_file_ptr = const_cast<EsmFile *>(item);
auto *non_const_file_ptr = const_cast<EsmFile *>(item);
if (item)
return index(mFiles.indexOf(non_const_file_ptr),0);
@ -354,7 +355,7 @@ QMimeData *ContentSelectorModel::ContentModel::mimeData(const QModelIndexList &i
encodedData.append(item(index.row())->encodedData());
}
QMimeData *mimeData = new QMimeData();
auto *mimeData = new QMimeData();
mimeData->setData(mMimeType, encodedData);
return mimeData;
@ -438,11 +439,10 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
fileReader.setEncoder(&encoder);
fileReader.open(std::string(dir.absoluteFilePath(path2).toUtf8().constData()));
EsmFile *file = new EsmFile(path2);
auto *file = new EsmFile(path2);
for (std::vector<ESM::Header::MasterData>::const_iterator itemIter = fileReader.getGameFiles().begin();
itemIter != fileReader.getGameFiles().end(); ++itemIter)
file->addGameFile(QString::fromUtf8(itemIter->name.c_str()));
for (const auto & itemIter : fileReader.getGameFiles())
file->addGameFile(QString::fromUtf8(itemIter.name.c_str()));
file->setAuthor (QString::fromUtf8(fileReader.getAuthor().c_str()));
file->setDate (info.lastModified());

View file

@ -24,7 +24,7 @@ namespace ContentSelectorModel
Q_OBJECT
public:
explicit ContentModel(QObject *parent, QIcon warningIcon);
~ContentModel();
~ContentModel() override;
void setEncoding(const QString &encoding);

View file

@ -2,6 +2,7 @@
#include <QMimeData>
#include <QDataStream>
#include <utility>
int ContentSelectorModel::EsmFile::sPropertyCount = 7;
QString ContentSelectorModel::EsmFile::sToolTip = QString("<b>Author:</b> %1<br/> \
@ -13,7 +14,7 @@ QString ContentSelectorModel::EsmFile::sToolTip = QString("<b>Author:</b> %1<br/
ContentSelectorModel::EsmFile::EsmFile(QString fileName, ModelItem *parent)
: ModelItem(parent), mFileName(fileName), mFormat(0)
: ModelItem(parent), mFileName(std::move(fileName)), mFormat(0)
{}
void ContentSelectorModel::EsmFile::setFileName(const QString &fileName)
@ -65,7 +66,7 @@ QByteArray ContentSelectorModel::EsmFile::encodedData() const
bool ContentSelectorModel::EsmFile::isGameFile() const
{
return (mGameFiles.size() == 0) &&
return (mGameFiles.empty()) &&
(mFileName.endsWith(QLatin1String(".esm"), Qt::CaseInsensitive) ||
mFileName.endsWith(QLatin1String(".omwgame"), Qt::CaseInsensitive));
}
@ -76,31 +77,24 @@ QVariant ContentSelectorModel::EsmFile::fileProperty(const FileProperty prop) co
{
case FileProperty_FileName:
return mFileName;
break;
case FileProperty_Author:
return mAuthor;
break;
case FileProperty_Format:
return mFormat;
break;
case FileProperty_DateModified:
return mModified.toString(Qt::ISODate);
break;
case FileProperty_FilePath:
return mPath;
break;
case FileProperty_Description:
return mDescription;
break;
case FileProperty_GameFile:
return mGameFiles;
break;
default:
break;

View file

@ -28,17 +28,14 @@ namespace ContentSelectorModel
FileProperty_GameFile = 6
};
EsmFile(QString fileName = QString(), ModelItem *parent = 0);
// EsmFile(const EsmFile &);
explicit EsmFile(QString fileName = QString(), ModelItem *parent = nullptr);
~EsmFile()
{}
~EsmFile() override = default;
void setFileProperty (const FileProperty prop, const QString &value);
void setFileProperty (FileProperty prop, const QString &value);
void setFileName(const QString &fileName);
void setAuthor(const QString &author);
void setSize(const int size);
void setDate(const QDateTime &modified);
void setFormat(const int format);
void setFilePath(const QString &path);
@ -46,7 +43,7 @@ namespace ContentSelectorModel
void setDescription(const QString &description);
inline void addGameFile (const QString &name) {mGameFiles.append(name); }
QVariant fileProperty (const FileProperty prop) const;
QVariant fileProperty (FileProperty prop) const;
inline QString fileName() const { return mFileName; }
inline QString author() const { return mAuthor; }

View file

@ -2,6 +2,7 @@
#define LOADORDERERROR_HPP
#include <QString>
#include <utility>
namespace ContentSelectorModel
{
@ -19,7 +20,7 @@ namespace ContentSelectorModel
inline LoadOrderError() : mErrorCode(ErrorCode_None) {}
inline LoadOrderError(ErrorCode errorCode, QString fileName)
: mErrorCode(errorCode), mFileName(fileName) {}
: mErrorCode(errorCode), mFileName(std::move(fileName)) {}
inline ErrorCode errorCode() const { return mErrorCode; }
inline QString fileName() const { return mFileName; }
QString toolTip() const;

View file

@ -2,21 +2,13 @@
ContentSelectorModel::ModelItem::ModelItem(ModelItem *parent)
: mParentItem(parent)
{
}
/*
ContentSelectorModel::ModelItem::ModelItem(const ModelItem *parent)
// : mParentItem(parent)
{
}
*/
{ }
ContentSelectorModel::ModelItem::~ModelItem()
{
qDeleteAll(mChildItems);
}
ContentSelectorModel::ModelItem *ContentSelectorModel::ModelItem::parent() const
{
return mParentItem;
@ -33,9 +25,6 @@ int ContentSelectorModel::ModelItem::row() const
{
if (mParentItem)
return 1;
//return mParentItem->childRow(const_cast<ModelItem*>(this));
//return mParentItem->mChildItems.indexOf(const_cast<ModelItem*>(this));
return -1;
}
@ -48,7 +37,6 @@ int ContentSelectorModel::ModelItem::childCount() const
int ContentSelectorModel::ModelItem::childRow(ModelItem *child) const
{
Q_ASSERT(child);
return mChildItems.indexOf(child);
}
@ -57,7 +45,6 @@ ContentSelectorModel::ModelItem *ContentSelectorModel::ModelItem::child(int row)
return mChildItems.value(row);
}
void ContentSelectorModel::ModelItem::appendChild(ModelItem *item)
{
mChildItems.append(item);

View file

@ -11,10 +11,8 @@ namespace ContentSelectorModel
Q_OBJECT
public:
ModelItem(ModelItem *parent = 0);
//ModelItem(const ModelItem *parent = 0);
~ModelItem();
explicit ModelItem(ModelItem *parent = nullptr);
~ModelItem() override;
ModelItem *parent() const;
int row() const;

View file

@ -89,7 +89,7 @@ bool naturalSortLessThanCS( const QString &left, const QString &right )
return (naturalCompare( left, right, Qt::CaseSensitive ) < 0);
}
bool naturalSortLessThanCI( const QString &left, const QString &right )
[[maybe_unused]] bool naturalSortLessThanCI( const QString &left, const QString &right )
{
return (naturalCompare( left, right, Qt::CaseInsensitive ) < 0);
}
@ -99,7 +99,7 @@ bool naturalSortGreaterThanCS( const QString &left, const QString &right )
return (naturalCompare( left, right, Qt::CaseSensitive ) > 0);
}
bool naturalSortGreaterThanCI( const QString &left, const QString &right )
[[maybe_unused]] bool naturalSortGreaterThanCI( const QString &left, const QString &right )
{
return (naturalCompare( left, right, Qt::CaseInsensitive ) > 0);
}

View file

@ -4,8 +4,8 @@
#include <QString>
bool naturalSortLessThanCS( const QString &left, const QString &right );
bool naturalSortLessThanCI( const QString &left, const QString &right );
[[maybe_unused]] bool naturalSortLessThanCI( const QString &left, const QString &right );
bool naturalSortGreaterThanCS( const QString &left, const QString &right );
bool naturalSortGreaterThanCI( const QString &left, const QString &right );
[[maybe_unused]] bool naturalSortGreaterThanCI( const QString &left, const QString &right );
#endif