Add initial project structure with essential files including .gitignore, application resources, and various model and view components for the application. Implemented asynchronous parsing support and database structure checks.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
#include "projectparampreview.h"
|
||||
#include <QDebug>
|
||||
|
||||
ProjectParamPreview::ProjectParamPreview(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
, m_tableModel(nullptr)
|
||||
{
|
||||
setUp();
|
||||
}
|
||||
|
||||
void ProjectParamPreview::setUp(){
|
||||
setWidgets();
|
||||
setUpLayout();
|
||||
setUpConnections();
|
||||
}
|
||||
|
||||
void ProjectParamPreview::setWidgets(){
|
||||
m_tableView = new QTableView(this);
|
||||
m_tableModel = new ProjectParamTableModel(this);
|
||||
|
||||
// Настраиваем таблицу
|
||||
m_tableView->setModel(m_tableModel);
|
||||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_tableView->setAlternatingRowColors(true);
|
||||
m_tableView->horizontalHeader()->setStretchLastSection(true);
|
||||
m_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
m_tableView->verticalHeader()->setVisible(false);
|
||||
}
|
||||
|
||||
void ProjectParamPreview::setUpLayout(){
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->addWidget(m_tableView);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void ProjectParamPreview::setUpConnections(){
|
||||
// Подключаем сигналы изменения данных
|
||||
connect(m_tableModel, &ProjectParamTableModel::dataChanged,
|
||||
this, [this](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
|
||||
if (topLeft.isValid() && topLeft.row() < m_tableModel->rowCount()) {
|
||||
ProjectParamTableData param = m_tableModel->getProjectParam(topLeft.row());
|
||||
emit projectParamChanged(topLeft.row(), param.name, param.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ProjectParamPreview::updateView()
|
||||
{
|
||||
if (m_tableView) {
|
||||
m_tableView->reset();
|
||||
m_tableView->resizeColumnsToContents();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectParamPreview::setProjectParams(const QList<ProjectParamTableData> ¶ms)
|
||||
{
|
||||
if (m_tableModel) {
|
||||
m_tableModel->setProjectParams(params);
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectParamPreview::addProjectParam(const ProjectParamTableData ¶m)
|
||||
{
|
||||
if (m_tableModel) {
|
||||
m_tableModel->addProjectParam(param);
|
||||
emit projectParamAdded(param);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectParamPreview::removeProjectParam(int row)
|
||||
{
|
||||
if (m_tableModel && row >= 0 && row < m_tableModel->rowCount()) {
|
||||
m_tableModel->removeProjectParam(row);
|
||||
emit projectParamRemoved(row);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectParamPreview::clear()
|
||||
{
|
||||
if (m_tableModel) {
|
||||
m_tableModel->clear();
|
||||
}
|
||||
}
|
||||
|
||||
ProjectParamTableModel* ProjectParamPreview::tableModel() const
|
||||
{
|
||||
return m_tableModel;
|
||||
}
|
||||
Reference in New Issue
Block a user