mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-24 15:05:35 -04:00
added some debug info in RsCollectionModel
This commit is contained in:
parent
9ba4ac6362
commit
c1a6b8fe12
2 changed files with 81 additions and 27 deletions
|
@ -129,20 +129,20 @@ QModelIndex RsCollectionModel::index(int row, int column, const QModelIndex & pa
|
||||||
if(row < 0 || column < 0 || column >= columnCount(parent) || row >= rowCount(parent))
|
if(row < 0 || column < 0 || column >= columnCount(parent) || row >= rowCount(parent))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
EntryIndex i;
|
EntryIndex parent_index;
|
||||||
|
|
||||||
if(!parent.isValid()) // root
|
if(!parent.isValid()) // root
|
||||||
{
|
{
|
||||||
i.is_file = false;
|
parent_index.is_file = false;
|
||||||
i.index = 0;
|
parent_index.index = 0;
|
||||||
}
|
}
|
||||||
else if(!convertInternalIdToIndex(parent.internalId(),i))
|
else if(!convertInternalIdToIndex(parent.internalId(),parent_index))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
if(i.is_file || i.index >= mCollection.fileTree().numDirs())
|
if(parent_index.is_file || parent_index.index >= mCollection.fileTree().numDirs())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
const auto& parentData(mCollection.fileTree().directoryData(i.index));
|
const auto& parentData(mCollection.fileTree().directoryData(parent_index.index));
|
||||||
|
|
||||||
if((size_t)row < parentData.subdirs.size())
|
if((size_t)row < parentData.subdirs.size())
|
||||||
{
|
{
|
||||||
|
@ -450,6 +450,8 @@ void RsCollectionModel::postMods()
|
||||||
mUpdating = false;
|
mUpdating = false;
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
emit sizesChanged();
|
emit sizesChanged();
|
||||||
|
|
||||||
|
debugDump();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsCollectionModel::recursUpdateLocalStructures(RsFileTree::DirIndex dir_index,int depth)
|
void RsCollectionModel::recursUpdateLocalStructures(RsFileTree::DirIndex dir_index,int depth)
|
||||||
|
@ -461,27 +463,6 @@ void RsCollectionModel::recursUpdateLocalStructures(RsFileTree::DirIndex dir_ind
|
||||||
|
|
||||||
const auto& dd(mCollection.fileTree().directoryData(dir_index));
|
const auto& dd(mCollection.fileTree().directoryData(dir_index));
|
||||||
|
|
||||||
for(uint32_t i=0;i<dd.subfiles.size();++i)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_COLLECTION_MODEL
|
|
||||||
for(int j=0;j<depth;++j) std::cerr << " ";
|
|
||||||
std::cerr << "File \"" << mCollection.fileTree().fileData(dd.subfiles[i]).name << "\"" << std::endl;
|
|
||||||
#endif
|
|
||||||
auto& ref(mFileInfos[dd.subfiles[i]]);
|
|
||||||
|
|
||||||
if(ref.is_checked)
|
|
||||||
{
|
|
||||||
total_size += mCollection.fileTree().fileData(dd.subfiles[i]).size;
|
|
||||||
++total_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
ref.parent_index = dir_index;
|
|
||||||
ref.parent_row = i + dd.subdirs.size();
|
|
||||||
|
|
||||||
all_checked = all_checked && ref.is_checked;
|
|
||||||
all_unchecked = all_unchecked && !ref.is_checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint32_t i=0;i<dd.subdirs.size();++i)
|
for(uint32_t i=0;i<dd.subdirs.size();++i)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLLECTION_MODEL
|
#ifdef DEBUG_COLLECTION_MODEL
|
||||||
|
@ -502,6 +483,26 @@ void RsCollectionModel::recursUpdateLocalStructures(RsFileTree::DirIndex dir_ind
|
||||||
all_checked = all_checked && (ref.check_state == SELECTED);
|
all_checked = all_checked && (ref.check_state == SELECTED);
|
||||||
all_unchecked = all_unchecked && (ref.check_state == UNSELECTED);
|
all_unchecked = all_unchecked && (ref.check_state == UNSELECTED);
|
||||||
}
|
}
|
||||||
|
for(uint32_t i=0;i<dd.subfiles.size();++i)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_COLLECTION_MODEL
|
||||||
|
for(int j=0;j<depth;++j) std::cerr << " ";
|
||||||
|
std::cerr << "File \"" << mCollection.fileTree().fileData(dd.subfiles[i]).name << "\"" << std::endl;
|
||||||
|
#endif
|
||||||
|
auto& ref(mFileInfos[dd.subfiles[i]]);
|
||||||
|
|
||||||
|
if(ref.is_checked)
|
||||||
|
{
|
||||||
|
total_size += mCollection.fileTree().fileData(dd.subfiles[i]).size;
|
||||||
|
++total_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
ref.parent_index = dir_index;
|
||||||
|
ref.parent_row = i + dd.subdirs.size();
|
||||||
|
|
||||||
|
all_checked = all_checked && ref.is_checked;
|
||||||
|
all_unchecked = all_unchecked && !ref.is_checked;
|
||||||
|
}
|
||||||
|
|
||||||
auto& r(mDirInfos[dir_index]);
|
auto& r(mDirInfos[dir_index]);
|
||||||
|
|
||||||
|
@ -516,6 +517,57 @@ void RsCollectionModel::recursUpdateLocalStructures(RsFileTree::DirIndex dir_ind
|
||||||
r.check_state = PARTIALLY_SELECTED;
|
r.check_state = PARTIALLY_SELECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsCollectionModel::debugDump()
|
||||||
|
{
|
||||||
|
std::function<void(RsFileTree::DirIndex,int)> recursDump = [&](RsFileTree::DirIndex indx,int depth) {
|
||||||
|
const auto& dir_data(mCollection.fileTree().directoryData(indx));
|
||||||
|
|
||||||
|
for(int i=0;i<depth;++i) std::cerr << " ";
|
||||||
|
std::cerr << "Directory: \"" << dir_data.name << "\" total_size: " << mDirInfos[indx].total_size << " cnt: " << mDirInfos[indx].total_count << std::endl;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<dir_data.subdirs.size();++i)
|
||||||
|
recursDump(dir_data.subdirs[i],depth+1);
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<dir_data.subfiles.size();++i)
|
||||||
|
{
|
||||||
|
for(int i=0;i<depth+1;++i) std::cerr << " ";
|
||||||
|
std::cerr << "File: \"" << mCollection.fileTree().fileData(dir_data.subfiles[i]).name << "\"" << std::endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::cerr << "mCollectionModel data: " << std::endl;
|
||||||
|
|
||||||
|
recursDump(mCollection.fileTree().root(),0);
|
||||||
|
|
||||||
|
std::function<void(QModelIndex index,int)> recursDump2 = [&](QModelIndex indx,int depth) {
|
||||||
|
|
||||||
|
for(int i=0;i<depth;++i) std::cerr << " ";
|
||||||
|
|
||||||
|
EntryIndex entry;
|
||||||
|
convertInternalIdToIndex(indx.internalId(),entry);
|
||||||
|
|
||||||
|
std::cerr << "Index: " << indx << " has_children: " << RsCollectionModel::hasChildren(indx)
|
||||||
|
<< ", rowCount: " << RsCollectionModel::rowCount(indx)
|
||||||
|
<< ", type: " << (entry.is_file?"file":"dir") << " number " << entry.index
|
||||||
|
<< ", display role: \"" << displayRole(entry,0).toString().toStdString()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
for(int i=0;i<RsCollectionModel::rowCount(indx);++i)
|
||||||
|
recursDump2(RsCollectionModel::index(i,0,indx),depth+1);
|
||||||
|
};
|
||||||
|
|
||||||
|
std::cerr << "mCollectionModel index structure: " << std::endl;
|
||||||
|
|
||||||
|
recursDump2(QModelIndex(),0);
|
||||||
|
|
||||||
|
std::cerr << "mCollectionModel internal data: " << std::endl;
|
||||||
|
std::cerr << "Directories: "<< std::endl;
|
||||||
|
for(uint32_t i=0;i<mCollection.fileTree().numDirs();++i)
|
||||||
|
std::cerr << " " << mCollection.fileTree().directoryData(i).name << std::endl;
|
||||||
|
std::cerr << "Files: "<< std::endl;
|
||||||
|
for(uint32_t i=0;i<mCollection.fileTree().numFiles();++i)
|
||||||
|
std::cerr << " " << mCollection.fileTree().fileData(i).name << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ class RsCollectionModel: public QAbstractItemModel
|
||||||
QVariant checkStateRole(const EntryIndex& i,int col) const;
|
QVariant checkStateRole(const EntryIndex& i,int col) const;
|
||||||
//QVariant filterRole(const DirDetails& details,int coln) const;
|
//QVariant filterRole(const DirDetails& details,int coln) const;
|
||||||
|
|
||||||
|
void debugDump();
|
||||||
|
|
||||||
bool mUpdating ;
|
bool mUpdating ;
|
||||||
|
|
||||||
const RsCollection& mCollection;
|
const RsCollection& mCollection;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue