Refactoring

This commit is contained in:
Jonas Kvinge
2024-10-22 18:12:33 +02:00
parent dfcf715291
commit 8da2b9cd94
623 changed files with 9071 additions and 5126 deletions

View File

@@ -17,15 +17,6 @@
*
*/
#ifndef FILENAMECONSTANTS_H
#define FILENAMECONSTANTS_H
#include "coveroptions.h"
#include "core/arraysize.h"
constexpr char kProblematicCharactersRegex[] = "[:?*\"<>|]";
constexpr char kInvalidFatCharactersRegex[] = "[^a-zA-Z0-9!#\\$%&'()\\-@\\^_`{}~/. ]";
constexpr char kInvalidDirCharactersRegex[] = "[/\\\\]";
constexpr char kInvalidPrefixCharacters[] = ".";
constexpr int kInvalidPrefixCharactersCount = arraysize(kInvalidPrefixCharacters) - 1;
#endif // FILENAMECONSTANTS_H
CoverOptions::CoverOptions() : cover_type(CoverType::Cache), cover_filename(CoverFilename::Hash), cover_overwrite(false), cover_lowercase(true), cover_replace_spaces(true) {}

View File

@@ -20,6 +20,8 @@
#ifndef COVEROPTIONS_H
#define COVEROPTIONS_H
#include <QString>
class CoverOptions {
public:
@@ -34,7 +36,7 @@ class CoverOptions {
Pattern = 2
};
explicit CoverOptions() : cover_type(CoverType::Cache), cover_filename(CoverFilename::Hash), cover_overwrite(false), cover_lowercase(true), cover_replace_spaces(true) {}
explicit CoverOptions();
CoverType cover_type;
CoverFilename cover_filename;
QString cover_pattern;

View File

@@ -26,7 +26,7 @@
#include <QStandardPaths>
#include <QCryptographicHash>
#include "filenameconstants.h"
#include "constants/filenameconstants.h"
#include "transliterate.h"
#include "coverutils.h"
#include "core/logging.h"

View File

@@ -34,7 +34,7 @@
#include "diskutils.h"
#ifdef Q_OS_WIN32
# include "core/scopedwchararray.h"
# include "scopedwchararray.h"
#endif
namespace Utilities {

View File

@@ -29,7 +29,7 @@
#include <QFile>
#include "core/logging.h"
#include "core/scoped_ptr.h"
#include "includes/scoped_ptr.h"
#include "fileutils.h"

View File

@@ -0,0 +1,29 @@
/*
* Strawberry Music Player
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QString>
#include "scopedwchararray.h"
ScopedWCharArray::ScopedWCharArray(const QString &str)
: chars_(str.length()), data_(new wchar_t[chars_ + 1]) {
str.toWCharArray(data_.get());
data_[chars_] = '\0';
}

View File

@@ -0,0 +1,48 @@
/*
* Strawberry Music Player
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SCOPEDWCHARARRAY_H
#define SCOPEDWCHARARRAY_H
#include <QObject>
#include <QString>
#include "includes/scoped_ptr.h"
class ScopedWCharArray {
public:
explicit ScopedWCharArray(const QString &str);
QString ToString() const { return QString::fromWCharArray(data_.get()); }
wchar_t *get() const { return data_.get(); }
explicit operator wchar_t *() const { return get(); }
qint64 characters() const { return chars_; }
qint64 bytes() const { return (chars_ + 1) * sizeof(wchar_t); }
private:
Q_DISABLE_COPY(ScopedWCharArray)
qint64 chars_;
ScopedPtr<wchar_t[]> data_;
};
#endif // SCOPEDWCHARARRAY_H

View File

@@ -1,32 +0,0 @@
/* This file was part of Clementine.
Copyright 2011, David Sansome <me@davidsansome.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef TIMECONSTANTS_H
#define TIMECONSTANTS_H
#include <QtGlobal>
// Use these to convert between time units
constexpr qint64 kMsecPerSec = 1000ll;
constexpr qint64 kUsecPerMsec = 1000ll;
constexpr qint64 kUsecPerSec = 1000000ll;
constexpr qint64 kNsecPerUsec = 1000ll;
constexpr qint64 kNsecPerMsec = 1000000ll;
constexpr qint64 kNsecPerSec = 1000000000ll;
constexpr qint64 kSecsPerDay = 24 * 60 * 60;
#endif // TIMECONSTANTS_H

View File

@@ -27,7 +27,7 @@
#include <QSize>
#include <QLocale>
#include "timeconstants.h"
#include "constants/timeconstants.h"
#include "timeutils.h"
namespace Utilities {

View File

@@ -27,7 +27,7 @@
#include <QByteArray>
#include <QString>
#include "core/scoped_ptr.h"
#include "includes/scoped_ptr.h"
#include "transliterate.h"
namespace Utilities {