structurelibraryview.hpp 1.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*
 * <32021 by Stellaris. Copying Art is an act of love. Love is not subject to law.
 */
#ifndef STRUCTURELIBRARYVIEW_HPP
#define STRUCTURELIBRARYVIEW_HPP

#include <QFrame>

#include <QDir>
#include <QTreeWidgetItem>
11
#include <QFileSystemWatcher>
12
13
14
15
16
17
18

#include "structure.hpp"

namespace Ui {
class StructureLibraryView;
}

19
20
// TODO : Documenter

21
22
23
24
25
26
27
28
29
30
31
class StructureLibraryView : public QFrame
{
    Q_OBJECT

public:
    explicit StructureLibraryView(QWidget *parent = nullptr);
    ~StructureLibraryView();

signals:
    void structure_copied(const Structure& s);

32
33
34
35
public slots:
    //! Permet de mettre à jour la taille en pixels d'une cellule, pour que l'affichage d'un drag&drop soit correct
    void update_cell_pixel_size(unsigned size);

36
37
38
private:
    void load_structures();
    QTreeWidgetItem *add_directory_contents(const QDir& dir);
39
    bool try_load_structure(const QString& filename, Structure& s);
Yann Boucher's avatar
Yann Boucher committed
40
    void update_preview(const Structure& s);
41
42
    QImage create_preview_image(const Structure &s, QColor background);
    void create_drag(QTreeWidgetItem* item, int column);
43
44
45
46
47
48
49

private slots:
    void update_info(QTreeWidgetItem* item, int column);
    void copy_button_clicked();

private:
    Ui::StructureLibraryView *ui;
50
    QFileSystemWatcher m_watcher;
51
    unsigned m_cell_pixel_size;
52
53
54
};

#endif // STRUCTURELIBRARYVIEW_HPP