From 339d44d18c531cda011c687b1a7dd4fca6552b18 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Mon, 26 Jan 2026 15:13:18 +0400 Subject: [PATCH] Remove from git --- StorageUIComponent.cpp | 11 -- StorageUIComponent.h | 14 -- src/StorageWidget.cpp | 304 ----------------------------------------- src/StorageWidget.h | 85 ------------ src/StorageWindow.cpp | 75 ---------- src/StorageWindow.h | 25 ---- 6 files changed, 514 deletions(-) delete mode 100644 StorageUIComponent.cpp delete mode 100644 StorageUIComponent.h delete mode 100644 src/StorageWidget.cpp delete mode 100644 src/StorageWidget.h delete mode 100644 src/StorageWindow.cpp delete mode 100644 src/StorageWindow.h diff --git a/StorageUIComponent.cpp b/StorageUIComponent.cpp deleted file mode 100644 index db9d8bb..0000000 --- a/StorageUIComponent.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "StorageUIComponent.h" -#include "src/StorageWidget.h" - -QWidget* StorageUIComponent::createWidget(LogosAPI* logosAPI) { - // LogosAPI parameter available but not used - StorageWidget creates its own - return new StorageWidget(); -} - -void StorageUIComponent::destroyWidget(QWidget* widget) { - delete widget; -} \ No newline at end of file diff --git a/StorageUIComponent.h b/StorageUIComponent.h deleted file mode 100644 index 402a396..0000000 --- a/StorageUIComponent.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include - -class StorageUIComponent : public QObject, public IComponent { - Q_OBJECT - Q_INTERFACES(IComponent) - Q_PLUGIN_METADATA(IID IComponent_iid FILE "metadata.json") - -public: - Q_INVOKABLE QWidget* createWidget(LogosAPI* logosAPI = nullptr) override; - void destroyWidget(QWidget* widget) override; -}; \ No newline at end of file diff --git a/src/StorageWidget.cpp b/src/StorageWidget.cpp deleted file mode 100644 index aae757f..0000000 --- a/src/StorageWidget.cpp +++ /dev/null @@ -1,304 +0,0 @@ -#include "StorageWidget.h" -#include "logos_api_client.h" -#include -#include -#include -// #include -#include - -int RET_OK = 0; - -// Static pointer to the active StorageWidget for callbacks -static StorageWidget* activeWidget = nullptr; - -StorageWidget::StorageWidget(QWidget* parent) - : QWidget(parent), isStorageInitialized(false), m_isStorageRunning(false), m_logosAPI(nullptr) { - - // Set as the active widget - activeWidget = this; - - m_logosAPI = new LogosAPI("core", this); - logos = new LogosModules(m_logosAPI); - - // mainLayout = new QVBoxLayout(this); - // quickWidget = new QQuickWidget(this); - // quickWidget->rootContext()->setContextProperty("storage", this); - // quickWidget->setSource(QUrl("qrc:StorageWidget.qml")); - // mainLayout->addWidget(quickWidget); - - // // Main vertical layout - mainLayout = new QVBoxLayout(this); - - // Create status label - statusLayout = new QHBoxLayout(); - statusLabel = new QLabel("Status: Not initialized", this); - statusLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - statusLabel->setLineWidth(1); - statusLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - statusLabel->setMinimumHeight(30); - statusLayout->addWidget(statusLabel, 4); - - startButton = new QPushButton("Start", this); - statusLayout->addWidget(startButton, 1); - - debugButton = new QPushButton("Debug", this); - statusLayout->addWidget(debugButton, 1); - // Create display - // storageDisplay = new QTextEdit(this); - // storageDisplay->setReadOnly(true); - // storageDisplay->setMinimumHeight(300); - - // Create input layout - // inputLayout = new QHBoxLayout(); - // messageInput = new QLineEdit(this); - // messageInput->setPlaceholderText("Type your message here..."); - // sendButton = new QPushButton("Send", this); - - // inputLayout->addWidget(messageInput, 4); - // inputLayout->addWidget(sendButton, 1); - - // Add all components to main layout - mainLayout->addLayout(statusLayout); - // mainLayout->addWidget(storageDisplay); - // mainLayout->addLayout(inputLayout); - - // Set spacing and margins - mainLayout->setSpacing(10); - mainLayout->setContentsMargins(20, 20, 20, 20); - - // Connect signals to slots - connect(startButton, &QPushButton::clicked, this, &StorageWidget::onStartButtonClicked); - connect(debugButton, &QPushButton::clicked, this, &StorageWidget::onDebugButtonClicked); - - // connect(messageInput, &QLineEdit::returnPressed, this, &StorageWidget::onStartButtonClicked); - - // Disable UI components until Storage is initialized - // messageInput->setEnabled(false); - // sendButton->setEnabled(false); - startButton->setEnabled(false); - debugButton->setEnabled(false); - - // Auto-initialize Storage - initStorage(); -} - -StorageWidget::~StorageWidget() { - // Reset the active widget if it's this instance - if (activeWidget == this) { - activeWidget = nullptr; - } -} - -void StorageWidget::initStorage() { - updateStatus("Initializing Storage..."); - emit storageRunningChanged(); - response = logos->storage_module.init("{}"); - - qDebug() << "StorageWidget: Storage module init response:" << response; - - isStorageInitialized = true; - m_isStorageRunning = false; - - updateStatus("Storage initialized."); - - if (!logos->storage_module.on("storageStart", [this](const QVariantList& data) { - int code = data[0].toInt(); - - if (code != RET_OK) { - updateStatus("Error starting Storage."); - } else { - updateStatus("Storage started successfully."); - m_isStorageRunning = true; - startButton->setText("Stop"); - // messageInput->setEnabled(true); - // sendButton->setEnabled(true); - } - - startButton->setEnabled(true); - debugButton->setEnabled(true); - })) { - qWarning() << "StorageWidget: failed to subscribe to storageStart events"; - } - - if (!logos->storage_module.on("storageStop", [this](const QVariantList& data) { - int code = data[0].toInt(); - - if (code != RET_OK) { - updateStatus("Error stopping Storage."); - } else { - updateStatus("Storage stopped successfully."); - m_isStorageRunning = false; - startButton->setText("Start"); - // messageInput->setEnabled(false); - // sendButton->setEnabled(false); - } - - startButton->setEnabled(true); - - emit storageStop(); - })) { - qWarning() << "StorageWidget: failed to subscribe to storageStop events"; - } - - startStorage(); - // if (!storageModule.on("storageVersion", [this] - // std::string version = data[1].toString().toStdString();(const QVariantList& data) { - // qDebug() << "Storage Version:" << QString::fromStdString(version); - // })) { - // qWarning() << "ChatWidget: failed to subscribe to historyMessage events"; - // } - // if (!storageModule.on("storageVersion", [this] - // std::string version = data[1].toString().toStdString();(const QVariantList& data) { - // qDebug() << "Storage Version:" << QString::fromStdString(version); - // })) { - // qWarning() << "ChatWidget: failed to subscribe to historyMessage events"; - // } -} - -QString StorageWidget::storageVersion() const { - if (!isStorageInitialized) { - qDebug() << "StorageWidget: Storage not initialized, cannot get version."; - return ""; - } - - return logos->storage_module.version(); -} - -QString StorageWidget::storageDebug() const { - if (!isStorageInitialized) { - qDebug() << "StorageWidget: Storage not initialized, cannot get debug info."; - return ""; - } - - return logos->storage_module.debug(); -} - -void StorageWidget::startStorage() { - updateStatus("Starting Storage..."); - - if (!isStorageInitialized) { - qDebug() << "StorageWidget: Storage not initialized, nothing to start."; - return; - } - - if (m_isStorageRunning) { - qDebug() << "StorageWidget: Storage already started."; - return; - } - - if (!logos->storage_module.start()) { - qWarning() << "StorageWidget: Failed to send start command to Storage."; - } else { - qDebug() << "StorageWidget: Start command sent to Storage."; - } -} - -void StorageWidget::stopStorage() { - if (!isStorageInitialized) { - qDebug() << "StorageWidget: Storage not initialized, nothing to stop."; - emit storageStop(); - return; - } - - if (!m_isStorageRunning) { - qDebug() << "StorageWidget: Storage already stopped."; - emit storageStop(); - return; - } - - updateStatus("Stopping Storage..."); - - if (!logos->storage_module.stop()) { - qWarning() << "StorageWidget: Failed to send stop command to Storage."; - } else { - qDebug() << "StorageWidget: Stop command sent to Storage."; - } -} - -void StorageWidget::destroy() { - qDebug() << "StorageWidget: destroy function called..."; - - if (!isStorageInitialized) { - qDebug() << "StorageWidget: Storage not initialized, nothing to stop."; - return; - } - - if (!logos->storage_module.destroy()) { - qWarning() << "StorageWidget: Failed to send destroy command to Storage."; - } else { - qDebug() << "StorageWidget: Destroy command sent to Storage."; - } - - qDebug() << "StorageWidget: Emitting storageCleanup signal."; - - emit storageCleanup(); -} - -void StorageWidget::onStartButtonClicked() { - qDebug() << "Starting Storage from button"; - - startButton->setEnabled(false); - - if (m_isStorageRunning) { - stopStorage(); - } else { - startStorage(); - } -} - -void StorageWidget::onDebugButtonClicked() { - qDebug() << "version" << logos->storage_module.version(); - qDebug() << "spr" << logos->storage_module.spr(); - qDebug() << "peerId" << logos->storage_module.peerId(); - - logos->storage_module.updateLogLevel("TRACE"); - - qDebug() << "Debug button clicked"; - emit debug(); -} - -void StorageWidget::onSendButtonClicked() { - QString message = messageInput->text().trimmed(); - if (message.isEmpty()) { - QMessageBox::warning(this, "Storage Error", "Message is empty."); - - return; - } - - // Check if Storage is running - if (!m_isStorageRunning) { - QMessageBox::warning(this, "Storage Error", "Storage is not running. Please initialize Storage first."); - return; - } - - // if (m_logosAPI && m_logosAPI->getClient("storage")->isConnected()) - // { - - // logos->storage_module.storageVersion(); - // } - // else - // { - // qDebug() << "LogosAPI not connected"; - // } - - qDebug() << "LogosAPI not connected!!"; - - // Clear input field - messageInput->clear(); -} - -void StorageWidget::updateStatus(const QString& message) { - statusLabel->setText(message); - qDebug() << "StorageWidget Status:" << message; -} - -void StorageWidget::displayMessage(const QString& sender, const QString& message) { - QString timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"); - QString formattedMessage = QString("[%1] %2: %3").arg(timestamp, sender, message); - storageDisplay->append(formattedMessage); -} - -QString StorageWidget::statusText() const { return m_statusText; } -bool StorageWidget::storageRunning() const { return m_isStorageRunning; } - -void StorageWidget::requestDebug() { emit debug(); } diff --git a/src/StorageWidget.h b/src/StorageWidget.h deleted file mode 100644 index 0beb8f2..0000000 --- a/src/StorageWidget.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once - -#include "logos_api.h" -#include "logos_api_client.h" -#include "logos_sdk.h" -#include -#include -#include -#include -// #include -#include -#include -#include -#include - -using StringCallback = std::function; - -class StorageWidget : public QWidget { - Q_OBJECT - Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) - Q_PROPERTY(bool storageRunning READ storageRunning NOTIFY storageRunningChanged) - - public: - explicit StorageWidget(QWidget* parent = nullptr); - ~StorageWidget(); - - Q_INVOKABLE void requestDebug(); - - QString statusText() const; - bool storageRunning() const; - - // Storage operations - Q_INVOKABLE void initStorage(); - Q_INVOKABLE void startStorage(); - Q_INVOKABLE void stopStorage(); - Q_INVOKABLE QString storageVersion() const; - Q_INVOKABLE QString storageDebug() const; - Q_INVOKABLE void destroy(); - - private slots: - void onSendButtonClicked(); - void onStartButtonClicked(); - void onDebugButtonClicked(); - - private: - // UI elements - // QQuickWidget* quickWidget; - QString m_statusText; - - QVBoxLayout* mainLayout; - QHBoxLayout* inputLayout; - QHBoxLayout* statusLayout; - QHBoxLayout* channelLayout; - - QTextEdit* storageDisplay; - QLineEdit* messageInput; - QLineEdit* channelInput; - QPushButton* sendButton; - QPushButton* startButton; - QPushButton* debugButton; - QLabel* statusLabel; - - // LogosAPI instance for remote method calls - LogosAPI* m_logosAPI; - LogosModules* logos; - - // Connection status - bool isStorageInitialized; - bool m_isStorageRunning; - QString currentPubSubTopic; - QString currentChannel; - bool response; - - // Helper methods - void updateStatus(const QString& message); - void displayMessage(const QString& sender, const QString& message); - void emitEvent(const QString& eventName, const QVariantList& data); - - signals: - void storageCleanup(); - void storageStop(); - void debug(); - void statusTextChanged(); - void storageRunningChanged(); -}; diff --git a/src/StorageWindow.cpp b/src/StorageWindow.cpp deleted file mode 100644 index df94486..0000000 --- a/src/StorageWindow.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "StorageWindow.h" -#include -#include -#include - -StorageWindow::StorageWindow(QWidget* parent) : QMainWindow(parent) { - // Create central widget - storageWidget = new StorageWidget(this); - setCentralWidget(storageWidget); - - // Setup the UI - // setupMenu(); - setupStatusBar(); - - // Set window properties - setMinimumSize(640, 480); - - // connect(stor, &StorageWindow::onDebugButtonClicked, this, [this] { - // debugDock->show(); - // debugDock->raise(); - // debugDock->setFocus(); - // }); -} - -StorageWindow::~StorageWindow() { - // StorageWidget will be deleted automatically as it's a child of this window -} - -void StorageWindow::setupStatusBar() { - statusBar = new QStatusBar(this); - setStatusBar(statusBar); - statusBar->showMessage("Ready"); -} - -void StorageWindow::onAboutAction() { - QMessageBox::about(this, "About Logos Storage", - "Logos Storage Application\n\n" - "A sample Qt application demonstrating Storage integration."); -} - -void StorageWindow::onInitStorage() { - qDebug() << "Initializing Storage from menu"; - storageWidget->initStorage(); - statusBar->showMessage("Storage initialization requested"); -} - -// void StorageWindow::onStopStorage() { -// qDebug() << "Stopping Storage from menu"; -// // storageWidget->stopStorage(); -// statusBar->showMessage("Storage stop requested"); -// } - -// void StorageWindow::showAbout() { -// QString version; - -// qDebug() << "StorageWindow: Retrieving Storage version for About Dialog..."; - -// QMetaObject::invokeMethod(storageWidget, "storageVersion", Qt::DirectConnection, Q_RETURN_ARG(QString, version)); - -// qDebug() << "StorageWindow: Showing About Dialog, version:" << version; -// AboutDialog dlg(this, version); -// dlg.exec(); -// } - -// void MainWindow::showDebug() { -// QString debug; - -// qDebug() << "MainWindow: Retrieving Storage debug for Debug Dialog..."; - -// QMetaObject::invokeMethod(storageWidget, "storageDebug", Qt::DirectConnection, Q_RETURN_ARG(QString, debug)); - -// qDebug() << "MainWindow: Showing Debug Dialog, debug:" << debug; -// DebugDialog dlg(this, debug); -// dlg.exec(); -// } diff --git a/src/StorageWindow.h b/src/StorageWindow.h deleted file mode 100644 index 9c68b3a..0000000 --- a/src/StorageWindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "StorageWidget.h" -#include -#include -#include -#include - -class StorageWindow : public QMainWindow { - Q_OBJECT - - public: - explicit StorageWindow(QWidget* parent = nullptr); - ~StorageWindow(); - - private slots: - void onAboutAction(); - void onInitStorage(); - - private: - void setupStatusBar(); - - StorageWidget* storageWidget; - QStatusBar* statusBar; -};