refs #452 the mapping tool (swiftdata)

This commit is contained in:
Klaus Basan
2015-09-24 02:01:26 +02:00
committed by Mathew Sutcliffe
parent 8281ef5910
commit 8b5bec3a15
5 changed files with 295 additions and 38 deletions

View File

@@ -9,12 +9,12 @@
#include "swiftdata.h"
#include "ui_swiftdata.h"
#include "blackgui/components/logcomponent.h"
#include "blackgui/components/datamaininfoareacomponent.h"
#include "blackgui/components/datamappingcomponent.h"
#include "blackgui/components/datainfoareacomponent.h"
#include "blackgui/components/logcomponent.h"
#include "blackgui/components/enableforruntime.h"
#include "blackgui/stylesheetutility.h"
#include "blackcore/web_datareader.h"
#include "blackcore/webdataservices.h"
#include "blackmisc/icon.h"
#include "blackmisc/loghandler.h"
#include "blackmisc/project.h"
@@ -28,8 +28,10 @@ using namespace BlackGui;
using namespace BlackGui::Components;
CSwiftData::CSwiftData(QWidget *parent) :
QMainWindow(parent), CIdentifiable(this), ui(new Ui::CSwiftData),
m_webDataReader(new CWebDataReader(CWebDataReader::AllSwiftDbReaders))
QMainWindow(parent),
CIdentifiable(this),
ui(new Ui::CSwiftData),
m_webDataReader(new CWebDataServices(CWebReaderFlags::AllSwiftDbReaders))
{
ui->setupUi(this);
this->init();
@@ -50,9 +52,21 @@ void CSwiftData::initStyleSheet()
CSwiftData::~CSwiftData()
{ }
void CSwiftData::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event);
this->performGracefulShutdown();
QApplication::exit();
}
void CSwiftData::ps_appendLogMessage(const CStatusMessage &message)
{
ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToList(message);
CLogComponent *logComponent = ui->comp_MainInfoArea->getLogComponent();
Q_ASSERT_X(logComponent, Q_FUNC_INFO, "missing log component");
logComponent->appendStatusMessageToList(message);
// status bar
m_statusBar.displayStatusMessage(message);
}
void CSwiftData::ps_onStyleSheetsChanged()
@@ -66,12 +80,16 @@ void CSwiftData::init()
this->setWindowTitle(QString("swiftdata %1").arg(CProject::version()));
this->setObjectName("CSwiftData");
this->initStyleSheet();
this->initLogDisplay();
connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CSwiftData::ps_onStyleSheetsChanged);
this->initReaders();
this->initMenu();
}
void CSwiftData::initLogDisplay()
{
this->m_statusBar.initStatusBar(this->ui->sb_SwiftData);
CLogHandler::instance()->install(true);
CLogHandler::instance()->enableConsoleOutput(false); // default disable
auto logHandler = CLogHandler::instance()->handlerForPattern(
@@ -83,9 +101,35 @@ void CSwiftData::initLogDisplay()
void CSwiftData::initReaders()
{
CDataMappingComponent *mc = this->ui->comp_MainInfoArea->getMappingComponent();
Q_ASSERT_X(mc, Q_FUNC_INFO, "Missing mapping component");
Q_ASSERT_X(this->m_webDataReader, Q_FUNC_INFO, "Missing reader");
mc->readersInitialized(this->m_webDataReader);
this->m_webDataReader->readAllInBackground(1000); // kick of readers
this->ui->comp_MainInfoArea->setProvider(this->m_webDataReader);
this->ui->comp_InfoBar->setProvider(this->m_webDataReader);
this->m_webDataReader->readAllInBackground(1000); // kick of readers a little delayed
}
void CSwiftData::initMenu()
{
// menu
this->initDynamicMenus();
this->ui->menu_WindowMinimize->setIcon(this->style()->standardIcon(QStyle::SP_TitleBarMinButton));
connect(this->ui->menu_TestInternals, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_FileExit, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_WindowFont, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_WindowMinimize, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_WindowToggleOnTop, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_DebugMetaTypes, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_MappingMaxData, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
connect(this->ui->menu_MappingMaxMapping, &QAction::triggered, this, &CSwiftData::ps_onMenuClicked);
}
void CSwiftData::performGracefulShutdown()
{
if (this->m_webDataReader)
{
m_webDataReader->gracefulShutdown();
m_webDataReader = nullptr;
}
}

View File

@@ -14,20 +14,20 @@
#include "blackcore/context_runtime.h"
#include "blackgui/systemtraywindow.h"
#include "blackgui/components/enableforruntime.h"
#include "blackgui/managedstatusbar.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/identifiable.h"
#include <QScopedPointer>
namespace Ui { class CSwiftData; }
namespace BlackCore { class CWebDataReader; }
namespace BlackCore { class CWebDataServices; }
//! swift data entry control
/*!
* swift data entry control (aka mapping tool)
*/
class CSwiftData :
public QMainWindow,
public BlackMisc::CIdentifiable,
public BlackGui::Components::CEnableForRuntime
public BlackMisc::CIdentifiable
{
Q_OBJECT
@@ -38,6 +38,10 @@ public:
//! Destructor
~CSwiftData();
protected:
//! \copydoc QMainWindow::closeEvent
virtual void closeEvent(QCloseEvent *event) override;
private slots:
//! Append log message
void ps_appendLogMessage(const BlackMisc::CStatusMessage &message);
@@ -45,14 +49,21 @@ private slots:
//! Style sheet has changed
void ps_onStyleSheetsChanged();
//! Menu clicked
void ps_onMenuClicked();
private:
void init();
void initLogDisplay();
void initStyleSheet();
void initReaders();
void initMenu();
void initDynamicMenus();
void performGracefulShutdown();
QScopedPointer<Ui::CSwiftData> ui;
BlackGui::CManagedStatusBar m_statusBar;
BlackCore::CWebDataReader *m_webDataReader = nullptr;
BlackCore::CWebDataServices *m_webDataReader = nullptr;
};
#endif // guard

View File

@@ -2,6 +2,7 @@ include ($$SourceRoot/config.pri)
include ($$SourceRoot/build.pri)
QT += core dbus network xml multimedia gui svg
CONFIG += console
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

View File

@@ -2,24 +2,22 @@
<ui version="4.0">
<class>CSwiftData</class>
<widget class="QMainWindow" name="CSwiftData">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
<width>900</width>
<height>700</height>
</size>
</property>
<property name="windowTitle">
<string>swiftdata</string>
</property>
<widget class="QWidget" name="qw_CentralWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="vl_CentralWidget">
<property name="leftMargin">
<number>2</number>
@@ -33,6 +31,16 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Components::CInfoBarWebReadersStatusComponent" name="comp_InfoBar">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="sw_CentralWidget">
<property name="sizePolicy">
@@ -44,13 +52,8 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pq_MainInfoArea">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="BlackGui::Components::CDataMainInfoAreaComponent" name="comp_MainInfoArea" native="true"/>
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CDataMainInfoAreaComponent" name="comp_MainInfoArea"/>
<widget class="QWidget" name="emptyPage"/>
</widget>
</item>
</layout>
@@ -60,24 +63,132 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>1024</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<widget class="QMenu" name="menu_File">
<property name="title">
<string>File</string>
</property>
<addaction name="actionExit"/>
<addaction name="menu_FileSettingsDirectory"/>
<addaction name="menu_FileResetSettings"/>
<addaction name="menu_FileReloadStyleSheets"/>
<addaction name="separator"/>
<addaction name="menu_FileExit"/>
</widget>
<addaction name="menuFile"/>
<widget class="QMenu" name="menu_Window">
<property name="title">
<string>Window</string>
</property>
<addaction name="menu_WindowFont"/>
<addaction name="menu_WindowMinimize"/>
</widget>
<widget class="QMenu" name="menu_InfoAreas">
<property name="title">
<string>Info areas</string>
</property>
</widget>
<widget class="QMenu" name="menu_Mapping">
<property name="title">
<string>Mapping</string>
</property>
<addaction name="menu_MappingMaxData"/>
<addaction name="menu_MappingMaxMapping"/>
</widget>
<widget class="QMenu" name="menu_Internals">
<property name="title">
<string>Test</string>
</property>
<widget class="QMenu" name="menu_Debugging">
<property name="title">
<string>Debug</string>
</property>
<addaction name="menu_DebugMetaTypes"/>
</widget>
<addaction name="menu_TestInternals"/>
<addaction name="separator"/>
<addaction name="menu_Debugging"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>Help</string>
</property>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Window"/>
<addaction name="menu_InfoAreas"/>
<addaction name="menu_Help"/>
<addaction name="menu_Mapping"/>
<addaction name="menu_Internals"/>
</widget>
<widget class="QStatusBar" name="sb_SwiftData"/>
<action name="actionExit">
<action name="menu_FileExit">
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="menu_FileSettingsDirectory">
<property name="text">
<string>Settings directory</string>
</property>
</action>
<action name="menu_FileResetSettings">
<property name="text">
<string>Reset settings</string>
</property>
</action>
<action name="menu_FileReloadStyleSheets">
<property name="text">
<string>Reload style sheets</string>
</property>
</action>
<action name="menu_WindowFont">
<property name="text">
<string>Font</string>
</property>
</action>
<action name="menu_WindowMinimize">
<property name="text">
<string>Minimize</string>
</property>
</action>
<action name="menu_TestInternals">
<property name="text">
<string>Internals</string>
</property>
</action>
<action name="menu_MappingMaxMapping">
<property name="text">
<string>Max. mapping area</string>
</property>
<property name="shortcut">
<string>Ctrl+M, M</string>
</property>
</action>
<action name="menu_MappingMaxData">
<property name="text">
<string>Max. data area</string>
</property>
<property name="shortcut">
<string>Ctrl+M, D</string>
</property>
</action>
<action name="menu_WindowToggleOnTop">
<property name="text">
<string>Toggle stay on top</string>
</property>
</action>
<action name="actionNavigator">
<property name="text">
<string>Navigator</string>
</property>
</action>
<action name="menu_DebugMetaTypes">
<property name="text">
<string>Debug metatypes (to console)</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@@ -87,6 +198,12 @@
<header>blackgui/components/datamaininfoareacomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInfoBarWebReadersStatusComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/infobarwebreadersstatuscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -0,0 +1,84 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "swiftdata.h"
#include "ui_swiftdata.h"
#include "blackgui/components/dbmappingcomponent.h"
#include "blackgui/components/logcomponent.h"
#include "blackgui/stylesheetutility.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/logmessage.h"
#include <QPoint>
#include <QMenu>
#include <QDesktopServices>
#include <QProcess>
#include <QFontDialog>
using namespace BlackGui;
using namespace BlackGui::Components;
using namespace BlackMisc;
/*
* Menu clicked
*/
void CSwiftData::ps_onMenuClicked()
{
QObject *sender = QObject::sender();
if (sender == this->ui->menu_FileReloadStyleSheets)
{
CStyleSheetUtility::instance().read();
}
else if (sender == this->ui->menu_WindowFont)
{
// this->ps_setMainPageToInfoArea();
// this->ui->comp_MainInfoArea->selectSettingsTab(BlackGui::Components::CSettingsComponent::SettingTabGui);
}
else if (sender == this->ui->menu_WindowMinimize)
{
this->showMinimized();
}
else if (sender == this->ui->menu_FileExit)
{
CLogMessage(this).info("Closing");
this->close(); // graceful shutdown in close event
}
else if (sender == this->ui->menu_FileSettingsDirectory)
{
QString path;
QDesktopServices::openUrl(QUrl("file:///" + path));
}
else if (sender == this->ui->menu_FileResetSettings)
{
// !\todo reset settings
}
else if (sender == this->ui->menu_DebugMetaTypes)
{
QString metadata;
QTextStream stream(&metadata);
BlackMisc::displayAllUserMetatypesTypes(stream);
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(metadata);
}
else if (sender == this->ui->menu_MappingMaxData)
{
CDbMappingComponent *mappingComponent = this->ui->comp_MainInfoArea->getMappingComponent();
mappingComponent->resizeForSelect();
}
else if (sender == this->ui->menu_MappingMaxMapping)
{
CDbMappingComponent *mappingComponent = this->ui->comp_MainInfoArea->getMappingComponent();
mappingComponent->resizeForMapping();
}
}
void CSwiftData::initDynamicMenus()
{
Q_ASSERT(this->ui->menu_InfoAreas);
Q_ASSERT(this->ui->comp_MainInfoArea);
this->ui->menu_InfoAreas->addActions(this->ui->comp_MainInfoArea->getInfoAreaSelectActions(this->ui->menu_InfoAreas));
}