ORE Studio 0.0.4
Loading...
Searching...
No Matches
ConnectionBrowserMdiWindow.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_CONNECTION_BROWSER_MDI_WINDOW_HPP
21#define ORES_QT_CONNECTION_BROWSER_MDI_WINDOW_HPP
22
23#include <QWidget>
24#include <QTreeView>
25#include <QToolBar>
26#include <QAction>
27#include <QVBoxLayout>
28#include <QSplitter>
29#include <QMdiArea>
30#include <QMainWindow>
31#include <QList>
32#include <QPointer>
33#include <QSize>
34#include <QCloseEvent>
35#include <memory>
36#include <boost/uuid/uuid.hpp>
37#include "ores.logging/make_logger.hpp"
38#include "ores.qt/ConnectionTypes.hpp"
39
40namespace ores::connections::service {
41class connection_manager;
42}
43
44namespace ores::qt {
45
46class ConnectionTreeModel;
47class ConnectionDetailPanel;
48class DetachableMdiSubWindow;
49
56class ConnectionBrowserMdiWindow : public QWidget {
57 Q_OBJECT
58
59private:
60 inline static std::string_view logger_name =
61 "ores.qt.connection_browser_mdi_window";
62
63 [[nodiscard]] static auto& lg() {
64 using namespace ores::logging;
65 static auto instance = make_logger(logger_name);
66 return instance;
67 }
68
69public:
72 QWidget* parent = nullptr);
74
75 QSize sizeHint() const override;
76
81
85 void setMdiArea(QMdiArea* mdiArea, QMainWindow* mainWindow,
86 QList<QPointer<DetachableMdiSubWindow>>* allDetachableWindows);
87
88signals:
89 void statusChanged(const QString& message);
90 void errorOccurred(const QString& errorMessage);
91
95 void connectRequested(const boost::uuids::uuid& connectionId,
96 const QString& connectionName);
97
101 void environmentConnectRequested(const boost::uuids::uuid& environmentId,
102 const QString& environmentName);
103
108
113
114public slots:
115 void reload();
116 void openAddDialog();
117 void editSelected();
118 void copySelected();
119 void deleteSelected();
120 void connectToSelected();
121 void changeMasterPassword();
122 void purgeDatabase();
123
124private slots:
125 void onSelectionChanged();
126 void onDoubleClicked(const QModelIndex& index);
127 void showContextMenu(const QPoint& pos);
128
129protected:
130 void closeEvent(QCloseEvent* event) override;
131
132private:
133 void setupUI();
134 void updateActionStates();
135 void updateDetailPanel();
136 void restoreExpansionState();
137
138 QVBoxLayout* layout_;
139 QSplitter* splitter_;
140 QTreeView* treeView_;
141 ConnectionDetailPanel* detailPanel_;
142 QToolBar* toolBar_;
143
144 QAction* addAction_;
145 QAction* editAction_;
146 QAction* copyAction_;
147 QAction* deleteAction_;
148 QAction* connectAction_;
149 QAction* refreshAction_;
150 QAction* changeMasterPasswordAction_;
151 QAction* purgeDatabaseAction_;
152
153 std::unique_ptr<ConnectionTreeModel> model_;
155 TestConnectionCallback testCallback_;
156
157 QMdiArea* mdiArea_;
158 QMainWindow* mainWindow_;
159 QList<QPointer<DetachableMdiSubWindow>>* allDetachableWindows_;
160
161 QSize savedWindowSize_;
162
163 inline static const QString settings_group_ = "ConnectionBrowserWindow";
164};
165
166}
167
168#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
std::function< QString(const QString &host, int port, const QString &username, const QString &password)> TestConnectionCallback
Callback type for testing connections.
Definition ConnectionTypes.hpp:36
High-level service for managing server connections and environments.
Definition connection_manager.hpp:53
MDI window for browsing and managing saved server connections.
Definition ConnectionBrowserMdiWindow.hpp:56
void databasePurged()
Emitted when user purges the database.
void setTestCallback(TestConnectionCallback callback)
Set callback for testing connections from dialogs.
Definition ConnectionBrowserMdiWindow.cpp:67
void connectRequested(const boost::uuids::uuid &connectionId, const QString &connectionName)
Emitted when user requests to connect using a saved connection.
void changeMasterPasswordRequested()
Emitted when user requests to change the master password.
void setMdiArea(QMdiArea *mdiArea, QMainWindow *mainWindow, QList< QPointer< DetachableMdiSubWindow > > *allDetachableWindows)
Set MDI area and main window for creating sub-windows.
Definition ConnectionBrowserMdiWindow.cpp:71
void environmentConnectRequested(const boost::uuids::uuid &environmentId, const QString &environmentName)
Emitted when user requests to connect using a pure environment.
Detail panel showing read-only information about selected item.
Definition ConnectionDetailPanel.hpp:49