#ifndef FILE_DIALOG_HPP #define FILE_DIALOG_HPP #include #include #include #include "bookmouse_time.hpp" #include 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>; 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 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