enhanced documentation

pull/23/head
JuanJakobo 2021-03-08 10:10:32 +01:00
parent 2e7b816ea7
commit 2233df0584
12 changed files with 152 additions and 80 deletions

View File

@ -22,7 +22,7 @@ std::unique_ptr<EventHandler> EventHandler::_eventHandlerStatic;
EventHandler::EventHandler()
{
//create a event to create handlers
//create an copy of the eventhandler to handle methods that require static functions
_eventHandlerStatic = std::unique_ptr<EventHandler>(this);
_loginView = nullptr;
@ -134,10 +134,12 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
{
if (type == EVT_POINTERDOWN)
{
//menu is clicked
if (IsInRect(par1, par2, _menu.getMenuButtonRect()) == 1)
{
return _menu.createMenu(_nextcloud.isLoggedIn(), _nextcloud.isWorkOffline(), EventHandler::mainMenuHandlerStatic);
}
//if listView is shown
else if (_listView != nullptr)
{
int itemID = _listView->listClicked(par1, par2);
@ -225,6 +227,7 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
return 1;
}
//if loginView is shown
else if (_loginView != nullptr)
{
if (_loginView->logginClicked(par1, par2) == 2)

View File

@ -45,21 +45,16 @@ private:
string _tempPath;
/**
* Functions needed to call C function, redirects to real function
* Function needed to call C function, redirects to real function
*
* @param type event type
* @param par1 first argument of the event
* @param par2 second argument of the event
* @return int returns if the event was handled
* @param index int of the menu that is set
*/
static void mainMenuHandlerStatic(const int index);
/**
* Handles menu events and redirects them
*
* @param type event type
* @param par1 first argument of the event
* @param par2 second argument of the event
* @return int returns if the event was handled
* @param index int of the menu that is set
*/
void mainMenuHandler(const int index);
@ -73,6 +68,11 @@ private:
*/
int pointerHandler(const int type, const int par1, const int par2);
static void DialogHandlerStatic(int clicked);
/**
* Handles the cancel button on the progressbar
*
* @param clicked button that has been clicked
*/
static void DialogHandlerStatic(const int clicked);
};
#endif

View File

@ -37,8 +37,14 @@ public:
*/
int createMenu(bool loggedIn, bool workOffline, iv_menuhandler handler);
/**
* Draws a loading screen at the top of the screen
*/
void drawLoadingScreen();
/**
* Clears the area of the loading screen
*/
void clearLoadingScreen();
private:
@ -62,11 +68,8 @@ private:
char *_info = strdup("Info");
char *_exit = strdup("Close App");
/**
* Functions needed to call C function, handles the panel
*
* @return void
*/
static void panelHandlerStatic();
};

View File

@ -122,19 +122,19 @@ void ListView::drawEntries()
}
}
void ListView::actualizePage(int _pageToShown)
void ListView::actualizePage(int pageToShown)
{
if (_pageToShown > _page)
if (pageToShown > _page)
{
Message(ICON_INFORMATION, "Info", "You have reached the last page, to return to the first, please click \"first.\"", 1200);
}
else if (_pageToShown < 1)
else if (pageToShown < 1)
{
Message(ICON_INFORMATION, "Info", "You are already on the first page.", 1200);
}
else
{
_shownPage = _pageToShown;
_shownPage = pageToShown;
FillArea(_contentRect->x, _contentRect->y + _headerHeight, _contentRect->w, _contentRect->h, WHITE);
drawEntries();
drawFooter();

View File

@ -31,33 +31,39 @@ public:
*/
ListView(const irect *contentRect, const vector<Item> &items);
/**
* Destructor
*/
~ListView();
/**
* draws the header including an item to navigate a page up
* Draws the header
*
* @param headerText the text that shall be displayed in the header
*
*/
void drawHeader(string headerText);
/**
* draws the footer including a page changer
*
* Draws the footer including a page changer
*/
void drawFooter();
/**
* Draws an single entry to the screen
*
* @param itemID the id of the item that shall be drawn
*/
void drawEntry(int itemID);
/**
* iterates through the items and sends them to the listViewEntry Class for drawing
*
* Iterates through the items and sends them to the listViewEntry Class for drawing
*/
void drawEntries();
void actualizePage(int _pageToShown);
/**
* Navigates to the selected page
*
* @param pageToShown page that shall be shown
*/
void actualizePage(int pageToShown);
/**
* Checkes if the listview has been clicked and either changes the page or returns item ID
@ -69,11 +75,11 @@ public:
int listClicked(int x, int y);
private:
int _footerHeight;
int _headerHeight;
int _footerHeight;
int _headerHeight;
int _headerFontHeight;
int _footerFontHeight;
int _entryFontHeight;
int _entryFontHeight;
const irect *_contentRect;
std::unique_ptr<const vector<Item>> _items;
vector<ListViewEntry> _entries;
@ -88,6 +94,6 @@ private:
irect _prevPageButton;
irect _firstPageButton;
irect _lastPageButton;
int _itemCount = 7;
int _itemCount = 7;
};
#endif

View File

@ -30,6 +30,9 @@ public:
* draws the listViewEntry to the screen
*
* @param item item that shall be drawn
* @param entryFont font for the entry itself
* @param entryFontBold bold font for the header
* @param fontHeight height of the font
*/
void draw(const Item &item, ifont *entryFont, ifont *entryFontBold, int fontHeight);

View File

@ -15,7 +15,7 @@
using std::string;
enum KeyboardTarget
enum KeyboardTarget
{
IURL,
IUSERNAME,
@ -27,10 +27,22 @@ const int KEYBOARD_STRING_LENGHT = 90;
class LoginView
{
public:
/**
* Draws the loginView includin URL, Username and Password buttons inside the contentRect
*
* @param contentRect area where the loginscreen shall be drawn
*/
LoginView(const irect *contentRect);
~LoginView();
/**
* Checks which part of the loginscreen is shown and reacts accordingly
*
* @param x x-coordinate
* @param y y-coordinate
* @return int if event has been handled. Returns 2 if login has been clicked and all items are set
*/
int logginClicked(int x, int y);
string getUsername() { return _username; };
@ -40,7 +52,7 @@ public:
private:
static LoginView *_loginViewStatic;
int _loginFontHeight;
ifont *_loginFont;
ifont *_loginFont;
const irect *_contentRect;
irect _urlButton;
irect _loginButton;
@ -53,12 +65,17 @@ private:
string _temp;
/**
* Functions needed to call C function, handles the panel
* Functions needed to call C function, handles the keyboard
*
* @return void
* @param text text that has been typed in by the user
*/
static void keyboardHandlerStatic(char *text);
/**
* Called by the static method and saves and writes the input from the user to the screen
*
* @param text text that has been typed in by the user
*/
void keyboardHandler(char *text);
};

View File

@ -32,7 +32,6 @@ enum FileState
class Item
{
public:
/**
* Creates an item by receiving the xml from nextcloud and parses it into an object
*
@ -44,16 +43,16 @@ public:
* Creates a new item by receiving localPath from the pocketbook
*
* @param localPath path where the file is placed
* @param FileState state of the file
* @param state state of the file
* @param type type of the item (folder/file)
*/
Item(const string &localPath, FileState state, Itemtype type);
/**
* 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; };
@ -72,7 +71,7 @@ public:
string getLastEditDate() const { return _lastEditDate; };
void setLastEditDate(const string &date) { _lastEditDate = date; };
double getSize() const { return _size;};
double getSize() const { return _size; };
string getSizeString() const;
string getFiletype() const { return _fileType; };

View File

@ -378,7 +378,7 @@ vector<Item> Nextcloud::getDataStructure(const string &pathUrl, const string &Us
}
else
{
Log::writeLog(localPath + "Couldnt save copy of tree structure locally.");
Log::writeLog(localPath + " Couldnt save copy of tree structure locally.");
}
outFile.close();

View File

@ -39,48 +39,62 @@ public:
void setStartFolder(const string &Path);
bool setItems(const vector<Item> &tempItems);
const vector<Item> &getItems() const { return _items; };
bool isLoggedIn() const { return _loggedIn; };
bool isWorkOffline() const { return _workOffline; };
void switchWorkOffline() { _workOffline = !_workOffline; };
/**
* 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
*/
* Handles login by receiving userdat from config
*
* @return true - login succeeded, false - login failed
*/
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
*/
* 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 - login succeeded, false - login failed
*/
bool login(const string &Url, const string &Username, const string &Pass);
/**
* 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
*/
* Downloads a certain item from the Nextcloud and saves it locally
* @param tempItems set of items where the item is in
* @param itemID id of the item
*/
void downloadItem(vector<Item> &tempItems, int itemID);
/**
*
*
*/
* Downloads a certain folder from the Nextcloud and saves it locally
* @param tempItems set of items where the item is in
* @param itemID id of the item
*/
void downloadFolder(vector<Item> &tempItems, int itemId);
void download(int itemId);
/**
* Checks the network connection and starts the download of the certain itemId
*
* @param itemID id of the item that shall be downloaded
*/
void download(int itemID);
/**
* Removes the item
*
* @param itemID id of the item that shall be removed
* @return bool true - success, false - failure
*/
bool removeItem(int itemID);
/**
* gets the dataStructure of the given URL and writes its WEBDAV items to the items vector, reads Userdata from configfile
*
@ -89,8 +103,20 @@ public:
*/
vector<Item> getDataStructure(string &pathUrl);
/**
* formats the pathUrl to a local path
*
* @param path online path
* @return local path
*/
static string getLocalPath(string path);
/**
* checks the local storage checks if the items are locally available
*
* @param tempItems items that shall be compared
* @param localPath path that has to be checked
*/
void getLocalFileStructure(vector<Item> &tempItems, const string &localPath);
private:
@ -116,16 +142,27 @@ private:
string getStartFolder();
/**
* Handles the end of the game dialog and lets the user
* choose inbetween starting a new game or closing the app
*
* @param Button id of the button that was pressed
* @return void
*/
* Handles the end of the game dialog and lets the user
* choose inbetween starting a new game or closing the app
*
* @param Button id of the button that was pressed
* @return void
*/
static void DialogHandlerStatic(int Button);
/**
* Reads in the xml and creates a vector of items of it
*
* @param xml xml formatted result from curl call
* @return vector<Item> the items that have been read from the xml
*/
vector<Item> readInXML(string xml);
/**
* Checks if a .structure file exists and if that is the case return a vector of items
* @param pathUrl path that shall be checked
* @return return the items for the structure if available offline
*/
vector<Item> getOfflineStructure(const string &pathUrl);
};

View File

@ -78,13 +78,13 @@ string Util::getXMLAttribute(const string &buffer, const string &name)
return NULL;
}
void Util::decodeUrl(string &item)
void Util::decodeUrl(string &text)
{
char *buffer;
CURL *curl = curl_easy_init();
buffer = curl_easy_unescape(curl,item.c_str(),0,NULL);
item = buffer;
buffer = curl_easy_unescape(curl,text.c_str(),0,NULL);
text = buffer;
curl_free(buffer);
curl_easy_cleanup(curl);

View File

@ -62,12 +62,16 @@ public:
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
/**
* Returns an integer representing the download progress
*
* get an XML Attribute from the buffer
*/
static string getXMLAttribute(const string &buffer, const string &name);
static void decodeUrl(string &item);
/**
* Decodes an URL
*
* @param text text that shall be converted
*/
static void decodeUrl(string &text);
private:
Util() {}