48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#ifndef KDENOTE_METADATA_H
|
|
#define KDENOTE_METADATA_H
|
|
|
|
#include <QDateTime>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
|
|
namespace Denote {
|
|
|
|
/// Metadata extracted from a denote-style filename.
|
|
struct Metadata {
|
|
QString path; ///< Full filesystem path
|
|
QString identifier; ///< YYYYMMDDTHHMMSS timestamp
|
|
QString signature; ///< Optional signature component
|
|
QString title; ///< Title (from filename or frontmatter)
|
|
QStringList tags; ///< Keywords / tags
|
|
|
|
/// Parse the identifier into a QDateTime.
|
|
QDateTime creationDate() const;
|
|
|
|
/// True if the filename conforms to denote naming.
|
|
bool isValid() const { return !identifier.isEmpty(); }
|
|
};
|
|
|
|
/// Parse a denote-style filename into its components.
|
|
/// Works on filename only (no file I/O).
|
|
Metadata parseFilename(const QString &path);
|
|
|
|
/// Generate a new identifier from the current time.
|
|
QString generateIdentifier();
|
|
|
|
/// Build a canonical denote filename from components.
|
|
/// Returns just the filename (no directory).
|
|
QString buildFilename(const QString &title,
|
|
const QStringList &tags = {},
|
|
const QString &signature = {},
|
|
const QString &ext = QStringLiteral(".md"));
|
|
|
|
/// Slugify a title for use in a denote filename.
|
|
QString slugifyTitle(const QString &title);
|
|
|
|
/// Check if a tag is valid (lowercase alphanumeric/unicode letters).
|
|
bool isValidTag(const QString &tag);
|
|
|
|
} // namespace Denote
|
|
|
|
#endif // KDENOTE_METADATA_H
|