22 #ifndef CRNDOCUMENT_HEADER
23 #define CRNDOCUMENT_HEADER
94 SBlock
GetView(
size_t num)
const;
132 class iterator:
public std::iterator<std::input_iterator_tag, SBlock>
150 void init_block() {
if (num < doc->views.size()) b = doc->
GetView(num);
else b =
nullptr; }
163 #ifdef CRN_USING_HARU
175 void addView(const
Path &fname, const
String &
id);
178 virtual
Path completeFilename(const
Path &fn) const override;
180 virtual
void load(const
Path &fname) override;
182 virtual
void save(const
Path &fname) override;
185 UImage createThumbnail(const
Path &imagename) const;
188 String createNewId() const;
194 view(
const Path &fname =
"",
const String &unique_id = U
""):filename(fname),id(unique_id) {}
197 bool operator==(
const view &other)
const noexcept {
return filename == other.filename; }
203 std::vector<view> views;
209 static const Path thumbdir;
210 static size_t thumbWidth;
211 static size_t thumbHeight;
215 inline size_t Size(
const Document &doc) noexcept {
return doc.GetNbViews(); }
Iterator on the blocks of the document.
void ReorderViewsTo(const std::vector< size_t > &to)
Reorders the views.
bool operator!=(const iterator &it) const noexcept
iterator(const iterator &it)
static void SetThumbHeight(size_t h)
static void SetThumbWidth(size_t w)
Base class for a progress display.
size_t GetIndex() const noexcept
virtual ~Document() override
Destructor.
complex base abstract class
void SetDate(const String &s)
Sets the date of the document.
SBlock GetView(size_t num) const
Returns a pointer to a view.
iterator & operator=(const iterator &it)
Document & operator=(const Document &)=delete
std::unique_ptr< ImageBase > UImage
iterator(const Document *d, size_t n)
#define CRN_ADD_RANGED_FOR_TO_POINTERS(TYPE)
Enables ranged for for smart pointers on a type.
void SetBasename(const Path &s)
Sets the base name of the document if any.
std::vector< Path > GetFilenames() const
Gets the list of the image files of the document.
A UTF32 character string class.
static Path GetDefaultDirName()
Returns the default directory where the documents are saved.
Path GetThumbnailFilename(size_t index, bool refresh=false) const
Returns the filename of a thumbnail of a view (cached)
UImage GetThumbnail(size_t index, bool refresh=false) const
Returns a thumbnail of a view (cached)
String AddView(const Path &fname)
Adds a new image.
String InsertView(const Path &fname, size_t pos)
Inserts a new image.
size_t Size(const Vector &v) noexcept
Size of a vector.
const String & GetAuthor() const noexcept
Gets the author of the document.
Path GetViewFilename(size_t num) const
Returns the filename of a view.
A convenience class for file paths.
static size_t GetThumbHeight() noexcept
iterator operator++(int nouse)
Path GetThumbnailPath() const
Returns the path of the thumbnails.
String GetViewId(size_t num) const
Returns the id of a view.
iterator begin() const
Returns an iterator to the first block.
value_type operator*() const noexcept
static size_t GetThumbWidth() noexcept
bool operator==(const iterator &it) const noexcept
void RemoveView(const Path &fname)
Removes a view.
Attributes to create a PDF export of a document.
size_t GetViewIndex(const String &id) const
Returns the index of a view.
iterator end() const
Returns an iterator after the last block.
const String & GetDate() const noexcept
Gets the date of the document.
size_t GetNbViews() const noexcept
Returns the number of views.
void Clear()
Removes all views and unsets all data.
bool operator==(const String &s1, const String &s2)
Tests equality of two strings.
const Path & GetBasename() const noexcept
Gets the file base name of the document.
void ReorderViewsFrom(const std::vector< size_t > &from)
Reorders the views.
void SetAuthor(const String &s)
Sets the author of the document.
std::vector< String > GetViewIds() const
Gets the list of the view ids of the document.
value_type operator->() const noexcept