refactor: intab() test
fix: toggle bookmarks in editors that not in tab shouldn't affect main window.
This commit is contained in:
parent
3728cbed5e
commit
b060ecc09e
|
@ -213,11 +213,11 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
updateCaption();
|
updateCaption();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mParentPageControl==nullptr) {
|
if (!inTab()) {
|
||||||
setExtraKeystrokes();
|
setExtraKeystrokes();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
connect(&mFunctionTipTimer, &QTimer::timeout,
|
connect(&mFunctionTipTimer, &QTimer::timeout,
|
||||||
this, &Editor::onFunctionTipsTimer);
|
this, &Editor::onFunctionTipsTimer);
|
||||||
mAutoBackupTimer.setInterval(1);
|
mAutoBackupTimer.setInterval(1);
|
||||||
|
@ -285,7 +285,7 @@ void Editor::loadFile(QString filename) {
|
||||||
|
|
||||||
//this->setModified(false);
|
//this->setModified(false);
|
||||||
updateCaption();
|
updateCaption();
|
||||||
if (mParentPageControl)
|
if (inTab())
|
||||||
pMainWindow->updateForEncodingInfo(this);
|
pMainWindow->updateForEncodingInfo(this);
|
||||||
switch(getFileType(mFilename)) {
|
switch(getFileType(mFilename)) {
|
||||||
case FileType::CppSource:
|
case FileType::CppSource:
|
||||||
|
@ -344,7 +344,7 @@ void Editor::saveFile(QString filename) {
|
||||||
unit->setRealEncoding(mFileEncoding);
|
unit->setRealEncoding(mFileEncoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isVisible() && mParentPageControl)
|
if (isVisible() && inTab())
|
||||||
pMainWindow->updateForEncodingInfo(this);
|
pMainWindow->updateForEncodingInfo(this);
|
||||||
emit fileSaved(filename, inProject());
|
emit fileSaved(filename, inProject());
|
||||||
// QFile::remove(backupFilename);
|
// QFile::remove(backupFilename);
|
||||||
|
@ -634,7 +634,7 @@ void Editor::setEncodingOption(const QByteArray& encoding) noexcept{
|
||||||
tr("Error Load File"),
|
tr("Error Load File"),
|
||||||
e.reason());
|
e.reason());
|
||||||
}
|
}
|
||||||
} else if (mParentPageControl)
|
} else if (inTab())
|
||||||
pMainWindow->updateForEncodingInfo(this);
|
pMainWindow->updateForEncodingInfo(this);
|
||||||
resolveAutoDetectEncodingOption();
|
resolveAutoDetectEncodingOption();
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
|
@ -672,7 +672,7 @@ void Editor::setPageControl(QTabWidget *newPageControl)
|
||||||
{
|
{
|
||||||
if (mParentPageControl==newPageControl)
|
if (mParentPageControl==newPageControl)
|
||||||
return;
|
return;
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
int index = findWidgetInPageControl(mParentPageControl,this);
|
int index = findWidgetInPageControl(mParentPageControl,this);
|
||||||
if (index>=0)
|
if (index>=0)
|
||||||
mParentPageControl->removeTab(index);
|
mParentPageControl->removeTab(index);
|
||||||
|
@ -766,7 +766,7 @@ void Editor::wheelEvent(QWheelEvent *event) {
|
||||||
void Editor::focusInEvent(QFocusEvent *event)
|
void Editor::focusInEvent(QFocusEvent *event)
|
||||||
{
|
{
|
||||||
QSynEdit::focusInEvent(event);
|
QSynEdit::focusInEvent(event);
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
pMainWindow->updateClassBrowserForEditor(this);
|
pMainWindow->updateClassBrowserForEditor(this);
|
||||||
pMainWindow->updateAppTitle(this);
|
pMainWindow->updateAppTitle(this);
|
||||||
pMainWindow->updateEditorActions(this);
|
pMainWindow->updateEditorActions(this);
|
||||||
|
@ -1561,7 +1561,7 @@ void Editor::closeEvent(QCloseEvent *)
|
||||||
mCompletionPopup->hide();
|
mCompletionPopup->hide();
|
||||||
if (pMainWindow->functionTip())
|
if (pMainWindow->functionTip())
|
||||||
pMainWindow->functionTip()->hide();
|
pMainWindow->functionTip()->hide();
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
pMainWindow->updateForEncodingInfo(true);
|
pMainWindow->updateForEncodingInfo(true);
|
||||||
pMainWindow->updateStatusbarForLineCol(true);
|
pMainWindow->updateStatusbarForLineCol(true);
|
||||||
pMainWindow->updateForStatusbarModeInfo(true);
|
pMainWindow->updateForStatusbarModeInfo(true);
|
||||||
|
@ -1585,7 +1585,7 @@ void Editor::showEvent(QShowEvent */*event*/)
|
||||||
if (!pMainWindow->openingFiles() && !pMainWindow->openingProject())
|
if (!pMainWindow->openingFiles() && !pMainWindow->openingProject())
|
||||||
reparse(false);
|
reparse(false);
|
||||||
}
|
}
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
pMainWindow->debugger()->setIsForProject(inProject());
|
pMainWindow->debugger()->setIsForProject(inProject());
|
||||||
pMainWindow->bookmarkModel()->setIsForProject(inProject());
|
pMainWindow->bookmarkModel()->setIsForProject(inProject());
|
||||||
pMainWindow->todoModel()->setIsForProject(inProject());
|
pMainWindow->todoModel()->setIsForProject(inProject());
|
||||||
|
@ -1600,7 +1600,7 @@ void Editor::showEvent(QShowEvent */*event*/)
|
||||||
reparseTodo();
|
reparseTodo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
pMainWindow->updateClassBrowserForEditor(this);
|
pMainWindow->updateClassBrowserForEditor(this);
|
||||||
pMainWindow->updateAppTitle(this);
|
pMainWindow->updateAppTitle(this);
|
||||||
pMainWindow->updateEditorActions(this);
|
pMainWindow->updateEditorActions(this);
|
||||||
|
@ -1854,7 +1854,7 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
|
||||||
}
|
}
|
||||||
if (changes.testFlag(QSynedit::StatusChange::Modified)) {
|
if (changes.testFlag(QSynedit::StatusChange::Modified)) {
|
||||||
mCurrentLineModified = true;
|
mCurrentLineModified = true;
|
||||||
if (mParentPageControl)
|
if (inTab())
|
||||||
mCanAutoSave = true;
|
mCanAutoSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1967,7 +1967,7 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
|
||||||
|
|
||||||
pMainWindow->updateEditorActions();
|
pMainWindow->updateEditorActions();
|
||||||
|
|
||||||
if (changes.testFlag(QSynedit::StatusChange::CaretY) && mParentPageControl) {
|
if (changes.testFlag(QSynedit::StatusChange::CaretY) && inTab()) {
|
||||||
pMainWindow->caretList().addCaret(this,caretY(),caretX());
|
pMainWindow->caretList().addCaret(this,caretY(),caretX());
|
||||||
pMainWindow->updateCaretActions();
|
pMainWindow->updateCaretActions();
|
||||||
}
|
}
|
||||||
|
@ -2162,7 +2162,7 @@ void Editor::onTooltipTimer()
|
||||||
&& !mHeaderCompletionPopup->isVisible()) {
|
&& !mHeaderCompletionPopup->isVisible()) {
|
||||||
if (pMainWindow->debugger()->executing()
|
if (pMainWindow->debugger()->executing()
|
||||||
&& (pSettings->editor().enableDebugTooltips())) {
|
&& (pSettings->editor().enableDebugTooltips())) {
|
||||||
if (mParentPageControl) {
|
if (inTab()) {
|
||||||
showDebugHint(s,p.line);
|
showDebugHint(s,p.line);
|
||||||
}
|
}
|
||||||
} else if (pSettings->editor().enableIdentifierToolTips()) {
|
} else if (pSettings->editor().enableIdentifierToolTips()) {
|
||||||
|
@ -3217,7 +3217,7 @@ void Editor::reparse(bool resetParser)
|
||||||
{
|
{
|
||||||
if (!mInited)
|
if (!mInited)
|
||||||
return;
|
return;
|
||||||
if (!mParentPageControl)
|
if (!inTab())
|
||||||
return;
|
return;
|
||||||
if (!pSettings->codeCompletion().enabled())
|
if (!pSettings->codeCompletion().enabled())
|
||||||
return;
|
return;
|
||||||
|
@ -3253,7 +3253,7 @@ void Editor::reparseTodo()
|
||||||
{
|
{
|
||||||
if (!mInited)
|
if (!mInited)
|
||||||
return;
|
return;
|
||||||
if (!mParentPageControl)
|
if (!inTab())
|
||||||
return;
|
return;
|
||||||
if (pSettings->editor().parseTodos())
|
if (pSettings->editor().parseTodos())
|
||||||
pMainWindow->todoParser()->parseFile(mFilename, inProject());
|
pMainWindow->todoParser()->parseFile(mFilename, inProject());
|
||||||
|
@ -3711,7 +3711,7 @@ void Editor::showHeaderCompletion(bool autoComplete, bool forceShow)
|
||||||
|
|
||||||
void Editor::initAutoBackup()
|
void Editor::initAutoBackup()
|
||||||
{
|
{
|
||||||
if (!mParentPageControl)
|
if (!inTab())
|
||||||
return;
|
return;
|
||||||
cleanAutoBackup();
|
cleanAutoBackup();
|
||||||
if (!pSettings->editor().enableEditTempBackup())
|
if (!pSettings->editor().enableEditTempBackup())
|
||||||
|
@ -5164,7 +5164,7 @@ void Editor::checkSyntaxInBack()
|
||||||
{
|
{
|
||||||
if (!mInited)
|
if (!mInited)
|
||||||
return;
|
return;
|
||||||
if (!mParentPageControl)
|
if (!inTab())
|
||||||
return;
|
return;
|
||||||
if (readOnly())
|
if (readOnly())
|
||||||
return;
|
return;
|
||||||
|
@ -5207,9 +5207,11 @@ void Editor::toggleBreakpoint(int line)
|
||||||
{
|
{
|
||||||
if (hasBreakpoint(line)) {
|
if (hasBreakpoint(line)) {
|
||||||
mBreakpointLines.remove(line);
|
mBreakpointLines.remove(line);
|
||||||
|
if (inTab())
|
||||||
pMainWindow->debugger()->removeBreakpoint(line,this);
|
pMainWindow->debugger()->removeBreakpoint(line,this);
|
||||||
} else {
|
} else {
|
||||||
mBreakpointLines.insert(line);
|
mBreakpointLines.insert(line);
|
||||||
|
if (inTab())
|
||||||
pMainWindow->debugger()->addBreakpoint(line,this);
|
pMainWindow->debugger()->addBreakpoint(line,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5527,7 +5529,7 @@ void Editor::applyColorScheme(const QString& schemeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::updateCaption(const QString& newCaption) {
|
void Editor::updateCaption(const QString& newCaption) {
|
||||||
if (!mParentPageControl) {
|
if (!inTab()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int index = mParentPageControl->indexOf(this);
|
int index = mParentPageControl->indexOf(this);
|
||||||
|
|
|
@ -249,6 +249,8 @@ public:
|
||||||
void selectToFileStart() { processCommand(QSynedit::EditCommand::SelFileStart); }
|
void selectToFileStart() { processCommand(QSynedit::EditCommand::SelFileStart); }
|
||||||
void selectToFileEnd() { processCommand(QSynedit::EditCommand::SelFileEnd); }
|
void selectToFileEnd() { processCommand(QSynedit::EditCommand::SelFileEnd); }
|
||||||
|
|
||||||
|
bool inTab() { return mParentPageControl!=nullptr; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void renamed(const QString& oldName, const QString& newName, bool firstSave);
|
void renamed(const QString& oldName, const QString& newName, bool firstSave);
|
||||||
void fileSaved(const QString& filename, bool inProject);
|
void fileSaved(const QString& filename, bool inProject);
|
||||||
|
|
Loading…
Reference in New Issue