Add unsaved changes indication to SQL tabs
This commit is contained in:
parent
d12fb60af8
commit
50cd865b1a
2 changed files with 30 additions and 9 deletions
|
|
@ -80,7 +80,7 @@ void QueryTool::newdoc()
|
|||
{
|
||||
ui->queryEdit->clear();
|
||||
setFileName(tr("new"));
|
||||
m_queryTextChanged = false;
|
||||
setQueryTextChanged(false);
|
||||
m_new = true;
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ bool QueryTool::load(const QString &filename)
|
|||
}
|
||||
|
||||
ui->queryEdit->setPlainText(text);
|
||||
m_queryTextChanged = false;
|
||||
setQueryTextChanged(false);
|
||||
setFileName(filename);
|
||||
m_new = false;
|
||||
result = true;
|
||||
|
|
@ -244,9 +244,19 @@ QString QueryTool::title() const
|
|||
void QueryTool::setFileName(const QString &filename)
|
||||
{
|
||||
m_fileName = filename;
|
||||
QFileInfo fileInfo(filename);
|
||||
QString fn(fileInfo.fileName());
|
||||
m_context->setTitleForWidget(this, fn, m_fileName);
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void QueryTool::updateTitle()
|
||||
{
|
||||
QFileInfo fileInfo(m_fileName);
|
||||
QString title = fileInfo.fileName();
|
||||
|
||||
if (m_queryTextChanged) {
|
||||
title = "*" + title;
|
||||
}
|
||||
|
||||
m_context->setTitleForWidget(this, title, m_fileName);
|
||||
}
|
||||
|
||||
bool QueryTool::continueWithoutSavingWarning()
|
||||
|
|
@ -284,7 +294,7 @@ bool QueryTool::saveSqlTo(const QString &filename)
|
|||
|
||||
stream.flush();
|
||||
if (stream.status() == QTextStream::Ok) {
|
||||
m_queryTextChanged = false;
|
||||
setQueryTextChanged(false);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -300,7 +310,7 @@ QString QueryTool::promptUserForSaveSqlFilename()
|
|||
|
||||
void QueryTool::queryTextChanged()
|
||||
{
|
||||
m_queryTextChanged = true;
|
||||
setQueryTextChanged(true);
|
||||
}
|
||||
|
||||
void QueryTool::connectionStateChanged(ASyncDBConnection::State state)
|
||||
|
|
@ -622,3 +632,11 @@ void QueryTool::exportData()
|
|||
tr("Export data"), home_dir, tr("CSV file (*.csv)"));
|
||||
exportDataToFilename(file_name);
|
||||
}
|
||||
|
||||
void QueryTool::setQueryTextChanged(bool queryTextChanged)
|
||||
{
|
||||
if (m_queryTextChanged != queryTextChanged) {
|
||||
m_queryTextChanged = queryTextChanged;
|
||||
updateTitle();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,9 +56,10 @@ public:
|
|||
|
||||
QString title() const;
|
||||
|
||||
|
||||
public slots:
|
||||
void execute();
|
||||
/// Save the document under its current name, a file save dialog will be shown if this is a new document
|
||||
void execute();
|
||||
/// Save the document under its current name, a file save dialog will be shown if this is a new document
|
||||
bool save();
|
||||
/// Saves the document under a new name and continue editing the document under this new name.
|
||||
bool saveAs();
|
||||
|
|
@ -103,6 +104,8 @@ private:
|
|||
|
||||
void clearResult();
|
||||
void markError(const Pgsql::ErrorDetails &details);
|
||||
void updateTitle();
|
||||
void setQueryTextChanged(bool queryTextChanged);
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue