"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/texstudio.cpp" between
texstudio-3.1.0.tar.gz and texstudio-3.1.1.tar.gz

About: TeXstudio is an integrated environment for writing LaTeX documents (as easy and comfortable as possible).

texstudio.cpp  (texstudio-3.1.0):texstudio.cpp  (texstudio-3.1.1)
skipping to change at line 469 skipping to change at line 469
if (configManager.sessionRestore && !ConfigManager::dontRestoreSession) { if (configManager.sessionRestore && !ConfigManager::dontRestoreSession) {
fileRestoreSession(false, false); fileRestoreSession(false, false);
} }
splashscreen = nullptr; splashscreen = nullptr;
} }
/*! /*!
* \brief destructor * \brief destructor
*/ */
Texstudio::~Texstudio() Texstudio::~Texstudio()
{ {
structureTreeView->setModel(nullptr);
iconCache.clear(); iconCache.clear();
QDocument::setDefaultFormatScheme(m_formatsOldDefault); //prevents crash when deleted latexeditorview accesses the default format scheme, as m_format is going to be deleted QDocument::setDefaultFormatScheme(m_formatsOldDefault); //prevents crash when deleted latexeditorview accesses the default format scheme, as m_format is going to be deleted
programStopped = true; programStopped = true;
Guardian::shutdown(); Guardian::shutdown();
if (latexStyleParser) latexStyleParser->stop(); if (latexStyleParser) latexStyleParser->stop();
if (packageListReader) packageListReader->stop(); if (packageListReader) packageListReader->stop();
GrammarCheck::staticMetaObject.invokeMethod(grammarCheck, "shutdown", Qt: :BlockingQueuedConnection); GrammarCheck::staticMetaObject.invokeMethod(grammarCheck, "shutdown", Qt: :BlockingQueuedConnection);
skipping to change at line 670 skipping to change at line 670
//disabled because it also reacts to expand, connect(structureTreeView, SIGNAL(activated(const QModelIndex &)), SLOT(clickedOnStructureEntry(const QMode lIndex &))); //enter or double click (+single click on some platforms) //disabled because it also reacts to expand, connect(structureTreeView, SIGNAL(activated(const QModelIndex &)), SLOT(clickedOnStructureEntry(const QMode lIndex &))); //enter or double click (+single click on some platforms)
connect(structureTreeView, SIGNAL(pressed(const QModelIndex &)), SLOT(cl ickedOnStructureEntry(const QModelIndex &))); //single click connect(structureTreeView, SIGNAL(pressed(const QModelIndex &)), SLOT(cl ickedOnStructureEntry(const QModelIndex &))); //single click
leftPanel->addWidget(structureTreeView, "structureTreeView", tr("Structu re"), getRealIconFile("structure")); leftPanel->addWidget(structureTreeView, "structureTreeView", tr("Structu re"), getRealIconFile("structure"));
} else leftPanel->setWidgetText(structureTreeView, tr("Structure")); } else leftPanel->setWidgetText(structureTreeView, tr("Structure"));
if(!topTOCTreeWidget){ if(!topTOCTreeWidget){
topTOCTreeWidget = new QTreeWidget(); topTOCTreeWidget = new QTreeWidget();
connect(topTOCTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *,int)), th is, SLOT(gotoLine(QTreeWidgetItem *,int))); connect(topTOCTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *,int)), th is, SLOT(gotoLine(QTreeWidgetItem *,int)));
connect(topTOCTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(syncExpanded(QTreeWidgetItem *))); connect(topTOCTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(syncExpanded(QTreeWidgetItem *)));
connect(topTOCTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this , SLOT(syncCollapsed(QTreeWidgetItem *))); connect(topTOCTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this , SLOT(syncCollapsed(QTreeWidgetItem *)));
connect(topTOCTreeWidget, &QTreeWidget::customContextMenuRequested, this , &Texstudio::customMenuTOC);
topTOCTreeWidget->setHeaderHidden(true); topTOCTreeWidget->setHeaderHidden(true);
topTOCTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
leftPanel->addWidget(topTOCTreeWidget, "topTOCTreeWidget", tr("TOC"), ge tRealIconFile("toc")); leftPanel->addWidget(topTOCTreeWidget, "topTOCTreeWidget", tr("TOC"), ge tRealIconFile("toc"));
} else leftPanel->setWidgetText(topTOCTreeWidget, tr("TOC")); } else leftPanel->setWidgetText(topTOCTreeWidget, tr("TOC"));
if (!leftPanel->widget("bookmarks")) { if (!leftPanel->widget("bookmarks")) {
QListWidget *bookmarksWidget = bookmarks->widget(); QListWidget *bookmarksWidget = bookmarks->widget();
bookmarks->setDarkMode(darkMode); bookmarks->setDarkMode(darkMode);
connect(bookmarks, SIGNAL(loadFileRequest(QString)), this, SLOT(load(QSt ring))); connect(bookmarks, SIGNAL(loadFileRequest(QString)), this, SLOT(load(QSt ring)));
connect(bookmarks, SIGNAL(gotoLineRequest(int, int, LatexEditorView *)), this, SLOT(gotoLine(int, int, LatexEditorView *))); connect(bookmarks, SIGNAL(gotoLineRequest(int, int, LatexEditorView *)), this, SLOT(gotoLine(int, int, LatexEditorView *)));
leftPanel->addWidget(bookmarksWidget, "bookmarks", tr("Bookmarks"), getR ealIconFile("bookmarks")); leftPanel->addWidget(bookmarksWidget, "bookmarks", tr("Bookmarks"), getR ealIconFile("bookmarks"));
} else leftPanel->setWidgetText("bookmarks", tr("Bookmarks")); } else leftPanel->setWidgetText("bookmarks", tr("Bookmarks"));
skipping to change at line 1842 skipping to change at line 1844
connect(edit->editor->document(), SIGNAL(lineRemoved(QDocumentLineHandle *)), edit->document, SLOT(patchStructureRemoval(QDocumentLineHandle *))); connect(edit->editor->document(), SIGNAL(lineRemoved(QDocumentLineHandle *)), edit->document, SLOT(patchStructureRemoval(QDocumentLineHandle *)));
connect(edit->editor->document(), SIGNAL(lineDeleted(QDocumentLineHandle *,i nt)), edit->document, SLOT(patchStructureRemoval(QDocumentLineHandle *,int))); connect(edit->editor->document(), SIGNAL(lineDeleted(QDocumentLineHandle *,i nt)), edit->document, SLOT(patchStructureRemoval(QDocumentLineHandle *,int)));
connect(edit->document, SIGNAL(updateCompleter()), this, SLOT(completerNe edsUpdate())); connect(edit->document, SIGNAL(updateCompleter()), this, SLOT(completerNe edsUpdate()));
connect(edit->editor, SIGNAL(needUpdatedCompleter()), this, SLOT(needUpda tedCompleter())); connect(edit->editor, SIGNAL(needUpdatedCompleter()), this, SLOT(needUpda tedCompleter()));
connect(edit->document, SIGNAL(importPackage(QString)), this, SLOT(import Package(QString))); connect(edit->document, SIGNAL(importPackage(QString)), this, SLOT(import Package(QString)));
connect(edit->document, SIGNAL(bookmarkLineUpdated(int)), bookmarks, SLOT (updateLineWithBookmark(int))); connect(edit->document, SIGNAL(bookmarkLineUpdated(int)), bookmarks, SLOT (updateLineWithBookmark(int)));
connect(edit->document, SIGNAL(encodingChanged()), this, SLOT(updateStatu sBarEncoding())); connect(edit->document, SIGNAL(encodingChanged()), this, SLOT(updateStatu sBarEncoding()));
connect(edit, SIGNAL(thesaurus(int, int)), this, SLOT(editThesaurus(int, int))); connect(edit, SIGNAL(thesaurus(int, int)), this, SLOT(editThesaurus(int, int)));
connect(edit, SIGNAL(changeDiff(QPoint)), this, SLOT(editChangeDiff(QPoin t))); connect(edit, SIGNAL(changeDiff(QPoint)), this, SLOT(editChangeDiff(QPoin t)));
connect(edit, SIGNAL(saveCurrentCursorToHistoryRequested()), this, SLOT(s aveCurrentCursorToHistory())); connect(edit, SIGNAL(saveCurrentCursorToHistoryRequested()), this, SLOT(s aveCurrentCursorToHistory()));
connect(edit->document,SIGNAL(structureUpdated(LatexDocument*)),this,SLOT(up dateTOC()));
edit->document->saveLineSnapshot(); // best guess of the lines used during l ast latex compilation edit->document->saveLineSnapshot(); // best guess of the lines used during l ast latex compilation
if (!hidden) { if (!hidden) {
int index = reloadFromDoc ? documents.documents.indexOf(edit->doc ument, 0) : -1; // index: we still assume here that the order of documents and e ditors is synchronized int index = reloadFromDoc ? documents.documents.indexOf(edit->doc ument, 0) : -1; // index: we still assume here that the order of documents and e ditors is synchronized
editors->insertEditor(edit, index); editors->insertEditor(edit, index);
edit->editor->setFocus(); edit->editor->setFocus();
updateCaption(); updateCaption();
} }
} }
/*! /*!
skipping to change at line 1981 skipping to change at line 1984
if (!existingView) { if (!existingView) {
doc = documents.findDocumentFromName(f_real); doc = documents.findDocumentFromName(f_real);
if (doc) existingView = doc->getEditorView(); if (doc) existingView = doc->getEditorView();
} }
if (existingView) { if (existingView) {
if (hidden) if (hidden)
return existingView; return existingView;
if (asProject) documents.setMasterDocument(existingView->document); if (asProject) documents.setMasterDocument(existingView->document);
if (existingView->document->isHidden()) { if (existingView->document->isHidden()) {
// clear baseStructure outside treeview context // clear baseStructure outside treeview context
foreach(StructureEntry *elem,existingView->document->baseStructu re->children){ /*foreach(StructureEntry *elem,existingView->document->baseStruc ture->children){
delete elem; delete elem;
} }
existingView->document->baseStructure->children.clear(); existingView->document->baseStructure->children.clear();*/
// //
existingView->editor->setLineWrapping(configManager.editorConfig ->wordwrap > 0); existingView->editor->setLineWrapping(configManager.editorConfig ->wordwrap > 0);
documents.deleteDocument(existingView->document, true); documents.deleteDocument(existingView->document, true);
existingView->editor->setSilentReloadOnExternalChanges(existingV iew->document->remeberAutoReload); existingView->editor->setSilentReloadOnExternalChanges(existingV iew->document->remeberAutoReload);
existingView->editor->setHidden(false); existingView->editor->setHidden(false);
documents.addDocument(existingView->document, false); documents.addDocument(existingView->document, false);
editors->addEditor(existingView); editors->addEditor(existingView);
if(asProject) if(asProject)
editors->moveEditor(existingView,Editors::AbsoluteFront); // somewhat redundant, but we run into that problem with issue #899 editors->moveEditor(existingView,Editors::AbsoluteFront); // somewhat redundant, but we run into that problem with issue #899
updateStructure(false, existingView->document, true); updateStructure(false, existingView->document, true);
skipping to change at line 11027 skipping to change at line 11030
for(int i=elem->level+1;i<latexParser.MAX_STRUCTURE_LEVEL;i++){ for(int i=elem->level+1;i<latexParser.MAX_STRUCTURE_LEVEL;i++){
rootVector[i]=item; rootVector[i]=item;
} }
parseStruct(elem,rootVector); parseStruct(elem,rootVector);
} }
if(elem->type == StructureEntry::SE_INCLUDE){ if(elem->type == StructureEntry::SE_INCLUDE){
LatexDocument *doc=elem->document; LatexDocument *doc=elem->document;
QString fn=ensureTrailingDirSeparator(doc->getRootDocument()->getFil eInfo().absolutePath())+elem->title; QString fn=ensureTrailingDirSeparator(doc->getRootDocument()->getFil eInfo().absolutePath())+elem->title;
doc=documents.findDocumentFromName(fn); doc=documents.findDocumentFromName(fn);
if(!doc){ if(!doc){
documents.findDocumentFromName(fn+".tex"); doc=documents.findDocumentFromName(fn+".tex");
} }
bool ea=false; bool ea=false;
if(doc){ if(doc){
ea=parseStruct(doc->baseStructure,rootVector); ea=parseStruct(doc->baseStructure,rootVector);
} }
if(!ea){ if(!ea){
QTreeWidgetItem * item=new QTreeWidgetItem(); QTreeWidgetItem * item=new QTreeWidgetItem();
item->setText(0,elem->title); item->setText(0,elem->title);
item->setToolTip(0,tr("Document: ")+docName); item->setToolTip(0,tr("Document: ")+docName);
item->setIcon(0,documents.model->iconInclude); item->setIcon(0,documents.model->iconInclude);
skipping to change at line 11065 skipping to change at line 11068
/*! /*!
* \brief sync collapsed state to structure entry * \brief sync collapsed state to structure entry
* \param item * \param item
*/ */
void Texstudio::syncCollapsed(QTreeWidgetItem *item){ void Texstudio::syncCollapsed(QTreeWidgetItem *item){
StructureEntry *se=item->data(0,Qt::UserRole).value<StructureEntry *>(); StructureEntry *se=item->data(0,Qt::UserRole).value<StructureEntry *>();
if(!se) return; if(!se) return;
se->expanded=false; se->expanded=false;
} }
void Texstudio::customMenuTOC(const QPoint &pos){
QTreeWidgetItem *item = topTOCTreeWidget->itemAt(pos);
StructureEntry *contextEntry = item->data(0,Qt::UserRole).value<StructureEnt
ry *>();
if (!contextEntry) return;
if (contextEntry->type == StructureEntry::SE_SECTION) {
QMenu menu(this);
StructureEntry *labelEntry = LatexDocumentsModel::labelForStructureEntry
(contextEntry);
if (labelEntry) {
menu.addAction(tr("Insert Label"), structureTreeView, SLOT(insertTex
tFromAction()))->setData(labelEntry->title); // a bit indirect approach, the cod
e should be refactored ...
foreach (QString refCmd, configManager.referenceCommandsInContextMen
u.split(",")) {
refCmd = refCmd.trimmed();
if (!refCmd.startsWith('\\')) continue;
menu.addAction(QString(tr("Insert %1 to Label", "autoreplaced, e
.g.: Insert \\ref to Label").arg(refCmd)), this, SLOT(insertTextFromAction()))->
setData(QString("%1{%2}").arg(refCmd).arg(labelEntry->title));
}
menu.addSeparator();
} else {
menu.addAction(tr("Create Label"), structureTreeView, SLOT(createLab
elFromAction()))->setData(QVariant::fromValue(contextEntry));
menu.addSeparator();
}
menu.addAction(tr("Copy"), this, SLOT(editSectionCopy()));
menu.addAction(tr("Cut"), this, SLOT(editSectionCut()));
menu.addAction(tr("Paste Before"), this, SLOT(editSectionPasteBefore()))
;
menu.addAction(tr("Paste After"), this, SLOT(editSectionPasteAfter()));
menu.addSeparator();
menu.addAction(tr("Indent Section"), this, SLOT(editIndentSection()));
menu.addAction(tr("Unindent Section"), this, SLOT(editUnIndentSection())
);
menu.exec(topTOCTreeWidget->mapToGlobal(pos));
return;
}
}
/*!
* context menu action: Select the selected section and copy it to the clipboard
.
* TODO: the logic should probably be moved to LatexDocument or LatexEditorView
*/
void Texstudio::editSectionCopy()
{
// called by action
QTreeWidgetItem *item = topTOCTreeWidget->currentItem();
StructureEntry *entry = item->data(0,Qt::UserRole).value<StructureEntry *>()
;
if(!entry) return;
LatexEditorView *edView = entry->document->getEditorView();
if(!edView) return;
editors->setCurrentEditor(edView);
QDocumentSelection sel = entry->document->sectionSelection(entry);
edView->editor->setCursorPosition(sel.startLine, 0);
QDocumentCursor cur = edView->editor->cursor();
//m_cursor.movePosition(1, QDocumentCursor::NextLine, QDocumentCursor::KeepA
nchor);
cur.setSilent(true);
cur.movePosition(sel.endLine - sel.startLine - 1, QDocumentCursor::NextLine,
QDocumentCursor::KeepAnchor);
cur.movePosition(0, QDocumentCursor::EndOfLine, QDocumentCursor::KeepAnchor)
;
edView->editor->setCursor(cur);
edView->editor->copy();
}
/*!
* context menu action: Cut the selected section to the clipboard.
* TODO: the logic should probably be moved to LatexDocument or LatexEditorView
*/
void Texstudio::editSectionCut()
{
// called by action
QTreeWidgetItem *item = topTOCTreeWidget->currentItem();
StructureEntry *entry = item->data(0,Qt::UserRole).value<StructureEntry *>()
;
if (!entry) return;
LatexEditorView *edView = entry->document->getEditorView();
if (!edView) return;
editors->setCurrentEditor(edView);
QDocumentSelection sel = entry->document->sectionSelection(entry);
edView->editor->setCursorPosition(sel.startLine, 0);
QDocumentCursor cur = edView->editor->cursor();
//m_cursor.movePosition(1, QDocumentCursor::NextLine, QDocumentCursor::KeepA
nchor);
cur.setSilent(true);
cur.movePosition(sel.endLine - sel.startLine - 1, QDocumentCursor::NextLine,
QDocumentCursor::KeepAnchor);
cur.movePosition(0, QDocumentCursor::EndOfLine, QDocumentCursor::KeepAnchor)
;
edView->editor->setCursor(cur);
edView->editor->cut();
}
/*!
* context menu action: Paste the clipboard contents before the selected section
.
* TODO: the logic should probably be moved to LatexDocument or LatexEditorView
*/
void Texstudio::editSectionPasteBefore()
{
QTreeWidgetItem *item = topTOCTreeWidget->currentItem();
StructureEntry *entry = item->data(0,Qt::UserRole).value<StructureEntry *>()
;
if (!entry) return;
LatexEditorView *edView = entry->document->getEditorView();
if (!edView) return;
editors->setCurrentEditor(edView);
int line = entry->getRealLineNumber();
edView->editor->setCursorPosition(line, 0);
edView->editor->insertText("\n");
edView->editor->setCursorPosition(line, 0);
edView->paste();
}
/*!
* context menu action: Paste the clipboard contents after the selected section.
* TODO: the logic should probably be moved to LatexDocument or LatexEditorView
*/
void Texstudio::editSectionPasteAfter()
{
QTreeWidgetItem *item = topTOCTreeWidget->currentItem();
StructureEntry *entry = item->data(0,Qt::UserRole).value<StructureEntry *>()
;
if (!entry) return;
LatexEditorView *edView = entry->document->getEditorView();
if (!edView) return;
editors->setCurrentEditor(edView);
QDocumentSelection sel = entry->document->sectionSelection(entry);
int line = sel.endLine;
if (line >= edView->editor->document()->lines()) {
edView->editor->setCursorPosition(line - 1, 0);
QDocumentCursor c = edView->editor->cursor();
c.movePosition(1, QDocumentCursor::End, QDocumentCursor::MoveAnchor);
edView->editor->setCursor(c);
edView->editor->insertText("\n");
} else {
edView->editor->setCursorPosition(line, 0);
edView->editor->insertText("\n");
edView->editor->setCursorPosition(line, 0);
}
edView->paste();
}
/*!
* context menu action: Indent the selected section.
* This replaces the sections and all its sub-sections with a lower heading, e.g
.
* \section -> \subsection
* \chapter -> \section
* TODO: the logic should probably be moved to LatexDocument or LatexEditorView
*/
void Texstudio::editIndentSection()
{
QTreeWidgetItem *item = topTOCTreeWidget->currentItem();
StructureEntry *entry = item->data(0,Qt::UserRole).value<StructureEntry *>()
;
if (!entry) return;
LatexEditorView *edView = entry->document->getEditorView();
if (!edView) return;
editors->setCurrentEditor(edView);
QDocumentSelection sel = entry->document->sectionSelection(entry);
QStringList sectionOrder;
sectionOrder << "\\subparagraph" << "\\paragraph" << "\\subsubsection" << "\
\subsection" << "\\section" << "\\chapter";
// replace sections
QString line;
QDocumentCursor cursor = edView->editor->cursor();
for (int l = sel.startLine; l < sel.endLine; l++) {
edView->editor->setCursorPosition(l, 0);
cursor = edView->editor->cursor();
line = edView->editor->cursor().line().text();
QString m_old = "";
foreach (const QString &elem, sectionOrder) {
if (m_old != "") line.replace(elem, m_old);
m_old = elem;
}
cursor.movePosition(1, QDocumentCursor::EndOfLine, QDocumentCursor::Keep
Anchor);
edView->editor->setCursor(cursor);
edView->editor->insertText(line);
}
}
/*!
* context menu action: Unindent the selected section.
* This replaces the sections and all its sub-sections with a higher heading, e.
g.
* \subsection -> \section
* \section -> \chapter
* TODO: the logic should probably be moved to LatexDocument or LatexEditorView
*/
void Texstudio::editUnIndentSection()
{
QTreeWidgetItem *item = topTOCTreeWidget->currentItem();
StructureEntry *entry = item->data(0,Qt::UserRole).value<StructureEntry *>()
;
if (!entry) return;
LatexEditorView *edView = entry->document->getEditorView();
if (!edView) return;
editors->setCurrentEditor(edView);
QDocumentSelection sel = entry->document->sectionSelection(entry);
QStringList sectionOrder;
sectionOrder << "\\chapter" << "\\section" << "\\subsection" << "\\subsubsec
tion" << "\\paragraph" << "\\subparagraph" ;
// replace sections
QString line;
QDocumentCursor cursor = edView->editor->cursor();
for (int l = sel.startLine; l < sel.endLine; l++) {
edView->editor->setCursorPosition(l, 0);
cursor = edView->editor->cursor();
line = edView->editor->cursor().line().text();
QString m_old = "";
foreach (const QString &elem, sectionOrder) {
if (m_old != "") line.replace(elem, m_old);
m_old = elem;
}
cursor.movePosition(1, QDocumentCursor::EndOfLine, QDocumentCursor::Keep
Anchor);
edView->editor->setCursor(cursor);
edView->editor->insertText(line);
}
}
/*! @} */ /*! @} */
 End of changes. 8 change blocks. 
4 lines changed or deleted 248 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)