Skip to content

Commit

Permalink
fix switchuing single doc toc/multi doc toc
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Jan 14, 2024
1 parent 7e98303 commit 3f26e43
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12116,6 +12116,45 @@ void Texstudio::updateStructureLocally(bool updateAll){
if(configManager.parseMaster && master && master->isHidden()){
showHiddenMasterFirst=true;
}
// reorder documents
// on multi doc update only
if(!configManager.structureShowSingleDoc){
for(int i=0;i<documents.documents.length();++i){
bool found=false;
int j=i;
LatexDocument *document;
for(;j<structureTreeWidget->topLevelItemCount();++j){
QTreeWidgetItem *item = structureTreeWidget->topLevelItem(j);
document = static_cast<LatexDocument*>(item->data(0,Qt::UserRole).value<void*>());
if(document == documents.documents.value(i)){
found=true;
break;
}
}
if(found && i<j){
QTreeWidgetItem *item = structureTreeWidget->takeTopLevelItem(j);
if(document==master){
item->setIcon(0,getRealIcon("masterdoc"));
}else{
item->setIcon(0,getRealIcon("doc"));
}
structureTreeWidget->insertTopLevelItem(i,item);
}
if(!found){
QTreeWidgetItem *item=new QTreeWidgetItem();
LatexDocument *doc=documents.documents.value(i);

item->setText(0,doc->getFileInfo().fileName());
item->setData(0,Qt::UserRole,QVariant::fromValue<void*>(static_cast<void*>(doc)));
if(doc==master){
item->setIcon(0,getRealIcon("masterdoc"));
}else{
item->setIcon(0,getRealIcon("doc"));
}
structureTreeWidget->insertTopLevelItem(i,item);
}
}
}

for(LatexDocument *doc:docs){
bool hiddenMasterStructureIsVisible=false;
Expand Down Expand Up @@ -12153,45 +12192,6 @@ void Texstudio::updateStructureLocally(bool updateAll){
}
}
}
// reorder documents
for(int i=0;i<documents.documents.length();++i){
bool found=false;
int j=i;
LatexDocument *document;
for(;j<structureTreeWidget->topLevelItemCount();++j){
QTreeWidgetItem *item = structureTreeWidget->topLevelItem(j);
document = static_cast<LatexDocument*>(item->data(0,Qt::UserRole).value<void*>());
if(document == documents.documents.value(i)){
found=true;
break;
}
}
if(found && i<j){
QTreeWidgetItem *item = structureTreeWidget->takeTopLevelItem(j);
if(document==master){
item->setIcon(0,getRealIcon("masterdoc"));
}else{
item->setIcon(0,getRealIcon("doc"));
}
structureTreeWidget->insertTopLevelItem(i,item);
}
if(!found){
QTreeWidgetItem *item=new QTreeWidgetItem();
LatexDocument *doc=documents.documents.value(i);

item->setText(0,doc->getFileInfo().fileName());
item->setData(0,Qt::UserRole,QVariant::fromValue<void*>(static_cast<void*>(doc)));
if(doc==master){
item->setIcon(0,getRealIcon("masterdoc"));
}else{
item->setIcon(0,getRealIcon("doc"));
}
structureTreeWidget->insertTopLevelItem(i,item);
if(doc==documents.getCurrentDocument()){
root=item;
}
}
}
}
StructureEntry *selectedEntry=nullptr;
bool itemExpandedLABEL=false;
Expand Down

0 comments on commit 3f26e43

Please sign in to comment.