Add method to actualize currentFolder

dev
JuanJakobo 2022-07-28 19:02:54 +02:00
parent 5413efd281
commit 3df14b8a0e
1 changed files with 94 additions and 13 deletions

View File

@ -107,19 +107,100 @@ void EventHandler::mainMenuHandler(const int index)
{ {
switch (index) switch (index)
{ {
//TODO actualize current folder //Actualize the current folder
case 101: case 101:
{ {
break; //TODO startfolder use same as above
} //TODO parent path not needed
//Logout OpenProgressbar(1, "Actualizing current folder", ("Actualizing path" + _currentPath).c_str(), 0, NULL);
case 102: string childrenPath = _currentPath;
{ childrenPath = childrenPath.substr(NEXTCLOUD_ROOT_PATH.length(), childrenPath.length());
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "Do you want to delete local files?", "Yes", "No", "Cancel"); std::string path = NEXTCLOUD_ROOT_PATH;
switch (dialogResult) std::vector<WebDAVItem> currentWebDAVItems;
{ size_t found = 0;
case 1: int i = 0;
_webDAV.logout(true); while((found = childrenPath.find("/"),found) != std::string::npos)
{
path += childrenPath.substr(0, found+1);
childrenPath = childrenPath.substr(found+1,childrenPath.length());
auto state = _sqllite.getState(path);
Log::writeInfoLog("cur path " + path);
if(i < 1 || state == FileState::IOUTSYNCED || state == FileState::ICLOUD)
{
UpdateProgressbar(("Upgrading " + path).c_str(), 0);
currentWebDAVItems = _webDAV.getDataStructure(path);
Log::writeInfoLog("syncing");
}
else
{
break;
}
if(currentWebDAVItems.empty())
{
Log::writeErrorLog("Could not sync " + path + " via actualize.");
Message(ICON_WARNING, "Warning", "Could not sync the file structure.", 2000);
HideHourglass();
break;
}
else
{
updateItems(currentWebDAVItems);
}
i++;
}
Log::writeInfoLog("stopped at " + path );
currentWebDAVItems = _sqllite.getItemsChildren(_currentPath);
for(auto &item : currentWebDAVItems)
{
Log::writeInfoLog(item.path);
if(item.state == FileState::IOUTSYNCED || item.state == FileState::ICLOUD)
{
UpdateProgressbar(("Upgrading " + item.path).c_str(), 0);
vector<WebDAVItem> tempWebDAVItems = _webDAV.getDataStructure(item.path);
updateItems(tempWebDAVItems);
}
}
//TODO twice
currentWebDAVItems = _sqllite.getItemsChildren(_currentPath);
CloseProgressbar();
if(!currentWebDAVItems.empty())
drawWebDAVItems(currentWebDAVItems);
break;
}
//Logout
case 102:
{
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "Do you want to delete local files?", "Yes", "No", "Cancel");
switch (dialogResult)
{
case 1:
_webDAV.logout(true);
break;
case 3:
return;
default:
_webDAV.logout();
break;
}
_webDAVView.release();
_loginView = std::make_unique<LoginView>(LoginView(_menu->getContentRect()));
FullUpdate();
break;
}
//Info
case 103:
{
Message(ICON_INFORMATION, "Information", "Version 0.98 \n For support please open a ticket at https://github.com/JuanJakobo/Pocketbook-Nextcloud-Client/issues", 1200);
break;
}
//Exit
case 104:
CloseApp();
break; break;
case 3: case 3:
return; return;