extended documentation and cleanup

pull/23/head
JuanJakobo 2021-01-10 18:18:25 +01:00
parent c32bcc03f0
commit 77521aeeed
6 changed files with 41 additions and 15 deletions

View File

@ -144,7 +144,6 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
_tempPath = _nextcloud.getItems()->at(itemID).getPath(); _tempPath = _nextcloud.getItems()->at(itemID).getPath();
if (!_tempPath.empty()) if (!_tempPath.empty())
_nextcloud.getDataStructure(_tempPath); _nextcloud.getDataStructure(_tempPath);
_listView.reset(new ListView(_menu.getContentRect(), _nextcloud.getItems())); _listView.reset(new ListView(_menu.getContentRect(), _nextcloud.getItems()));
_listView->drawHeader(_tempPath.substr(NEXTCLOUD_ROOT_PATH.length())); _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(); _nextcloud.getItems()->at(itemID).open();
break; break;
case 2: case 2:
//TODO implement upload if local file
if (_nextcloud.isWorkOffline()) if (_nextcloud.isWorkOffline())
{ {
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "You are in offline modus. Go back online?", "Yes", "No", "Cancel"); int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "You are in offline modus. Go back online?", "Yes", "No", "Cancel");

View File

@ -51,7 +51,6 @@ ListView::ListView(const irect *contentRect, const std::shared_ptr<vector<Item>>
_pageIcon = iRect(_contentRect->w - 100, _contentRect->h + _contentRect->y - _footerHeight, 100, _footerHeight, ALIGN_CENTER); _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); _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); _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); _nextPageButton = iRect(_contentRect->x + 300, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER);

View File

@ -21,7 +21,6 @@ using namespace std;
Item::Item(const string &xmlItem) Item::Item(const string &xmlItem)
{ {
_path = Util::getXMLAttribute(xmlItem, "d:href"); _path = Util::getXMLAttribute(xmlItem, "d:href");
//TODO also test for url
if (_path.find(NEXTCLOUD_END_PATH) != std::string::npos) if (_path.find(NEXTCLOUD_END_PATH) != std::string::npos)
_path.erase(0, NEXTCLOUD_END_PATH.length()); _path.erase(0, NEXTCLOUD_END_PATH.length());

View File

@ -31,9 +31,28 @@ enum FileState
class Item class Item
{ {
public: 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); 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); 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; }; void setPath(const string &path) { _path = path; };
string getPath() const { return _path; }; string getPath() const { return _path; };
@ -55,10 +74,6 @@ public:
string getFiletype() const { return _fileType; }; string getFiletype() const { return _fileType; };
void open() const;
bool removeFile();
private: private:
string _path; string _path;
Itemtype _type; Itemtype _type;
@ -69,6 +84,11 @@ private:
string _size{"Error"}; string _size{"Error"};
string _fileType; string _fileType;
/**
* Converts the size to an easier readble format
*
* @param tempSize Size of the item in bytes
*/
void setSize(double tempSize); void setSize(double tempSize);
}; };
#endif #endif

View File

@ -394,7 +394,6 @@ bool Nextcloud::getOfflineStructure(const string &pathUrl)
ifstream inFile(localPath); ifstream inFile(localPath);
std::stringstream buffer; std::stringstream buffer;
buffer << inFile.rdbuf(); buffer << inFile.rdbuf();
//TODO also show in offline modus all files!
if (!readInXML(buffer.str())) if (!readInXML(buffer.str()))
return false; return false;

View File

@ -33,18 +33,29 @@ public:
explicit Nextcloud(); explicit Nextcloud();
/** /**
* Handles first login to nextcloud, if sucessfull saves userdata * Handles first login to nextcloud, if sucessfull saves userdata
* *
* @param Username the username of the Nextcloud instance * @param Username the username of the Nextcloud instance
* @param Pass the pass of the Nextcloud instance * @param Pass the pass of the Nextcloud instance
* @return true - sucessfull login, false - failed login * @return true - sucessfull login, false - failed login
*/ */
bool login(const string &Url, const string &Username, const string &Pass); bool login(const string &Url, const string &Username, const string &Pass);
/**
* Handles login by receiving userdat from config
*/
bool login(); 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); 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); void downloadItem(int itemID);
/** /**