Minor fixes, formatting, static const

This commit is contained in:
Klaus Basan
2017-10-24 12:21:32 +02:00
parent e25a3bdc93
commit 5612033924
8 changed files with 122 additions and 123 deletions

View File

@@ -90,7 +90,7 @@ namespace BlackGui
} }
// write to disk // write to disk
bool s = sGui->getWebDataServices()->writeDbDataToDisk(CDirectoryUtils::staticDbFilesDirectory()); const bool s = sGui->getWebDataServices()->writeDbDataToDisk(CDirectoryUtils::staticDbFilesDirectory());
if (s) if (s)
{ {
CLogMessage(this).info("Written DB data"); CLogMessage(this).info("Written DB data");
@@ -104,7 +104,7 @@ namespace BlackGui
bool CDataInfoAreaComponent::readDbDataFromResourceDir() bool CDataInfoAreaComponent::readDbDataFromResourceDir()
{ {
bool s = sGui && const bool s = sGui &&
sGui->getWebDataServices()->readDbDataFromDisk(CDirectoryUtils::staticDbFilesDirectory(), true); sGui->getWebDataServices()->readDbDataFromDisk(CDirectoryUtils::staticDbFilesDirectory(), true);
// info // info

View File

@@ -24,7 +24,6 @@ class QPixmap;
class QWidget; class QWidget;
namespace Ui { class CDataInfoAreaComponent; } namespace Ui { class CDataInfoAreaComponent; }
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Components
@@ -62,7 +61,7 @@ namespace BlackGui
explicit CDataInfoAreaComponent(QWidget *parent = nullptr); explicit CDataInfoAreaComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
~CDataInfoAreaComponent(); virtual ~CDataInfoAreaComponent();
//! DB model component //! DB model component
CDbModelComponent *getModelComponent() const; CDbModelComponent *getModelComponent() const;
@@ -105,7 +104,6 @@ namespace BlackGui
private: private:
QScopedPointer <Ui::CDataInfoAreaComponent> ui; QScopedPointer <Ui::CDataInfoAreaComponent> ui;
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -17,6 +17,7 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Simulation::Settings; using namespace BlackMisc::Simulation::Settings;
using namespace BlackGui::Settings; using namespace BlackGui::Settings;
using namespace BlackCore::Db;
namespace BlackGui namespace BlackGui
{ {
@@ -52,7 +53,7 @@ namespace BlackGui
return ok ? secs : -1; return ok ? secs : -1;
} }
void CSettingsModelComponent::setBackgroundUpdater(const BlackCore::Db::CBackgroundDataUpdater *updater) void CSettingsModelComponent::setBackgroundUpdater(const CBackgroundDataUpdater *updater)
{ {
m_updater = updater; m_updater = updater;
} }
@@ -86,7 +87,7 @@ namespace BlackGui
const bool updater = const bool updater =
on && on &&
sApp && !sApp->isShuttingDown() && sApp && !sApp->isShuttingDown() &&
this->m_updater && this->m_updater->isEnabled(); m_updater && m_updater->isEnabled();
ui->comp_Led->setOn(updater); ui->comp_Led->setOn(updater);
// avoid unnecessary roundtrips // avoid unnecessary roundtrips

View File

@@ -43,7 +43,7 @@ namespace BlackGui
QMainWindow(parent), QMainWindow(parent),
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "framelessInfoArea", this) CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "framelessInfoArea", this)
{ {
this->ps_setWholeInfoAreaFloating(this->m_infoAreaFloating); this->ps_setWholeInfoAreaFloating(m_infoAreaFloating);
} }
CInfoArea::~CInfoArea() CInfoArea::~CInfoArea()
@@ -52,10 +52,10 @@ namespace BlackGui
void CInfoArea::initInfoArea() void CInfoArea::initInfoArea()
{ {
// after(!) GUI is setup // after(!) GUI is setup
if (this->m_dockWidgetInfoAreas.isEmpty()) if (m_dockWidgetInfoAreas.isEmpty())
{ {
this->m_dockWidgetInfoAreas = this->findOwnDockWidgetInfoAreas(); m_dockWidgetInfoAreas = this->findOwnDockWidgetInfoAreas();
Q_ASSERT(!this->m_dockWidgetInfoAreas.isEmpty()); Q_ASSERT(!m_dockWidgetInfoAreas.isEmpty());
} }
this->ps_setDockArea(Qt::TopDockWidgetArea); this->ps_setDockArea(Qt::TopDockWidgetArea);
@@ -93,7 +93,7 @@ namespace BlackGui
lockTabBarMenuAction->setIconText("Lock tab bar"); lockTabBarMenuAction->setIconText("Lock tab bar");
lockTabBarMenuAction->setIcon(CIcons::lockClosed16()); lockTabBarMenuAction->setIcon(CIcons::lockClosed16());
lockTabBarMenuAction->setCheckable(true); lockTabBarMenuAction->setCheckable(true);
lockTabBarMenuAction->setChecked(this->m_lockTabBar); lockTabBarMenuAction->setChecked(m_lockTabBar);
menu->addAction(lockTabBarMenuAction); menu->addAction(lockTabBarMenuAction);
connect(lockTabBarMenuAction, &QAction::toggled, this, &CInfoArea::ps_toggleTabBarLocked); connect(lockTabBarMenuAction, &QAction::toggled, this, &CInfoArea::ps_toggleTabBarLocked);
@@ -111,9 +111,9 @@ namespace BlackGui
QSignalMapper *signalMapperToggleFloating = new QSignalMapper(menu); QSignalMapper *signalMapperToggleFloating = new QSignalMapper(menu);
bool c = false; // check connections bool c = false; // check connections
for (int i = 0; i < this->m_dockWidgetInfoAreas.size(); i++) for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
{ {
const CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(i); const CDockWidgetInfoArea *dw = m_dockWidgetInfoAreas.at(i);
const QString t = dw->windowTitleBackup(); const QString t = dw->windowTitleBackup();
const QPixmap pm = indexToPixmap(i); const QPixmap pm = indexToPixmap(i);
QAction *toggleFloatingMenuAction = new QAction(menu); QAction *toggleFloatingMenuAction = new QAction(menu);
@@ -145,7 +145,7 @@ namespace BlackGui
showMenuText->setIconText("Show tab text"); showMenuText->setIconText("Show tab text");
showMenuText->setIcon(CIcons::headingOne16()); showMenuText->setIcon(CIcons::headingOne16());
showMenuText->setCheckable(true); showMenuText->setCheckable(true);
showMenuText->setChecked(this->m_showTabTexts); showMenuText->setChecked(m_showTabTexts);
menu->addAction(showMenuText); menu->addAction(showMenuText);
connect(showMenuText, &QAction::toggled, this, &CInfoArea::ps_showTabTexts); connect(showMenuText, &QAction::toggled, this, &CInfoArea::ps_showTabTexts);
@@ -155,7 +155,7 @@ namespace BlackGui
showTabbar->setIconText("Show tab bar"); showTabbar->setIconText("Show tab bar");
showTabbar->setIcon(CIcons::dockBottom16()); showTabbar->setIcon(CIcons::dockBottom16());
showTabbar->setCheckable(true); showTabbar->setCheckable(true);
showTabbar->setChecked(this->m_showTabBar); showTabbar->setChecked(m_showTabBar);
menu->addAction(showTabbar); menu->addAction(showTabbar);
connect(showTabbar, &QAction::toggled, this, &CInfoArea::ps_showTabBar); connect(showTabbar, &QAction::toggled, this, &CInfoArea::ps_showTabBar);
@@ -177,7 +177,7 @@ namespace BlackGui
// we assume that there can only be 1, non floating info area, // we assume that there can only be 1, non floating info area,
// which is the only visible one // which is the only visible one
// selecting is tab text independent (can be hidden) // selecting is tab text independent (can be hidden)
if (!this->m_tabBar || this->m_tabBar->count() < 1) { return nullptr; } if (!m_tabBar || m_tabBar->count() < 1) { return nullptr; }
for (const CDockWidgetInfoArea *ia : m_dockWidgetInfoAreas) for (const CDockWidgetInfoArea *ia : m_dockWidgetInfoAreas)
{ {
if (ia->isFloating()) { continue; } if (ia->isFloating()) { continue; }
@@ -293,7 +293,7 @@ namespace BlackGui
QList<int> indexes; QList<int> indexes;
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++) for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
{ {
if (this->m_dockWidgetInfoAreas.at(i)->isFloating() == floating) if (m_dockWidgetInfoAreas.at(i)->isFloating() == floating)
{ {
indexes.append(i); indexes.append(i);
} }
@@ -332,7 +332,7 @@ namespace BlackGui
void CInfoArea::adjustSizeForAllDockWidgets() void CInfoArea::adjustSizeForAllDockWidgets()
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
dw->adjustSize(); dw->adjustSize();
} }
@@ -340,7 +340,7 @@ namespace BlackGui
void CInfoArea::floatAllWidgets() void CInfoArea::floatAllWidgets()
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
if (dw->isFloating()) continue; if (dw->isFloating()) continue;
dw->toggleFloating(); dw->toggleFloating();
@@ -349,13 +349,13 @@ namespace BlackGui
void CInfoArea::toggleFloatingWholeInfoArea() void CInfoArea::toggleFloatingWholeInfoArea()
{ {
this->ps_setWholeInfoAreaFloating(!this->m_infoAreaFloating); this->ps_setWholeInfoAreaFloating(!m_infoAreaFloating);
} }
void CInfoArea::toggleFloatingByIndex(int areaIndex) void CInfoArea::toggleFloatingByIndex(int areaIndex)
{ {
if (!this->isValidAreaIndex(areaIndex)) { return; } if (!this->isValidAreaIndex(areaIndex)) { return; }
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex); CDockWidgetInfoArea *dw = m_dockWidgetInfoAreas.at(areaIndex);
BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area"); BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area");
if (!dw) { return; } if (!dw) { return; }
dw->toggleFloating(); dw->toggleFloating();
@@ -364,7 +364,7 @@ namespace BlackGui
void CInfoArea::toggleVisibility(int areaIndex) void CInfoArea::toggleVisibility(int areaIndex)
{ {
if (!this->isValidAreaIndex(areaIndex)) { return; } if (!this->isValidAreaIndex(areaIndex)) { return; }
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex); CDockWidgetInfoArea *dw = m_dockWidgetInfoAreas.at(areaIndex);
BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area"); BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area");
if (!dw) { return; } if (!dw) { return; }
dw->toggleVisibility(); dw->toggleVisibility();
@@ -372,10 +372,10 @@ namespace BlackGui
void CInfoArea::selectArea(int areaIndex) void CInfoArea::selectArea(int areaIndex)
{ {
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex); CDockWidgetInfoArea *dw = m_dockWidgetInfoAreas.at(areaIndex);
BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area"); BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area");
if (!dw) { return; } if (!dw) { return; }
Q_ASSERT(this->m_tabBar); Q_ASSERT(m_tabBar);
if (m_tabBar->count() < 1) { return; } if (m_tabBar->count() < 1) { return; }
if (dw->isFloating()) if (dw->isFloating())
@@ -390,7 +390,7 @@ namespace BlackGui
void CInfoArea::resetPosition(int areaIndex) void CInfoArea::resetPosition(int areaIndex)
{ {
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex); CDockWidgetInfoArea *dw = m_dockWidgetInfoAreas.at(areaIndex);
BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area"); BLACK_VERIFY_X(dw, Q_FUNC_INFO, "Missing info area");
if (!dw) { return; } if (!dw) { return; }
dw->resetPosition(); dw->resetPosition();
@@ -436,7 +436,7 @@ namespace BlackGui
void CInfoArea::restoreDockWidgetInfoAreaByIndex(int areaIndex) void CInfoArea::restoreDockWidgetInfoAreaByIndex(int areaIndex)
{ {
if (!this->isValidAreaIndex(areaIndex)) { return; } if (!this->isValidAreaIndex(areaIndex)) { return; }
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex); CDockWidgetInfoArea *dw = m_dockWidgetInfoAreas.at(areaIndex);
Q_ASSERT(dw); Q_ASSERT(dw);
if (!dw) return; if (!dw) return;
dw->restoreFromSettings(); dw->restoreFromSettings();
@@ -444,35 +444,35 @@ namespace BlackGui
void CInfoArea::selectLeftTab() void CInfoArea::selectLeftTab()
{ {
if (!this->m_tabBar) return; if (!m_tabBar) return;
if (this->m_tabBar->count() < 2) return; if (m_tabBar->count() < 2) return;
if (this->m_tabBar->currentIndex() > 0) if (m_tabBar->currentIndex() > 0)
{ {
this->m_tabBar->setCurrentIndex(this->m_tabBar->currentIndex() - 1); m_tabBar->setCurrentIndex(m_tabBar->currentIndex() - 1);
} }
else else
{ {
this->m_tabBar->setCurrentIndex(this->m_tabBar->count() - 1); m_tabBar->setCurrentIndex(m_tabBar->count() - 1);
} }
} }
void CInfoArea::selectRightTab() void CInfoArea::selectRightTab()
{ {
if (!this->m_tabBar) return; if (!m_tabBar) return;
if (this->m_tabBar->count() < 2) return; if (m_tabBar->count() < 2) return;
if (this->m_tabBar->currentIndex() < this->m_tabBar->count() - 2) if (m_tabBar->currentIndex() < m_tabBar->count() - 2)
{ {
this->m_tabBar->setCurrentIndex(this->m_tabBar->currentIndex() + 1); m_tabBar->setCurrentIndex(m_tabBar->currentIndex() + 1);
} }
else else
{ {
this->m_tabBar->setCurrentIndex(0); m_tabBar->setCurrentIndex(0);
} }
} }
void CInfoArea::displayStatusMessage(const CStatusMessage &statusMessage) void CInfoArea::displayStatusMessage(const CStatusMessage &statusMessage)
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
dw->displayStatusMessage(statusMessage); dw->displayStatusMessage(statusMessage);
} }
@@ -484,7 +484,7 @@ namespace BlackGui
void CInfoArea::displayStatusMessages(const CStatusMessageList &statusMessages) void CInfoArea::displayStatusMessages(const CStatusMessageList &statusMessages)
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
dw->displayStatusMessages(statusMessages); dw->displayStatusMessages(statusMessages);
} }
@@ -496,7 +496,7 @@ namespace BlackGui
void CInfoArea::ps_setDockArea(Qt::DockWidgetArea area) void CInfoArea::ps_setDockArea(Qt::DockWidgetArea area)
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
Qt::DockWidgetAreas newAreas = static_cast<Qt::DockWidgetAreas>(area); Qt::DockWidgetAreas newAreas = static_cast<Qt::DockWidgetAreas>(area);
Qt::DockWidgetAreas oldAreas = dw->allowedAreas(); Qt::DockWidgetAreas oldAreas = dw->allowedAreas();
@@ -509,8 +509,8 @@ namespace BlackGui
void CInfoArea::ps_setWholeInfoAreaFloating(bool floating) void CInfoArea::ps_setWholeInfoAreaFloating(bool floating)
{ {
// float whole info area // float whole info area
this->m_infoAreaFloating = floating; m_infoAreaFloating = floating;
if (this->m_infoAreaFloating) if (m_infoAreaFloating)
{ {
QPoint p = CGuiUtility::mainWindowPosition(); QPoint p = CGuiUtility::mainWindowPosition();
this->setWindowFlags(Qt::Dialog); this->setWindowFlags(Qt::Dialog);
@@ -523,7 +523,7 @@ namespace BlackGui
// https://qt-project.org/forums/viewthread/17519 // https://qt-project.org/forums/viewthread/17519
// http://www.qtcentre.org/threads/12569-QMainWindow-as-a-child-of-QMainWindow // http://www.qtcentre.org/threads/12569-QMainWindow-as-a-child-of-QMainWindow
// this->setParent(this->m_originalParent, this->windowFlags() & ~Qt::Window); // this->setParent(m_originalParent, this->windowFlags() & ~Qt::Window);
this->setWindowFlags(this->windowFlags() & ~Qt::Window); this->setWindowFlags(this->windowFlags() & ~Qt::Window);
// RW: The line below is commented to prevent making this widget visible as a top window // RW: The line below is commented to prevent making this widget visible as a top window
@@ -539,12 +539,12 @@ namespace BlackGui
void CInfoArea::tabifyAllWidgets() void CInfoArea::tabifyAllWidgets()
{ {
this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East); this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East);
bool init = this->m_tabBar ? false : true; bool init = m_tabBar ? false : true;
for (int i = 0; i < this->m_dockWidgetInfoAreas.size(); i++) for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
{ {
CDockWidgetInfoArea *first = i > 0 ? this->m_dockWidgetInfoAreas.at(i - 1) : nullptr; CDockWidgetInfoArea *first = i > 0 ? m_dockWidgetInfoAreas.at(i - 1) : nullptr;
CDockWidgetInfoArea *after = this->m_dockWidgetInfoAreas.at(i); CDockWidgetInfoArea *after = m_dockWidgetInfoAreas.at(i);
Q_ASSERT(after); Q_ASSERT(after);
// trick, init widget as floating // trick, init widget as floating
@@ -577,46 +577,46 @@ namespace BlackGui
// as now tabified, now set tab // as now tabified, now set tab
if (init) if (init)
{ {
this->m_tabBar = this->findChild<QTabBar *>(); m_tabBar = this->findChild<QTabBar *>();
// if we have > 1 docked widgets, we have a tab bar // if we have > 1 docked widgets, we have a tab bar
if (this->m_tabBar) if (m_tabBar)
{ {
QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab()); QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab());
this->m_tabBar->setStyleSheet(qss); m_tabBar->setStyleSheet(qss);
this->m_tabBar->setObjectName("comp_MainInfoAreaDockWidgetTab"); m_tabBar->setObjectName("comp_MainInfoAreaDockWidgetTab");
this->m_tabBar->setMovable(false); m_tabBar->setMovable(false);
this->m_tabBar->setElideMode(Qt::ElideNone); m_tabBar->setElideMode(Qt::ElideNone);
this->m_tabBar->setUsesScrollButtons(true); m_tabBar->setUsesScrollButtons(true);
// East / West does not work (shown, but area itself empty) // East / West does not work (shown, but area itself empty)
// South does not have any effect // South does not have any effect
this->m_tabBar->setShape(QTabBar::TriangularSouth); m_tabBar->setShape(QTabBar::TriangularSouth);
// signals // signals
connect(this->m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::ps_tabBarDoubleClicked); connect(m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::ps_tabBarDoubleClicked);
connect(this->m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::ps_onTabBarIndexChanged); connect(m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::ps_onTabBarIndexChanged);
} }
else else
{ {
// <= 1 dock widget // <= 1 dock widget
this->m_tabBar = new QTabBar(this); m_tabBar = new QTabBar(this);
this->m_tabBar->hide(); m_tabBar->hide();
} }
} }
// set current index, and always set pixmaps // set current index, and always set pixmaps
if (this->countDockedWidgetInfoAreas() > 0) { this->m_tabBar->setCurrentIndex(0); } if (this->countDockedWidgetInfoAreas() > 0) { m_tabBar->setCurrentIndex(0); }
if (this->m_tabBar->count() > 0) { this->setTabPixmaps(); } if (m_tabBar->count() > 0) { this->setTabPixmaps(); }
} }
void CInfoArea::unTabifyAllWidgets() void CInfoArea::unTabifyAllWidgets()
{ {
if (this->m_dockWidgetInfoAreas.size() < 2) return; if (m_dockWidgetInfoAreas.size() < 2) return;
CDockWidgetInfoArea *first = this->m_dockWidgetInfoAreas.first(); CDockWidgetInfoArea *first = m_dockWidgetInfoAreas.first();
for (int i = 1; i < this->m_dockWidgetInfoAreas.size(); i++) for (int i = 1; i < m_dockWidgetInfoAreas.size(); i++)
{ {
CDockWidgetInfoArea *after = this->m_dockWidgetInfoAreas.at(i); CDockWidgetInfoArea *after = m_dockWidgetInfoAreas.at(i);
Q_ASSERT(after); Q_ASSERT(after);
this->splitDockWidget(first, after, Qt::Horizontal); this->splitDockWidget(first, after, Qt::Horizontal);
} }
@@ -624,13 +624,13 @@ namespace BlackGui
bool CInfoArea::isValidAreaIndex(int areaIndex) const bool CInfoArea::isValidAreaIndex(int areaIndex) const
{ {
if (!this->m_tabBar) { return false; } if (!m_tabBar) { return false; }
return areaIndex >= 0 && areaIndex < this->m_dockWidgetInfoAreas.size(); return areaIndex >= 0 && areaIndex < m_dockWidgetInfoAreas.size();
} }
void CInfoArea::connectTopLevelChanged() void CInfoArea::connectTopLevelChanged()
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
connect(dw, &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CInfoArea::ps_onWidgetTopLevelChanged); connect(dw, &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CInfoArea::ps_onWidgetTopLevelChanged);
} }
@@ -676,15 +676,15 @@ namespace BlackGui
int CInfoArea::countDockedWidgetInfoAreas() const int CInfoArea::countDockedWidgetInfoAreas() const
{ {
if (!this->m_tabBar) return 0; if (!m_tabBar) return 0;
return this->m_tabBar->count(); return m_tabBar->count();
} }
CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex) const CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex) const
{ {
if (tabBarIndex >= this->m_dockWidgetInfoAreas.count() || tabBarIndex < 0) { return nullptr; } if (tabBarIndex >= m_dockWidgetInfoAreas.count() || tabBarIndex < 0) { return nullptr; }
if (!this->m_tabBar) { return nullptr; } if (!m_tabBar) { return nullptr; }
const QString t(this->m_tabBar->tabText(tabBarIndex)); const QString t(m_tabBar->tabText(tabBarIndex));
// we have a title and search by that (best option, as order does not matter) // we have a title and search by that (best option, as order does not matter)
if (!t.isEmpty()) { return getDockWidgetInfoAreaByWindowTitle(t); } if (!t.isEmpty()) { return getDockWidgetInfoAreaByWindowTitle(t); }
@@ -692,7 +692,7 @@ namespace BlackGui
// no title, we assume the n-th not floating tab is correct // no title, we assume the n-th not floating tab is correct
// this will work if the order in m_dockWidgetInfoAreas matches // this will work if the order in m_dockWidgetInfoAreas matches
int c = 0; int c = 0;
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
if (dw->isFloating()) { continue; } if (dw->isFloating()) { continue; }
if (c == tabBarIndex) { return dw; } if (c == tabBarIndex) { return dw; }
@@ -705,7 +705,7 @@ namespace BlackGui
CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByWindowTitle(const QString &title) const CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByWindowTitle(const QString &title) const
{ {
Q_ASSERT_X(!title.isEmpty(), Q_FUNC_INFO, "No title"); Q_ASSERT_X(!title.isEmpty(), Q_FUNC_INFO, "No title");
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
if (CGuiUtility::lenientTitleComparison(dw->windowTitleOrBackup(), title)) { return dw; } if (CGuiUtility::lenientTitleComparison(dw->windowTitleOrBackup(), title)) { return dw; }
} }
@@ -745,7 +745,7 @@ namespace BlackGui
void CInfoArea::selectArea(const CDockWidgetInfoArea *dockWidgetInfoArea) void CInfoArea::selectArea(const CDockWidgetInfoArea *dockWidgetInfoArea)
{ {
if (!this->m_tabBar) { return; } if (!m_tabBar) { return; }
int tabIndex = this->dockWidgetInfoAreaToTabBarIndex(dockWidgetInfoArea); int tabIndex = this->dockWidgetInfoAreaToTabBarIndex(dockWidgetInfoArea);
if (tabIndex >= 0 && tabIndex < m_tabBar->count()) if (tabIndex >= 0 && tabIndex < m_tabBar->count())
{ {
@@ -755,7 +755,7 @@ namespace BlackGui
void CInfoArea::setFeaturesForDockableWidgets(QDockWidget::DockWidgetFeatures features) void CInfoArea::setFeaturesForDockableWidgets(QDockWidget::DockWidgetFeatures features)
{ {
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
dw->setFeatures(features); dw->setFeatures(features);
} }
@@ -763,18 +763,18 @@ namespace BlackGui
void CInfoArea::setTabPixmaps() void CInfoArea::setTabPixmaps()
{ {
if (!this->m_tabBar) { return; } if (!m_tabBar) { return; }
for (int i = 0; i < this->m_tabBar->count(); i++) for (int i = 0; i < m_tabBar->count(); i++)
{ {
const QString t(this->m_tabBar->tabText(i)); const QString t(m_tabBar->tabText(i));
int areaIndex = t.isEmpty() ? i : this->getAreaIndexByWindowTitle(t); const int areaIndex = t.isEmpty() ? i : this->getAreaIndexByWindowTitle(t);
this->m_tabBar->setTabIcon(i, indexToPixmap(areaIndex)); m_tabBar->setTabIcon(i, indexToPixmap(areaIndex));
} }
} }
void CInfoArea::ps_tabBarDoubleClicked(int tabBarIndex) void CInfoArea::ps_tabBarDoubleClicked(int tabBarIndex)
{ {
if (this->m_lockTabBar) if (m_lockTabBar)
{ {
CLogMessage(this).info("Locked, double click will not cause floating"); CLogMessage(this).info("Locked, double click will not cause floating");
return; return;
@@ -796,7 +796,7 @@ namespace BlackGui
// select index // select index
if (!topLevel) if (!topLevel)
{ {
CDockWidgetInfoArea *dwia = dynamic_cast<CDockWidgetInfoArea *>(dockWidget); const CDockWidgetInfoArea *dwia = dynamic_cast<CDockWidgetInfoArea *>(dockWidget);
this->selectArea(dwia); this->selectArea(dwia);
} }
@@ -807,10 +807,10 @@ namespace BlackGui
void CInfoArea::ps_onStyleSheetChanged() void CInfoArea::ps_onStyleSheetChanged()
{ {
if (this->m_tabBar) if (m_tabBar)
{ {
QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab()); const QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab());
this->m_tabBar->setStyleSheet(qss); m_tabBar->setStyleSheet(qss);
} }
} }
@@ -826,9 +826,9 @@ namespace BlackGui
void CInfoArea::ps_showTabTexts(bool show) void CInfoArea::ps_showTabTexts(bool show)
{ {
if (show == this->m_showTabTexts) { return; } if (show == m_showTabTexts) { return; }
this->m_showTabTexts = show; m_showTabTexts = show;
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) for (CDockWidgetInfoArea *dw : m_dockWidgetInfoAreas)
{ {
dw->showTitleWhenDocked(show); dw->showTitleWhenDocked(show);
} }
@@ -836,17 +836,17 @@ namespace BlackGui
void CInfoArea::ps_showTabBar(bool show) void CInfoArea::ps_showTabBar(bool show)
{ {
if (show == this->m_showTabBar) return; if (show == m_showTabBar) return;
this->m_showTabBar = show; m_showTabBar = show;
if (!this->m_tabBar) return; if (!m_tabBar) return;
this->m_tabBar->setVisible(show); // not working, but setting right value will not harm anything m_tabBar->setVisible(show); // not working, but setting right value will not harm anything
this->m_tabBar->setMaximumHeight(show ? 10000 : 0); // does the trick m_tabBar->setMaximumHeight(show ? 10000 : 0); // does the trick
this->adjustSizeForAllDockWidgets(); this->adjustSizeForAllDockWidgets();
} }
void CInfoArea::ps_toggleTabBarLocked(bool locked) void CInfoArea::ps_toggleTabBarLocked(bool locked)
{ {
this->m_lockTabBar = locked; m_lockTabBar = locked;
} }
void CInfoArea::ps_setTabBarPosition(QTabWidget::TabPosition position) void CInfoArea::ps_setTabBarPosition(QTabWidget::TabPosition position)

View File

@@ -90,19 +90,19 @@ namespace BlackGui
if (model.hasFileName()) if (model.hasFileName())
{ {
menuActions.addMenuSimulator(); menuActions.addMenuSimulator();
this->m_fileAction = menuActions.addAction(this->m_fileAction, CIcons::text16(), "Open simulator file", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::showSimulatorFile }); m_fileAction = menuActions.addAction(m_fileAction, CIcons::text16(), "Open simulator file", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::showSimulatorFile });
added = true; added = true;
if (CModelConverterX::supportsModelConverterX()) if (CModelConverterX::supportsModelConverterX())
{ {
this->m_modelConverterX = menuActions.addAction(this->m_modelConverterX, CIcons::modelConverterX(), "ModelConverterX", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::startModelConverterX }); m_modelConverterX = menuActions.addAction(m_modelConverterX, CIcons::modelConverterX(), "ModelConverterX", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::startModelConverterX });
} }
} }
if (this->m_messageFrame && !model.getIconPath().isEmpty()) if (m_messageFrame && !model.getIconPath().isEmpty())
{ {
added = true; added = true;
menuActions.addMenuSimulator(); menuActions.addMenuSimulator();
this->m_iconAction = menuActions.addAction(this->m_iconAction, CIcons::appAircraft16(), "Display icon", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::displayIcon }); m_iconAction = menuActions.addAction(m_iconAction, CIcons::appAircraft16(), "Display icon", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::displayIcon });
} }
if (added) if (added)
@@ -136,7 +136,7 @@ namespace BlackGui
const CPixmap pm(model.loadIcon(msg)); const CPixmap pm(model.loadIcon(msg));
if (msg.isSuccess()) if (msg.isSuccess())
{ {
this->m_messageFrame->showOverlayImage(pm); m_messageFrame->showOverlayImage(pm);
} }
else else
{ {
@@ -181,10 +181,10 @@ namespace BlackGui
menuActions.addMenuConsolidateModels(); menuActions.addMenuConsolidateModels();
this->m_consolidateAll = menuActions.addAction(this->m_consolidateAll, CIcons::databaseEdit16(), "All with DB data", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithDbDataMenu::consolidateData }); m_consolidateAll = menuActions.addAction(m_consolidateAll, CIcons::databaseEdit16(), "All with DB data", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithDbDataMenu::consolidateData });
if (mv->hasSelection()) if (mv->hasSelection())
{ {
this->m_consolidateSelected = menuActions.addAction(this->m_consolidateSelected, CIcons::databaseEdit16(), "Selected with DB data", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithDbDataMenu::consolidateSelectedData }); m_consolidateSelected = menuActions.addAction(m_consolidateSelected, CIcons::databaseEdit16(), "Selected with DB data", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithDbDataMenu::consolidateSelectedData });
} }
this->nestedCustomMenu(menuActions); this->nestedCustomMenu(menuActions);
} }
@@ -252,12 +252,12 @@ namespace BlackGui
IModelsSetable *CConsolidateWithDbDataMenu::modelsTargetSetable() const IModelsSetable *CConsolidateWithDbDataMenu::modelsTargetSetable() const
{ {
return qobject_cast<IModelsSetable *>(this->m_modelsTarget); return qobject_cast<IModelsSetable *>(m_modelsTarget);
} }
IModelsUpdatable *CConsolidateWithDbDataMenu::modelsTargetUpdatable() const IModelsUpdatable *CConsolidateWithDbDataMenu::modelsTargetUpdatable() const
{ {
return qobject_cast<IModelsUpdatable *>(this->m_modelsTarget); return qobject_cast<IModelsUpdatable *>(m_modelsTarget);
} }
// --------------------------------- with simulator models --------------------------------- // --------------------------------- with simulator models ---------------------------------
@@ -288,10 +288,10 @@ namespace BlackGui
menuActions.addMenuConsolidateModels(); menuActions.addMenuConsolidateModels();
this->m_consolidateAll = menuActions.addAction(this->m_consolidateAll, CIcons::appModels16(), "All with simulator models", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateData }); m_consolidateAll = menuActions.addAction(m_consolidateAll, CIcons::appModels16(), "All with simulator models", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateData });
if (mv->hasSelection()) if (mv->hasSelection())
{ {
this->m_consolidateSelected = menuActions.addAction(this->m_consolidateSelected, CIcons::appModels16(), "Selected with simulator models", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateSelectedData }); m_consolidateSelected = menuActions.addAction(m_consolidateSelected, CIcons::appModels16(), "Selected with simulator models", CMenuAction::pathViewModelsConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateSelectedData });
} }
this->nestedCustomMenu(menuActions); this->nestedCustomMenu(menuActions);
} }
@@ -362,31 +362,31 @@ namespace BlackGui
IModelsPerSimulatorSetable *CConsolidateWithSimulatorModels::modelsTargetSetable() const IModelsPerSimulatorSetable *CConsolidateWithSimulatorModels::modelsTargetSetable() const
{ {
return qobject_cast<IModelsPerSimulatorSetable *>(this->m_modelsTarget); return qobject_cast<IModelsPerSimulatorSetable *>(m_modelsTarget);
} }
IModelsPerSimulatorUpdatable *CConsolidateWithSimulatorModels::modelsTargetUpdatable() const IModelsPerSimulatorUpdatable *CConsolidateWithSimulatorModels::modelsTargetUpdatable() const
{ {
return qobject_cast<IModelsPerSimulatorUpdatable *>(this->m_modelsTarget); return qobject_cast<IModelsPerSimulatorUpdatable *>(m_modelsTarget);
} }
ISimulatorSelectable *CConsolidateWithSimulatorModels::simulatorSelectable() const ISimulatorSelectable *CConsolidateWithSimulatorModels::simulatorSelectable() const
{ {
return qobject_cast<ISimulatorSelectable *>(this->m_modelsTarget); return qobject_cast<ISimulatorSelectable *>(m_modelsTarget);
} }
Components::CDbMappingComponent *CConsolidateWithSimulatorModels::getMappingComponent() const Components::CDbMappingComponent *CConsolidateWithSimulatorModels::getMappingComponent() const
{ {
// try to cast target // try to cast target
CDbMappingComponent *mc = nullptr; CDbMappingComponent *mc = nullptr;
CDbMappingComponentAware *mca = qobject_cast<CDbMappingComponentAware *>(this->m_modelsTarget); CDbMappingComponentAware *mca = qobject_cast<CDbMappingComponentAware *>(m_modelsTarget);
if (mca) if (mca)
{ {
mc = mca->getMappingComponent(); mc = mca->getMappingComponent();
} }
if (!mc) if (!mc)
{ {
mc = qobject_cast<CDbMappingComponent *>(this->m_modelsTarget); mc = qobject_cast<CDbMappingComponent *>(m_modelsTarget);
} }
return mc; return mc;
} }

View File

@@ -14,17 +14,17 @@ namespace BlackMisc
{ {
CConnectionGuard::CConnectionGuard(const QMetaObject::Connection &connection) CConnectionGuard::CConnectionGuard(const QMetaObject::Connection &connection)
{ {
this->m_connections.append(connection); m_connections.append(connection);
} }
void CConnectionGuard::append(const QMetaObject::Connection &connection) void CConnectionGuard::append(const QMetaObject::Connection &connection)
{ {
this->m_connections.append(connection); m_connections.append(connection);
} }
void CConnectionGuard::append(const QList<QMetaObject::Connection> &connections) void CConnectionGuard::append(const QList<QMetaObject::Connection> &connections)
{ {
this->m_connections.append(connections); m_connections.append(connections);
} }
CConnectionGuard::~CConnectionGuard() CConnectionGuard::~CConnectionGuard()
@@ -34,13 +34,13 @@ namespace BlackMisc
int CConnectionGuard::disconnectAll() int CConnectionGuard::disconnectAll()
{ {
if (this->m_connections.isEmpty()) { return 0; } if (m_connections.isEmpty()) { return 0; }
int c = 0; int c = 0;
for (const QMetaObject::Connection &con : as_const(this->m_connections)) for (const QMetaObject::Connection &con : as_const(m_connections))
{ {
if (QObject::disconnect(con)) { c++; } if (QObject::disconnect(con)) { c++; }
} }
this->m_connections.clear(); m_connections.clear();
return c; return c;
} }
} // ns } // ns

View File

@@ -173,7 +173,7 @@ namespace BlackMisc
const QString &CDirectoryUtils::staticDbFilesDirectory() const QString &CDirectoryUtils::staticDbFilesDirectory()
{ {
static QString s(getSwiftStaticDbFilesDirImpl()); static const QString s(getSwiftStaticDbFilesDirImpl());
return s; return s;
} }
@@ -188,7 +188,7 @@ namespace BlackMisc
const QString &CDirectoryUtils::soundFilesDirectory() const QString &CDirectoryUtils::soundFilesDirectory()
{ {
static QString s(getSoundFilesDirImpl()); static const QString s(getSoundFilesDirImpl());
return s; return s;
} }
@@ -203,7 +203,7 @@ namespace BlackMisc
const QString &CDirectoryUtils::stylesheetsDirectory() const QString &CDirectoryUtils::stylesheetsDirectory()
{ {
static QString s(getStylesheetsDirImpl()); static const QString s(getStylesheetsDirImpl());
return s; return s;
} }

View File

@@ -48,7 +48,7 @@ namespace BlackMisc
{ {
QString s(string.trimmed().toLower()); QString s(string.trimmed().toLower());
if (s.isEmpty()) { return false; } if (s.isEmpty()) { return false; }
QChar c = s.at(0); const QChar c = s.at(0);
// explicit values // explicit values
if (c == '1' || c == 't' || c == 'y' || c == 'x') { return true; } if (c == '1' || c == 't' || c == 'y' || c == 'x') { return true; }