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,18 +59,14 @@
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainPlotWindow::RiuMainPlotWindow()
: m_activePlotViewWindow(nullptr),
m_windowMenu(NULL),
m_blockSlotSubWindowActivated(false)
RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(NULL), m_blockSlotSubWindowActivated(false)
{
m_mdiArea = new QMdiArea;
m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
setCentralWidget(m_mdiArea);
createMenus();
@ -84,8 +80,7 @@ RiuMainPlotWindow::RiuMainPlotWindow()
// Enabling the line below will activate the undo stack
// 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();
if (!app->tryCloseMainWindow()) return;
if (!app->tryCloseMainWindow())
return;
app->closeProject();
}
@ -292,7 +288,10 @@ void RiuMainPlotWindow::createToolBars()
CVF_ASSERT(cmdFeatureMgr);
QStringList toolbarNames;
toolbarNames << "Standard" << "Window Management" << "View Snapshots" << "View";
toolbarNames << "Standard"
<< "Window Management"
<< "View Snapshots"
<< "View";
for (QString toolbarName : toolbarNames)
{
@ -354,7 +353,8 @@ void RiuMainPlotWindow::createDockPanels()
connect(m_projectTreeView, SIGNAL(selectionChanged()), this, SLOT(selectedObjectsChanged()));
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");
}
@ -367,7 +367,7 @@ void RiuMainPlotWindow::createDockPanels()
m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget);
dockWidget->setWidget(m_pdmUiPropertyView);
m_pdmUiPropertyView->layout()->setContentsMargins(5,0,0,0);
m_pdmUiPropertyView->layout()->setContentsMargins(5, 0, 0, 0);
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
}
@ -503,10 +503,12 @@ void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot)
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
{
if (!subWindow) return;
if (!subWindow)
return;
RimProject * proj = RiaApplication::instance()->project();
if (!proj) return;
RimProject* proj = RiaApplication::instance()->project();
if (!proj)
return;
// Select in Project Tree
@ -530,8 +532,9 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer)
{
m_blockSlotSubWindowActivated = true;
QMdiSubWindow * swin = findMdiSubWindow(viewer);
if (swin) m_mdiArea->setActiveSubWindow(swin);
QMdiSubWindow* swin = findMdiSubWindow(viewer);
if (swin)
m_mdiArea->setActiveSubWindow(swin);
m_blockSlotSubWindowActivated = false;
}
@ -558,7 +561,8 @@ void RiuMainPlotWindow::slotBuildWindowActions()
{
if (dock)
{
if (i == 4) m_windowMenu->addSeparator();
if (i == 4)
m_windowMenu->addSeparator();
m_windowMenu->addAction(dock->toggleViewAction());
++i;
}
@ -601,7 +605,6 @@ void RiuMainPlotWindow::selectedObjectsChanged()
{
toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar();
}
}
m_summaryPlotToolBar->setFields(toolBarFields);
m_summaryPlotToolBar->updateUi();
@ -613,10 +616,12 @@ void RiuMainPlotWindow::selectedObjectsChanged()
if (!firstSelectedObject)
{
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);
if (!selectedWindow)
@ -678,7 +683,8 @@ void RiuMainPlotWindow::restoreTreeViewState()
QString currentIndexString = RiaApplication::instance()->project()->plotWindowCurrentModelIndexPath;
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);
}
}
@ -751,8 +757,9 @@ void RiuMainPlotWindow::tileWindows()
// Based on workaround described here
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
QMdiSubWindow *a = m_mdiArea->activeSubWindow();
QList<QMdiSubWindow *> list = m_mdiArea->subWindowList(m_mdiArea->activationOrder());
QMdiSubWindow* a = m_mdiArea->activeSubWindow();
QList<QMdiSubWindow*> list = m_mdiArea->subWindowList(m_mdiArea->activationOrder());
for (int i = 0; i < list.count(); i++)
{
m_mdiArea->setActiveSubWindow(list[i]);
@ -769,4 +776,3 @@ bool RiuMainPlotWindow::isAnyMdiSubWindowVisible()
{
return m_mdiArea->subWindowList().size() > 0;
}