Commit acff7e32 authored by Alexander Semke's avatar Alexander Semke
Browse files

Mark the project as modified also when the entries are move or deleted and...

Mark the project as modified also when the entries are move or deleted and properly notify the user about the changes in the window title bar and in the tab names.
parent 41a16e0a
......@@ -446,7 +446,8 @@ void CantorShell::activateWorksheet(int index)
}
}
updateWindowTitle(m_part->url().fileName());
updateWindowTitle(m_part->url().fileName(), m_part->isModified());
updatePanel();
}
else
......@@ -461,16 +462,29 @@ void CantorShell::setTabCaption(const QString& caption, const QIcon& icon)
auto* part = dynamic_cast<KParts::ReadWritePart*>(sender());
if (part)
{
const int index = m_tabWidget->indexOf(part->widget());
if (!caption.isEmpty())
m_tabWidget->setTabText(m_tabWidget->indexOf(part->widget()), caption);
m_tabWidget->setTabIcon(m_tabWidget->indexOf(part->widget()), icon);
{
if (part->isModified())
m_tabWidget->setTabText(index, caption + QLatin1String(" *"));
else
m_tabWidget->setTabText(index, caption);
if (part == m_part)
updateWindowTitle(m_part->url().fileName(), m_part->isModified());
}
m_tabWidget->setTabIcon(index, icon);
}
}
void CantorShell::updateWindowTitle(const QString& fileName)
void CantorShell::updateWindowTitle(const QString& fileName, bool modified)
{
QFileInfo info(fileName);
setWindowTitle(info.baseName());
QString title = info.baseName();
if (modified)
title += QLatin1String(" [") + i18n("Changed") + QLatin1Char(']');
setWindowTitle(title);
}
void CantorShell::closeTab(int index)
......
......@@ -106,7 +106,7 @@ private:
void closeEvent(QCloseEvent*) override;
bool reallyClose(bool checkAllParts = true);
bool reallyCloseThisPart(KParts::ReadWritePart*);
void updateWindowTitle(const QString&);
void updateWindowTitle(const QString&, bool modified = false);
void saveDockPanelsState(KParts::ReadWritePart*);
KParts::ReadWritePart* findPart(QWidget*);
......
......@@ -128,6 +128,7 @@ CantorPart::CantorPart( QWidget *parentWidget, QObject *parent, const QVariantLi
m_worksheetview = new WorksheetView(m_worksheet, widget);
m_worksheetview->setEnabled(false); //disable input until the session has successfully logged in and emits the ready signal
connect(m_worksheet, &Worksheet::modified, this, static_cast<void (KParts::ReadWritePart::*)()>(&KParts::ReadWritePart::setModified));
connect(m_worksheet, &Worksheet::modified, this, &CantorPart::updateCaption);
connect(m_worksheet, &Worksheet::showHelp, this, &CantorPart::showHelp);
connect(m_worksheet, &Worksheet::loaded, this, &CantorPart::initialized);
connect(m_worksheet, &Worksheet::hierarchyChanged, this, &CantorPart::hierarchyChanged);
......@@ -472,6 +473,7 @@ bool CantorPart::saveFile()
else
m_worksheet->save( localFilePath() );
setModified(false);
updateCaption();
emit worksheetSave(QUrl::fromLocalFile(localFilePath()));
return true;
......
......@@ -427,10 +427,7 @@ WorksheetView* Worksheet::worksheetView()
void Worksheet::setModified()
{
if (m_isClosing)
return;
if (!m_isLoadingFromFile)
if (!m_isClosing && !m_isLoadingFromFile)
emit modified();
}
......
......@@ -800,6 +800,8 @@ void WorksheetEntry::remove()
// make the entry invisible to QGraphicsScene's itemAt() function
forceRemove();
worksheet()->setModified();
}
void WorksheetEntry::setSize(QSizeF size)
......@@ -995,6 +997,8 @@ void WorksheetEntry::moveToNext(bool updateLayout)
if (updateLayout)
worksheet()->updateLayout();
worksheet()->setModified();
}
}
......@@ -1025,6 +1029,8 @@ void WorksheetEntry::moveToPrevious(bool updateLayout)
if (updateLayout)
worksheet()->updateLayout();
worksheet()->setModified();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment