blob: 6a787b392f130540df9aca58f2b935def56dbe6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#ifndef FILE_DIALOG_HPP
#define FILE_DIALOG_HPP
#include <fud_status.hpp>
#include <fud_string.hpp>
#include <fud_directory.hpp>
#include "bookmouse_time.hpp"
#include <vector>
namespace bookmouse {
using DirEntryType = fud::DirectoryEntryType;
struct DialogEntry : public fud::DirectoryEntry {
TimeInfo timeInfo;
fud::String niceTime;
bool selected;
bool valid;
bool gotTime;
DialogEntry() = default;
DialogEntry(fud::DirectoryEntry&& entry);
fud::FudStatus formatTime(TimeFormat& format);
};
constexpr char DirEntryTypeToChar(DirEntryType entryType)
{
char entryLetter = 'D';
switch (entryType) {
case DirEntryType::Directory:
entryLetter = 'D';
break;
case DirEntryType::RegularFile:
entryLetter = 'F';
break;
case DirEntryType::Character:
entryLetter = 'F';
break;
case DirEntryType::UnixSocket:
entryLetter = 'S';
break;
case DirEntryType::NamedPipe:
entryLetter = 'P';
break;
case DirEntryType::SymbolicLink:
entryLetter = 'L';
break;
case DirEntryType::Block:
entryLetter = 'B';
break;
case DirEntryType::Unknown:
default:
entryLetter = '?';
break;
}
return entryLetter;
}
using FilePickerResult = std::optional<std::vector<fud::String>>;
class FileDialog {
public:
FileDialog(
const fud::String& directoryName,
TimeFormat& timeFormat);
FilePickerResult pickFiles();
constexpr bool valid() const {
return m_valid;
}
constexpr bool canceled() const {
return m_canceled;
}
private:
fud::FudStatus getDirectoryContents();
fud::String m_directoryName;
fud::Directory m_directory;
TimeFormat& m_timeFormat;
std::vector<DialogEntry> m_directoryContents{};
bool m_valid{false};
bool m_canceled{false};
bool m_typeSelected{false};
bool m_nameSelectede{false};
bool m_sizeSelected{false};
bool m_dateSelected{false};
};
} // namespace bookmouse
#endif
|