Fix warnings
This commit is contained in:
parent
8158ef930a
commit
e535e20720
|
@ -506,15 +506,15 @@ void setTagInfo(const SetTagInfoArgs &args)
|
||||||
static string context("setting tags");
|
static string context("setting tags");
|
||||||
for (const char *file : args.filesArg.values()) {
|
for (const char *file : args.filesArg.values()) {
|
||||||
Diagnostics diag;
|
Diagnostics diag;
|
||||||
AbortableProgressFeedback progress; // FIXME: actually use the progress object
|
AbortableProgressFeedback parsingProgress; // FIXME: actually use the progress object
|
||||||
try {
|
try {
|
||||||
// parse tags and tracks (tracks are relevent because track meta-data such as language can be changed as well)
|
// parse tags and tracks (tracks are relevent because track meta-data such as language can be changed as well)
|
||||||
cout << TextAttribute::Bold << "Setting tag information for \"" << file << "\" ..." << Phrases::EndFlush;
|
cout << TextAttribute::Bold << "Setting tag information for \"" << file << "\" ..." << Phrases::EndFlush;
|
||||||
fileInfo.setPath(file);
|
fileInfo.setPath(file);
|
||||||
fileInfo.parseContainerFormat(diag, progress);
|
fileInfo.parseContainerFormat(diag, parsingProgress);
|
||||||
fileInfo.parseTags(diag, progress);
|
fileInfo.parseTags(diag, parsingProgress);
|
||||||
fileInfo.parseTracks(diag, progress);
|
fileInfo.parseTracks(diag, parsingProgress);
|
||||||
fileInfo.parseAttachments(diag, progress);
|
fileInfo.parseAttachments(diag, parsingProgress);
|
||||||
vector<Tag *> tags;
|
vector<Tag *> tags;
|
||||||
|
|
||||||
// remove tags with the specified targets
|
// remove tags with the specified targets
|
||||||
|
@ -618,16 +618,16 @@ void setTagInfo(const SetTagInfoArgs &args)
|
||||||
// add value from file
|
// add value from file
|
||||||
try {
|
try {
|
||||||
// assume the file refers to a picture
|
// assume the file refers to a picture
|
||||||
MediaFileInfo fileInfo(relevantDenotedValue->value);
|
MediaFileInfo coverFileInfo(relevantDenotedValue->value);
|
||||||
Diagnostics diag;
|
Diagnostics coverDiag;
|
||||||
AbortableProgressFeedback progress; // FIXME: actually use the progress object
|
AbortableProgressFeedback coverProgress; // FIXME: actually use the progress object
|
||||||
fileInfo.open(true);
|
coverFileInfo.open(true);
|
||||||
fileInfo.parseContainerFormat(diag, progress);
|
coverFileInfo.parseContainerFormat(coverDiag, coverProgress);
|
||||||
auto buff = make_unique<char[]>(fileInfo.size());
|
auto buff = make_unique<char[]>(coverFileInfo.size());
|
||||||
fileInfo.stream().seekg(static_cast<streamoff>(fileInfo.containerOffset()));
|
coverFileInfo.stream().seekg(static_cast<streamoff>(coverFileInfo.containerOffset()));
|
||||||
fileInfo.stream().read(buff.get(), static_cast<streamoff>(fileInfo.size()));
|
coverFileInfo.stream().read(buff.get(), static_cast<streamoff>(coverFileInfo.size()));
|
||||||
TagValue value(move(buff), fileInfo.size(), TagDataType::Picture);
|
TagValue value(move(buff), coverFileInfo.size(), TagDataType::Picture);
|
||||||
value.setMimeType(fileInfo.mimeType());
|
value.setMimeType(coverFileInfo.mimeType());
|
||||||
convertedValues.emplace_back(move(value));
|
convertedValues.emplace_back(move(value));
|
||||||
} catch (const TagParser::Failure &) {
|
} catch (const TagParser::Failure &) {
|
||||||
diag.emplace_back(DiagLevel::Critical, "Unable to parse specified cover file.", context);
|
diag.emplace_back(DiagLevel::Critical, "Unable to parse specified cover file.", context);
|
||||||
|
@ -703,8 +703,8 @@ void setTagInfo(const SetTagInfoArgs &args)
|
||||||
bool attachmentsModified = false;
|
bool attachmentsModified = false;
|
||||||
if (args.addAttachmentArg.isPresent() || args.updateAttachmentArg.isPresent() || args.removeAttachmentArg.isPresent()
|
if (args.addAttachmentArg.isPresent() || args.updateAttachmentArg.isPresent() || args.removeAttachmentArg.isPresent()
|
||||||
|| args.removeExistingAttachmentsArg.isPresent()) {
|
|| args.removeExistingAttachmentsArg.isPresent()) {
|
||||||
static const string context("setting attachments");
|
static const string attachmentsContext("setting attachments");
|
||||||
fileInfo.parseAttachments(diag, progress);
|
fileInfo.parseAttachments(diag, parsingProgress);
|
||||||
if (fileInfo.attachmentsParsingStatus() == ParsingStatus::Ok && container) {
|
if (fileInfo.attachmentsParsingStatus() == ParsingStatus::Ok && container) {
|
||||||
// ignore all existing attachments if argument is specified
|
// ignore all existing attachments if argument is specified
|
||||||
if (args.removeExistingAttachmentsArg.isPresent()) {
|
if (args.removeExistingAttachmentsArg.isPresent()) {
|
||||||
|
@ -737,8 +737,8 @@ void setTagInfo(const SetTagInfoArgs &args)
|
||||||
attachmentsModified |= currentInfo.next(container, diag);
|
attachmentsModified |= currentInfo.next(container, diag);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
diag.emplace_back(
|
diag.emplace_back(DiagLevel::Critical, "Unable to assign attachments because the container object has not been initialized.",
|
||||||
DiagLevel::Critical, "Unable to assign attachments because the container object has not been initialized.", context);
|
attachmentsContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,11 +746,11 @@ void setTagInfo(const SetTagInfoArgs &args)
|
||||||
fileInfo.setSaveFilePath(currentOutputFile != noMoreOutputFiles ? string(*currentOutputFile) : string());
|
fileInfo.setSaveFilePath(currentOutputFile != noMoreOutputFiles ? string(*currentOutputFile) : string());
|
||||||
try {
|
try {
|
||||||
// create handler for progress updates and aborting
|
// create handler for progress updates and aborting
|
||||||
AbortableProgressFeedback progress(logNextStep, logStepPercentage);
|
AbortableProgressFeedback applyProgress(logNextStep, logStepPercentage);
|
||||||
const InterruptHandler handler(bind(&AbortableProgressFeedback::tryToAbort, ref(progress)));
|
const InterruptHandler handler(bind(&AbortableProgressFeedback::tryToAbort, ref(applyProgress)));
|
||||||
|
|
||||||
// apply changes
|
// apply changes
|
||||||
fileInfo.applyChanges(diag, progress);
|
fileInfo.applyChanges(diag, applyProgress);
|
||||||
|
|
||||||
// notify about completion
|
// notify about completion
|
||||||
finalizeLog();
|
finalizeLog();
|
||||||
|
@ -855,7 +855,7 @@ void extractField(
|
||||||
: outputFileArg.values().front();
|
: outputFileArg.values().front();
|
||||||
try {
|
try {
|
||||||
outputFileStream.open(path, ios_base::out | ios_base::binary);
|
outputFileStream.open(path, ios_base::out | ios_base::binary);
|
||||||
outputFileStream.write(value.first->dataPointer(), value.first->dataSize());
|
outputFileStream.write(value.first->dataPointer(), static_cast<std::streamsize>(value.first->dataSize()));
|
||||||
outputFileStream.flush();
|
outputFileStream.flush();
|
||||||
cout << " - Value has been saved to \"" << path << "\"." << endl;
|
cout << " - Value has been saved to \"" << path << "\"." << endl;
|
||||||
} catch (const std::ios_base::failure &) {
|
} catch (const std::ios_base::failure &) {
|
||||||
|
@ -865,7 +865,7 @@ void extractField(
|
||||||
} else {
|
} else {
|
||||||
// write data to stdout if no output file has been specified
|
// write data to stdout if no output file has been specified
|
||||||
for (const auto &value : values) {
|
for (const auto &value : values) {
|
||||||
cout.write(value.first->dataPointer(), value.first->dataSize());
|
cout.write(value.first->dataPointer(), static_cast<std::streamsize>(value.first->dataSize()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -86,7 +86,7 @@ TagValue QueryResultsModel::fieldValue(int row, KnownField knownField) const
|
||||||
case KnownField::Cover:
|
case KnownField::Cover:
|
||||||
if (!res.cover.isEmpty()) {
|
if (!res.cover.isEmpty()) {
|
||||||
TagValue tagValue(res.cover.data(), static_cast<size_t>(res.cover.size()), TagDataType::Picture);
|
TagValue tagValue(res.cover.data(), static_cast<size_t>(res.cover.size()), TagDataType::Picture);
|
||||||
tagValue.setMimeType(containerMimeType(parseSignature(res.cover.data(), res.cover.size())));
|
tagValue.setMimeType(containerMimeType(parseSignature(res.cover.data(), static_cast<std::size_t>(res.cover.size()))));
|
||||||
return tagValue;
|
return tagValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -251,14 +251,14 @@ void MusicBrainzResultsModel::parseInitialResults(const QByteArray &data)
|
||||||
}
|
}
|
||||||
// -> sort recordings within each release by track number and add recordings to results
|
// -> sort recordings within each release by track number and add recordings to results
|
||||||
for (auto &releaseAndRecordings : recordingsByRelease) {
|
for (auto &releaseAndRecordings : recordingsByRelease) {
|
||||||
auto &recordings = releaseAndRecordings.second;
|
auto &recordingsOfRelease = releaseAndRecordings.second;
|
||||||
std::sort(recordings.begin(), recordings.end(), [](const auto &recording1, const auto &recording2) {
|
std::sort(recordingsOfRelease.begin(), recordingsOfRelease.end(), [](const auto &recording1, const auto &recording2) {
|
||||||
if (recording1.disk != recording2.disk) {
|
if (recording1.disk != recording2.disk) {
|
||||||
return recording1.disk < recording2.disk;
|
return recording1.disk < recording2.disk;
|
||||||
}
|
}
|
||||||
return recording1.track < recording2.track;
|
return recording1.track < recording2.track;
|
||||||
});
|
});
|
||||||
for (auto &recording : recordings) {
|
for (auto &recording : recordingsOfRelease) {
|
||||||
m_results << move(recording);
|
m_results << move(recording);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ void AttachmentsEdit::setFileInfo(TagParser::MediaFileInfo *fileInfo, bool updat
|
||||||
if (fileInfo && fileInfo->areAttachmentsSupported()) {
|
if (fileInfo && fileInfo->areAttachmentsSupported()) {
|
||||||
if (AbstractContainer *container = fileInfo->container()) {
|
if (AbstractContainer *container = fileInfo->container()) {
|
||||||
auto count = container->attachmentCount();
|
auto count = container->attachmentCount();
|
||||||
m_currentAttachments.reserve(count);
|
m_currentAttachments.reserve(static_cast<decltype(m_currentAttachments)::size_type>(count));
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
m_currentAttachments << container->attachment(i);
|
m_currentAttachments << container->attachment(i);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ void AttachmentsEdit::extractSelected()
|
||||||
NativeFileStream file;
|
NativeFileStream file;
|
||||||
file.exceptions(ios_base::badbit | ios_base::failbit);
|
file.exceptions(ios_base::badbit | ios_base::failbit);
|
||||||
try {
|
try {
|
||||||
input.seekg(data->startOffset());
|
input.seekg(static_cast<std::streamoff>(data->startOffset()), std::ios_base::beg);
|
||||||
file.open(toNativeFileName(fileName).data(), ios_base::out | ios_base::binary);
|
file.open(toNativeFileName(fileName).data(), ios_base::out | ios_base::binary);
|
||||||
CopyHelper<0x1000> helper;
|
CopyHelper<0x1000> helper;
|
||||||
helper.copy(input, file, data->size());
|
helper.copy(input, file, data->size());
|
||||||
|
|
|
@ -189,6 +189,7 @@ Qt::ItemFlags AttachmentsModel::flags(const QModelIndex &index) const
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0:
|
case 0:
|
||||||
flags |= Qt::ItemIsUserCheckable;
|
flags |= Qt::ItemIsUserCheckable;
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
flags |= Qt::ItemIsEditable;
|
flags |= Qt::ItemIsEditable;
|
||||||
|
|
|
@ -508,8 +508,8 @@ void DbQueryWidget::applyResults(TagEdit *tagEdit, const QModelIndex &resultInde
|
||||||
if (row != index.row()) {
|
if (row != index.row()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto *const tagEdit = m_tagEditorWidget->activeTagEdit()) {
|
if (auto *const activeTagEdit = m_tagEditorWidget->activeTagEdit()) {
|
||||||
tagEdit->setValue(KnownField::Cover, m_model->fieldValue(row, KnownField::Cover), previousValueHandling);
|
activeTagEdit->setValue(KnownField::Cover, m_model->fieldValue(row, KnownField::Cover), previousValueHandling);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -531,8 +531,8 @@ void DbQueryWidget::applyResults(TagEdit *tagEdit, const QModelIndex &resultInde
|
||||||
if (row != index.row()) {
|
if (row != index.row()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto *const tagEdit = m_tagEditorWidget->activeTagEdit()) {
|
if (auto *const activeTagEdit = m_tagEditorWidget->activeTagEdit()) {
|
||||||
tagEdit->setValue(KnownField::Lyrics, m_model->fieldValue(row, KnownField::Lyrics), previousValueHandling);
|
activeTagEdit->setValue(KnownField::Lyrics, m_model->fieldValue(row, KnownField::Lyrics), previousValueHandling);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <tagparser/mediafileinfo.h>
|
#include <tagparser/mediafileinfo.h>
|
||||||
#include <tagparser/signature.h>
|
#include <tagparser/signature.h>
|
||||||
|
|
||||||
|
#include <qtutilities/misc/conversion.h>
|
||||||
#include <qtutilities/misc/dialogutils.h>
|
#include <qtutilities/misc/dialogutils.h>
|
||||||
#include <qtutilities/models/checklistmodel.h>
|
#include <qtutilities/models/checklistmodel.h>
|
||||||
|
|
||||||
|
@ -89,9 +90,8 @@ EnterTargetDialog::~EnterTargetDialog()
|
||||||
|
|
||||||
void EnterTargetDialog::updateLevelNamePlaceholderText(int i)
|
void EnterTargetDialog::updateLevelNamePlaceholderText(int i)
|
||||||
{
|
{
|
||||||
const auto levelName
|
m_ui->levelNameLineEdit->setPlaceholderText(qstringFromStdStringView(
|
||||||
= i >= 0 ? tagTargetLevelName(containerTargetLevel(m_currentContainerFormat, static_cast<std::uint32_t>(i))) : std::string_view();
|
i >= 0 ? tagTargetLevelName(containerTargetLevel(m_currentContainerFormat, static_cast<std::uint32_t>(i))) : std::string_view()));
|
||||||
m_ui->levelNameLineEdit->setPlaceholderText(QString::fromUtf8(levelName.data(), levelName.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TagParser::TagTarget EnterTargetDialog::target() const
|
TagParser::TagTarget EnterTargetDialog::target() const
|
||||||
|
|
|
@ -51,7 +51,7 @@ QStandardItem *defaultItem(const QString &text)
|
||||||
|
|
||||||
QStandardItem *defaultItem(std::string_view text)
|
QStandardItem *defaultItem(std::string_view text)
|
||||||
{
|
{
|
||||||
return defaultItem(QString::fromUtf8(text.data(), text.size()));
|
return defaultItem(qstringFromStdStringView(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
class ItemHelper {
|
class ItemHelper {
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
void appendRow(const QString &label, std::string_view text)
|
void appendRow(const QString &label, std::string_view text)
|
||||||
{
|
{
|
||||||
if (!text.empty()) {
|
if (!text.empty()) {
|
||||||
appendRow(label, QString::fromUtf8(text.data(), text.size()));
|
appendRow(label, qstringFromStdStringView(text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,10 +313,9 @@ void FileInfoModel::updateCache()
|
||||||
QString containerName;
|
QString containerName;
|
||||||
const auto containerFormatName = m_file->containerFormatName();
|
const auto containerFormatName = m_file->containerFormatName();
|
||||||
if (const auto subversion = m_file->containerFormatSubversion(); !subversion.empty()) {
|
if (const auto subversion = m_file->containerFormatSubversion(); !subversion.empty()) {
|
||||||
containerName = QString::fromUtf8(containerFormatName.data(), containerFormatName.size()) % QChar(' ')
|
containerName = qstringFromStdStringView(containerFormatName) % QChar(' ') % qstringFromStdStringView(subversion);
|
||||||
% QString::fromUtf8(subversion.data(), subversion.size());
|
|
||||||
} else {
|
} else {
|
||||||
containerName = QString::fromUtf8(containerFormatName.data(), containerFormatName.size());
|
containerName = qstringFromStdStringView(containerFormatName);
|
||||||
}
|
}
|
||||||
setItem(currentRow, 1, defaultItem(containerName));
|
setItem(currentRow, 1, defaultItem(containerName));
|
||||||
|
|
||||||
|
@ -465,8 +464,8 @@ void FileInfoModel::updateCache()
|
||||||
if (const auto cc = track->channelConfigString(); !cc.empty()) {
|
if (const auto cc = track->channelConfigString(); !cc.empty()) {
|
||||||
const auto ecc = track->extensionChannelConfigString();
|
const auto ecc = track->extensionChannelConfigString();
|
||||||
trackHelper.appendRow(tr("Channel config"),
|
trackHelper.appendRow(tr("Channel config"),
|
||||||
!ecc.empty() ? QString::fromUtf8(ecc.data(), ecc.size()) % QStringLiteral(" / ") % QString::fromUtf8(cc.data(), cc.size())
|
!ecc.empty() ? qstringFromStdStringView(ecc) % QStringLiteral(" / ") % qstringFromStdStringView(cc)
|
||||||
: QString::fromUtf8(cc.data(), cc.size()));
|
: qstringFromStdStringView(cc));
|
||||||
} else {
|
} else {
|
||||||
trackHelper.appendRow(tr("Channel count"), track->channelCount());
|
trackHelper.appendRow(tr("Channel count"), track->channelCount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,14 +452,14 @@ void MainWindow::selectNextFile(QItemSelectionModel *selectionModel, const QMode
|
||||||
[this, selectionModel, currentIndex, conn](const QModelIndex &parent, int, int) {
|
[this, selectionModel, currentIndex, conn](const QModelIndex &parent, int, int) {
|
||||||
disconnect(*conn);
|
disconnect(*conn);
|
||||||
if (parent == currentIndex) {
|
if (parent == currentIndex) {
|
||||||
const QModelIndex next = m_fileFilterModel->index(0, 0, parent);
|
const QModelIndex nextFetched = m_fileFilterModel->index(0, 0, parent);
|
||||||
if (next.isValid()) {
|
if (nextFetched.isValid()) {
|
||||||
if (m_ui->filesTreeView->model()->hasChildren(next)) {
|
if (m_ui->filesTreeView->model()->hasChildren(nextFetched)) {
|
||||||
// next item is a directory -> keep on searching
|
// next item is a directory -> keep on searching
|
||||||
selectNextFile(selectionModel, next, false);
|
selectNextFile(selectionModel, nextFetched, false);
|
||||||
} else {
|
} else {
|
||||||
m_ui->filesTreeView->selectionModel()->setCurrentIndex(
|
m_ui->filesTreeView->selectionModel()->setCurrentIndex(
|
||||||
next, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
nextFetched, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selectNextFile(selectionModel, currentIndex, true);
|
selectNextFile(selectionModel, currentIndex, true);
|
||||||
|
|
|
@ -347,11 +347,11 @@ template <class TagType> void pushId3v2CoverValues(TagType *tag, KnownField fiel
|
||||||
using FieldType = typename TagType::FieldType;
|
using FieldType = typename TagType::FieldType;
|
||||||
using TypeInfoType = typename FieldType::TypeInfoType;
|
using TypeInfoType = typename FieldType::TypeInfoType;
|
||||||
using IndexCompareType = typename Traits::Conditional<std::is_unsigned<TypeInfoType>, make_unsigned<decltype(index)>::type, TypeInfoType>;
|
using IndexCompareType = typename Traits::Conditional<std::is_unsigned<TypeInfoType>, make_unsigned<decltype(index)>::type, TypeInfoType>;
|
||||||
FieldType field(id, values[index]);
|
auto newField = FieldType(id, values[index]);
|
||||||
if (static_cast<IndexCompareType>(index) < numeric_limits<TypeInfoType>::max()) {
|
if (static_cast<IndexCompareType>(index) < numeric_limits<TypeInfoType>::max()) {
|
||||||
field.setTypeInfo(static_cast<TypeInfoType>(index));
|
newField.setTypeInfo(static_cast<TypeInfoType>(index));
|
||||||
}
|
}
|
||||||
fields.insert(std::make_pair(id, field));
|
fields.insert(std::make_pair(id, newField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,8 +422,7 @@ void PicturePreviewSelection::addOfSelectedType(const QString &path)
|
||||||
fileInfo.open(true);
|
fileInfo.open(true);
|
||||||
fileInfo.parseContainerFormat(diag, progress);
|
fileInfo.parseContainerFormat(diag, progress);
|
||||||
|
|
||||||
const auto detectedMimeType = fileInfo.mimeType();
|
auto mimeType = qstringFromStdStringView(fileInfo.mimeType());
|
||||||
auto mimeType = QString::fromUtf8(detectedMimeType.data(), detectedMimeType.size());
|
|
||||||
bool ok;
|
bool ok;
|
||||||
mimeType = QInputDialog::getText(
|
mimeType = QInputDialog::getText(
|
||||||
this, tr("Enter/confirm MIME type"), tr("Confirm or enter the MIME type of the selected file."), QLineEdit::Normal, mimeType, &ok);
|
this, tr("Enter/confirm MIME type"), tr("Confirm or enter the MIME type of the selected file."), QLineEdit::Normal, mimeType, &ok);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <tagparser/tag.h>
|
#include <tagparser/tag.h>
|
||||||
|
|
||||||
|
#include <qtutilities/misc/conversion.h>
|
||||||
|
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
@ -199,8 +201,7 @@ QString TagEdit::generateLabel() const
|
||||||
QStringList tagNames;
|
QStringList tagNames;
|
||||||
tagNames.reserve(m_tags.size());
|
tagNames.reserve(m_tags.size());
|
||||||
for (const Tag *const tag : m_tags) {
|
for (const Tag *const tag : m_tags) {
|
||||||
const auto typeName = tag->typeName();
|
tagNames << QtUtilities::qstringFromStdStringView(tag->typeName());
|
||||||
tagNames << QString::fromUtf8(typeName.data(), typeName.size());
|
|
||||||
if (!differentTargets && !(target == tag->target())) {
|
if (!differentTargets && !(target == tag->target())) {
|
||||||
differentTargets = true;
|
differentTargets = true;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +213,7 @@ QString TagEdit::generateLabel() const
|
||||||
if (differentTargets) {
|
if (differentTargets) {
|
||||||
res.append(tr(" with different targets"));
|
res.append(tr(" with different targets"));
|
||||||
} else if (haveMatroskaTags || !target.isEmpty()) {
|
} else if (haveMatroskaTags || !target.isEmpty()) {
|
||||||
res.append(tr(" targeting %1").arg(QString::fromUtf8(m_tags.front()->targetString().c_str())));
|
res.append(tr(" targeting %1").arg(QString::fromStdString(m_tags.front()->targetString())));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,17 +411,18 @@ void TagEditorWidget::updateTagEditsAndAttachmentEdits(bool updateUi, PreviousVa
|
||||||
|
|
||||||
// add/update AttachmentsEdit widget
|
// add/update AttachmentsEdit widget
|
||||||
if (m_fileInfo.areAttachmentsSupported()) {
|
if (m_fileInfo.areAttachmentsSupported()) {
|
||||||
AttachmentsEdit *edit;
|
AttachmentsEdit *attachmentsEdit;
|
||||||
// reuse existing edit (assigned in if-condition!) or ...
|
// reuse existing edit (assigned in if-condition!) or ...
|
||||||
if ((widgetIndex < m_ui->stackedWidget->count()) && (edit = qobject_cast<AttachmentsEdit *>(m_ui->stackedWidget->widget(widgetIndex)))) {
|
if ((widgetIndex < m_ui->stackedWidget->count())
|
||||||
edit->setFileInfo(&m_fileInfo, true);
|
&& (attachmentsEdit = qobject_cast<AttachmentsEdit *>(m_ui->stackedWidget->widget(widgetIndex)))) {
|
||||||
|
attachmentsEdit->setFileInfo(&m_fileInfo, true);
|
||||||
} else {
|
} else {
|
||||||
// ... create and add a new edit
|
// ... create and add a new edit
|
||||||
edit = new AttachmentsEdit(&m_fileInfo, this);
|
attachmentsEdit = new AttachmentsEdit(&m_fileInfo, this);
|
||||||
connect(m_ui->clearEntriesPushButton, &QPushButton::clicked, edit, &AttachmentsEdit::clear);
|
connect(m_ui->clearEntriesPushButton, &QPushButton::clicked, attachmentsEdit, &AttachmentsEdit::clear);
|
||||||
connect(m_ui->restoreEntriesPushButton, &QPushButton::clicked, edit, &AttachmentsEdit::restore);
|
connect(m_ui->restoreEntriesPushButton, &QPushButton::clicked, attachmentsEdit, &AttachmentsEdit::restore);
|
||||||
//connect(edit, &AttachmentsEdit::returnPressed, this, &TagEditorWidget::handleReturnPressed);
|
//connect(edit, &AttachmentsEdit::returnPressed, this, &TagEditorWidget::handleReturnPressed);
|
||||||
m_ui->stackedWidget->insertWidget(widgetIndex, edit);
|
m_ui->stackedWidget->insertWidget(widgetIndex, attachmentsEdit);
|
||||||
}
|
}
|
||||||
++widgetIndex;
|
++widgetIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <tagparser/tag.h>
|
#include <tagparser/tag.h>
|
||||||
#include <tagparser/tagvalue.h>
|
#include <tagparser/tagvalue.h>
|
||||||
|
|
||||||
|
#include <qtutilities/misc/conversion.h>
|
||||||
#include <qtutilities/widgets/clearcombobox.h>
|
#include <qtutilities/widgets/clearcombobox.h>
|
||||||
#include <qtutilities/widgets/clearlineedit.h>
|
#include <qtutilities/widgets/clearlineedit.h>
|
||||||
#include <qtutilities/widgets/clearplaintextedit.h>
|
#include <qtutilities/widgets/clearplaintextedit.h>
|
||||||
|
@ -572,9 +573,9 @@ bool TagFieldEdit::updateValue(const TagValue &value, PreviousValueHandling prev
|
||||||
if (m_lineEdit || m_comboBox || m_plainTextEdit) {
|
if (m_lineEdit || m_comboBox || m_plainTextEdit) {
|
||||||
const auto text([&] {
|
const auto text([&] {
|
||||||
try {
|
try {
|
||||||
const auto text(Utility::tagValueToQString(value));
|
const auto textValue = Utility::tagValueToQString(value);
|
||||||
const auto correctedText = applyAutoCorrection(text);
|
const auto correctedText = applyAutoCorrection(textValue);
|
||||||
if (correctedText != text) {
|
if (correctedText != textValue) {
|
||||||
autoCorrectionApplied = true;
|
autoCorrectionApplied = true;
|
||||||
}
|
}
|
||||||
return correctedText;
|
return correctedText;
|
||||||
|
@ -699,17 +700,17 @@ bool TagFieldEdit::updateValue(const TagValue &value, PreviousValueHandling prev
|
||||||
}
|
}
|
||||||
const auto pixmap(QIcon::fromTheme(QStringLiteral("emblem-error")).pixmap(16));
|
const auto pixmap(QIcon::fromTheme(QStringLiteral("emblem-error")).pixmap(16));
|
||||||
const auto text([&] {
|
const auto text([&] {
|
||||||
QString text;
|
QString textValue;
|
||||||
if (conversionError) {
|
if (conversionError) {
|
||||||
text = tr("The value of this field could not be read from the file because it couldn't be converted properly.");
|
textValue = tr("The value of this field could not be read from the file because it couldn't be converted properly.");
|
||||||
if (!canApplyField) {
|
if (!canApplyField) {
|
||||||
text += QChar('\n');
|
textValue += QChar('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!canApplyField) {
|
if (!canApplyField) {
|
||||||
text += tr("The field can not be applied when saving the file and will be lost.");
|
textValue += tr("The field can not be applied when saving the file and will be lost.");
|
||||||
}
|
}
|
||||||
return text;
|
return textValue;
|
||||||
}());
|
}());
|
||||||
for (auto *const overlay : widgets) {
|
for (auto *const overlay : widgets) {
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
|
@ -919,9 +920,7 @@ void TagFieldEdit::handleRestoreButtonClicked()
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto *const tag : tags()) {
|
for (auto *const tag : tags()) {
|
||||||
const auto typeName = tag->typeName();
|
const auto *const action = menu.addAction(tr("restore to value from %1 (%2)").arg(qstringFromStdStringView(tag->typeName())).arg(++i));
|
||||||
const auto *const action
|
|
||||||
= menu.addAction(tr("restore to value from %1 (%2)").arg(QString::fromUtf8(typeName.data(), typeName.size())).arg(++i));
|
|
||||||
connect(action, &QAction::triggered, [this, tag] {
|
connect(action, &QAction::triggered, [this, tag] {
|
||||||
setLocked(false);
|
setLocked(false);
|
||||||
updateValue(tag, PreviousValueHandling::Clear);
|
updateValue(tag, PreviousValueHandling::Clear);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <tagparser/mp4/mp4container.h>
|
#include <tagparser/mp4/mp4container.h>
|
||||||
#include <tagparser/signature.h>
|
#include <tagparser/signature.h>
|
||||||
|
|
||||||
|
#include <qtutilities/misc/conversion.h>
|
||||||
#include <qtutilities/resources/resources.h>
|
#include <qtutilities/resources/resources.h>
|
||||||
|
|
||||||
#include <c++utilities/chrono/datetime.h>
|
#include <c++utilities/chrono/datetime.h>
|
||||||
|
@ -276,7 +277,7 @@ template <> void mkElementContent(QXmlStreamWriter &writer, EbmlElement *element
|
||||||
const auto seekIdName = matroskaIdName(static_cast<std::uint32_t>(seekId));
|
const auto seekIdName = matroskaIdName(static_cast<std::uint32_t>(seekId));
|
||||||
if (!seekIdName.empty()) {
|
if (!seekIdName.empty()) {
|
||||||
writer.writeCharacters(QStringLiteral(" \""));
|
writer.writeCharacters(QStringLiteral(" \""));
|
||||||
writer.writeCharacters(QString::fromLatin1(seekIdName.data(), seekIdName.size()));
|
writer.writeCharacters(qstringFromStdStringView(seekIdName));
|
||||||
writer.writeCharacters(QStringLiteral("\""));
|
writer.writeCharacters(QStringLiteral("\""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,7 +963,7 @@ public:
|
||||||
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Padding size"),
|
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Padding size"),
|
||||||
QStringLiteral("%1 (%2 %)")
|
QStringLiteral("%1 (%2 %)")
|
||||||
.arg(qstr(dataSizeToString(m_file.paddingSize(), true)))
|
.arg(qstr(dataSizeToString(m_file.paddingSize(), true)))
|
||||||
.arg(static_cast<double>(m_file.paddingSize()) / m_file.size() * 100.0, 0, 'g', 2));
|
.arg(static_cast<double>(m_file.paddingSize()) / static_cast<double>(m_file.size()) * 100.0, 0, 'g', 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_writer.writeEndElement();
|
m_writer.writeEndElement();
|
||||||
|
|
|
@ -124,8 +124,8 @@ string qstringToString(const QString &value, TagTextEncoding textEncoding)
|
||||||
#else
|
#else
|
||||||
case TagTextEncoding::Utf16BigEndian:
|
case TagTextEncoding::Utf16BigEndian:
|
||||||
#endif
|
#endif
|
||||||
encodedString = QByteArray(
|
encodedString = QByteArray(reinterpret_cast<const char *>(value.utf16()),
|
||||||
reinterpret_cast<const char *>(value.utf16()), static_cast<int>(value.size() * static_cast<int>(sizeof(ushort) / sizeof(char))));
|
static_cast<QByteArray::size_type>(value.size()) * static_cast<QByteArray::size_type>(sizeof(ushort) / sizeof(char)));
|
||||||
break;
|
break;
|
||||||
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
|
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
|
||||||
case TagTextEncoding::Utf16BigEndian: {
|
case TagTextEncoding::Utf16BigEndian: {
|
||||||
|
@ -139,7 +139,7 @@ string qstringToString(const QString &value, TagTextEncoding textEncoding)
|
||||||
"UTF-16BE",
|
"UTF-16BE",
|
||||||
#endif
|
#endif
|
||||||
textEncodingToCodecName(textEncoding), reinterpret_cast<const char *>(value.utf16()),
|
textEncodingToCodecName(textEncoding), reinterpret_cast<const char *>(value.utf16()),
|
||||||
static_cast<int>(value.size() * static_cast<int>(sizeof(ushort) / sizeof(char))), 2.0f);
|
static_cast<std::size_t>(value.size()) * (sizeof(ushort) / sizeof(char)), 2.0f);
|
||||||
return string(utf16Data.first.get(), utf16Data.second);
|
return string(utf16Data.first.get(), utf16Data.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,9 +243,9 @@ void parseFileName(const QString &fileName, QString &title, int &trackNumber)
|
||||||
trackNumber = QtUtilities::midRef(title, lastDelimIndex, delimIndex - lastDelimIndex).toInt(&ok);
|
trackNumber = QtUtilities::midRef(title, lastDelimIndex, delimIndex - lastDelimIndex).toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
int titleStart = delimIndex + delim.size();
|
int titleStart = delimIndex + delim.size();
|
||||||
for (const auto &delim : delims) {
|
for (const auto &delim2 : delims) {
|
||||||
if (QtUtilities::midRef(title, titleStart).startsWith(delim)) {
|
if (QtUtilities::midRef(title, titleStart).startsWith(delim2)) {
|
||||||
titleStart += delim.size();
|
titleStart += delim2.size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue