Add ChatRootView QML item

This commit is contained in:
Petr Mironychev 2024-10-06 18:47:10 +02:00
parent 7442256bab
commit 30fcd7e019
4 changed files with 92 additions and 5 deletions

View File

@ -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

34
chatview/ChatRootView.cpp Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
*/
#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

46
chatview/ChatRootView.hpp Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <QQuickItem>
#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

View File

@ -1,7 +1,13 @@
import QtQuick
import ChatView
Rectangle {
ChatRootView {
id: root
color: "gray"
Rectangle {
id: bg
anchors.fill: parent
color: "gray"
}
}