Enhance fileBrowser by possiblity to choose to include files

master
JuanJakobo 2022-07-31 13:35:35 +02:00
parent 7fd2d3cfb7
commit 708efdbbdb
7 changed files with 50 additions and 63 deletions

View File

@ -16,11 +16,10 @@ using std::string;
using std::vector;
FileBrowser::FileBrowser()
FileBrowser::FileBrowser(bool includeFiles) : _includeFiles(includeFiles)
{
}
//TODO let the user choose if file or only folders, create API class or do inside here?
std::vector<FileItem> FileBrowser::getFileStructure(const std::string &path)
{
//get local files, https://stackoverflow.com/questions/306533/how-do-i-get-a-list-of-files-in-a-directory-in-c
@ -58,24 +57,22 @@ std::vector<FileItem> FileBrowser::getFileStructure(const std::string &path)
if (stat(fullFileName.c_str(), &st) == -1)
continue;
FileItem temp;
if ((st.st_mode & S_IFDIR) != 0)
{
temp.path = fullFileName;
FileItem temp;
temp.path = fullFileName + '/';
temp.name = fullFileName.substr(fullFileName.find_last_of("/") + 1, fullFileName.length());
temp.type = Type::FFOLDER;
temp.path += '/';
items.push_back(temp);
}
else
else if (_includeFiles)
{
/*
//TODO test for files
FileItem temp;
temp.path = fullFileName;
temp.name = fullFileName.substr(fullFileName.find_last_of("/") + 1, fullFileName.length());
temp.type = Type::FFILE;
temp.path += '/';
items.push_back(temp);
*/
}
}
closedir(dir);

View File

@ -22,15 +22,15 @@ class FileBrowser
* Creates a new FileBrowser object
*
*/
FileBrowser();
void test();
FileBrowser(bool includeFiles);
std::vector<FileItem> getFileStructure(const std::string &path);
void setIncludeFiles(bool includeFiles) { _includeFiles = includeFiles;};
private:
std::string _currentLocation;
bool _includeFiles;
};
#endif

View File

@ -41,10 +41,11 @@ WebDAV::WebDAV()
std::vector<WebDAVItem> WebDAV::login(const string &Url, const string &Username, const string &Pass)
{
string uuid;
std::size_t found = Url.find(NEXTCLOUD_ROOT_PATH);
_password = Pass;
_username = Username;
std::size_t found = Url.find(NEXTCLOUD_ROOT_PATH);
if (found != std::string::npos)
{
_url = Url.substr(0, found);
@ -149,7 +150,6 @@ vector<WebDAVItem> WebDAV::getDataStructure(const string &pathUrl)
tempItem.path.erase(0,tempItem.path.find(NEXTCLOUD_START_PATH));
tempItem.title = tempItem.path;
//TODO make lambda?
tempItem.localPath = tempItem.path;
Util::decodeUrl(tempItem.localPath);
if (tempItem.localPath.find(NEXTCLOUD_ROOT_PATH) != string::npos)

View File

@ -154,7 +154,6 @@ void EventHandler::mainMenuHandler(const int index)
}
}
//TODO twice
currentWebDAVItems = _sqllite.getItemsChildren(_currentPath);
CloseProgressbar();
@ -185,10 +184,7 @@ void EventHandler::mainMenuHandler(const int index)
case 103:
{
if(_currentPath.back() != '/')
_currentPath = _currentPath + "/nextcloud";
else
_currentPath = _currentPath + "nextcloud";
_currentPath =+ (_currentPath.back() != '/') ? "/nextcloud" : "nextcloud";
if (iv_mkdir(_currentPath.c_str(), 0777) != 0)
Message(ICON_ERROR, "Error", "The permissions are not sufficient.", 1000);
@ -352,7 +348,7 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
{
case 1:
{
FileBrowser fileBrowser = FileBrowser();
FileBrowser fileBrowser = FileBrowser(false);
vector<FileItem> currentFolder = fileBrowser.getFileStructure(path);
_currentPath = path;
_loginView.reset();
@ -377,7 +373,7 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
if (_fileView->getCurrentEntry().type == Type::FFOLDER)
{
FileBrowser fileBrowser = FileBrowser();
FileBrowser fileBrowser = FileBrowser(false);
_currentPath = _fileView->getCurrentEntry().path;
vector<FileItem> currentFolder = fileBrowser.getFileStructure(_currentPath);
@ -659,10 +655,7 @@ void EventHandler::updateItems(vector<WebDAVItem> &items)
if (_sqllite.getEtag(item.path).compare(item.etag) != 0)
{
if( item.state == FileState::ISYNCED)
item.state = FileState::IOUTSYNCED;
else
item.state = FileState::ICLOUD;
item.state = (item.state == FileState::ISYNCED) ? FileState::IOUTSYNCED : FileState::ICLOUD;
}
}
items.at(0).state =FileState::ISYNCED;

View File

@ -40,10 +40,7 @@ WebDAVView::WebDAVView(const irect &contentRect, vector<WebDAVItem> &items, int
if (item.type == IFILE)
entrySize += _entryFontHeight;
if(item.title.find("click to go back") != std::string::npos)
entrySize += 0.5 * _entryFontHeight;
else
entrySize += 2.5 * _entryFontHeight;
entrySize += (item.title.find("click to go back") != std::string::npos) ? 0.5 * _entryFontHeight : 2.5 * _entryFontHeight;
if ((pageHeight + entrySize) > contentHeight)