2022-04-09 06:24:37 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Dylan Katz <dykatz@uw.edu>
|
2022-12-29 02:26:56 +03:00
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
2022-04-09 06:24:37 +03:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/LexicalPath.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
#include <LibGUI/Widget.h>
|
2022-06-05 18:58:35 +03:00
|
|
|
#include <LibSQL/SQLClient.h>
|
2022-04-09 06:24:37 +03:00
|
|
|
|
|
|
|
namespace SQLStudio {
|
|
|
|
|
|
|
|
class ScriptEditor;
|
|
|
|
|
|
|
|
class MainWidget : public GUI::Widget {
|
2023-04-17 09:01:00 +03:00
|
|
|
C_OBJECT_ABSTRACT(MainWidget)
|
2022-04-09 06:24:37 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~MainWidget() = default;
|
2023-04-17 09:01:00 +03:00
|
|
|
static ErrorOr<NonnullRefPtr<MainWidget>> create();
|
2022-04-09 06:24:37 +03:00
|
|
|
|
2023-04-16 15:46:48 +03:00
|
|
|
ErrorOr<void> initialize_menu(GUI::Window*);
|
2022-04-09 06:24:37 +03:00
|
|
|
void open_new_script();
|
|
|
|
void open_script_from_file(LexicalPath const&);
|
|
|
|
|
|
|
|
bool request_close();
|
|
|
|
|
|
|
|
private:
|
2023-04-17 09:01:00 +03:00
|
|
|
ErrorOr<void> setup();
|
2022-04-09 06:24:37 +03:00
|
|
|
|
2022-12-29 02:26:56 +03:00
|
|
|
ScriptEditor* active_editor();
|
|
|
|
|
2022-04-09 06:24:37 +03:00
|
|
|
void update_title();
|
|
|
|
void on_editor_change();
|
|
|
|
void update_statusbar(ScriptEditor*);
|
|
|
|
void update_editor_actions(ScriptEditor*);
|
|
|
|
|
2022-11-05 00:32:17 +03:00
|
|
|
virtual void drag_enter_event(GUI::DragEvent&) override;
|
2022-04-09 06:24:37 +03:00
|
|
|
virtual void drop_event(GUI::DropEvent&) override;
|
|
|
|
|
|
|
|
RefPtr<GUI::Action> m_new_action;
|
|
|
|
RefPtr<GUI::Action> m_open_action;
|
|
|
|
RefPtr<GUI::Action> m_save_action;
|
|
|
|
RefPtr<GUI::Action> m_save_as_action;
|
|
|
|
RefPtr<GUI::Action> m_save_all_action;
|
|
|
|
RefPtr<GUI::Action> m_copy_action;
|
|
|
|
RefPtr<GUI::Action> m_cut_action;
|
|
|
|
RefPtr<GUI::Action> m_paste_action;
|
|
|
|
RefPtr<GUI::Action> m_undo_action;
|
|
|
|
RefPtr<GUI::Action> m_redo_action;
|
2022-12-29 07:09:23 +03:00
|
|
|
RefPtr<GUI::Action> m_connect_to_database_action;
|
2022-06-05 18:52:42 +03:00
|
|
|
RefPtr<GUI::Action> m_run_script_action;
|
2022-04-09 06:24:37 +03:00
|
|
|
|
|
|
|
int m_new_script_counter { 1 };
|
2022-12-29 07:09:23 +03:00
|
|
|
RefPtr<GUI::ComboBox> m_databases_combo_box;
|
2022-04-09 06:24:37 +03:00
|
|
|
RefPtr<GUI::TabWidget> m_tab_widget;
|
|
|
|
RefPtr<GUI::Statusbar> m_statusbar;
|
2022-06-05 21:58:40 +03:00
|
|
|
RefPtr<GUI::TabWidget> m_action_tab_widget;
|
|
|
|
RefPtr<GUI::Widget> m_query_results_widget;
|
2022-06-05 18:52:42 +03:00
|
|
|
RefPtr<GUI::TableView> m_query_results_table_view;
|
2022-06-05 18:58:35 +03:00
|
|
|
|
|
|
|
RefPtr<SQL::SQLClient> m_sql_client;
|
2022-12-29 02:30:34 +03:00
|
|
|
Optional<SQL::ConnectionID> m_connection_id;
|
2023-12-16 17:19:34 +03:00
|
|
|
Vector<ByteString> m_result_column_names;
|
|
|
|
Vector<Vector<ByteString>> m_results;
|
2022-06-05 18:58:35 +03:00
|
|
|
|
2022-12-28 18:57:30 +03:00
|
|
|
void read_next_sql_statement_of_editor();
|
2023-12-16 17:19:34 +03:00
|
|
|
Optional<ByteString> read_next_line_of_editor();
|
2022-06-05 18:58:35 +03:00
|
|
|
size_t m_current_line_for_parsing { 0 };
|
|
|
|
int m_editor_line_level { 0 };
|
2022-04-09 06:24:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using SQLStudio::MainWidget;
|