Commit 769d399e authored by Gil Moskowitz's avatar Gil Moskowitz

Merge pull request #64 from andersdd/27956_metasql_last_saved_dir

Issue #27956: Add last saved directory to MetaSQL editor
parents a1e28f56 bc8add6b
......@@ -32,6 +32,7 @@
#include <QSqlRecord>
#include <QTextDocument>
#include <QTextStream>
#include <QSettings>
#include <parameter.h>
#include <xsqlquery.h>
......@@ -47,6 +48,8 @@
#define DEBUG false
static QString lastSaveDir = QString();
MQLEdit::MQLEdit(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
{
......@@ -125,6 +128,9 @@ MQLEdit::MQLEdit(QWidget* parent, Qt::WindowFlags fl)
_highlighter = new MetaSQLHighlighter(_document);
QSettings settings("xTuple.com", "mqlEditor");
lastSaveDir = settings.value("LastDirectory").toString();
clear();
setDestType(MQLUnknown);
......@@ -132,6 +138,8 @@ MQLEdit::MQLEdit(QWidget* parent, Qt::WindowFlags fl)
MQLEdit::~MQLEdit()
{
QSettings settings("xTuple.com", "mqlEditor");
settings.setValue("LastDirectory",lastSaveDir);
// no need to delete child widgets, Qt does it all for us
}
......@@ -150,7 +158,8 @@ void MQLEdit::fileOpen()
{
if(askSaveIfModified())
{
QString fileName = QFileDialog::getOpenFileName(this);
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
lastSaveDir, tr("MetaSQL (*.mql)"));
if(!fileName.isEmpty())
{
QFile file(fileName);
......@@ -168,6 +177,8 @@ void MQLEdit::fileOpen()
setWindowTitle(getTitleString(MQLFile));
setDestType(MQLFile);
}
QFileInfo fi(file);
lastSaveDir = fi.absolutePath();
}
}
}
......@@ -330,6 +341,7 @@ bool MQLEdit::save()
}
QFile file(_fileName);
QFileInfo fi(file);
if (file.open(QIODevice::WriteOnly))
{
QTextStream stream(&file);
......@@ -347,6 +359,7 @@ bool MQLEdit::save()
return false;
}
_text->document()->setModified(false);
lastSaveDir = fi.absolutePath();
return true;
}
......@@ -363,6 +376,8 @@ bool MQLEdit::saveAs()
tmpfilename = _mqlGroup + "-" + _mqlName + ".mql";
tmpfilename = QFileDialog::getSaveFileName(this, tr("Save MetaSQL File"),
lastSaveDir +
QDir::separator() +
tmpfilename,
tr("MetaSQL Files (*.mql);;"
"Text Files (*.txt)"));
......
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