#ifndef DATAFILE_H
#define DATAFILE_H

#include <QObject>
#include <QIcon>

#define NAME_LENGTH 103

class DataFile : public QObject
{
    Q_OBJECT
public:
    explicit DataFile(QString path, QObject *parent = nullptr, bool fromDisk = false);
    ~DataFile();
public:
    bool isDirectory() const { return m_bIsDirectory; }
    bool isDisk() const { return m_bIsDisk; }
    QIcon   icon() const { return m_oIcon; }
    unsigned long size() const { return m_u64Size; }
    QString stringSize();
    QString display() const { return m_oDisplayName; }
    QString source() const { return m_oSource; }
    QString destination() const { return m_oDestination; }
    DataFile *linkTarget() { return m_oLinkTarget; }
    void setLinkTarget(DataFile *t) { m_oLinkTarget = t; }
    QString type() const { return m_oType; }
    unsigned int level() const { return m_u32Level; }
    bool attrHidden() const { return m_bAttrHidden; }
    bool attrSymbolLink() const { return m_bAttrLink; }
    void rename(QString, bool add = false);
    void copy();
    void filter();
    void changeParent(DataFile *p);
    bool valid() const { return m_bIsValid; }
    void setValid(bool b) { m_bIsValid = b; }
public slots:
    void onUpdate(QString);
private slots:
    void slotsDoHidde(bool);
    void slotsDoBroken(bool);
    void slotsDoRepleace(bool);
protected:
    unsigned int     m_u32Level;//当前文件在整个数据集中的级别
    bool             m_bIsDirectory;//当前文件是否为文件夹
    bool             m_bAttrHidden;//当前文件是否有隐藏属性
    bool             m_bAttrLink;//当前文件是否为连接文件
    bool             m_bIsDisk;//当前文件来源是否为光盘
    bool             m_bIsValid;
    unsigned long    m_u64Size;//当前文件大小（字节单位）
    QString          m_oRealName;//当前文件真实名称
    QString          m_oDisplayName;//当前文件展示名称
    QString          m_oSource;//当前文件源
    QString          m_oDestination;//当前文件将被缓存的目的路径
    QString          m_oType;//当前文件类别
    QString          m_oCreateTime;//当前文件创建时间
    QString          m_oAddTime;//当前文件添加到刻录内时间
    DataFile        *m_oLinkTarget;//当前文件连接的目标文件
    QIcon            m_oIcon;//当前文件类别对应主题内图标
signals:
    // log
    void info(QString); void warn(QString);
    void error(QString); void debug(QString);
    // logic
    void size(unsigned long, bool);
    void file(bool, DataFile *f);
    void directory(bool, DataFile *d);
    // child
    void child(DataFile *, bool);
    // copy
    void copied(QString, /* to */QString);
    void update(QString);
    // filter
    void hidden(bool b = true);
    void broken(bool b = true);
    void repleace(bool b = true);
    void doHidden(void *);
    void doBroken(void *);
    void doRepleace(void *);
};

#endif // DATAFILE_H
