[nostalgia] Update for Ox changes
This commit is contained in:
parent
ae62f89fe8
commit
0099129a19
@ -66,12 +66,14 @@ void Project::lsProcDir(QStringList *paths, QString path) const {
|
||||
const auto fullPath = path + "/" + name.c_str();
|
||||
oxRequireT(stat, m_fs->stat(fullPath.toUtf8().data()));
|
||||
switch (stat.fileType) {
|
||||
case ox::FileType_NormalFile:
|
||||
case ox::FileType::NormalFile:
|
||||
paths->push_back(fullPath);
|
||||
break;
|
||||
case ox::FileType_Directory:
|
||||
case ox::FileType::Directory:
|
||||
lsProcDir(paths, fullPath);
|
||||
break;
|
||||
case ox::FileType::None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
OxFSFile::OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem) {
|
||||
OxFSFile::OxFSFile(ox::FileSystem *fs, const QString &path, OxFSFile *parentItem) {
|
||||
m_path = path;
|
||||
m_parentItem = parentItem;
|
||||
// find children
|
||||
oxRequireT(stat, fs->stat(static_cast<const char*>(m_path.toUtf8())));
|
||||
QVector<QString> ls;
|
||||
if (stat.fileType == ox::FileType_Directory) {
|
||||
if (stat.fileType == ox::FileType::Directory) {
|
||||
oxRequireT(names, fs->ls(m_path.toUtf8()));
|
||||
for (const auto &name : names) {
|
||||
if (name[0] != '.') {
|
||||
@ -33,14 +33,14 @@ OxFSFile::OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem) {
|
||||
}
|
||||
auto p = m_path;
|
||||
// make sure ends with path separator
|
||||
if (fs->stat(p.toUtf8().data()).value.fileType == ox::FileType_Directory &&
|
||||
if (fs->stat(p.toUtf8().data()).value.fileType == ox::FileType::Directory &&
|
||||
p.size() && p.back() != QDir::separator()) {
|
||||
p += QDir::separator();
|
||||
}
|
||||
for (const auto &name : ls) {
|
||||
if (name != "." && name != "..") {
|
||||
const auto path = m_path.size() ? m_path + '/' + name : name;
|
||||
const auto ch = new OxFSFile(fs, path, this);
|
||||
const auto filePath = m_path.size() ? m_path + '/' + name : name;
|
||||
const auto ch = new OxFSFile(fs, filePath, this);
|
||||
m_childItems.push_back(ch);
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ void OxFSFile::appendChild(OxFSModel *model, QStringList pathItems, QString curr
|
||||
if (!pathItems.empty()) {
|
||||
const auto &target = pathItems[0];
|
||||
currentPath += "/" + target;
|
||||
int index = m_childItems.size();
|
||||
int index = static_cast<int>(m_childItems.size());
|
||||
for (int i = 0; i < m_childItems.size(); i++) {
|
||||
if (m_childItems[i]->name() >= target) {
|
||||
index = i;
|
||||
@ -82,7 +82,7 @@ OxFSFile *OxFSFile::child(int row) {
|
||||
}
|
||||
|
||||
int OxFSFile::childCount() const {
|
||||
return m_childItems.size();
|
||||
return static_cast<int>(m_childItems.size());
|
||||
}
|
||||
|
||||
int OxFSFile::columnCount() const {
|
||||
@ -95,7 +95,7 @@ QVariant OxFSFile::data(int) const {
|
||||
|
||||
int OxFSFile::row() const {
|
||||
if (m_parentItem) {
|
||||
return m_parentItem->m_childItems.indexOf(const_cast<OxFSFile*>(this));
|
||||
return static_cast<int>(m_parentItem->m_childItems.indexOf(const_cast<OxFSFile*>(this)));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -209,7 +209,7 @@ int OxFSModel::columnCount(const QModelIndex &parent) const {
|
||||
}
|
||||
}
|
||||
|
||||
void OxFSModel::updateFile(QString path) {
|
||||
void OxFSModel::updateFile(const QString &path) {
|
||||
auto pathItems = path.split("/").mid(1);
|
||||
m_rootItem->appendChild(this, pathItems, "");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class OxFSFile {
|
||||
QVector<OxFSFile*> m_childItems;
|
||||
|
||||
public:
|
||||
OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem = nullptr);
|
||||
OxFSFile(ox::FileSystem *fs, const QString &path, OxFSFile *parentItem = nullptr);
|
||||
|
||||
~OxFSFile();
|
||||
|
||||
@ -31,19 +31,25 @@ class OxFSFile {
|
||||
|
||||
OxFSFile *child(int row);
|
||||
|
||||
[[nodiscard]] int childCount() const;
|
||||
[[nodiscard]]
|
||||
int childCount() const;
|
||||
|
||||
[[nodiscard]] int columnCount() const;
|
||||
[[nodiscard]]
|
||||
int columnCount() const;
|
||||
|
||||
[[nodiscard]] QVariant data(int column) const;
|
||||
[[nodiscard]]
|
||||
QVariant data(int column) const;
|
||||
|
||||
[[nodiscard]] int row() const;
|
||||
[[nodiscard]]
|
||||
int row() const;
|
||||
|
||||
OxFSFile *parentItem();
|
||||
|
||||
[[nodiscard]] QString name() const;
|
||||
[[nodiscard]]
|
||||
QString name() const;
|
||||
|
||||
[[nodiscard]] QString path() const;
|
||||
[[nodiscard]]
|
||||
QString path() const;
|
||||
};
|
||||
|
||||
class OxFSModel: public QAbstractItemModel {
|
||||
@ -75,7 +81,7 @@ class OxFSModel: public QAbstractItemModel {
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent) const override;
|
||||
|
||||
public slots:
|
||||
void updateFile(QString path);
|
||||
void updateFile(const QString &path);
|
||||
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@ static ox::Error transformClaw(ox::FileSystem *dest, const ox::String &path) noe
|
||||
for (const auto &name : fileList) {
|
||||
const auto filePath = path + name;
|
||||
oxRequire(stat, dest->stat(filePath.c_str()));
|
||||
if (stat.fileType == ox::FileType_Directory) {
|
||||
if (stat.fileType == ox::FileType::Directory) {
|
||||
const auto dir = path + name + '/';
|
||||
oxReturnError(transformClaw(dest, dir));
|
||||
} else {
|
||||
@ -83,7 +83,7 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, const ox::Strin
|
||||
}
|
||||
oxOutf("reading {}\n", name);
|
||||
oxRequire(stat, src->stat(currentFile.c_str()));
|
||||
if (stat.fileType == ox::FileType_Directory) {
|
||||
if (stat.fileType == ox::FileType::Directory) {
|
||||
oxReturnError(dest->mkdir(currentFile.c_str(), true));
|
||||
oxReturnError(copy(src, dest, currentFile + '/'));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user