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 <memory>
33#include <boost/uuid/uuid.hpp>
34#include "ores.logging/make_logger.hpp"
35#include "ores.qt/ConnectionTypes.hpp"
36
37namespace ores::connections::service {
38class connection_manager;
39}
40
41namespace ores::qt {
42
43class ConnectionTreeModel;
44class ConnectionDetailPanel;
45class DetachableMdiSubWindow;
46
53class ConnectionBrowserMdiWindow : public QWidget {
54 Q_OBJECT
55
56private:
57 inline static std::string_view logger_name =
58 "ores.qt.connection_browser_mdi_window";
59
60 [[nodiscard]] static auto& lg() {
61 using namespace ores::logging;
62 static auto instance = make_logger(logger_name);
63 return instance;
64 }
65
66public:
69 QWidget* parent = nullptr);
71
72 QSize sizeHint() const override;
73
78
82 void setMdiArea(QMdiArea* mdiArea, QMainWindow* mainWindow,
83 QList<DetachableMdiSubWindow*>* allDetachableWindows);
84
85signals:
86 void statusChanged(const QString& message);
87 void errorOccurred(const QString& errorMessage);
88
92 void connectRequested(const boost::uuids::uuid& environmentId,
93 const QString& connectionName);
94
99
104
105public slots:
106 void reload();
107 void openAddDialog();
108 void editSelected();
109 void deleteSelected();
110 void connectToSelected();
111 void changeMasterPassword();
112 void purgeDatabase();
113
114private slots:
115 void onSelectionChanged();
116 void onDoubleClicked(const QModelIndex& index);
117 void showContextMenu(const QPoint& pos);
118
119private:
120 void setupUI();
121 void updateActionStates();
122 void updateDetailPanel();
123
124 QVBoxLayout* layout_;
125 QSplitter* splitter_;
126 QTreeView* treeView_;
127 ConnectionDetailPanel* detailPanel_;
128 QToolBar* toolBar_;
129
130 QAction* addAction_;
131 QAction* editAction_;
132 QAction* deleteAction_;
133 QAction* connectAction_;
134 QAction* refreshAction_;
135 QAction* changeMasterPasswordAction_;
136 QAction* purgeDatabaseAction_;
137
138 std::unique_ptr<ConnectionTreeModel> model_;
140 TestConnectionCallback testCallback_;
141
142 QMdiArea* mdiArea_;
143 QMainWindow* mainWindow_;
144 QList<DetachableMdiSubWindow*>* allDetachableWindows_;
145};
146
147}
148
149#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
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.
Definition connection_manager.hpp:48
MDI window for browsing and managing saved server connections.
Definition ConnectionBrowserMdiWindow.hpp:53
void connectRequested(const boost::uuids::uuid &environmentId, const QString &connectionName)
Emitted when user requests to connect using a saved environment.
void databasePurged()
Emitted when user purges the database.
void setMdiArea(QMdiArea *mdiArea, QMainWindow *mainWindow, QList< DetachableMdiSubWindow * > *allDetachableWindows)
Set MDI area and main window for creating sub-windows.
Definition ConnectionBrowserMdiWindow.cpp:59
void setTestCallback(TestConnectionCallback callback)
Set callback for testing connections from dialogs.
Definition ConnectionBrowserMdiWindow.cpp:55
void changeMasterPasswordRequested()
Emitted when user requests to change the master password.
Detail panel showing read-only information about selected item.
Definition ConnectionDetailPanel.hpp:47