Improve source code layout

This commit is contained in:
Magne Sjaastad 2017-11-29 13:10:46 +01:00
parent c9ae3821e2
commit 6d9891da09

View File

@ -59,14 +59,10 @@
/// ///
//================================================================================================== //==================================================================================================
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuMainPlotWindow::RiuMainPlotWindow() RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(NULL), m_blockSlotSubWindowActivated(false)
: m_activePlotViewWindow(nullptr),
m_windowMenu(NULL),
m_blockSlotSubWindowActivated(false)
{ {
m_mdiArea = new QMdiArea; m_mdiArea = new QMdiArea;
m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
@ -85,7 +81,6 @@ RiuMainPlotWindow::RiuMainPlotWindow()
// Enabling the line below will activate the undo stack // Enabling the line below will activate the undo stack
// When enableUndoCommandSystem is set false, all commands are executed and deleted immediately // When enableUndoCommandSystem is set false, all commands are executed and deleted immediately
// caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true); // caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -163,7 +158,8 @@ void RiuMainPlotWindow::closeEvent(QCloseEvent* event)
saveWinGeoAndDockToolBarLayout(); saveWinGeoAndDockToolBarLayout();
if (!app->tryCloseMainWindow()) return; if (!app->tryCloseMainWindow())
return;
app->closeProject(); app->closeProject();
} }
@ -292,7 +288,10 @@ void RiuMainPlotWindow::createToolBars()
CVF_ASSERT(cmdFeatureMgr); CVF_ASSERT(cmdFeatureMgr);
QStringList toolbarNames; QStringList toolbarNames;
toolbarNames << "Standard" << "Window Management" << "View Snapshots" << "View"; toolbarNames << "Standard"
<< "Window Management"
<< "View Snapshots"
<< "View";
for (QString toolbarName : toolbarNames) for (QString toolbarName : toolbarNames)
{ {
@ -354,7 +353,8 @@ void RiuMainPlotWindow::createDockPanels()
connect(m_projectTreeView, SIGNAL(selectionChanged()), this, SLOT(selectedObjectsChanged())); connect(m_projectTreeView, SIGNAL(selectionChanged()), this, SLOT(selectedObjectsChanged()));
m_projectTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu); m_projectTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(customMenuRequested(const QPoint&))); connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)),
SLOT(customMenuRequested(const QPoint&)));
m_projectTreeView->setUiConfigurationName("PlotWindow"); m_projectTreeView->setUiConfigurationName("PlotWindow");
} }
@ -503,10 +503,12 @@ void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
{ {
if (!subWindow) return; if (!subWindow)
return;
RimProject* proj = RiaApplication::instance()->project(); RimProject* proj = RiaApplication::instance()->project();
if (!proj) return; if (!proj)
return;
// Select in Project Tree // Select in Project Tree
@ -531,7 +533,8 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer)
m_blockSlotSubWindowActivated = true; m_blockSlotSubWindowActivated = true;
QMdiSubWindow* swin = findMdiSubWindow(viewer); QMdiSubWindow* swin = findMdiSubWindow(viewer);
if (swin) m_mdiArea->setActiveSubWindow(swin); if (swin)
m_mdiArea->setActiveSubWindow(swin);
m_blockSlotSubWindowActivated = false; m_blockSlotSubWindowActivated = false;
} }
@ -558,7 +561,8 @@ void RiuMainPlotWindow::slotBuildWindowActions()
{ {
if (dock) if (dock)
{ {
if (i == 4) m_windowMenu->addSeparator(); if (i == 4)
m_windowMenu->addSeparator();
m_windowMenu->addAction(dock->toggleViewAction()); m_windowMenu->addAction(dock->toggleViewAction());
++i; ++i;
} }
@ -601,7 +605,6 @@ void RiuMainPlotWindow::selectedObjectsChanged()
{ {
toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar(); toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar();
} }
} }
m_summaryPlotToolBar->setFields(toolBarFields); m_summaryPlotToolBar->setFields(toolBarFields);
m_summaryPlotToolBar->updateUi(); m_summaryPlotToolBar->updateUi();
@ -613,10 +616,12 @@ void RiuMainPlotWindow::selectedObjectsChanged()
if (!firstSelectedObject) if (!firstSelectedObject)
{ {
caf::PdmFieldHandle* selectedField = dynamic_cast<caf::PdmFieldHandle*>(uiItems[0]); caf::PdmFieldHandle* selectedField = dynamic_cast<caf::PdmFieldHandle*>(uiItems[0]);
if (selectedField) firstSelectedObject = selectedField->ownerObject(); if (selectedField)
firstSelectedObject = selectedField->ownerObject();
} }
if (!firstSelectedObject) return; if (!firstSelectedObject)
return;
RimViewWindow* selectedWindow = dynamic_cast<RimViewWindow*>(firstSelectedObject); RimViewWindow* selectedWindow = dynamic_cast<RimViewWindow*>(firstSelectedObject);
if (!selectedWindow) if (!selectedWindow)
@ -678,7 +683,8 @@ void RiuMainPlotWindow::restoreTreeViewState()
QString currentIndexString = RiaApplication::instance()->project()->plotWindowCurrentModelIndexPath; QString currentIndexString = RiaApplication::instance()->project()->plotWindowCurrentModelIndexPath;
if (!currentIndexString.isEmpty()) if (!currentIndexString.isEmpty())
{ {
QModelIndex mi = caf::QTreeViewStateSerializer::getModelIndexFromString(m_projectTreeView->treeView()->model(), currentIndexString); QModelIndex mi = caf::QTreeViewStateSerializer::getModelIndexFromString(m_projectTreeView->treeView()->model(),
currentIndexString);
m_projectTreeView->treeView()->setCurrentIndex(mi); m_projectTreeView->treeView()->setCurrentIndex(mi);
} }
} }
@ -752,6 +758,7 @@ void RiuMainPlotWindow::tileWindows()
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode // https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
QMdiSubWindow* a = m_mdiArea->activeSubWindow(); QMdiSubWindow* a = m_mdiArea->activeSubWindow();
QList<QMdiSubWindow*> list = m_mdiArea->subWindowList(m_mdiArea->activationOrder()); QList<QMdiSubWindow*> list = m_mdiArea->subWindowList(m_mdiArea->activationOrder());
for (int i = 0; i < list.count(); i++) for (int i = 0; i < list.count(); i++)
{ {
@ -769,4 +776,3 @@ bool RiuMainPlotWindow::isAnyMdiSubWindowVisible()
{ {
return m_mdiArea->subWindowList().size() > 0; return m_mdiArea->subWindowList().size() > 0;
} }