mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
Views: JSON values can be shown as popup
This commit is contained in:
@@ -59,7 +59,7 @@ namespace BlackGui
|
|||||||
CTextMessageTextEdit::~CTextMessageTextEdit()
|
CTextMessageTextEdit::~CTextMessageTextEdit()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void CTextMessageTextEdit::insertTextMessage(const BlackMisc::Network::CTextMessage &textMessage, int maxMessages)
|
void CTextMessageTextEdit::insertTextMessage(const CTextMessage &textMessage, int maxMessages)
|
||||||
{
|
{
|
||||||
if (maxMessages < 0 && m_keepMaxMessages >= 0) { maxMessages = m_keepMaxMessages; }
|
if (maxMessages < 0 && m_keepMaxMessages >= 0) { maxMessages = m_keepMaxMessages; }
|
||||||
if (maxMessages >= 0)
|
if (maxMessages >= 0)
|
||||||
|
|||||||
@@ -7,22 +7,22 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackconfig/buildconfig.h"
|
#include "blackgui/components/texteditdialog.h"
|
||||||
#include "blackgui/dockwidgetinfoarea.h"
|
#include "blackgui/views/viewbase.h"
|
||||||
|
#include "blackgui/views/viewbaseproxystyle.h"
|
||||||
|
#include "blackgui/views/viewbaseitemdelegate.h"
|
||||||
#include "blackgui/filters/filterdialog.h"
|
#include "blackgui/filters/filterdialog.h"
|
||||||
#include "blackgui/filters/filterwidget.h"
|
#include "blackgui/filters/filterwidget.h"
|
||||||
#include "blackgui/guiapplication.h"
|
|
||||||
#include "blackgui/guiutility.h"
|
|
||||||
#include "blackgui/loadindicator.h"
|
|
||||||
#include "blackgui/models/allmodels.h"
|
#include "blackgui/models/allmodels.h"
|
||||||
#include "blackgui/models/allmodelcontainers.h"
|
#include "blackgui/models/allmodelcontainers.h"
|
||||||
#include "blackgui/menus/menuaction.h"
|
#include "blackgui/menus/menuaction.h"
|
||||||
#include "blackgui/menus/menudelegate.h"
|
#include "blackgui/menus/menudelegate.h"
|
||||||
#include "blackgui/menus/fontmenus.h"
|
#include "blackgui/menus/fontmenus.h"
|
||||||
|
#include "blackgui/dockwidgetinfoarea.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
|
#include "blackgui/guiutility.h"
|
||||||
|
#include "blackgui/loadindicator.h"
|
||||||
#include "blackgui/shortcut.h"
|
#include "blackgui/shortcut.h"
|
||||||
#include "blackgui/views/viewbase.h"
|
|
||||||
#include "blackgui/views/viewbaseproxystyle.h"
|
|
||||||
#include "blackgui/views/viewbaseitemdelegate.h"
|
|
||||||
#include "blackmisc/fileutils.h"
|
#include "blackmisc/fileutils.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "blackmisc/namevariantpairlist.h"
|
#include "blackmisc/namevariantpairlist.h"
|
||||||
#include "blackmisc/propertyindexvariantmap.h"
|
#include "blackmisc/propertyindexvariantmap.h"
|
||||||
#include "blackmisc/worker.h"
|
#include "blackmisc/worker.h"
|
||||||
|
#include "blackconfig/buildconfig.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTextEdit>
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ using namespace BlackGui::Menus;
|
|||||||
using namespace BlackGui::Models;
|
using namespace BlackGui::Models;
|
||||||
using namespace BlackGui::Filters;
|
using namespace BlackGui::Filters;
|
||||||
using namespace BlackGui::Settings;
|
using namespace BlackGui::Settings;
|
||||||
|
using namespace BlackGui::Components;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -342,6 +345,15 @@ namespace BlackGui
|
|||||||
return directories.propertyByIndex(m_dirSettingsIndex).toQString();
|
return directories.propertyByIndex(m_dirSettingsIndex).toQString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Components::CTextEditDialog *CViewBaseNonTemplate::textEditDialog()
|
||||||
|
{
|
||||||
|
if (!m_textEditDialog)
|
||||||
|
{
|
||||||
|
m_textEditDialog = new CTextEditDialog(this);
|
||||||
|
}
|
||||||
|
return m_textEditDialog;
|
||||||
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::customMenu(CMenuActions &menuActions)
|
void CViewBaseNonTemplate::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
// delegate?
|
// delegate?
|
||||||
@@ -440,6 +452,16 @@ namespace BlackGui
|
|||||||
a->setEnabled(!autoResize);
|
a->setEnabled(!autoResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export actions, display in text edit
|
||||||
|
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||||
|
{
|
||||||
|
menuActions.addAction(CIcons::tableSheet16(), "Display as JSON", CMenuAction::pathViewLoadSave(), { this, &CViewBaseNonTemplate::displayJsonPopup });
|
||||||
|
if (this->hasSelection())
|
||||||
|
{
|
||||||
|
menuActions.addAction(CIcons::tableSheet16(), "Display selected as JSON", CMenuAction::pathViewLoadSave(), { this, &CViewBaseNonTemplate::displaySelectedJsonPopup });;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QAction *actionInteractiveResize = menuActions.addAction(CIcons::viewMultiColumn(), "Resize (auto)", CMenuAction::pathViewResize(), nullptr);
|
QAction *actionInteractiveResize = menuActions.addAction(CIcons::viewMultiColumn(), "Resize (auto)", CMenuAction::pathViewResize(), nullptr);
|
||||||
actionInteractiveResize->setObjectName(this->objectName().append("ActionResizing"));
|
actionInteractiveResize->setObjectName(this->objectName().append("ActionResizing"));
|
||||||
actionInteractiveResize->setCheckable(true);
|
actionInteractiveResize->setCheckable(true);
|
||||||
@@ -646,6 +668,16 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CViewBaseNonTemplate::displayJsonPopup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CViewBaseNonTemplate::displaySelectedJsonPopup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::ps_triggerReload()
|
void CViewBaseNonTemplate::ps_triggerReload()
|
||||||
{
|
{
|
||||||
this->showLoadIndicatorWithTimeout(m_loadIndicatorTimeoutMsDefault);
|
this->showLoadIndicatorWithTimeout(m_loadIndicatorTimeoutMsDefault);
|
||||||
@@ -1617,6 +1649,17 @@ namespace BlackGui
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class ModelClass, class ContainerType, class ObjectType>
|
||||||
|
void CViewBase<ModelClass, ContainerType, ObjectType>::displayContainerAsJsonPopup(bool selectedOnly)
|
||||||
|
{
|
||||||
|
const ContainerType container = selectedOnly ? this->selectedObjects() : this->container();
|
||||||
|
const QString json = container.toJsonString();
|
||||||
|
QTextEdit *te = this->textEditDialog()->textEdit();
|
||||||
|
te->setReadOnly(true);
|
||||||
|
te->setText(json);
|
||||||
|
this->textEditDialog()->show();
|
||||||
|
}
|
||||||
|
|
||||||
template <class ModelClass, class ContainerType, class ObjectType>
|
template <class ModelClass, class ContainerType, class ObjectType>
|
||||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::ps_loadJson(const QString &directory)
|
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::ps_loadJson(const QString &directory)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ namespace BlackGui
|
|||||||
class CFilterWidget;
|
class CFilterWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
class CTextEditDialog;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Views
|
namespace Views
|
||||||
{
|
{
|
||||||
//! Non templated base class, allows Q_OBJECT and signals / slots to be used
|
//! Non templated base class, allows Q_OBJECT and signals / slots to be used
|
||||||
@@ -451,6 +456,12 @@ namespace BlackGui
|
|||||||
//! Save JSON for action/menu, void return signatur
|
//! Save JSON for action/menu, void return signatur
|
||||||
void saveSelectedJsonAction();
|
void saveSelectedJsonAction();
|
||||||
|
|
||||||
|
//! Display JSON data
|
||||||
|
virtual void displayJsonPopup() = 0;
|
||||||
|
|
||||||
|
//! Display JSON data
|
||||||
|
virtual void displaySelectedJsonPopup() = 0;
|
||||||
|
|
||||||
//! Load JSON for action/menu, void return signatur
|
//! Load JSON for action/menu, void return signatur
|
||||||
void loadJsonAction();
|
void loadJsonAction();
|
||||||
|
|
||||||
@@ -483,6 +494,9 @@ namespace BlackGui
|
|||||||
virtual void paste() = 0;
|
virtual void paste() = 0;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Init text edit dialog if required and return pointer to it
|
||||||
|
Components::CTextEditDialog *textEditDialog();
|
||||||
|
|
||||||
ResizeMode m_resizeMode = PresizeSubset; //!< mode
|
ResizeMode m_resizeMode = PresizeSubset; //!< mode
|
||||||
RowsResizeMode m_rowResizeMode = Interactive; //!< row resize mode for row height
|
RowsResizeMode m_rowResizeMode = Interactive; //!< row resize mode for row height
|
||||||
SelectionMode m_originalSelectionMode = this->selectionMode(); //!< Selection mode set
|
SelectionMode m_originalSelectionMode = this->selectionMode(); //!< Selection mode set
|
||||||
@@ -506,6 +520,7 @@ namespace BlackGui
|
|||||||
Menus::IMenuDelegate *m_menu = nullptr; //!< custom menu if any
|
Menus::IMenuDelegate *m_menu = nullptr; //!< custom menu if any
|
||||||
Menus::CFontMenu *m_fontMenu = nullptr; //!< font menu if applicable
|
Menus::CFontMenu *m_fontMenu = nullptr; //!< font menu if applicable
|
||||||
CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed
|
CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed
|
||||||
|
Components::CTextEditDialog *m_textEditDialog = nullptr; //!< text edit dialog
|
||||||
QMap<MenuFlag, Menus::CMenuActions> m_menuFlagActions; //!< initialized actions
|
QMap<MenuFlag, Menus::CMenuActions> m_menuFlagActions; //!< initialized actions
|
||||||
QString m_saveFileName; //!< save file name (JSON)
|
QString m_saveFileName; //!< save file name (JSON)
|
||||||
BlackMisc::CDirectories::ColumnIndex m_dirSettingsIndex = BlackMisc::CDirectories::IndexDirLastViewJsonOrDefault; //!< allows to set more specialized directories //!< remember last JSON directory, having this member allows to have specific dir
|
BlackMisc::CDirectories::ColumnIndex m_dirSettingsIndex = BlackMisc::CDirectories::IndexDirLastViewJsonOrDefault; //!< allows to set more specialized directories //!< remember last JSON directory, having this member allows to have specific dir
|
||||||
@@ -738,6 +753,8 @@ namespace BlackGui
|
|||||||
virtual void copy() override;
|
virtual void copy() override;
|
||||||
virtual void cut() override;
|
virtual void cut() override;
|
||||||
virtual void paste() override;
|
virtual void paste() override;
|
||||||
|
virtual void displayJsonPopup() override { this->displayContainerAsJsonPopup(false); }
|
||||||
|
virtual void displaySelectedJsonPopup() override { this->displayContainerAsJsonPopup(true); }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Modify JSON data loaded in BlackGui::Views::CViewBaseNonTemplate::ps_loadJson
|
//! Modify JSON data loaded in BlackGui::Views::CViewBaseNonTemplate::ps_loadJson
|
||||||
@@ -756,6 +773,9 @@ namespace BlackGui
|
|||||||
//! \copydoc BlackGui::Views::CViewBaseNonTemplate::customMenu
|
//! \copydoc BlackGui::Views::CViewBaseNonTemplate::customMenu
|
||||||
virtual BlackMisc::CStatusMessage loadJsonFile(const QString &fileName) override;
|
virtual BlackMisc::CStatusMessage loadJsonFile(const QString &fileName) override;
|
||||||
|
|
||||||
|
//! Display the container as JSON popup
|
||||||
|
virtual void displayContainerAsJsonPopup(bool selectedOnly);
|
||||||
|
|
||||||
// --------------------------------------------- SLOTS start here -----------------------------------------
|
// --------------------------------------------- SLOTS start here -----------------------------------------
|
||||||
|
|
||||||
//! \name Slot overrides from base class
|
//! \name Slot overrides from base class
|
||||||
|
|||||||
Reference in New Issue
Block a user