Use listDirs() instead of list() for section loading
list() returns files AND directories. Section entries are directories only. Files like 'title', 'keyword', 'body' were being incorrectly treated as child sections. Using listDirs() filters to directories only.
This commit is contained in:
parent
350ce66860
commit
7f948de2ab
|
|
@ -4,7 +4,6 @@
|
|||
#include <QDebug>
|
||||
|
||||
static const QStringList DONE_KEYWORDS = {"DONE", "CANCELLED", "CANCELED"};
|
||||
static const QStringList SKIP_ENTRIES = {"raw", "body", "meta", "new"};
|
||||
|
||||
DocumentModel::DocumentModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
|
|
@ -158,12 +157,13 @@ void DocumentModel::loadDocument()
|
|||
|
||||
void DocumentModel::loadSections(const QString &parentPath, const QString &parentId, int level)
|
||||
{
|
||||
QStringList entries = m_client->list(parentPath);
|
||||
// Use listDirs to only get directories (actual sections), not files
|
||||
QStringList entries = m_client->listDirs(parentPath);
|
||||
QStringList sectionIds;
|
||||
|
||||
for (const QString &entry : entries) {
|
||||
// Skip non-section entries (raw, body, meta, new, etc.)
|
||||
if (SKIP_ENTRIES.contains(entry))
|
||||
// Skip special directories
|
||||
if (entry == "new")
|
||||
continue;
|
||||
|
||||
Section sec;
|
||||
|
|
@ -179,13 +179,12 @@ void DocumentModel::loadSections(const QString &parentPath, const QString &paren
|
|||
loadSections(sec.path, entry, level + 1);
|
||||
}
|
||||
|
||||
// Now that all children are loaded, populate childIds for each section at this level
|
||||
// Populate childIds for each section at this level
|
||||
for (const QString &id : sectionIds) {
|
||||
Section &sec = m_sections[id];
|
||||
QStringList childEntries = m_client->list(sec.path);
|
||||
QStringList childEntries = m_client->listDirs(sec.path);
|
||||
for (const QString &childEntry : childEntries) {
|
||||
// Only include entries that were actually added as sections
|
||||
if (m_sections.contains(childEntry) && m_sections[childEntry].parentId == id) {
|
||||
if (childEntry != "new" && m_sections.contains(childEntry) && m_sections[childEntry].parentId == id) {
|
||||
sec.childIds.append(childEntry);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue