forked from qt-creator/qt-creator
AnnotationEditor: Merge dialogs
Change-Id: Ibabd7d0d328af8cae8a4ced6747db52b33274bf0 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -636,7 +636,6 @@ extend_qtc_plugin(QmlDesigner
|
||||
SOURCES_PREFIX components/annotationeditor
|
||||
SOURCES annotationcommenttab.cpp annotationcommenttab.h annotationcommenttab.ui
|
||||
annotationeditordialog.cpp annotationeditordialog.h annotationeditordialog.ui
|
||||
globalannotationeditordialog.cpp globalannotationeditordialog.h globalannotationeditordialog.ui
|
||||
annotationeditor.cpp annotationeditor.h
|
||||
globalannotationeditor.cpp globalannotationeditor.h
|
||||
defaultannotations.cpp defaultannotations.h
|
||||
|
@@ -2,7 +2,6 @@ HEADERS += $$PWD/annotationcommenttab.h
|
||||
HEADERS += $$PWD/annotationeditordialog.h
|
||||
HEADERS += $$PWD/annotationeditor.h
|
||||
HEADERS += $$PWD/globalannotationeditor.h
|
||||
HEADERS += $$PWD/globalannotationeditordialog.h
|
||||
HEADERS += $$PWD/defaultannotations.h
|
||||
HEADERS += $$PWD/annotationtableview.h
|
||||
HEADERS += $$PWD/annotationtabwidget.h
|
||||
@@ -11,14 +10,12 @@ SOURCES += $$PWD/annotationcommenttab.cpp
|
||||
SOURCES += $$PWD/annotationeditordialog.cpp
|
||||
SOURCES += $$PWD/annotationeditor.cpp
|
||||
SOURCES += $$PWD/globalannotationeditor.cpp
|
||||
SOURCES += $$PWD/globalannotationeditordialog.cpp
|
||||
SOURCES += $$PWD/defaultannotations.cpp
|
||||
SOURCES += $$PWD/annotationtableview.cpp
|
||||
SOURCES += $$PWD/annotationtabwidget.cpp
|
||||
|
||||
FORMS += $$PWD/annotationcommenttab.ui
|
||||
FORMS += $$PWD/annotationeditordialog.ui
|
||||
FORMS += $$PWD/globalannotationeditordialog.ui
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
|
@@ -39,58 +39,193 @@
|
||||
#include <QToolBar>
|
||||
|
||||
namespace QmlDesigner {
|
||||
BasicAnnotationEditorDialog::BasicAnnotationEditorDialog(QWidget *parent)
|
||||
AnnotationEditorDialog::AnnotationEditorDialog(QWidget *parent,
|
||||
const QString &targetId,
|
||||
const QString &customId)
|
||||
: QDialog(parent)
|
||||
, m_defaults(std::make_unique<DefaultAnnotationsModel>())
|
||||
, m_customId(customId)
|
||||
, ui(std::make_unique<Ui::AnnotationEditorDialog>())
|
||||
, m_statusIsActive(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setGlobal(m_isGlobal);
|
||||
|
||||
setWindowFlag(Qt::Tool, true);
|
||||
setModal(true);
|
||||
loadDefaultAnnotations(DefaultAnnotationsModel::defaultJsonFilePath());
|
||||
ui->tabWidget->setDefaultAnnotations(defaultAnnotations());
|
||||
ui->tableView->setDefaultAnnotations(defaultAnnotations());
|
||||
|
||||
connect(ui->tableView,
|
||||
&AnnotationTableView::richTextEditorRequested,
|
||||
this,
|
||||
[&](int index, QString const &) {
|
||||
switchToTabView();
|
||||
ui->tabWidget->setCurrentIndex(index);
|
||||
});
|
||||
|
||||
connect(ui->statusAddButton, &QPushButton::clicked, this, [&](bool) {
|
||||
setStatusVisibility(true);
|
||||
});
|
||||
|
||||
connect(ui->rbTableView,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&AnnotationEditorDialog::switchToTableView);
|
||||
connect(ui->rbTabView,
|
||||
&QRadioButton::clicked,
|
||||
this, &AnnotationEditorDialog::switchToTabView);
|
||||
|
||||
setStatus(m_globalStatus);
|
||||
switchToTabView();
|
||||
|
||||
connect(this, &QDialog::accepted, this, &AnnotationEditorDialog::acceptedClicked);
|
||||
|
||||
ui->targetIdEdit->setText(targetId);
|
||||
|
||||
connect(this, &QDialog::accepted, this, &BasicAnnotationEditorDialog::acceptedClicked);
|
||||
}
|
||||
|
||||
BasicAnnotationEditorDialog::~BasicAnnotationEditorDialog() {}
|
||||
AnnotationEditorDialog::~AnnotationEditorDialog() {
|
||||
}
|
||||
|
||||
Annotation const &BasicAnnotationEditorDialog::annotation() const
|
||||
bool AnnotationEditorDialog::isGlobal() const {
|
||||
return m_isGlobal;
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::setGlobal(bool global) {
|
||||
ui->annotationContainer->setVisible(!global);
|
||||
ui->statusAddButton->setVisible(global);
|
||||
ui->statusComboBox->setVisible(global);
|
||||
|
||||
setWindowTitle(global ? tr("Global Annotation Editor") : tr("Annotation Editor"));
|
||||
|
||||
if (m_isGlobal != global) {
|
||||
m_isGlobal = global;
|
||||
emit globalChanged();
|
||||
}
|
||||
}
|
||||
|
||||
AnnotationEditorDialog::ViewMode AnnotationEditorDialog::viewMode() const
|
||||
{
|
||||
return ui->rbTableView->isChecked() ? TableView : TabsView;
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::setStatus(GlobalAnnotationStatus status)
|
||||
{
|
||||
m_globalStatus = status;
|
||||
bool hasStatus = status.status() != GlobalAnnotationStatus::NoStatus;
|
||||
|
||||
if (hasStatus)
|
||||
ui->statusComboBox->setCurrentIndex(int(status.status()));
|
||||
|
||||
setStatusVisibility(hasStatus);
|
||||
}
|
||||
|
||||
GlobalAnnotationStatus AnnotationEditorDialog::globalStatus() const
|
||||
{
|
||||
return m_globalStatus;
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::showStatusContainer(bool show)
|
||||
{
|
||||
ui->statusContainer->setVisible(show);
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::switchToTabView()
|
||||
{
|
||||
m_annotation.setComments(ui->tableView->fetchComments());
|
||||
ui->rbTabView->setChecked(true);
|
||||
ui->tableView->hide();
|
||||
ui->tabWidget->show();
|
||||
fillFields();
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::switchToTableView()
|
||||
{
|
||||
m_annotation.setComments(ui->tabWidget->fetchComments());
|
||||
ui->rbTableView->setChecked(true);
|
||||
ui->tabWidget->hide();
|
||||
ui->tableView->show();
|
||||
fillFields();
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::acceptedClicked()
|
||||
{
|
||||
updateAnnotation();
|
||||
emit AnnotationEditorDialog::acceptedDialog();
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::fillFields()
|
||||
{
|
||||
ui->customIdEdit->setText(m_customId);
|
||||
ui->tabWidget->setupComments(m_annotation.comments());
|
||||
ui->tableView->setupComments(m_annotation.comments());
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::updateAnnotation()
|
||||
{
|
||||
m_customId = ui->customIdEdit->text();
|
||||
Annotation annotation;
|
||||
switch (viewMode()) {
|
||||
case TabsView:
|
||||
annotation.setComments(ui->tabWidget->fetchComments());
|
||||
break;
|
||||
case TableView:
|
||||
annotation.setComments(ui->tableView->fetchComments());
|
||||
break;
|
||||
}
|
||||
|
||||
m_annotation = annotation;
|
||||
|
||||
if (m_statusIsActive && m_isGlobal)
|
||||
m_globalStatus.setStatus(ui->statusComboBox->currentIndex());
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::addComment(const Comment &comment)
|
||||
{
|
||||
m_annotation.addComment(comment);
|
||||
ui->tabWidget->addCommentTab(comment);
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::removeComment(int index)
|
||||
{
|
||||
if ((m_annotation.commentsSize() > index) && (index >= 0)) {
|
||||
m_annotation.removeComment(index);
|
||||
ui->tabWidget->removeTab(index);
|
||||
}
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::setStatusVisibility(bool hasStatus)
|
||||
{
|
||||
ui->statusAddButton->setVisible(!hasStatus && m_isGlobal);
|
||||
ui->statusComboBox->setVisible(hasStatus && m_isGlobal);
|
||||
|
||||
m_statusIsActive = hasStatus;
|
||||
}
|
||||
|
||||
|
||||
Annotation const &AnnotationEditorDialog::annotation() const
|
||||
{
|
||||
return m_annotation;
|
||||
}
|
||||
|
||||
void BasicAnnotationEditorDialog::setAnnotation(const Annotation &annotation)
|
||||
void AnnotationEditorDialog::setAnnotation(const Annotation &annotation)
|
||||
{
|
||||
m_annotation = annotation;
|
||||
fillFields();
|
||||
}
|
||||
|
||||
void BasicAnnotationEditorDialog::loadDefaultAnnotations(QString const &filename)
|
||||
void AnnotationEditorDialog::loadDefaultAnnotations(QString const &filename)
|
||||
{
|
||||
m_defaults->loadFromFile(filename);
|
||||
}
|
||||
|
||||
DefaultAnnotationsModel *BasicAnnotationEditorDialog::defaultAnnotations() const
|
||||
DefaultAnnotationsModel *AnnotationEditorDialog::defaultAnnotations() const
|
||||
{
|
||||
return m_defaults.get();
|
||||
}
|
||||
|
||||
AnnotationEditorDialog::AnnotationEditorDialog(QWidget *parent,
|
||||
const QString &targetId,
|
||||
const QString &customId)
|
||||
: BasicAnnotationEditorDialog(parent)
|
||||
, ui(new Ui::AnnotationEditorDialog)
|
||||
, m_customId(customId)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->targetIdEdit->setText(targetId);
|
||||
|
||||
setWindowTitle(annotationEditorTitle);
|
||||
}
|
||||
|
||||
AnnotationEditorDialog::~AnnotationEditorDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::setCustomId(const QString &customId)
|
||||
{
|
||||
m_customId = customId;
|
||||
@@ -102,36 +237,5 @@ QString AnnotationEditorDialog::customId() const
|
||||
return m_customId;
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::acceptedClicked()
|
||||
{
|
||||
updateAnnotation();
|
||||
emit AnnotationEditorDialog::acceptedDialog();
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::fillFields()
|
||||
{
|
||||
ui->customIdEdit->setText(m_customId);
|
||||
ui->tabWidget->setupComments(m_annotation.comments());
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::updateAnnotation()
|
||||
{
|
||||
m_customId = ui->customIdEdit->text();
|
||||
Annotation annotation;
|
||||
annotation.setComments(ui->tabWidget->fetchComments());
|
||||
m_annotation = annotation;
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::addComment(const Comment &comment)
|
||||
{
|
||||
m_annotation.addComment(comment);
|
||||
ui->tabWidget->addCommentTab(comment);
|
||||
}
|
||||
|
||||
void AnnotationEditorDialog::removeComment(int index)
|
||||
{
|
||||
m_annotation.removeComment(index);
|
||||
ui->tabWidget->removeTab(index);
|
||||
}
|
||||
|
||||
} //namespace QmlDesigner
|
||||
|
@@ -36,60 +36,62 @@ class AnnotationEditorDialog;
|
||||
}
|
||||
class DefaultAnnotationsModel;
|
||||
|
||||
class BasicAnnotationEditorDialog : public QDialog
|
||||
class AnnotationEditorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BasicAnnotationEditorDialog(QWidget *parent);
|
||||
~BasicAnnotationEditorDialog();
|
||||
enum ViewMode { TableView, TabsView };
|
||||
|
||||
explicit AnnotationEditorDialog(QWidget *parent,
|
||||
const QString &targetId = {},
|
||||
const QString &customId = {});
|
||||
~AnnotationEditorDialog();
|
||||
|
||||
ViewMode viewMode() const;
|
||||
|
||||
Annotation const &annotation() const;
|
||||
void setAnnotation(const Annotation &annotation);
|
||||
|
||||
QString customId() const;
|
||||
void setCustomId(const QString &customId);
|
||||
|
||||
bool isGlobal() const;
|
||||
void setGlobal(bool = true);
|
||||
|
||||
void loadDefaultAnnotations(QString const &filename);
|
||||
|
||||
DefaultAnnotationsModel *defaultAnnotations() const;
|
||||
void setStatus(GlobalAnnotationStatus status);
|
||||
GlobalAnnotationStatus globalStatus() const;
|
||||
|
||||
public slots:
|
||||
void showStatusContainer(bool show);
|
||||
void switchToTabView();
|
||||
void switchToTableView();
|
||||
|
||||
private slots:
|
||||
void acceptedClicked();
|
||||
|
||||
signals:
|
||||
void acceptedDialog(); //use instead of QDialog::accepted
|
||||
|
||||
protected:
|
||||
virtual void fillFields() = 0;
|
||||
virtual void acceptedClicked() = 0;
|
||||
|
||||
Annotation m_annotation;
|
||||
std::unique_ptr<DefaultAnnotationsModel> m_defaults;
|
||||
};
|
||||
|
||||
class AnnotationEditorDialog : public BasicAnnotationEditorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AnnotationEditorDialog(QWidget *parent,
|
||||
const QString &targetId,
|
||||
const QString &customId);
|
||||
~AnnotationEditorDialog();
|
||||
|
||||
void setCustomId(const QString &customId);
|
||||
QString customId() const;
|
||||
|
||||
private slots:
|
||||
void acceptedClicked() override;
|
||||
|
||||
void globalChanged();
|
||||
private:
|
||||
void fillFields() override;
|
||||
void fillFields();
|
||||
void updateAnnotation();
|
||||
|
||||
void addComment(const Comment &comment);
|
||||
void removeComment(int index);
|
||||
|
||||
private:
|
||||
const QString annotationEditorTitle = {tr("Annotation Editor")};
|
||||
|
||||
Ui::AnnotationEditorDialog *ui;
|
||||
void setStatusVisibility(bool hasStatus);
|
||||
|
||||
std::unique_ptr<Ui::AnnotationEditorDialog> ui;
|
||||
GlobalAnnotationStatus m_globalStatus = GlobalAnnotationStatus::NoStatus;
|
||||
bool m_statusIsActive = false;
|
||||
bool m_isGlobal = false;
|
||||
Annotation m_annotation;
|
||||
QString m_customId;
|
||||
std::unique_ptr<DefaultAnnotationsModel> m_defaults;
|
||||
};
|
||||
|
||||
|
||||
} //namespace QmlDesigner
|
||||
|
@@ -14,6 +14,98 @@
|
||||
<string notr="true">Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QWidget" name="statusContainer" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="statusAddButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="statusComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>In Progress</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>In Review</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbTabView">
|
||||
<property name="text">
|
||||
<string>Tab View</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbTableView">
|
||||
<property name="text">
|
||||
<string>Table View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="annotationContainer" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
@@ -75,6 +167,9 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AnnotationTableView" name="tableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="focusPolicy">
|
||||
@@ -97,6 +192,11 @@
|
||||
<header>annotationtabwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AnnotationTableView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>annotationtableview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>targetIdEdit</tabstop>
|
||||
|
@@ -22,6 +22,7 @@
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QLabel>
|
||||
|
@@ -26,7 +26,8 @@
|
||||
#include "globalannotationeditor.h"
|
||||
|
||||
#include "annotation.h"
|
||||
#include "globalannotationeditordialog.h"
|
||||
#include "annotationeditordialog.h"
|
||||
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <QMessageBox>
|
||||
@@ -41,15 +42,18 @@ GlobalAnnotationEditor::~GlobalAnnotationEditor() {}
|
||||
|
||||
QWidget *GlobalAnnotationEditor::createWidget()
|
||||
{
|
||||
auto* dialog = new GlobalAnnotationEditorDialog(Core::ICore::dialogParent(),
|
||||
this->m_modelNode.globalStatus());
|
||||
auto *dialog = new AnnotationEditorDialog(Core::ICore::dialogParent());
|
||||
|
||||
dialog->setGlobal(true);
|
||||
dialog->setStatus(m_modelNode.globalStatus());
|
||||
|
||||
dialog->setAnnotation(this->m_modelNode.globalAnnotation());
|
||||
QObject::connect(dialog,
|
||||
&GlobalAnnotationEditorDialog::acceptedDialog,
|
||||
&AnnotationEditorDialog::acceptedDialog,
|
||||
this,
|
||||
&GlobalAnnotationEditor::acceptedClicked);
|
||||
QObject::connect(dialog,
|
||||
&GlobalAnnotationEditorDialog::rejected,
|
||||
&AnnotationEditorDialog::rejected,
|
||||
this,
|
||||
&GlobalAnnotationEditor::cancelClicked);
|
||||
return dialog;
|
||||
@@ -73,7 +77,7 @@ void GlobalAnnotationEditor::removeFullAnnotation()
|
||||
|
||||
void GlobalAnnotationEditor::acceptedClicked()
|
||||
{
|
||||
if (const auto *dialog = qobject_cast<GlobalAnnotationEditorDialog *>(widget())) {
|
||||
if (const auto *dialog = qobject_cast<AnnotationEditorDialog *>(widget())) {
|
||||
auto &node = this->m_modelNode;
|
||||
const Annotation annotation = dialog->annotation();
|
||||
|
||||
|
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "abstractaction.h"
|
||||
#include "annotation.h"
|
||||
#include "globalannotationeditordialog.h"
|
||||
|
||||
#include "editorproxy.h"
|
||||
#include "modelnode.h"
|
||||
|
@@ -1,179 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "globalannotationeditordialog.h"
|
||||
#include "annotation.h"
|
||||
#include "annotationcommenttab.h"
|
||||
#include "ui_globalannotationeditordialog.h"
|
||||
|
||||
#include <timelineicons.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
GlobalAnnotationEditorDialog::GlobalAnnotationEditorDialog(QWidget *parent,
|
||||
GlobalAnnotationStatus status)
|
||||
: BasicAnnotationEditorDialog(parent)
|
||||
, ui(new Ui::GlobalAnnotationEditorDialog)
|
||||
, m_globalStatus(status)
|
||||
, m_statusIsActive(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->setDefaultAnnotations(defaultAnnotations());
|
||||
ui->tableView->setDefaultAnnotations(defaultAnnotations());
|
||||
|
||||
connect(ui->tableView,
|
||||
&AnnotationTableView::richTextEditorRequested,
|
||||
this,
|
||||
[&](int index, QString const &) {
|
||||
switchToTabView();
|
||||
ui->tabWidget->setCurrentIndex(index);
|
||||
});
|
||||
|
||||
connect(ui->statusAddButton, &QPushButton::clicked, this, [&](bool) {
|
||||
setStatusVisibility(true);
|
||||
});
|
||||
|
||||
connect(ui->rbTableView,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&GlobalAnnotationEditorDialog::switchToTableView);
|
||||
connect(ui->rbTabView,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&GlobalAnnotationEditorDialog::switchToTabView);
|
||||
|
||||
setStatus(m_globalStatus);
|
||||
setWindowTitle(globalEditorTitle);
|
||||
switchToTabView();
|
||||
}
|
||||
|
||||
GlobalAnnotationEditorDialog::~GlobalAnnotationEditorDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
GlobalAnnotationEditorDialog::ViewMode GlobalAnnotationEditorDialog::viewMode() const
|
||||
{
|
||||
return ui->rbTableView->isChecked() ? TableView : TabsView;
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::setStatus(GlobalAnnotationStatus status)
|
||||
{
|
||||
m_globalStatus = status;
|
||||
bool hasStatus = status.status() != GlobalAnnotationStatus::NoStatus;
|
||||
|
||||
if (hasStatus)
|
||||
ui->statusComboBox->setCurrentIndex(int(status.status()));
|
||||
|
||||
setStatusVisibility(hasStatus);
|
||||
}
|
||||
|
||||
GlobalAnnotationStatus GlobalAnnotationEditorDialog::globalStatus() const
|
||||
{
|
||||
return m_globalStatus;
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::showStatusContainer(bool show)
|
||||
{
|
||||
ui->statusContainer->setVisible(show);
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::switchToTabView()
|
||||
{
|
||||
m_annotation.setComments(ui->tableView->fetchComments());
|
||||
ui->rbTabView->setChecked(true);
|
||||
ui->tableView->hide();
|
||||
ui->tabWidget->show();
|
||||
fillFields();
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::switchToTableView()
|
||||
{
|
||||
m_annotation.setComments(ui->tabWidget->fetchComments());
|
||||
ui->rbTableView->setChecked(true);
|
||||
ui->tabWidget->hide();
|
||||
ui->tableView->show();
|
||||
fillFields();
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::acceptedClicked()
|
||||
{
|
||||
updateAnnotation();
|
||||
emit GlobalAnnotationEditorDialog::acceptedDialog();
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::fillFields()
|
||||
{
|
||||
ui->tabWidget->setupComments(m_annotation.comments());
|
||||
ui->tableView->setupComments(m_annotation.comments());
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::updateAnnotation()
|
||||
{
|
||||
Annotation annotation;
|
||||
switch (viewMode()) {
|
||||
case TabsView:
|
||||
annotation.setComments(ui->tabWidget->fetchComments());
|
||||
break;
|
||||
case TableView:
|
||||
annotation.setComments(ui->tableView->fetchComments());
|
||||
break;
|
||||
}
|
||||
|
||||
m_annotation = annotation;
|
||||
|
||||
if (m_statusIsActive)
|
||||
m_globalStatus.setStatus(ui->statusComboBox->currentIndex());
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::addComment(const Comment &comment)
|
||||
{
|
||||
m_annotation.addComment(comment);
|
||||
ui->tabWidget->addCommentTab(comment);
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::removeComment(int index)
|
||||
{
|
||||
if ((m_annotation.commentsSize() > index) && (index >= 0)) {
|
||||
m_annotation.removeComment(index);
|
||||
ui->tabWidget->removeTab(index);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalAnnotationEditorDialog::setStatusVisibility(bool hasStatus)
|
||||
{
|
||||
ui->statusAddButton->setVisible(!hasStatus);
|
||||
ui->statusComboBox->setVisible(hasStatus);
|
||||
|
||||
m_statusIsActive = hasStatus;
|
||||
}
|
||||
|
||||
} //namespace QmlDesigner
|
@@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "annotationeditordialog.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
namespace Ui {
|
||||
class GlobalAnnotationEditorDialog;
|
||||
}
|
||||
|
||||
class GlobalAnnotationEditorDialog : public BasicAnnotationEditorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ViewMode {
|
||||
TableView,
|
||||
TabsView
|
||||
};
|
||||
|
||||
explicit GlobalAnnotationEditorDialog(
|
||||
QWidget *parent = nullptr, GlobalAnnotationStatus status = GlobalAnnotationStatus::NoStatus);
|
||||
~GlobalAnnotationEditorDialog();
|
||||
|
||||
ViewMode viewMode() const;
|
||||
|
||||
void setStatus(GlobalAnnotationStatus status);
|
||||
GlobalAnnotationStatus globalStatus() const;
|
||||
|
||||
public slots:
|
||||
void showStatusContainer(bool show);
|
||||
void switchToTabView();
|
||||
void switchToTableView();
|
||||
|
||||
private slots:
|
||||
void acceptedClicked() override;
|
||||
|
||||
private:
|
||||
|
||||
void fillFields() override;
|
||||
void updateAnnotation();
|
||||
void addComment(const Comment &comment);
|
||||
void removeComment(int index);
|
||||
|
||||
void setStatusVisibility(bool hasStatus);
|
||||
|
||||
private:
|
||||
const QString globalEditorTitle = {tr("Global Annotation Editor")};
|
||||
|
||||
Ui::GlobalAnnotationEditorDialog *ui;
|
||||
|
||||
GlobalAnnotationStatus m_globalStatus;
|
||||
bool m_statusIsActive;
|
||||
};
|
||||
|
||||
} //namespace QmlDesigner
|
@@ -1,198 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QmlDesigner::GlobalAnnotationEditorDialog</class>
|
||||
<widget class="QDialog" name="QmlDesigner::GlobalAnnotationEditorDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1344</width>
|
||||
<height>819</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QWidget" name="statusContainer" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="statusAddButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="statusComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>In Progress</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>In Review</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbTabView">
|
||||
<property name="text">
|
||||
<string>Tab View</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbTableView">
|
||||
<property name="text">
|
||||
<string>Table View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AnnotationTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AnnotationTableView" name="tableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AnnotationTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>annotationtabwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AnnotationTableView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>annotationtableview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QmlDesigner::GlobalAnnotationEditorDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>261</x>
|
||||
<y>473</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QmlDesigner::GlobalAnnotationEditorDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>329</x>
|
||||
<y>473</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -737,9 +737,6 @@ Project {
|
||||
"annotationeditor/annotationeditordialog.cpp",
|
||||
"annotationeditor/annotationeditordialog.h",
|
||||
"annotationeditor/annotationeditordialog.ui",
|
||||
"annotationeditor/globalannotationeditordialog.cpp",
|
||||
"annotationeditor/globalannotationeditordialog.h",
|
||||
"annotationeditor/globalannotationeditordialog.ui",
|
||||
"annotationeditor/defaultannotations.cpp",
|
||||
"annotationeditor/defaultannotations.h",
|
||||
"annotationeditor/annotationtableview.cpp",
|
||||
|
Reference in New Issue
Block a user