fixed proper display of file sharing flags

This commit is contained in:
mr-alice 2016-08-29 21:30:56 +02:00
parent 7c2ed3fca0
commit 1290aa8403
4 changed files with 65 additions and 14 deletions

View File

@ -207,8 +207,7 @@ public:
f.file_modtime = it->second.modtime;
f.file_size = it->second.size;
}
else
new_files.erase(f.file_name) ;
new_files.erase(f.file_name) ;
++i;
}
@ -881,7 +880,7 @@ void LocalDirectoryStorage::updateShareFlags(const SharedDirInfo& info)
{
RS_STACK_MUTEX(mDirStorageMtx) ;
std::map<std::string,SharedDirInfo>::iterator it = mLocalDirs.find(info.virtualname) ;
std::map<std::string,SharedDirInfo>::iterator it = mLocalDirs.find(info.filename) ;
if(it == mLocalDirs.end())
{
@ -944,8 +943,38 @@ bool LocalDirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
// here we should update the file sharing flags
d.flags.clear() ;
d.parent_groups.clear();
/* find parent pointer, and row */
std::string base_dir;
for(DirectoryStorage::EntryIndex i=((d.type==DIR_TYPE_FILE)?((intptr_t)d.parent):((intptr_t)d.ref));;)
{
const InternalFileHierarchyStorage::DirEntry *e = mFileHierarchy->getDirEntry(i) ;
if(e == NULL)
break ;
if(e->parent_index == 0)
{
base_dir = e->dir_name ;
break ;
}
i = e->parent_index ;
}
if(!base_dir.empty())
{
std::map<std::string,SharedDirInfo>::const_iterator it = mLocalDirs.find(base_dir) ;
if(it == mLocalDirs.end())
{
std::cerr << "(EE) very weird bug: base directory \"" << base_dir << "\" not found in shared dir list." << std::endl;
return false ;
}
#warning we should use a NodeGroupId here
d.flags = it->second.shareflags;
d.parent_groups = it->second.parent_groups;
}
return true;
}

View File

@ -121,7 +121,7 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
return true ;
}
#ifdef HASHSTORAGE_DEBUG
std::cerr << "Not in cache. Sceduling for re-hash." << std::endl ;
std::cerr << "Not in cache. Scheduling for re-hash." << std::endl ;
#endif
// we need to schedule a re-hashing

View File

@ -64,8 +64,12 @@ void p3FileDatabase::getSharedDirectories(std::list<SharedDirInfo>& shared_dirs)
}
void p3FileDatabase::updateShareFlags(const SharedDirInfo& info)
{
RS_STACK_MUTEX(mFLSMtx) ;
mLocalSharedDirs->updateShareFlags(info) ;
{
RS_STACK_MUTEX(mFLSMtx) ;
mLocalSharedDirs->updateShareFlags(info) ;
}
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
}
p3FileDatabase::~p3FileDatabase()
@ -135,7 +139,7 @@ int p3FileDatabase::tick()
last_print_time = now ;
//#warning this should be removed, but it's necessary atm for updating the GUI
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0);
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
}
if(mUpdateFlags)

View File

@ -250,9 +250,14 @@ void SharedFilesDialog::showEvent(QShowEvent *)
{
if(model!=NULL)
{
model->setVisible(true) ;
std::set<std::string> expanded_indexes ;
saveExpandedPaths(expanded_indexes);
model->setVisible(true) ;
model->update() ;
}
restoreExpandedPaths(expanded_indexes);
}
}
RemoteSharedFilesDialog::~RemoteSharedFilesDialog()
{
@ -348,9 +353,13 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
showProperColumns() ;
if(isVisible())
std::set<std::string> expanded_indexes ;
saveExpandedPaths(expanded_indexes);
if(isVisible())
{
model->setVisible(true) ;
model->setVisible(true) ;
model->update() ;
}
@ -360,7 +369,9 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
ui.dirTreeView->setModel(proxyModel);
ui.dirTreeView->update();
QHeaderView * header = ui.dirTreeView->header () ;
restoreExpandedPaths(expanded_indexes);
QHeaderView * header = ui.dirTreeView->header () ;
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive);
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_DIR) ;
@ -828,6 +839,10 @@ void SharedFilesDialog::preModDirectories(bool local)
void SharedFilesDialog::saveExpandedPaths(std::set<std::string>& expanded_indexes)
{
if(ui.dirTreeView->model() == NULL)
return ;
std::cerr << "Saving expanded items. " << std::endl;
for(int row = 0; row < ui.dirTreeView->model()->rowCount(); ++row)
{
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
@ -837,6 +852,9 @@ void SharedFilesDialog::saveExpandedPaths(std::set<std::string>& expanded_indexe
void SharedFilesDialog::restoreExpandedPaths(const std::set<std::string>& expanded_indexes)
{
if(ui.dirTreeView->model() == NULL)
return ;
std::cerr << "Restoring expanded items. " << std::endl;
for(int row = 0; row < ui.dirTreeView->model()->rowCount(); ++row)
{
@ -886,7 +904,7 @@ void SharedFilesDialog::postModDirectories(bool local)
}
std::set<std::string> expanded_indexes;
saveExpandedPaths(expanded_indexes) ;
std::cerr << "Saving expanded items. " << expanded_indexes.size() << " items found" << std::endl;
std::cerr << "Saving expanded items. " << expanded_indexes.size() << " items found" << std::endl;
/* Notify both models, only one is visible */
tree_model->postMods();