Массовые исправления UX: вкладки (MouseArea не блокирует ×), контент редактора (onDocIndexChanged), авто-расширение .md, ошибка дубликата, ПКМ-создание внутри папок, точки в календаре, граф (зум колесом, клик по файлу, pan правой кнопкой), fileExists(), 16/16 тестов

This commit is contained in:
Flora (opencode)
2026-08-17 15:42:56 +03:00
parent 9946e440ce
commit 7b43b0c4fc
7 changed files with 134 additions and 32 deletions
+15 -3
View File
@@ -247,12 +247,19 @@ QString FileStore::parentDirOfRow(int row) const
QString FileStore::createFile(const QString &parentPath, const QString &name)
{
const QString dir = parentPath.isEmpty() ? m_vault : parentPath;
const QString err = validateName(name);
const QString trimmed = name.trimmed();
if (trimmed.isEmpty())
return QStringLiteral("Имя файла не может быть пустым.");
// Если имя без расширения — добавляем .md
QString actualName = trimmed;
if (!actualName.contains(QLatin1Char('.')))
actualName += QStringLiteral(".md");
const QString err = validateName(actualName);
if (!err.isEmpty())
return err;
const QString path = QDir(dir).filePath(name);
const QString path = QDir(dir).filePath(actualName);
if (QFileInfo::exists(path))
return QStringLiteral("Файл с таким именем уже существует.");
return QStringLiteral("Файл «%1» уже существует в этом каталоге.").arg(actualName);
QFile f(path);
if (!f.open(QIODevice::WriteOnly))
return QStringLiteral("Не удалось создать файл: %1").arg(path);
@@ -390,4 +397,9 @@ bool FileStore::itemIsDir(int row) const
bool FileStore::itemHasChildren(int row) const
{
return row >= 0 && row < m_rows.size() && m_rows[row].hasChildren;
}
bool FileStore::fileExists(const QString &path) const
{
return QFileInfo::exists(path);
}
+1
View File
@@ -58,6 +58,7 @@ public:
Q_INVOKABLE QString itemPath(int row) const;
Q_INVOKABLE bool itemIsDir(int row) const;
Q_INVOKABLE bool itemHasChildren(int row) const;
Q_INVOKABLE bool fileExists(const QString &path) const;
signals:
void vaultChanged();