From 77521aeeedd487d53af6cac4d015c30ecb865aa4 Mon Sep 17 00:00:00 2001 From: JuanJakobo <34421964+JuanJakobo@users.noreply.github.com> Date: Sun, 10 Jan 2021 18:18:25 +0100 Subject: [PATCH] extended documentation and cleanup --- src/handler/eventHandler.cpp | 2 -- src/ui/listView.cpp | 1 - src/util/item.cpp | 1 - src/util/item.h | 28 ++++++++++++++++++++++++---- src/util/nextcloud.cpp | 1 - src/util/nextcloud.h | 23 +++++++++++++++++------ 6 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/handler/eventHandler.cpp b/src/handler/eventHandler.cpp index e1625b4..91d8958 100644 --- a/src/handler/eventHandler.cpp +++ b/src/handler/eventHandler.cpp @@ -144,7 +144,6 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2) _tempPath = _nextcloud.getItems()->at(itemID).getPath(); if (!_tempPath.empty()) _nextcloud.getDataStructure(_tempPath); - _listView.reset(new ListView(_menu.getContentRect(), _nextcloud.getItems())); _listView->drawHeader(_tempPath.substr(NEXTCLOUD_ROOT_PATH.length())); } @@ -162,7 +161,6 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2) _nextcloud.getItems()->at(itemID).open(); break; case 2: - //TODO implement upload if local file if (_nextcloud.isWorkOffline()) { int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "You are in offline modus. Go back online?", "Yes", "No", "Cancel"); diff --git a/src/ui/listView.cpp b/src/ui/listView.cpp index f611b4b..ce1c52d 100644 --- a/src/ui/listView.cpp +++ b/src/ui/listView.cpp @@ -51,7 +51,6 @@ ListView::ListView(const irect *contentRect, const std::shared_ptr> _pageIcon = iRect(_contentRect->w - 100, _contentRect->h + _contentRect->y - _footerHeight, 100, _footerHeight, ALIGN_CENTER); - //TODO draw botton back and next, draw just once? _firstPageButton = iRect(_contentRect->x, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER); _lastPageButton = iRect(_contentRect->x + 150, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER); _nextPageButton = iRect(_contentRect->x + 300, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER); diff --git a/src/util/item.cpp b/src/util/item.cpp index 9a40677..92025e9 100644 --- a/src/util/item.cpp +++ b/src/util/item.cpp @@ -21,7 +21,6 @@ using namespace std; Item::Item(const string &xmlItem) { _path = Util::getXMLAttribute(xmlItem, "d:href"); - //TODO also test for url if (_path.find(NEXTCLOUD_END_PATH) != std::string::npos) _path.erase(0, NEXTCLOUD_END_PATH.length()); diff --git a/src/util/item.h b/src/util/item.h index 67de9d0..b52cddc 100644 --- a/src/util/item.h +++ b/src/util/item.h @@ -31,9 +31,28 @@ enum FileState class Item { public: + + /** + * Creates an item by receiving the xml from nextcloud and parses it into an object + * + * @param xmlItem result of the nextcloud request + */ Item(const string &xmlItem); + /** + * Creates a new item by receiving localPath from the pocketbook + * + * @param localPath path where the file is placed + * @param FileState state of the file Item(const string &localPath, FileState state); + + /** + * Tries to open the item by checking the file format and then executes the fitting action + */ + void open() const; + + + bool removeFile(); void setPath(const string &path) { _path = path; }; string getPath() const { return _path; }; @@ -55,10 +74,6 @@ public: string getFiletype() const { return _fileType; }; - void open() const; - - bool removeFile(); - private: string _path; Itemtype _type; @@ -69,6 +84,11 @@ private: string _size{"Error"}; string _fileType; + /** + * Converts the size to an easier readble format + * + * @param tempSize Size of the item in bytes + */ void setSize(double tempSize); }; #endif \ No newline at end of file diff --git a/src/util/nextcloud.cpp b/src/util/nextcloud.cpp index 91f9d94..84baca1 100644 --- a/src/util/nextcloud.cpp +++ b/src/util/nextcloud.cpp @@ -394,7 +394,6 @@ bool Nextcloud::getOfflineStructure(const string &pathUrl) ifstream inFile(localPath); std::stringstream buffer; buffer << inFile.rdbuf(); - //TODO also show in offline modus all files! if (!readInXML(buffer.str())) return false; diff --git a/src/util/nextcloud.h b/src/util/nextcloud.h index bb4ff2d..a5b7599 100644 --- a/src/util/nextcloud.h +++ b/src/util/nextcloud.h @@ -33,18 +33,29 @@ public: explicit Nextcloud(); /** - * Handles first login to nextcloud, if sucessfull saves userdata - * - * @param Username the username of the Nextcloud instance - * @param Pass the pass of the Nextcloud instance - * @return true - sucessfull login, false - failed login - */ + * Handles first login to nextcloud, if sucessfull saves userdata + * + * @param Username the username of the Nextcloud instance + * @param Pass the pass of the Nextcloud instance + * @return true - sucessfull login, false - failed login + */ bool login(const string &Url, const string &Username, const string &Pass); + /** + * Handles login by receiving userdat from config + */ bool login(); + /** + * Deletes the config files and deletes are temp files + * @param deleteFiles default false, true - local files are deleted, false local files are kept + */ void logout(bool deleteFiles = false); + /** + * Downloads a certain item from the Nextcloud and saves it locally + * @param itemID id of the item + */ void downloadItem(int itemID); /**