parent
659955c974
commit
78606e42b3
|
@ -10,7 +10,6 @@
|
||||||
#include "eventHandler.h"
|
#include "eventHandler.h"
|
||||||
#include "menuHandler.h"
|
#include "menuHandler.h"
|
||||||
#include "listView.h"
|
#include "listView.h"
|
||||||
#include "item.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -25,6 +24,7 @@ EventHandler::EventHandler()
|
||||||
//create a event to create handlers
|
//create a event to create handlers
|
||||||
_eventHandlerStatic = this;
|
_eventHandlerStatic = this;
|
||||||
|
|
||||||
|
//TODO use pointer for menu?
|
||||||
_menu = std::unique_ptr<MenuHandler>(new MenuHandler("Nextcloud"));
|
_menu = std::unique_ptr<MenuHandler>(new MenuHandler("Nextcloud"));
|
||||||
_nextcloud = std::unique_ptr<Nextcloud>(new Nextcloud());
|
_nextcloud = std::unique_ptr<Nextcloud>(new Nextcloud());
|
||||||
_loginView = nullptr;
|
_loginView = nullptr;
|
||||||
|
@ -141,15 +141,11 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int dialogResult = 4;
|
int dialogResult = 2;
|
||||||
if (_nextcloud->getItems()[itemID].isDownloaded())
|
if (_nextcloud->getItems()[itemID].isDownloaded())
|
||||||
{
|
{
|
||||||
dialogResult = DialogSynchro(ICON_QUESTION, "Action", "What do you want to do?", "Open", "Sync", "Remove");
|
dialogResult = DialogSynchro(ICON_QUESTION, "Action", "What do you want to do?", "Open", "Sync", "Remove");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dialogResult = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (dialogResult)
|
switch (dialogResult)
|
||||||
{
|
{
|
||||||
|
@ -171,12 +167,16 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
_nextcloud->getItems()[itemID].removeFile();
|
_nextcloud->removeFile(itemID);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
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)
|
void EventHandler::DialogHandlerStatic(const int clicked)
|
||||||
{
|
{
|
||||||
|
//TODO cannot interact with it
|
||||||
//CloseProgressbar();
|
//CloseProgressbar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,7 @@ ListView::ListView(irect *contentRect, const vector<Item> &items) : _contentRect
|
||||||
|
|
||||||
_entries.clear();
|
_entries.clear();
|
||||||
|
|
||||||
int itemCount = 7;
|
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / _itemCount;
|
||||||
_footerHeight = 100;
|
|
||||||
_headerHeight = 40;
|
|
||||||
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / itemCount;
|
|
||||||
|
|
||||||
_shownPage = 1;
|
_shownPage = 1;
|
||||||
_page = 1;
|
_page = 1;
|
||||||
|
@ -43,7 +40,7 @@ ListView::ListView(irect *contentRect, const vector<Item> &items) : _contentRect
|
||||||
|
|
||||||
while (i > 0)
|
while (i > 0)
|
||||||
{
|
{
|
||||||
if (z >= itemCount)
|
if (z >= _itemCount)
|
||||||
{
|
{
|
||||||
_page++;
|
_page++;
|
||||||
z = 0;
|
z = 0;
|
||||||
|
@ -83,6 +80,12 @@ void ListView::drawFooter()
|
||||||
DrawTextRect2(&_pageButton, footer.c_str());
|
DrawTextRect2(&_pageButton, footer.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListView::drawEntry(int itemID)
|
||||||
|
{
|
||||||
|
FillAreaRect(_entries[itemID].getPosition(),WHITE);
|
||||||
|
_entries[itemID].draw(_items[itemID]);
|
||||||
|
}
|
||||||
|
|
||||||
void ListView::drawEntries()
|
void ListView::drawEntries()
|
||||||
{
|
{
|
||||||
for (auto i = 0; i < _entries.size(); i++)
|
for (auto i = 0; i < _entries.size(); i++)
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void drawFooter();
|
void drawFooter();
|
||||||
|
|
||||||
|
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
|
||||||
*
|
*
|
||||||
|
@ -66,13 +68,14 @@ public:
|
||||||
private:
|
private:
|
||||||
irect *_contentRect;
|
irect *_contentRect;
|
||||||
const vector<Item> _items;
|
const vector<Item> _items;
|
||||||
|
vector<ListViewEntry> _entries;
|
||||||
std::unique_ptr<ifont> _titleFont;
|
std::unique_ptr<ifont> _titleFont;
|
||||||
std::unique_ptr<ifont> _footerFont;
|
std::unique_ptr<ifont> _footerFont;
|
||||||
vector<ListViewEntry> _entries;
|
|
||||||
int _page;
|
int _page;
|
||||||
int _shownPage;
|
int _shownPage;
|
||||||
irect _pageButton;
|
irect _pageButton;
|
||||||
int _footerHeight;
|
int _footerHeight = 100;
|
||||||
int _headerHeight;
|
int _headerHeight = 40;
|
||||||
|
int _itemCount = 7;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -15,9 +15,6 @@
|
||||||
|
|
||||||
ListViewEntry::ListViewEntry(int page, irect rect) : _page(page), _position(rect)
|
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)
|
void ListViewEntry::draw(const Item &item)
|
||||||
|
|
|
@ -37,9 +37,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _page;
|
int _page;
|
||||||
int _fontHeight;
|
//TODO in central class?
|
||||||
std::unique_ptr<ifont> _entryFont;
|
int _fontHeight = 30;
|
||||||
std::unique_ptr<ifont> _entryFontBold;
|
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;
|
irect _position;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -157,6 +157,13 @@ bool Nextcloud::downloadItem(int itemID)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Nextcloud::removeFile(int itemID)
|
||||||
|
{
|
||||||
|
remove(_items[itemID].getLocalPath().c_str());
|
||||||
|
_items[itemID].setDownloaded(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool Nextcloud::getDataStructure(string &pathUrl)
|
bool Nextcloud::getDataStructure(string &pathUrl)
|
||||||
{
|
{
|
||||||
return getDataStructure(pathUrl, this->getUsername(), this->getPassword());
|
return getDataStructure(pathUrl, this->getUsername(), this->getPassword());
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
|
|
||||||
bool downloadItem(int itemID);
|
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
|
* gets the dataStructure of the given URL and writes its WEBDAV items to the items vector, reads Userdata from configfile
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue