bugfix: didnt change downloaded state of file

pull/23/head 0.3
JuanJakobo 2020-11-04 23:08:02 +01:00
parent 659955c974
commit 78606e42b3
7 changed files with 36 additions and 21 deletions

View File

@ -10,7 +10,6 @@
#include "eventHandler.h"
#include "menuHandler.h"
#include "listView.h"
#include "item.h"
#include "util.h"
#include <string>
@ -25,6 +24,7 @@ EventHandler::EventHandler()
//create a event to create handlers
_eventHandlerStatic = this;
//TODO use pointer for menu?
_menu = std::unique_ptr<MenuHandler>(new MenuHandler("Nextcloud"));
_nextcloud = std::unique_ptr<Nextcloud>(new Nextcloud());
_loginView = nullptr;
@ -141,15 +141,11 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
}
else
{
int dialogResult = 4;
int dialogResult = 2;
if (_nextcloud->getItems()[itemID].isDownloaded())
{
dialogResult = DialogSynchro(ICON_QUESTION, "Action", "What do you want to do?", "Open", "Sync", "Remove");
}
else
{
dialogResult = 2;
}
switch (dialogResult)
{
@ -171,12 +167,16 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
}
break;
case 3:
_nextcloud->getItems()[itemID].removeFile();
_nextcloud->removeFile(itemID);
break;
default:
break;
}
//TODO pass items only as ref, so this is not necessary and items exist only once
_listView.reset(new ListView(_menu->getContentRect(), _nextcloud->getItems()));
//_listView->drawEntry(itemID);
}
}
@ -203,5 +203,6 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
void EventHandler::DialogHandlerStatic(const int clicked)
{
//TODO cannot interact with it
//CloseProgressbar();
}

View File

@ -28,10 +28,7 @@ ListView::ListView(irect *contentRect, const vector<Item> &items) : _contentRect
_entries.clear();
int itemCount = 7;
_footerHeight = 100;
_headerHeight = 40;
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / itemCount;
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / _itemCount;
_shownPage = 1;
_page = 1;
@ -43,7 +40,7 @@ ListView::ListView(irect *contentRect, const vector<Item> &items) : _contentRect
while (i > 0)
{
if (z >= itemCount)
if (z >= _itemCount)
{
_page++;
z = 0;
@ -83,6 +80,12 @@ void ListView::drawFooter()
DrawTextRect2(&_pageButton, footer.c_str());
}
void ListView::drawEntry(int itemID)
{
FillAreaRect(_entries[itemID].getPosition(),WHITE);
_entries[itemID].draw(_items[itemID]);
}
void ListView::drawEntries()
{
for (auto i = 0; i < _entries.size(); i++)

View File

@ -48,6 +48,8 @@ public:
*/
void drawFooter();
void drawEntry(int itemID);
/**
* iterates through the items and sends them to the listViewEntry Class for drawing
*
@ -66,13 +68,14 @@ public:
private:
irect *_contentRect;
const vector<Item> _items;
vector<ListViewEntry> _entries;
std::unique_ptr<ifont> _titleFont;
std::unique_ptr<ifont> _footerFont;
vector<ListViewEntry> _entries;
int _page;
int _shownPage;
irect _pageButton;
int _footerHeight;
int _headerHeight;
int _footerHeight = 100;
int _headerHeight = 40;
int _itemCount = 7;
};
#endif

View File

@ -15,9 +15,6 @@
ListViewEntry::ListViewEntry(int page, irect rect) : _page(page), _position(rect)
{
_fontHeight = 30;
_entryFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", _fontHeight, 1));
_entryFontBold = std::unique_ptr<ifont>(OpenFont("LiberationMono-Bold", _fontHeight, 1));
}
void ListViewEntry::draw(const Item &item)

View File

@ -37,9 +37,10 @@ public:
private:
int _page;
int _fontHeight;
std::unique_ptr<ifont> _entryFont;
std::unique_ptr<ifont> _entryFontBold;
//TODO in central class?
int _fontHeight = 30;
std::unique_ptr<ifont> _entryFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", _fontHeight, 1));;
std::unique_ptr<ifont> _entryFontBold = std::unique_ptr<ifont>(OpenFont("LiberationMono-Bold", _fontHeight, 1));
irect _position;
};
#endif

View File

@ -157,6 +157,13 @@ bool Nextcloud::downloadItem(int itemID)
return false;
}
bool Nextcloud::removeFile(int itemID)
{
remove(_items[itemID].getLocalPath().c_str());
_items[itemID].setDownloaded(false);
}
bool Nextcloud::getDataStructure(string &pathUrl)
{
return getDataStructure(pathUrl, this->getUsername(), this->getPassword());

View File

@ -45,6 +45,9 @@ public:
bool downloadItem(int itemID);
bool removeFile(int itemID);
/**
* gets the dataStructure of the given URL and writes its WEBDAV items to the items vector, reads Userdata from configfile
*