Changed: #1150 fixed some dockwidgets bugs

This commit is contained in:
aquiles 2010-11-15 00:04:10 +01:00
parent 790bf9514c
commit 1aaa7df862
3 changed files with 26 additions and 8 deletions

View file

@ -274,6 +274,7 @@ namespace NLQT
Modules::mainWin().createEmptyView( Modules::mainWin().createEmptyView(
Modules::mainWin().getTreeViewList().takeFirst()); Modules::mainWin().getTreeViewList().takeFirst());
} }
Modules::mainWin().getTreeViewList().removeOne(this);
deleteLater(); deleteLater();
} }
} }

View file

@ -41,7 +41,7 @@ namespace NLQT
CMainWindow::CMainWindow(QWidget *parent) CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent), _GeorgesLogDialog(0), _ObjectViewerDialog(0), : QMainWindow(parent), _GeorgesLogDialog(0), _ObjectViewerDialog(0),
_GeorgesDirTreeDialog(0) _GeorgesDirTreeDialog(0),_emptyView(0)
{ {
setWindowTitle("Qt Georges Editor"); setWindowTitle("Qt Georges Editor");
@ -106,17 +106,31 @@ namespace NLQT
CMainWindow::~CMainWindow() CMainWindow::~CMainWindow()
{ {
// save state & geometry of window and widgets // save state & geometry of window and widgets
QSettings settings("georges_editor_qt.ini", QSettings::IniFormat);
settings.beginGroup("WindowSettings");
settings.setValue("QtWindowState", saveState());
settings.setValue("QtWindowGeometry", saveGeometry());
settings.endGroup();
_statusBarTimer->stop(); _statusBarTimer->stop();
delete _ObjectViewerDialog; delete _ObjectViewerDialog;
delete _GeorgesDirTreeDialog; delete _GeorgesDirTreeDialog;
delete _GeorgesLogDialog; delete _GeorgesLogDialog;
delete _emptyView;
}
void CMainWindow::closeEvent(QCloseEvent *event)
{
// TODO: dirty hack to have qt recognize possible state/geometry changes
// of new emptyView
CGeorgesTreeViewDialog *bla = new CGeorgesTreeViewDialog(this, true);
tabifyDockWidget(_emptyView, bla);
removeDockWidget(bla);
bla->deleteLater();
QSettings settings("georges_editor_qt.ini", QSettings::IniFormat);
settings.beginGroup("WindowSettings");
settings.setValue("QtWindowState", saveState());
settings.setValue("QtWindowGeometry", saveGeometry());
settings.endGroup();
event->accept();
} }
void CMainWindow::openTreeView(QString file) void CMainWindow::openTreeView(QString file)
@ -135,13 +149,12 @@ namespace NLQT
if (!newView) if (!newView)
{ {
newView = new CGeorgesTreeViewDialog(this); newView = new CGeorgesTreeViewDialog(this);
//newView->setAllowedAreas(Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
newView->setWindowTitle(file); newView->setWindowTitle(file);
if (_treeViewList.isEmpty()) if (_treeViewList.isEmpty())
{ {
_emptyView->deleteLater();
tabifyDockWidget(_emptyView, newView); tabifyDockWidget(_emptyView, newView);
_emptyView->deleteLater();
} }
else else
{ {
@ -245,8 +258,10 @@ namespace NLQT
void CMainWindow::createEmptyView(QDockWidget* w) void CMainWindow::createEmptyView(QDockWidget* w)
{ {
_emptyView = new CGeorgesTreeViewDialog(this, true); _emptyView = new CGeorgesTreeViewDialog(this, true);
if(w) if(w)
{ {
addDockWidget(Qt::TopDockWidgetArea, _emptyView);
tabifyDockWidget(w, _emptyView); tabifyDockWidget(w, _emptyView);
} }
else else
@ -401,6 +416,7 @@ namespace NLQT
void CMainWindow::tabChanged(int index) void CMainWindow::tabChanged(int index)
{ {
nlinfo(QString("%1").arg(index).toStdString().c_str());
if (index == -1) if (index == -1)
{ {
setWindowTitle("Qt Georges Editor"); setWindowTitle("Qt Georges Editor");

View file

@ -58,6 +58,7 @@ namespace NLQT
QList<CGeorgesTreeViewDialog*>& getTreeViewList() { return _treeViewList; } QList<CGeorgesTreeViewDialog*>& getTreeViewList() { return _treeViewList; }
QTabBar* getTabBar(); QTabBar* getTabBar();
void createEmptyView(QDockWidget* w = 0); void createEmptyView(QDockWidget* w = 0);
void closeEvent(QCloseEvent *event);
private Q_SLOTS: private Q_SLOTS:
void open(); void open();