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