diff --git a/chatview/CMakeLists.txt b/chatview/CMakeLists.txt index 14812bb..cdba3b7 100644 --- a/chatview/CMakeLists.txt +++ b/chatview/CMakeLists.txt @@ -6,10 +6,11 @@ qt_add_qml_module(QodeAssistChatView URI ChatView VERSION 1.0 QML_FILES - qml/RootItem.qml + qml/RootItem.qml SOURCES - BaseChatWidget.hpp BaseChatWidget.cpp - ChatModel.hpp ChatModel.cpp + BaseChatWidget.hpp BaseChatWidget.cpp + ChatModel.hpp ChatModel.cpp + ChatRootView.hpp ChatRootView.cpp ) target_link_libraries(QodeAssistChatView diff --git a/chatview/ChatRootView.cpp b/chatview/ChatRootView.cpp new file mode 100644 index 0000000..c98f1f4 --- /dev/null +++ b/chatview/ChatRootView.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Petr Mironychev + * + * This file is part of QodeAssist. + * + * QodeAssist is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * QodeAssist is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with QodeAssist. If not, see . + */ + +#include "ChatRootView.hpp" + +namespace QodeAssist::Chat { + +ChatRootView::ChatRootView(QQuickItem *parent) + : QQuickItem(parent) + , m_chatModel(new ChatModel(this)) +{} + +ChatModel *ChatRootView::chatModel() const +{ + return m_chatModel; +} + +} // namespace QodeAssist::Chat diff --git a/chatview/ChatRootView.hpp b/chatview/ChatRootView.hpp new file mode 100644 index 0000000..9f83ed7 --- /dev/null +++ b/chatview/ChatRootView.hpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 Petr Mironychev + * + * This file is part of QodeAssist. + * + * QodeAssist is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * QodeAssist is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with QodeAssist. If not, see . + */ + +#pragma once + +#include + +#include "ChatModel.hpp" + +namespace QodeAssist::Chat { + +class ChatRootView : public QQuickItem +{ + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(ChatModel *chatModel READ chatModel NOTIFY chatModelChanged FINAL) +public: + ChatRootView(QQuickItem *parent = nullptr); + + ChatModel *chatModel() const; + +signals: + void chatModelChanged(); + +private: + ChatModel *m_chatModel = nullptr; +}; + +} // namespace QodeAssist::Chat diff --git a/chatview/qml/RootItem.qml b/chatview/qml/RootItem.qml index a6a76c4..f166a45 100644 --- a/chatview/qml/RootItem.qml +++ b/chatview/qml/RootItem.qml @@ -1,7 +1,13 @@ import QtQuick +import ChatView -Rectangle { +ChatRootView { id: root - color: "gray" + Rectangle { + id: bg + + anchors.fill: parent + color: "gray" + } }