SessionManager fix - obtain all mainwindow QSplitters in "addEntry"
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
|||||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||||
project(qad)
|
project(qad)
|
||||||
set(qad_MAJOR 1)
|
set(qad_MAJOR 1)
|
||||||
set(qad_MINOR 16)
|
set(qad_MINOR 17)
|
||||||
set(qad_REVISION 0)
|
set(qad_REVISION 0)
|
||||||
set(qad_SUFFIX )
|
set(qad_SUFFIX )
|
||||||
set(qad_COMPANY SHS)
|
set(qad_COMPANY SHS)
|
||||||
|
|||||||
@@ -322,8 +322,10 @@ bool SQLRecordWidget::isEmpty() const {
|
|||||||
|
|
||||||
void SQLRecordWidget::updateRelations() {
|
void SQLRecordWidget::updateRelations() {
|
||||||
relations.clear();
|
relations.clear();
|
||||||
|
QSqlDatabase db(QSqlDatabase::database(connection_name));
|
||||||
|
if (!db.isOpen()) return;
|
||||||
for (int i = 0; i < relations_src.size(); ++i) {
|
for (int i = 0; i < relations_src.size(); ++i) {
|
||||||
QSqlQuery q(QString("SELECT %1,%2 FROM %3").arg(relations_src[i].key, relations_src[i].ocol, relations_src[i].table), QSqlDatabase::database(connection_name));
|
QSqlQuery q(QString("SELECT %1,%2 FROM %3").arg(relations_src[i].key, relations_src[i].ocol, relations_src[i].table), db);
|
||||||
QList<QPair<int, QString> > cr;
|
QList<QPair<int, QString> > cr;
|
||||||
while (q.next())
|
while (q.next())
|
||||||
cr << QPair<int, QString>(q.value(0).toInt(), q.value(1).toString());
|
cr << QPair<int, QString>(q.value(0).toInt(), q.value(1).toString());
|
||||||
|
|||||||
@@ -42,6 +42,12 @@ void SessionManager::removeMainWidget(QWidget * e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SessionManager::addEntry(const QString & name, QMainWindow * e) {
|
||||||
|
mwindows.push_back(QPair<QString, QMainWindow * >(name, e));
|
||||||
|
mw_splitters[e] = e->findChildren<QSplitter * >();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionManager::save() {
|
void SessionManager::save() {
|
||||||
if (file_.isEmpty()) {
|
if (file_.isEmpty()) {
|
||||||
qDebug() << "[SessionManager] filename is empty";
|
qDebug() << "[SessionManager] filename is empty";
|
||||||
@@ -54,8 +60,8 @@ void SessionManager::save() {
|
|||||||
sr.setValue(mwindows[i].first + " state", mwindows[i].second->saveState(), false);
|
sr.setValue(mwindows[i].first + " state", mwindows[i].second->saveState(), false);
|
||||||
sr.setValue(mwindows[i].first + " window state", (int)mwindows[i].second->windowState(), false);
|
sr.setValue(mwindows[i].first + " window state", (int)mwindows[i].second->windowState(), false);
|
||||||
sr.setValue(mwindows[i].first + " geometry " + QString::number((int)mwindows[i].second->windowState()), mwindows[i].second->saveGeometry(), false);
|
sr.setValue(mwindows[i].first + " geometry " + QString::number((int)mwindows[i].second->windowState()), mwindows[i].second->saveGeometry(), false);
|
||||||
QList<QSplitter * > sp = mwindows[i].second->findChildren<QSplitter * >();
|
QList<QSplitter*> spl = mw_splitters[mwindows[i].second];
|
||||||
foreach (QSplitter * s, sp)
|
foreach (QSplitter * s, spl)
|
||||||
sr.setValue(mwindows[i].first + " splitter " + s->objectName(), s->saveState(), false);
|
sr.setValue(mwindows[i].first + " splitter " + s->objectName(), s->saveState(), false);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < widgets.size(); ++i) {
|
for (int i = 0; i < widgets.size(); ++i) {
|
||||||
@@ -165,8 +171,8 @@ void SessionManager::load(bool onlyMainwindow) {
|
|||||||
QByteArray ba = sr.getValue(mwindows[i].first + " state").toByteArray();
|
QByteArray ba = sr.getValue(mwindows[i].first + " state").toByteArray();
|
||||||
if (!ba.isEmpty())
|
if (!ba.isEmpty())
|
||||||
mw->restoreState(ba);
|
mw->restoreState(ba);
|
||||||
QList<QSplitter * > sp = mw->findChildren<QSplitter * >();
|
QList<QSplitter*> spl = mw_splitters[mw];
|
||||||
foreach (QSplitter * s, sp) {
|
foreach (QSplitter * s, spl) {
|
||||||
ba = sr.getValue(mwindows[i].first + " splitter " + s->objectName()).toByteArray();
|
ba = sr.getValue(mwindows[i].first + " splitter " + s->objectName()).toByteArray();
|
||||||
if (!ba.isEmpty())
|
if (!ba.isEmpty())
|
||||||
s->restoreState(ba);
|
s->restoreState(ba);
|
||||||
@@ -261,6 +267,7 @@ void SessionManager::clear(bool with_filename) {
|
|||||||
bools.clear();
|
bools.clear();
|
||||||
ints.clear();
|
ints.clear();
|
||||||
floats.clear();
|
floats.clear();
|
||||||
|
mw_splitters.clear();
|
||||||
if (with_filename) setFile("");
|
if (with_filename) setFile("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,23 +52,23 @@ public:
|
|||||||
|
|
||||||
void setFile(const QString & file);
|
void setFile(const QString & file);
|
||||||
|
|
||||||
void addEntry(QMainWindow * e) {mwindows.push_back(QPair<QString, QMainWindow * >(e->objectName(), e));}
|
void addEntry(QMainWindow * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QCheckBox * e) {checks.push_back(QPair<QString, QCheckBox * >(e->objectName(), e));}
|
void addEntry(QCheckBox * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QLineEdit * e) {lines.push_back(QPair<QString, QLineEdit * >(e->objectName(), e));}
|
void addEntry(QLineEdit * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QComboBox * e) {combos.push_back(QPair<QString, QComboBox * >(e->objectName(), e));}
|
void addEntry(QComboBox * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QDoubleSpinBox * e) {dspins.push_back(QPair<QString, QDoubleSpinBox * >(e->objectName(), e));}
|
void addEntry(QDoubleSpinBox * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QSpinBox * e) {spins.push_back(QPair<QString, QSpinBox * >(e->objectName(), e));}
|
void addEntry(QSpinBox * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(SpinSlider * e) {spinsliders.push_back(QPair<QString, SpinSlider * >(e->objectName(), e));}
|
void addEntry(SpinSlider * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(EvalSpinBox * e) {evals.push_back(QPair<QString, EvalSpinBox * >(e->objectName(), e));}
|
void addEntry(EvalSpinBox * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QTabWidget * e) {tabs.push_back(QPair<QString, QTabWidget * >(e->objectName(), e));}
|
void addEntry(QTabWidget * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QGroupBox * e) {groups.push_back(QPair<QString, QGroupBox * >(e->objectName(), e));}
|
void addEntry(QGroupBox * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QAction * e) {actions.push_back(QPair<QString, QAction * >(e->objectName(), e));}
|
void addEntry(QAction * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QAbstractButton * e) {buttons.push_back(QPair<QString, QAbstractButton * >(e->objectName(), e));}
|
void addEntry(QAbstractButton * e) {addEntry(e->objectName(), e);}
|
||||||
void addEntry(QStackedWidget * e) {stacks.push_back(QPair<QString, QStackedWidget * >(e->objectName(), e));}
|
void addEntry(QStackedWidget * e) {addEntry(e->objectName(), e);}
|
||||||
void addMainWidget(QWidget * e) {widgets.push_back(QPair<QString, QWidget * >(e->objectName(), e));}
|
void addMainWidget(QWidget * e) {addMainWidget(e->objectName(), e);}
|
||||||
void removeMainWidget(QWidget * e);
|
void removeMainWidget(QWidget * e);
|
||||||
|
|
||||||
void addEntry(const QString & name, QMainWindow * e) {mwindows.push_back(QPair<QString, QMainWindow * >(name, e));}
|
void addEntry(const QString & name, QMainWindow * e);
|
||||||
void addEntry(const QString & name, QCheckBox * e) {checks.push_back(QPair<QString, QCheckBox * >(name, e));}
|
void addEntry(const QString & name, QCheckBox * e) {checks.push_back(QPair<QString, QCheckBox * >(name, e));}
|
||||||
void addEntry(const QString & name, QLineEdit * e) {lines.push_back(QPair<QString, QLineEdit * >(name, e));}
|
void addEntry(const QString & name, QLineEdit * e) {lines.push_back(QPair<QString, QLineEdit * >(name, e));}
|
||||||
void addEntry(const QString & name, QComboBox * e) {combos.push_back(QPair<QString, QComboBox * >(name, e));}
|
void addEntry(const QString & name, QComboBox * e) {combos.push_back(QPair<QString, QComboBox * >(name, e));}
|
||||||
@@ -112,6 +112,7 @@ private:
|
|||||||
QVector<QPair<QString, bool * > > bools;
|
QVector<QPair<QString, bool * > > bools;
|
||||||
QVector<QPair<QString, int * > > ints;
|
QVector<QPair<QString, int * > > ints;
|
||||||
QVector<QPair<QString, float * > > floats;
|
QVector<QPair<QString, float * > > floats;
|
||||||
|
QMap<QMainWindow*, QList<QSplitter*> > mw_splitters;
|
||||||
QString file_;
|
QString file_;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user