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