diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-22 03:02:30 +0200 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2019-10-22 10:28:38 +0200 |
commit | b2f3eb655ccd1b6cc1c83a33b8a8157f406e91e3 (patch) | |
tree | 7de025c51d4994936306e4b30ebbfda16b51cba0 | |
parent | 25ebbbf6f3ed849992692b247fc16ce079dedf86 (diff) | |
parent | 435a795b6ad899afe49e56130300ab0d966d0bd7 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I5f916f50d54ba36f9dd5b6c2c9aa6ce7fa2172bb
33 files changed, 704 insertions, 912 deletions
diff --git a/src/assistant/help/qhelpsearchquerywidget.cpp b/src/assistant/help/qhelpsearchquerywidget.cpp index 4cbd4b069..61902656d 100644 --- a/src/assistant/help/qhelpsearchquerywidget.cpp +++ b/src/assistant/help/qhelpsearchquerywidget.cpp @@ -111,9 +111,11 @@ private: void retranslate() { m_searchLabel->setText(QHelpSearchQueryWidget::tr("Search for:")); + m_searchButton->setText(QHelpSearchQueryWidget::tr("Search")); +#if QT_CONFIG(tooltip) m_prevQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Previous search")); m_nextQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Next search")); - m_searchButton->setText(QHelpSearchQueryWidget::tr("Search")); +#endif } void saveQuery(const QString &query) diff --git a/src/designer/src/components/propertyeditor/paletteeditor.cpp b/src/designer/src/components/propertyeditor/paletteeditor.cpp index 4bb1bf450..8fca31df0 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.cpp +++ b/src/designer/src/components/propertyeditor/paletteeditor.cpp @@ -35,9 +35,16 @@ #include <QtDesigner/abstractformwindowmanager.h> #include <QtCore/qmetaobject.h> +#include <QtGui/qguiapplication.h> #include <QtGui/qpainter.h> +#include <QtGui/qscreen.h> +#if QT_CONFIG(clipboard) +# include <QtGui/qclipboard.h> +#endif +#include <QtWidgets/qaction.h> #include <QtWidgets/qtoolbutton.h> #include <QtWidgets/qlabel.h> +#include <QtWidgets/qmenu.h> #include <QtWidgets/qheaderview.h> QT_BEGIN_NAMESPACE @@ -48,11 +55,7 @@ enum { BrushRole = 33 }; PaletteEditor::PaletteEditor(QDesignerFormEditorInterface *core, QWidget *parent) : QDialog(parent), - m_currentColorGroup(QPalette::Active), m_paletteModel(new PaletteModel(this)), - m_modelUpdated(false), - m_paletteUpdated(false), - m_compute(true), m_core(core) { ui.setupUi(this); @@ -71,6 +74,14 @@ PaletteEditor::PaletteEditor(QDesignerFormEditorInterface *core, QWidget *parent ui.paletteView->setRootIsDecorated(false); ui.paletteView->setColumnHidden(2, true); ui.paletteView->setColumnHidden(3, true); + ui.paletteView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui.paletteView, &QWidget::customContextMenuRequested, + this, &PaletteEditor::viewContextMenuRequested); + + const auto itemRect = ui.paletteView->visualRect(m_paletteModel->index(0, 0)); + const int minHeight = qMin(itemRect.height() * QPalette::NColorRoles, + (screen()->geometry().height() * 2) / 3); + ui.paletteView->setMinimumSize({itemRect.width() * 4, minHeight}); } PaletteEditor::~PaletteEditor() = default; @@ -221,6 +232,43 @@ QPalette PaletteEditor::getPalette(QDesignerFormEditorInterface *core, QWidget* return result == QDialog::Accepted ? dlg.palette() : init; } +void PaletteEditor::viewContextMenuRequested(const QPoint &pos) +{ + const auto index = ui.paletteView->indexAt(pos); + if (!index.isValid()) + return; + auto brush = m_paletteModel->brushAt(index); + const auto color = brush.color(); + if (!m_contextMenu) { + m_contextMenu = new QMenu(this); + m_lighterAction = m_contextMenu->addAction(tr("Lighter")); + m_darkerAction = m_contextMenu->addAction(tr("Darker")); + m_copyColorAction = m_contextMenu->addAction(QString()); + } + const auto rgb = color.rgb() & 0xffffffu; + const bool isBlack = rgb == 0u; + m_lighterAction->setEnabled(rgb != 0xffffffu); + m_darkerAction->setDisabled(isBlack); + m_copyColorAction->setText(tr("Copy color %1").arg(color.name())); + auto action = m_contextMenu->exec(ui.paletteView->viewport()->mapToGlobal(pos)); + if (!action) + return; + if (action == m_copyColorAction) { +#if QT_CONFIG(clipboard) + QGuiApplication::clipboard()->setText(color.name()); +#endif + return; + } + // Fall through to darker/lighter. Note: black cannot be made lighter due + // to QTBUG-9343. + enum : int { factor = 120 }; + const QColor newColor = action == m_darkerAction + ? color.darker(factor) + : (isBlack ? QColor(0x404040u) : color.lighter(factor)); + brush.setColor(newColor); + m_paletteModel->setData(index, QVariant(brush), BrushRole); +} + ////////////////////// PaletteModel::PaletteModel(QObject *parent) : @@ -230,14 +278,17 @@ PaletteModel::PaletteModel(QObject *parent) : const int index = meta->indexOfProperty("colorRole"); const QMetaProperty p = meta->property(index); const QMetaEnum e = p.enumerator(); + m_roleEntries.reserve(QPalette::NColorRoles); for (int r = QPalette::WindowText; r < QPalette::NColorRoles; r++) { - m_roleNames[static_cast<QPalette::ColorRole>(r)] = QLatin1String(e.key(r)); + const auto role = static_cast<QPalette::ColorRole>(r); + if (role != QPalette::NoRole) + m_roleEntries.append({QLatin1String(e.key(r)), role}); } } int PaletteModel::rowCount(const QModelIndex &) const { - return m_roleNames.count(); + return m_roleEntries.size(); } int PaletteModel::columnCount(const QModelIndex &) const @@ -245,29 +296,35 @@ int PaletteModel::columnCount(const QModelIndex &) const return 4; } +QBrush PaletteModel::brushAt(const QModelIndex &index) const +{ + return m_palette.brush(columnToGroup(index.column()), roleAt(index.row())); +} + QVariant PaletteModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); - if (index.row() < 0 || index.row() >= QPalette::NColorRoles) + if (index.row() < 0 || index.row() >= m_roleEntries.size()) return QVariant(); if (index.column() < 0 || index.column() >= 4) return QVariant(); if (index.column() == 0) { if (role == Qt::DisplayRole) - return m_roleNames[static_cast<QPalette::ColorRole>(index.row())]; + return m_roleEntries.at(index.row()).name; if (role == Qt::EditRole) { const uint mask = m_palette.resolve(); - if (mask & (1 << index.row())) + if (mask & (1 << int(roleAt(index.row())))) return true; return false; } return QVariant(); } + if (role == Qt::ToolTipRole) + return brushAt(index).color().name(); if (role == BrushRole) - return m_palette.brush(columnToGroup(index.column()), - static_cast<QPalette::ColorRole>(index.row())); + return brushAt(index); return QVariant(); } @@ -276,17 +333,19 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int if (!index.isValid()) return false; + const int row = index.row(); + const auto colorRole = roleAt(row); + if (index.column() != 0 && role == BrushRole) { const QBrush br = qvariant_cast<QBrush>(value); - const QPalette::ColorRole r = static_cast<QPalette::ColorRole>(index.row()); const QPalette::ColorGroup g = columnToGroup(index.column()); - m_palette.setBrush(g, r, br); + m_palette.setBrush(g, colorRole, br); - QModelIndex idxBegin = PaletteModel::index(r, 0); - QModelIndex idxEnd = PaletteModel::index(r, 3); + QModelIndex idxBegin = PaletteModel::index(row, 0); + QModelIndex idxEnd = PaletteModel::index(row, 3); if (m_compute) { - m_palette.setBrush(QPalette::Inactive, r, br); - switch (r) { + m_palette.setBrush(QPalette::Inactive, colorRole, br); + switch (colorRole) { case QPalette::WindowText: case QPalette::Text: case QPalette::ButtonText: @@ -298,18 +357,18 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int m_palette.setBrush(QPalette::Disabled, QPalette::Text, br); m_palette.setBrush(QPalette::Disabled, QPalette::ButtonText, br); idxBegin = PaletteModel::index(0, 0); - idxEnd = PaletteModel::index(m_roleNames.count() - 1, 3); + idxEnd = PaletteModel::index(m_roleEntries.size() - 1, 3); break; case QPalette::Window: m_palette.setBrush(QPalette::Disabled, QPalette::Base, br); m_palette.setBrush(QPalette::Disabled, QPalette::Window, br); - idxBegin = PaletteModel::index(QPalette::Base, 0); + idxBegin = PaletteModel::index(rowOf(QPalette::Base), 0); break; case QPalette::Highlight: //m_palette.setBrush(QPalette::Disabled, QPalette::Highlight, c.dark(120)); break; default: - m_palette.setBrush(QPalette::Disabled, r, br); + m_palette.setBrush(QPalette::Disabled, colorRole, br); break; } } @@ -320,22 +379,21 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int if (index.column() == 0 && role == Qt::EditRole) { uint mask = m_palette.resolve(); const bool isMask = qvariant_cast<bool>(value); - const int r = index.row(); if (isMask) - mask |= (1 << r); + mask |= (1 << int(colorRole)); else { - m_palette.setBrush(QPalette::Active, static_cast<QPalette::ColorRole>(r), - m_parentPalette.brush(QPalette::Active, static_cast<QPalette::ColorRole>(r))); - m_palette.setBrush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r), - m_parentPalette.brush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r))); - m_palette.setBrush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r), - m_parentPalette.brush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r))); - - mask &= ~(1 << index.row()); + m_palette.setBrush(QPalette::Active, colorRole, + m_parentPalette.brush(QPalette::Active, colorRole)); + m_palette.setBrush(QPalette::Inactive, colorRole, + m_parentPalette.brush(QPalette::Inactive, colorRole)); + m_palette.setBrush(QPalette::Disabled, colorRole, + m_parentPalette.brush(QPalette::Disabled, colorRole)); + + mask &= ~(1 << int(colorRole)); } m_palette.resolve(mask); emit paletteChanged(m_palette); - const QModelIndex idxEnd = PaletteModel::index(r, 3); + const QModelIndex idxEnd = PaletteModel::index(row, 3); emit dataChanged(index, idxEnd); return true; } @@ -375,7 +433,7 @@ void PaletteModel::setPalette(const QPalette &palette, const QPalette &parentPal m_parentPalette = parentPalette; m_palette = palette; const QModelIndex idxBegin = index(0, 0); - const QModelIndex idxEnd = index(m_roleNames.count() - 1, 3); + const QModelIndex idxEnd = index(m_roleEntries.size() - 1, 3); emit dataChanged(idxBegin, idxEnd); } @@ -397,6 +455,15 @@ int PaletteModel::groupToColumn(QPalette::ColorGroup group) const return 3; } +int PaletteModel::rowOf(QPalette::ColorRole role) const +{ + for (int row = 0, size = m_roleEntries.size(); row < size; ++row) { + if (m_roleEntries.at(row).role == role) + return row; + } + return -1; +} + ////////////////////////// BrushEditor::BrushEditor(QDesignerFormEditorInterface *core, QWidget *parent) : diff --git a/src/designer/src/components/propertyeditor/paletteeditor.h b/src/designer/src/components/propertyeditor/paletteeditor.h index 6124340dc..3355e3c97 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.h +++ b/src/designer/src/components/propertyeditor/paletteeditor.h @@ -34,7 +34,9 @@ QT_BEGIN_NAMESPACE +class QAction; class QListView; +class QMenu; class QLabel; class QtColorButton; class QDesignerFormEditorInterface; @@ -65,6 +67,7 @@ private slots: void on_detailsRadio_clicked(); void paletteChanged(const QPalette &palette); + void viewContextMenuRequested(const QPoint &pos); protected: @@ -81,12 +84,16 @@ private: Ui::PaletteEditor ui; QPalette m_editPalette; QPalette m_parentPalette; - QPalette::ColorGroup m_currentColorGroup; class PaletteModel *m_paletteModel; - bool m_modelUpdated; - bool m_paletteUpdated; - bool m_compute; QDesignerFormEditorInterface *m_core; + QAction *m_lighterAction = nullptr; + QAction *m_darkerAction = nullptr; + QAction *m_copyColorAction = nullptr; + QMenu *m_contextMenu = nullptr; + QPalette::ColorGroup m_currentColorGroup = QPalette::Active; + bool m_modelUpdated = false; + bool m_paletteUpdated = false; + bool m_compute = true; }; @@ -108,18 +115,27 @@ public: QPalette getPalette() const; void setPalette(const QPalette &palette, const QPalette &parentPalette); + QBrush brushAt(const QModelIndex &index) const; + QPalette::ColorRole colorRole() const { return QPalette::NoRole; } void setCompute(bool on) { m_compute = on; } signals: void paletteChanged(const QPalette &palette); private: + struct RoleEntry + { + QString name; + QPalette::ColorRole role; + }; QPalette::ColorGroup columnToGroup(int index) const; int groupToColumn(QPalette::ColorGroup group) const; + QPalette::ColorRole roleAt(int row) const { return m_roleEntries.at(row).role; } + int rowOf(QPalette::ColorRole role) const; QPalette m_palette; QPalette m_parentPalette; - QMap<QPalette::ColorRole, QString> m_roleNames; + QVector<RoleEntry> m_roleEntries; bool m_compute = true; }; diff --git a/src/designer/src/components/propertyeditor/paletteeditor.ui b/src/designer/src/components/propertyeditor/paletteeditor.ui index aa5965d79..2bb8cfedc 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.ui +++ b/src/designer/src/components/propertyeditor/paletteeditor.ui @@ -1,4 +1,5 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <comment>********************************************************************* ** ** Copyright (C) 2016 The Qt Company Ltd. @@ -27,175 +28,183 @@ ** *********************************************************************</comment> <class>qdesigner_internal::PaletteEditor</class> - <widget class="QDialog" name="qdesigner_internal::PaletteEditor" > - <property name="geometry" > + <widget class="QDialog" name="qdesigner_internal::PaletteEditor"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>365</width> - <height>409</height> + <width>918</width> + <height>599</height> </rect> </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Edit Palette</string> </property> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QGroupBox" name="advancedBox" > - <property name="minimumSize" > - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="title" > - <string>Tune Palette</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QtColorButton" name="buildButton" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>13</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QGroupBox" name="advancedBox"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="title"> + <string>Tune Palette</string> + </property> + <layout class="QGridLayout"> + <property name="leftMargin"> + <number>9</number> </property> - <property name="text" > - <string/> + <property name="topMargin"> + <number>9</number> </property> - </widget> - </item> - <item row="1" column="0" colspan="4" > - <widget class="QTreeView" name="paletteView" > - <property name="minimumSize" > - <size> - <width>0</width> - <height>200</height> - </size> + <property name="rightMargin"> + <number>9</number> </property> - </widget> - </item> - <item row="0" column="3" > - <widget class="QRadioButton" name="detailsRadio" > - <property name="text" > - <string>Show Details</string> + <property name="bottomMargin"> + <number>9</number> </property> - </widget> - </item> - <item row="0" column="2" > - <widget class="QRadioButton" name="computeRadio" > - <property name="text" > - <string>Compute Details</string> + <property name="spacing"> + <number>6</number> </property> - <property name="checked" > - <bool>true</bool> + <item row="0" column="1"> + <widget class="QtColorButton" name="buildButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Ignored"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="0" colspan="4"> + <widget class="QTreeView" name="paletteView"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>200</height> + </size> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QRadioButton" name="detailsRadio"> + <property name="text"> + <string>Show Details</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QRadioButton" name="computeRadio"> + <property name="text"> + <string>Compute Details</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Quick</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox126"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Preview</string> + </property> + <layout class="QGridLayout"> + <property name="leftMargin"> + <number>8</number> </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Quick</string> + <property name="topMargin"> + <number>8</number> </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="GroupBox126" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title" > - <string>Preview</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="2" > - <widget class="QRadioButton" name="disabledRadio" > - <property name="text" > - <string>Disabled</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QRadioButton" name="inactiveRadio" > - <property name="text" > - <string>Inactive</string> + <property name="rightMargin"> + <number>8</number> </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QRadioButton" name="activeRadio" > - <property name="text" > - <string>Active</string> + <property name="bottomMargin"> + <number>8</number> </property> - <property name="checked" > - <bool>true</bool> + <property name="spacing"> + <number>6</number> </property> - </widget> - </item> - <item row="1" column="0" colspan="3" > - <widget class="qdesigner_internal::PreviewFrame" native="1" name="previewFrame" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> + <item row="0" column="2"> + <widget class="QRadioButton" name="disabledRadio"> + <property name="text"> + <string>Disabled</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="inactiveRadio"> + <property name="text"> + <string>Inactive</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QRadioButton" name="activeRadio"> + <property name="text"> + <string>Active</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0" colspan="3"> + <widget class="qdesigner_internal::PreviewFrame" name="previewFrame" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> @@ -221,11 +230,11 @@ <receiver>qdesigner_internal::PaletteEditor</receiver> <slot>accept()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>180</x> <y>331</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>134</x> <y>341</y> </hint> @@ -237,11 +246,11 @@ <receiver>qdesigner_internal::PaletteEditor</receiver> <slot>reject()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>287</x> <y>329</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>302</x> <y>342</y> </hint> diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index f44c3cd5a..c2f53a46e 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -391,7 +391,7 @@ void ConnectionModel::connectionChanged(Connection *con) void ConnectionModel::updateAll() { - emit dataChanged(index(0, 0), index(rowCount(), columnCount())); + emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); } } @@ -734,6 +734,8 @@ void SignalSlotEditorWindow::setActiveFormWindow(QDesignerFormWindowInterface *f this, &SignalSlotEditorWindow::updateEditorSelection); disconnect(m_editor.data(), &SignalSlotEditor::connectionSelected, this, &SignalSlotEditorWindow::updateDialogSelection); + disconnect(m_editor.data(), &SignalSlotEditor::connectionAdded, + this, &SignalSlotEditorWindow::resizeColumns); if (integration) { disconnect(integration, &QDesignerIntegrationInterface::objectNameChanged, this, &SignalSlotEditorWindow::objectNameChanged); @@ -753,12 +755,15 @@ void SignalSlotEditorWindow::setActiveFormWindow(QDesignerFormWindowInterface *f this, &SignalSlotEditorWindow::updateEditorSelection); connect(m_editor.data(), &SignalSlotEditor::connectionSelected, this, &SignalSlotEditorWindow::updateDialogSelection); + connect(m_editor.data(), &SignalSlotEditor::connectionAdded, + this, &SignalSlotEditorWindow::resizeColumns); if (integration) { connect(integration, &QDesignerIntegrationInterface::objectNameChanged, this, &SignalSlotEditorWindow::objectNameChanged); } } + resizeColumns(); updateUi(); } @@ -826,6 +831,12 @@ void SignalSlotEditorWindow::updateUi() m_remove_button->setEnabled(!m_editor.isNull() && m_view->currentIndex().isValid()); } +void SignalSlotEditorWindow::resizeColumns() +{ + for (int c = 0, count = m_model->columnCount(); c < count; ++c) + m_view->resizeColumnToContents(c); +} + } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.h b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.h index 8a51a8ca0..4d7af91f8 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.h +++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.h @@ -65,6 +65,7 @@ private slots: void addConnection(); void removeConnection(); void updateUi(); + void resizeColumns(); private: QTreeView *m_view; diff --git a/src/macdeployqt/macdeployqt/main.cpp b/src/macdeployqt/macdeployqt/main.cpp index 698176cbc..3ee9eb915 100644 --- a/src/macdeployqt/macdeployqt/main.cpp +++ b/src/macdeployqt/macdeployqt/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char **argv) qDebug() << " -qmlimport=<path> : Add the given path to the QML module search locations"; qDebug() << " -always-overwrite : Copy files even if the target file exists"; qDebug() << " -codesign=<ident> : Run codesign with the given identity on all executables"; + qDebug() << " -hardened-runtime : Enable Hardened Runtime when code signing"; qDebug() << " -appstore-compliant: Skip deployment of components that use private API"; qDebug() << " -libpath=<path> : Add the given path to the library search path"; qDebug() << " -fs=<filesystem> : Set the filesystem used for the .dmg disk image (defaults to HFS+)"; @@ -96,6 +97,7 @@ int main(int argc, char **argv) QStringList qmlImportPaths; extern bool runCodesign; extern QString codesignIdentiy; + extern bool hardenedRuntime; extern bool appstoreCompliant; extern bool deployFramework; @@ -164,6 +166,9 @@ int main(int argc, char **argv) runCodesign = true; codesignIdentiy = argument.mid(index+1); } + } else if (argument.startsWith(QByteArray("-hardened-runtime"))) { + LogDebug() << "Argument found:" << argument; + hardenedRuntime = true; } else if (argument == QByteArray("-appstore-compliant")) { LogDebug() << "Argument found:" << argument; appstoreCompliant = true; diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp index a43267ae4..454e72b7c 100644 --- a/src/macdeployqt/shared/shared.cpp +++ b/src/macdeployqt/shared/shared.cpp @@ -53,6 +53,7 @@ bool alwaysOwerwriteEnabled = false; bool runCodesign = false; QStringList librarySearchPath; QString codesignIdentiy; +bool hardenedRuntime = false; bool appstoreCompliant = false; int logLevel = 1; bool deployFramework = false; @@ -1371,11 +1372,18 @@ void codesignFile(const QString &identity, const QString &filePath) if (!runCodesign) return; - LogNormal() << "codesign" << filePath; + QString codeSignLogMessage = "codesign"; + if (hardenedRuntime) + codeSignLogMessage += ", enable hardned runtime"; + LogNormal() << codeSignLogMessage << filePath; + + QStringList codeSignOptions = { "--preserve-metadata=identifier,entitlements", "--force", "-s", + identity, filePath }; + if (hardenedRuntime) + codeSignOptions << "-o" << "runtime"; QProcess codesign; - codesign.start("codesign", QStringList() << "--preserve-metadata=identifier,entitlements" - << "--force" << "-s" << identity << filePath); + codesign.start("codesign", codeSignOptions); codesign.waitForFinished(-1); QByteArray err = codesign.readAllStandardError(); diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index 7b96ebdd7..1ffcdd39a 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -261,12 +261,14 @@ QMap<QString, QStringList> Config::includeFilesMap_; /*! The constructor sets the \a programName and initializes all - internal state variables to empty values. + internal state variables to either default values or to ones + defined in command line arguments \a args. */ -Config::Config(const QString &programName) +Config::Config(const QString &programName, const QStringList &args) : prog(programName) { numInstances++; + processCommandLineOptions(args); reset(); } @@ -299,26 +301,51 @@ void Config::reset() setStringList(CONFIG_LANGUAGE, QStringList("Cpp")); // i.e. C++ setStringList(CONFIG_OUTPUTFORMATS, QStringList("HTML")); setStringList(CONFIG_TABSIZE, QStringList("8")); + + // Publish options from the command line as config variables + const auto setListFlag = [this](const QString &key, bool test) { + setStringList(key, QStringList(test ? QStringLiteral("true") : QStringLiteral("false"))); + }; +#define SET(opt, test) setListFlag(opt, m_parser.isSet(m_parser.test)) + SET(CONFIG_SYNTAXHIGHLIGHTING, highlightingOption); + SET(CONFIG_SHOWINTERNAL, showInternalOption); + SET(CONFIG_SINGLEEXEC, singleExecOption); + SET(CONFIG_WRITEQAPAGES, writeQaPagesOption); + SET(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL, redirectDocumentationToDevNullOption); + SET(CONFIG_AUTOLINKERRORS, autoLinkErrorsOption); + SET(CONFIG_OBSOLETELINKS, obsoleteLinksOption); +#undef SET + setListFlag(CONFIG_NOLINKERRORS, + m_parser.isSet(m_parser.noLinkErrorsOption) + || qEnvironmentVariableIsSet("QDOC_NOLINKERRORS")); + + // CONFIG_DEFINES and CONFIG_INCLUDEPATHS are set in load() } /*! Loads and parses the qdoc configuration file \a fileName. - This function first resets the Config instance, then - calls the other load() function, which does the loading, - parsing, and processing of the configuration file. - - Intializes the location variables returned by location() - and lastLocation(). + If a previous project was loaded, this function first resets the + Config instance. Then it calls the other load() function, which + does the loading, parsing, and processing of the configuration file. */ void Config::load(const QString &fileName) { - reset(); + // Reset if a previous project was loaded + if (configVars_.contains(CONFIG_PROJECT)) + reset(); + load(Location::null, fileName); if (loc.isEmpty()) loc = Location(fileName); else loc.setEtc(true); lastLocation_ = Location::null; + + // Add defines and includepaths from command line to their + // respective configuration variables. Values set here are + // always added to what's defined in configuration file. + insertStringList(CONFIG_DEFINES, m_defines); + insertStringList(CONFIG_INCLUDEPATHS, m_includePaths); } /*! @@ -339,40 +366,77 @@ void Config::insertStringList(const QString &var, const QStringList &values) } /*! - Set configuration options from \a qdocGlobals. + Process and store variables from the command line. */ -void Config::setOptions(const QDocGlobals &qdocGlobals) +void Config::processCommandLineOptions(const QStringList &args) { - setStringList(CONFIG_SYNTAXHIGHLIGHTING, QStringList(qdocGlobals.highlighting() ? "true" : "false")); - setStringList(CONFIG_SHOWINTERNAL, QStringList(qdocGlobals.showInternal() ? "true" : "false")); - setStringList(CONFIG_SINGLEEXEC, QStringList(qdocGlobals.singleExec() ? "true" : "false")); - setStringList(CONFIG_WRITEQAPAGES, QStringList(qdocGlobals.writeQaPages() ? "true" : "false")); - setStringList(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL, QStringList(qdocGlobals.redirectDocumentationToDevNull() ? "true" : "false")); - setStringList(CONFIG_NOLINKERRORS, QStringList(qdocGlobals.noLinkErrors() ? "true" : "false")); - setStringList(CONFIG_AUTOLINKERRORS, QStringList(qdocGlobals.autolinkErrors() ? "true" : "false")); - setStringList(CONFIG_OBSOLETELINKS, QStringList(qdocGlobals.obsoleteLinks() ? "true" : "false")); -} + m_parser.process(args); -/*! - Set configuration options from \a parser. - */ -void Config::setOptions(const QDocCommandLineParser &parser) -{ - generateExamples = !parser.isSet(parser.noExamplesOption); - if (parser.isSet(parser.installDirOption)) - installDir = parser.value(parser.installDirOption); - if (parser.isSet(parser.outputDirOption)) - overrideOutputDir = parser.value(parser.outputDirOption); + m_defines = m_parser.values(m_parser.defineOption); + m_dependModules = m_parser.values(m_parser.dependsOption); + setIndexDirs(); + setIncludePaths(); + + generateExamples = !m_parser.isSet(m_parser.noExamplesOption); + if (m_parser.isSet(m_parser.installDirOption)) + installDir = m_parser.value(m_parser.installDirOption); + if (m_parser.isSet(m_parser.outputDirOption)) + overrideOutputDir = m_parser.value(m_parser.outputDirOption); - const auto outputFormats = parser.values(parser.outputFormatOption); + const auto outputFormats = m_parser.values(m_parser.outputFormatOption); for (const auto &format : outputFormats) overrideOutputFormats.insert(format); - debug_ = parser.isSet(parser.debugOption); + debug_ = m_parser.isSet(m_parser.debugOption); + + // TODO: Make Generator use Config instead of storing these separately + if (m_parser.isSet(m_parser.prepareOption)) + Generator::setQDocPass(Generator::Prepare); + if (m_parser.isSet(m_parser.generateOption)) + Generator::setQDocPass(Generator::Generate); + if (m_parser.isSet(m_parser.singleExecOption)) + Generator::setSingleExec(); + if (m_parser.isSet(m_parser.writeQaPagesOption)) + Generator::setWriteQaPages(); + if (m_parser.isSet(m_parser.logProgressOption)) + Location::startLoggingProgress(); + if (m_parser.isSet(m_parser.timestampsOption)) + Generator::setUseTimestamps(); +} + +void Config::setIncludePaths() +{ + QDir currentDir = QDir::current(); + const auto addIncludePaths = [this, currentDir](const char *flag, const QStringList &paths) { + for (const auto &path : paths) + m_includePaths << currentDir.absoluteFilePath(path).insert(0, flag); + }; + + addIncludePaths("-I", m_parser.values(m_parser.includePathOption)); +#ifdef QDOC_PASS_ISYSTEM + addIncludePaths("-isystem", m_parser.values(m_parser.includePathSystemOption)); +#endif + addIncludePaths("-F", m_parser.values(m_parser.frameworkOption)); +} + +/*! + Stores paths from -indexdir command line option(s). + */ +void Config::setIndexDirs() +{ + m_indexDirs = m_parser.values(m_parser.indexDirOption); + auto it = std::remove_if(m_indexDirs.begin(), m_indexDirs.end(), + [](const QString &s) { return !QFile::exists(s); }); + + std::for_each(it, m_indexDirs.end(), + [](const QString &s) { + Location::logToStdErrAlways(tr("Cannot find index directory: %1").arg(s)); + }); + m_indexDirs.erase(it, m_indexDirs.end()); } /*! - Looks up the configuarion variable \a var in the string + Looks up the configuration variable \a var in the string map and returns the boolean value. */ bool Config::getBool(const QString &var) const diff --git a/src/qdoc/config.h b/src/qdoc/config.h index 615387f73..61ed53d87 100644 --- a/src/qdoc/config.h +++ b/src/qdoc/config.h @@ -35,7 +35,6 @@ #include "location.h" #include "qdoccommandlineparser.h" -#include "qdocglobals.h" #include <QtCore/qmap.h> #include <QtCore/qpair.h> @@ -75,7 +74,7 @@ class Config Q_DECLARE_TR_FUNCTIONS(QDoc::Config) public: - Config(const QString &programName); + Config(const QString &programName, const QStringList &args); ~Config(); bool getDebug() const { return debug_; } @@ -86,8 +85,8 @@ public: void setStringList(const QString &var, const QStringList &values); void insertStringList(const QString &var, const QStringList &values); - void setOptions(const QDocGlobals &qdocGlobals); - void setOptions(const QDocCommandLineParser &parser); + void showHelp(int exitCode = 0) { m_parser.showHelp(exitCode); } + QStringList qdocFiles() const { return m_parser.positionalArguments(); } const QString &programName() const { return prog; } const Location &location() const { return loc; } const Location &lastLocation() const { return lastLocation_; } @@ -146,7 +145,28 @@ public: static QString overrideOutputDir; static QSet<QString> overrideOutputFormats; + inline bool singleExec() const; + QStringList &defines() { return m_defines; } + QStringList &dependModules() { return m_dependModules; } + QStringList &includePaths() { return m_includePaths; } + QStringList &indexDirs() { return m_indexDirs; } + QString currentDir() const { return m_currentDir; } + void setCurrentDir(const QString &path) { m_currentDir = path; } + QString previousCurrentDir() const { return m_previousCurrentDir; } + void setPreviousCurrentDir(const QString &path) { m_previousCurrentDir = path; } + private: + void processCommandLineOptions(const QStringList &args); + void setIncludePaths(); + void setIndexDirs(); + + QStringList m_dependModules; + QStringList m_defines; + QStringList m_includePaths; + QStringList m_indexDirs; + QString m_currentDir; + QString m_previousCurrentDir; + static bool debug_; static bool isMetaKeyChar(QChar ch); void load(Location location, const QString &fileName); @@ -161,6 +181,7 @@ private: static int numInstances; static QStack<QString> workingDirs_; static QMap<QString, QStringList> includeFilesMap_; + QDocCommandLineParser m_parser; }; struct ConfigStrings @@ -326,6 +347,11 @@ struct ConfigStrings #define CONFIG_WARNINGLIMIT ConfigStrings::WARNINGLIMIT #define CONFIG_WRITEQAPAGES ConfigStrings::WRITEQAPAGES +inline bool Config::singleExec() const +{ + return getBool(CONFIG_SINGLEEXEC); +} + QT_END_NAMESPACE #endif diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 47f3f52a6..b05e2ab3c 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -458,22 +458,11 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis group = property.left(i); } + NodeList sharedNodes; QmlTypeNode *qmlType = qdb_->findQmlType(module, qmlTypeName); if (qmlType == nullptr) qmlType = new QmlTypeNode(qdb_->primaryTreeRoot(), qmlTypeName); - SharedCommentNode *scn = nullptr; - if (topics.size() > 1) { - scn = new SharedCommentNode(qmlType, topics.size(), group); - scn->setLocation(doc.startLocation()); - if (jsProps) - scn->setGenus(Node::JS); - else - scn->setGenus(Node::QML); - nodes.append(scn); - docs.append(doc); - } - for (int i=0; i<topics.size(); ++i) { QString cmd = topics.at(i).topic; arg = topics.at(i).args; @@ -492,20 +481,29 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis continue; } QmlPropertyNode *qpn = new QmlPropertyNode(qmlType, property, type, attached); - if (scn != nullptr) - qpn->setSharedCommentNode(scn); qpn->setLocation(doc.startLocation()); - if (jsProps) - qpn->setGenus(Node::JS); - else - qpn->setGenus(Node::QML); + qpn->setGenus(jsProps ? Node::JS : Node::QML); nodes.append(qpn); docs.append(doc); + sharedNodes << qpn; } } else { doc.startLocation().warning(tr("Command '\\%1'; not allowed with QML/JS property commands").arg(cmd)); } } + + // Construct a SharedCommentNode (scn) if multiple topics generated + // valid nodes. Note that it's important to do this *after* constructing + // the topic nodes - which need to be written to index before the related + // scn. + if (sharedNodes.count() > 1) { + SharedCommentNode *scn = new SharedCommentNode(qmlType, sharedNodes.count(), group); + scn->setLocation(doc.startLocation()); + nodes.append(scn); + docs.append(doc); + for (const auto n : sharedNodes) + scn->append(n); + } } /*! @@ -1005,7 +1003,7 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL bool found = false; for (SharedCommentNode *scn : sharedCommentNodes) { if (scn->parent() == node->parent()) { - node->setSharedCommentNode(scn); + scn->append(node); found = true; break; } diff --git a/src/qdoc/doc/qdoc-manual-contextcmds.qdoc b/src/qdoc/doc/qdoc-manual-contextcmds.qdoc index 2fef88099..2c42493e8 100644 --- a/src/qdoc/doc/qdoc-manual-contextcmds.qdoc +++ b/src/qdoc/doc/qdoc-manual-contextcmds.qdoc @@ -237,6 +237,24 @@ See how QDoc renders this property on the reference page for the \l {State::changes}{State} type. + \target dontdocument-command + \section1 \\dontdocument + + The \\dontdocument command is only used in a dontdocument.qdoc file + for a particular module. This file specifies publically declared + classes or structs that are not meant to be documented. QDoc will + not print warnings about missing \\class comments for these classes + and structs. + + Below you will find the \\dontdocument command in the + dontdocument.qdoc for widgets: + + \badcode + / *! + \dontdocument (QTypeInfo QMetaTypeId) + * / + \endcode + \target obsolete-command \section1 \\obsolete diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index 7810e7793..0430e832f 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -523,6 +523,11 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark switch (atom->type()) { case Atom::AutoLink: + if (relative && relative->name() == atom->string()) { + out() << protectEnc(atom->string()); + break; + } + Q_FALLTHROUGH(); case Atom::NavAutoLink: if (!inLink_ && !inContents_ && !inSectionHeading_) { const Node *node = nullptr; @@ -2419,6 +2424,13 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) logicalModuleVersion = collection->logicalModuleVersion(); else logicalModuleVersion = qcn->logicalModuleVersion(); + + if (logicalModuleVersion.isEmpty() || qcn->logicalModuleName().isEmpty()) + qcn->doc().location().warning(tr("Could not resolve QML import " + "statement for type '%1'").arg(qcn->name()), + tr("Maybe you forgot to use the " + "'\\%1' command?").arg(COMMAND_INQMLMODULE)); + text.clear(); text << "import " + qcn->logicalModuleName() + QLatin1Char(' ') + logicalModuleVersion; requisites.insert(importText, text); @@ -2726,20 +2738,30 @@ QString HtmlGenerator::generateAllQmlMembersFile(const Sections §ions, CodeM } out() << "<ul>\n"; for (int j=0; j<keys.size(); j++) { - if (nodes[j]->access() == Node::Private || nodes[j]->isInternal()) { + Node *node = nodes[j]; + if (node->access() == Node::Private || node->isInternal()) continue; - } - out() << "<li class=\"fn\">"; - QString prefix; - if (!keys.isEmpty()) { - prefix = keys.at(j).mid(1); - prefix = prefix.left(keys.at(j).indexOf("::")+1); - } - generateQmlItem(nodes[j], aggregate, marker, true); - if (nodes[j]->isAttached()) - out() << " [attached]"; - //generateSynopsis(nodes[j], qcn, marker, Section::AllMembers, false, &prefix); - out() << "</li>\n"; + if (node->isSharingComment() && + node->sharedCommentNode()->isPropertyGroup()) + continue; + + std::function<void(Node *)> generate = [&](Node *n) { + out() << "<li class=\"fn\">"; + generateQmlItem(n, aggregate, marker, true); + if (n->isDefault()) + out() << " [default]"; + else if (n->isAttached()) + out() << " [attached]"; + // Indent property group members + if (n->isPropertyGroup()) { + out() << "<ul>\n"; + const QVector<Node *> &collective = static_cast<SharedCommentNode *>(n)->collective(); + std::for_each(collective.begin(), collective.end(), generate); + out() << "</ul>\n"; + } + out() << "</li>\n"; + }; + generate(node); } out() << "</ul>\n"; } @@ -4026,13 +4048,11 @@ void HtmlGenerator::generateDetailedMember(const Node *node, if (collective.size() > 1) out() << "<div class=\"fngroup\">\n"; for (const auto *node : collective) { - if (node->isFunction()) { - nodeRef = refForNode(node); - out() << "<h3 class=\"fn fngroupitem\" id=\"" << nodeRef << "\">"; - out() << "<a name=\"" + nodeRef + "\"></a>"; - generateSynopsis(node, relative, marker, Section::Details); - out() << "</h3>"; - } + nodeRef = refForNode(node); + out() << "<h3 class=\"fn fngroupitem\" id=\"" << nodeRef << "\">"; + out() << "<a name=\"" + nodeRef + "\"></a>"; + generateSynopsis(node, relative, marker, Section::Details); + out() << "</h3>"; } if (collective.size() > 1) out() << "</div>"; diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index c85ddb44d..48166257d 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -38,9 +38,7 @@ #include "location.h" #include "loggingcategory.h" #include "puredocparser.h" -#include "qdoccommandlineparser.h" #include "qdocdatabase.h" -#include "qdocglobals.h" #include "qmlcodemarker.h" #include "qmlcodeparser.h" #include "utilities.h" @@ -79,7 +77,6 @@ static QList<Translator> translators; #endif static ClangCodeParser* clangParser_ = nullptr; -static QDocGlobals qdocGlobals; /*! Read some XML indexes containing definitions from other @@ -103,8 +100,8 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats) Location::null.warning(QString("Index file not found: %1").arg(index)); } - qdocGlobals.dependModules() += config.getStringList(CONFIG_DEPENDS); - qdocGlobals.dependModules().removeDuplicates(); + config.dependModules() += config.getStringList(CONFIG_DEPENDS); + config.dependModules().removeDuplicates(); QSet<QString> subDirs; for (const auto &format : formats) { @@ -118,41 +115,41 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats) } } - if (qdocGlobals.dependModules().size() > 0) { - if (qdocGlobals.indexDirs().size() > 0) { - for (int i = 0; i < qdocGlobals.indexDirs().size(); i++) { - if (qdocGlobals.indexDirs()[i].startsWith("..")) { - const QString prefix(QDir(qdocGlobals.currentDir()).relativeFilePath(qdocGlobals.previousCurrentDir())); + if (config.dependModules().size() > 0) { + if (config.indexDirs().size() > 0) { + for (int i = 0; i < config.indexDirs().size(); i++) { + if (config.indexDirs()[i].startsWith("..")) { + const QString prefix(QDir(config.currentDir()).relativeFilePath(config.previousCurrentDir())); if (!prefix.isEmpty()) - qdocGlobals.indexDirs()[i].prepend(prefix + QLatin1Char('/')); + config.indexDirs()[i].prepend(prefix + QLatin1Char('/')); } } /* Add all subdirectories of the indexdirs as dependModules, when an asterisk is used in the 'depends' list. */ - if (qdocGlobals.dependModules().contains("*")) { - qdocGlobals.dependModules().removeOne("*"); - for (int i = 0; i < qdocGlobals.indexDirs().size(); i++) { - QDir scanDir = QDir(qdocGlobals.indexDirs()[i]); + if (config.dependModules().contains("*")) { + config.dependModules().removeOne("*"); + for (int i = 0; i < config.indexDirs().size(); i++) { + QDir scanDir = QDir(config.indexDirs()[i]); scanDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList dirList = scanDir.entryInfoList(); for (int j = 0; j < dirList.size(); j++) { if (dirList[j].fileName().toLower() != config.getString(CONFIG_PROJECT).toLower()) - qdocGlobals.dependModules().append(dirList[j].fileName()); + config.dependModules().append(dirList[j].fileName()); } } } - for (int i = 0; i < qdocGlobals.dependModules().size(); i++) { + for (int i = 0; i < config.dependModules().size(); i++) { QString indexToAdd; QList<QFileInfo> foundIndices; // Always look in module-specific subdir, even with *.nosubdirs config - subDirs << qdocGlobals.dependModules()[i]; - for (int j = 0; j < qdocGlobals.indexDirs().size(); j++) { + subDirs << config.dependModules()[i]; + for (int j = 0; j < config.indexDirs().size(); j++) { for (const auto &subDir : subDirs) { - QString fileToLookFor = qdocGlobals.indexDirs()[j] + QString fileToLookFor = config.indexDirs()[j] + QLatin1Char('/') + subDir - + QLatin1Char('/') + qdocGlobals.dependModules()[i] + ".index"; + + QLatin1Char('/') + config.dependModules()[i] + ".index"; if (QFile::exists(fileToLookFor)) { QFileInfo tempFileInfo(fileToLookFor); if (!foundIndices.contains(tempFileInfo)) @@ -160,7 +157,7 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats) } } } - subDirs.remove(qdocGlobals.dependModules()[i]); + subDirs.remove(config.dependModules()[i]); std::sort(foundIndices.begin(), foundIndices.end(), creationTimeBefore); if (foundIndices.size() > 1) { /* @@ -169,13 +166,14 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats) highest UNIX timestamp. */ QStringList indexPaths; - for (int k = 0; k < foundIndices.size(); k++) - indexPaths << foundIndices[k].absoluteFilePath(); + indexPaths.reserve(foundIndices.size()); + for (const auto &found : qAsConst(foundIndices)) + indexPaths << found.absoluteFilePath(); Location::null.warning(QString("Multiple index files found for dependency \"%1\":\n%2").arg( - qdocGlobals.dependModules()[i], indexPaths.join('\n'))); + config.dependModules()[i], indexPaths.join('\n'))); Location::null.warning(QString("Using %1 as index file for dependency \"%2\"").arg( foundIndices[foundIndices.size() - 1].absoluteFilePath(), - qdocGlobals.dependModules()[i])); + config.dependModules()[i])); indexToAdd = foundIndices[foundIndices.size() - 1].absoluteFilePath(); } else if (foundIndices.size() == 1) { @@ -187,7 +185,7 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats) } else { Location::null.warning(QString("\"%1\" Cannot locate index file for dependency \"%2\"").arg( - config.getString(CONFIG_PROJECT), qdocGlobals.dependModules()[i])); + config.getString(CONFIG_PROJECT), config.dependModules()[i])); } } } @@ -205,7 +203,7 @@ static void loadIndexFiles(Config &config, const QSet<QString> &formats) */ static void processQdocconfFile(const QString &fileName, Config &config) { - qdocGlobals.setPreviousCurrentDir(QDir::currentPath()); + config.setPreviousCurrentDir(QDir::currentPath()); /* With the default configuration values in place, load @@ -223,16 +221,11 @@ static void processQdocconfFile(const QString &fileName, Config &config) Location::logToStdErrAlways(QLatin1String("qdoc can't run; no project set in qdocconf file")); exit(1); } - /* - Add the defines and includepaths to their respective configuration variables. - */ - config.insertStringList(CONFIG_DEFINES, qdocGlobals.defines()); - config.insertStringList(CONFIG_INCLUDEPATHS, qdocGlobals.includesPaths()); Location::terminate(); - qdocGlobals.setCurrentDir(QFileInfo(fileName).path()); - if (!qdocGlobals.currentDir().isEmpty()) - QDir::setCurrent(qdocGlobals.currentDir()); + config.setCurrentDir(QFileInfo(fileName).path()); + if (!config.currentDir().isEmpty()) + QDir::setCurrent(config.currentDir()); QString phase = " in "; if (Generator::singleExec()) @@ -343,9 +336,9 @@ static void processQdocconfFile(const QString &fileName, Config &config) else clangParser_->setModuleHeader(project); - qdocGlobals.dependModules() = config.getStringList(CONFIG_DEPENDS); - qdocGlobals.dependModules().removeDuplicates(); - qdb->setSearchOrder(qdocGlobals.dependModules()); + config.dependModules() = config.getStringList(CONFIG_DEPENDS); + config.dependModules().removeDuplicates(); + qdb->setSearchOrder(config.dependModules()); // Store the title of the index (landing) page NamespaceNode *root = qdb->primaryTreeRoot(); @@ -499,31 +492,11 @@ static void processQdocconfFile(const QString &fileName, Config &config) Doc::terminate(); Tokenizer::terminate(); Location::terminate(); - QDir::setCurrent(qdocGlobals.previousCurrentDir()); + QDir::setCurrent(config.previousCurrentDir()); qCDebug(lcQdoc, "qdoc classes terminated"); } -/* This method is an extremely ugly hack; - some or all of these settings must be set before the call to - various initialize() methods in main's processQdocconfFile(). -*/ -void postProcess(const QDocCommandLineParser &parser) -{ - if (parser.isSet(parser.prepareOption)) - Generator::setQDocPass(Generator::Prepare); - if (parser.isSet(parser.generateOption)) - Generator::setQDocPass(Generator::Generate); - if (parser.isSet(parser.singleExecOption)) - Generator::setSingleExec(); - if (parser.isSet(parser.writeQaPagesOption)) - Generator::setWriteQaPages(); - if (parser.isSet(parser.logProgressOption)) - Location::startLoggingProgress(); - if (parser.isSet(parser.timestampsOption)) - Generator::setUseTimestamps(); -} - QT_END_NAMESPACE int main(int argc, char **argv) @@ -565,41 +538,33 @@ int main(int argc, char **argv) HtmlGenerator htmlGenerator; WebXMLGenerator webXMLGenerator; - Config config(QCoreApplication::translate("QDoc", "qdoc")); - - // Set the globals declared at the top of this file: - QDocCommandLineParser parser; - parser.process(app.arguments()); - qdocGlobals.setOptions(parser); - config.setOptions(parser); - postProcess(parser); - config.setOptions(qdocGlobals); + Config config(QCoreApplication::translate("QDoc", "qdoc"), app.arguments()); // Get the list of files to act on: - QStringList qdocFiles = parser.positionalArguments(); + QStringList qdocFiles = config.qdocFiles(); if (qdocFiles.isEmpty()) - parser.showHelp(); + config.showHelp(); - if (qdocGlobals.singleExec()) + if (config.singleExec()) qdocFiles = Config::loadMaster(qdocFiles.at(0)); if (Generator::singleExec()) { // single qdoc process for prepare and generate phases Generator::setQDocPass(Generator::Prepare); for (const auto &file : qAsConst(qdocFiles)) { - qdocGlobals.dependModules().clear(); + config.dependModules().clear(); processQdocconfFile(file, config); } Generator::setQDocPass(Generator::Generate); QDocDatabase::qdocDB()->processForest(); for (const auto &file : qAsConst(qdocFiles)) { - qdocGlobals.dependModules().clear(); + config.dependModules().clear(); processQdocconfFile(file, config); } } else { // separate qdoc processes for prepare and generate phases for (const auto &file : qAsConst(qdocFiles)) { - qdocGlobals.dependModules().clear(); + config.dependModules().clear(); processQdocconfFile(file, config); } } diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 06f2d6bd6..839dd1336 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -1239,15 +1239,6 @@ void Node::setLocation(const Location& t) } /*! - Adds this node to the shared comment node \a t. - */ -void Node::setSharedCommentNode(SharedCommentNode *t) -{ - sharedCommentNode_ = t; - t->append(this); -} - -/*! Returns true if this node is sharing a comment and the shared comment is not empty. */ @@ -2455,10 +2446,10 @@ void Aggregate::addChild(Node *child) child->setOutputSubdirectory(this->outputSubdirectory()); child->setUrl(QString()); child->setIndexNodeFlag(isIndexNode()); + if (child->isFunction()) { addFunction(static_cast<FunctionNode *>(child)); - } - else { + } else if (!child->name().isEmpty()) { nonfunctionMap_.insertMulti(child->name(), child); if (child->isEnumType()) enumChildren_.append(child); @@ -2483,16 +2474,15 @@ void Aggregate::adoptChild(Node *child) child->setParent(this); if (child->isFunction()) { adoptFunction(static_cast<FunctionNode *>(child)); - } - else { + } else if (!child->name().isEmpty()) { nonfunctionMap_.insertMulti(child->name(), child); - if (child->isEnumType()) { + if (child->isEnumType()) enumChildren_.append(child); - } else if (child->isSharedCommentNode()) { - SharedCommentNode *scn = static_cast<SharedCommentNode *>(child); - for (Node *n : scn->collective()) - adoptChild(n); - } + } + if (child->isSharedCommentNode()) { + SharedCommentNode *scn = static_cast<SharedCommentNode *>(child); + for (Node *n : scn->collective()) + adoptChild(n); } } } diff --git a/src/qdoc/node.h b/src/qdoc/node.h index 71a603146..0b6eb9e62 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -323,7 +323,8 @@ public: bool isSharingComment() const { return (sharedCommentNode_ != nullptr); } bool hasSharedDoc() const; - void setSharedCommentNode(SharedCommentNode *t); + void setSharedCommentNode(SharedCommentNode *t) { sharedCommentNode_ = t; } + SharedCommentNode *sharedCommentNode() { return sharedCommentNode_; } //QString guid() const; QString extractClassName(const QString &string) const; @@ -899,7 +900,8 @@ class SharedCommentNode : public Node public: SharedCommentNode(Node *n) : Node(Node::SharedComment, n->parent(), QString()) { - collective_.reserve(1); n->setSharedCommentNode(this); + collective_.reserve(1); + append(n); } SharedCommentNode(QmlTypeNode *parent, int count, QString &group) : Node(Node::SharedComment, parent, group) { @@ -907,11 +909,13 @@ public: } ~SharedCommentNode() override { collective_.clear(); } - bool isPropertyGroup() const override { return !collective_.isEmpty() && - (collective_.at(0)->isQmlProperty() || collective_.at(0)->isJsProperty()); + bool isPropertyGroup() const override { + return !name().isEmpty() && + !collective_.isEmpty() && + (collective_.at(0)->isQmlProperty() || collective_.at(0)->isJsProperty()); } int count() const { return collective_.size(); } - void append(Node *n) { collective_.append(n); } + void append(Node *n) { collective_.append(n); n->setSharedCommentNode(this); setGenus(n->genus()); } const QVector<Node *> &collective() const { return collective_; } void setOverloadFlags(); void setRelatedNonmember(bool b) override; diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro index 234ebddbe..b6f2e1d3d 100644 --- a/src/qdoc/qdoc.pro +++ b/src/qdoc/qdoc.pro @@ -59,7 +59,6 @@ HEADERS += atom.h \ tokenizer.h \ tree.h \ webxmlgenerator.h \ - qdocglobals.h \ qdoccommandlineparser.h \ utilities.h @@ -93,7 +92,6 @@ SOURCES += atom.cpp \ tree.cpp \ yyindent.cpp \ webxmlgenerator.cpp \ - qdocglobals.cpp \ qdoccommandlineparser.cpp \ utilities.cpp diff --git a/src/qdoc/qdocglobals.cpp b/src/qdoc/qdocglobals.cpp deleted file mode 100644 index 05fa3a96f..000000000 --- a/src/qdoc/qdocglobals.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdocglobals.h" -#include "qdoccommandlineparser.h" - -#include <QtCore/qdebug.h> -#include <QtCore/qdir.h> -#include <QtCore/qfile.h> - -bool QDocGlobals::highlighting() const -{ - return m_highlighting; -} - -void QDocGlobals::enableHighlighting(bool value) -{ - m_highlighting = value; -} - -bool QDocGlobals::showInternal() const -{ - return m_showInternal; -} - -void QDocGlobals::setShowInternal(bool value) -{ - m_showInternal = value; -} - -bool QDocGlobals::singleExec() const -{ - return m_singleExec; -} -void QDocGlobals::setSingleExec(bool value) -{ - m_singleExec = value; -} - -bool QDocGlobals::writeQaPages() const -{ - return m_writeQaPages; -} -void QDocGlobals::setWriteQaPages(bool value) -{ - m_writeQaPages = value; -} - -bool QDocGlobals::redirectDocumentationToDevNull() const -{ - return m_redirectDocumentationToDevNull; -} - -void QDocGlobals::setRedirectDocumentationToDevNull(bool value) -{ - m_redirectDocumentationToDevNull = value; -} - -bool QDocGlobals::noLinkErrors() const -{ - return m_noLinkErrors; -} - -void QDocGlobals::setNoLinkErrors(bool value) -{ - m_noLinkErrors = value; -} - -bool QDocGlobals::autolinkErrors() const -{ - return m_autolinkErrors; -} - -void QDocGlobals::setAutolinkErrors(bool value) -{ - m_autolinkErrors = value; -} - -bool QDocGlobals::obsoleteLinks() const -{ - return m_obsoleteLinks; -} - -void QDocGlobals::setObsoleteLinks(bool value) -{ - m_obsoleteLinks = value; -} - -QStringList QDocGlobals::defines() const -{ - return m_defines; -} - -void QDocGlobals::addDefine(const QStringList &valueList) -{ - m_defines += valueList; -} - -QStringList QDocGlobals::includesPaths() const -{ - return m_includesPaths; -} - -void QDocGlobals::addIncludePath(const QString &flag, const QString &path) -{ - QString includePath = flag + path; - m_includesPaths << includePath; -} - -QStringList &QDocGlobals::dependModules() -{ - return m_dependModules; -} - -QStringList QDocGlobals::indexDirs() const -{ - return m_indexDirs; -} - -void QDocGlobals::appendToIndexDirs(const QString &path) -{ - m_indexDirs += path; -} - -QString QDocGlobals::currentDir() const -{ - return m_currentDir; -} - -void QDocGlobals::setCurrentDir(const QString &path) -{ - m_currentDir = path; -} - -QString QDocGlobals::previousCurrentDir() const -{ - return m_previousCurrentDir; -} - -void QDocGlobals::setPreviousCurrentDir(const QString &path) -{ - m_previousCurrentDir = path; -} - -void QDocGlobals::setIncludePaths(const QDocCommandLineParser &parser) -{ - QDir currentDir = QDir::current(); - auto includePaths = parser.values(parser.includePathOption); - for (const auto &path : qAsConst(includePaths)) - addIncludePath("-I", currentDir.absoluteFilePath(path)); - -#ifdef QDOC_PASS_ISYSTEM - includePaths = parser.values(parser.includePathSystemOption); - for (const auto &path : qAsConst(includePaths)) - addIncludePath("-isystem", currentDir.absoluteFilePath(path)); -#endif - includePaths = parser.values(parser.frameworkOption); - for (const auto &path : qAsConst(includePaths)) - addIncludePath("-F", currentDir.absoluteFilePath(path)); -} - -void QDocGlobals::setIndexDirs(const QDocCommandLineParser &parser) -{ - const auto indexDirs = parser.values(parser.indexDirOption); - for (const auto &indexDir : indexDirs) { - if (QFile::exists(indexDir)) - appendToIndexDirs(indexDir); - else - qDebug() << "Cannot find index directory" << indexDir; - } -} - -void QDocGlobals::setOptions(const QDocCommandLineParser &parser) -{ - addDefine(parser.values(parser.defineOption)); - m_dependModules += parser.values(parser.dependsOption); - enableHighlighting(parser.isSet(parser.highlightingOption)); - setShowInternal(parser.isSet(parser.showInternalOption)); - setSingleExec(parser.isSet(parser.singleExecOption)); - setWriteQaPages(parser.isSet(parser.writeQaPagesOption)); - setRedirectDocumentationToDevNull(parser.isSet(parser.redirectDocumentationToDevNullOption)); - setIndexDirs(parser); - setObsoleteLinks(parser.isSet(parser.obsoleteLinksOption)); - setNoLinkErrors(parser.isSet(parser.noLinkErrorsOption) || - qEnvironmentVariableIsSet("QDOC_NOLINKERRORS")); - setAutolinkErrors(parser.isSet(parser.autoLinkErrorsOption)); - setIncludePaths(parser); -} diff --git a/src/qdoc/qdocglobals.h b/src/qdoc/qdocglobals.h deleted file mode 100644 index 640dd6bf6..000000000 --- a/src/qdoc/qdocglobals.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDOCGLOBALS_H -#define QDOCGLOBALS_H - -#include <QtCore/qstringlist.h> -#include <QtCore/qhash.h> -#include <QtCore/qtranslator.h> - -QT_BEGIN_NAMESPACE - -struct QDocCommandLineParser; - -class QDocGlobals -{ -public: - bool highlighting() const; - void enableHighlighting(bool value); - - bool showInternal() const; - void setShowInternal(bool value); - - bool singleExec() const; - void setSingleExec(bool value); - - bool writeQaPages() const; - void setWriteQaPages(bool value); - - bool redirectDocumentationToDevNull() const; - void setRedirectDocumentationToDevNull(bool value); - - bool noLinkErrors() const; - void setNoLinkErrors(bool value); - - bool autolinkErrors() const; - void setAutolinkErrors(bool value); - - bool obsoleteLinks() const; - void setObsoleteLinks(bool value); - - QStringList defines() const; - void addDefine(const QStringList &valueList); - - QStringList includesPaths() const; - void addIncludePath(const QString &flag, const QString &path); - - QStringList &dependModules(); - - QStringList indexDirs() const; - void appendToIndexDirs(const QString &path); - - QString currentDir() const; - void setCurrentDir(const QString &path); - - QString previousCurrentDir() const; - void setPreviousCurrentDir(const QString &path); - - void setOptions(const QDocCommandLineParser &parser); - -private: - void setIncludePaths(const QDocCommandLineParser &parser); - void setIndexDirs(const QDocCommandLineParser &parser); - - bool m_highlighting = false; - bool m_showInternal = false; - bool m_singleExec = false; - bool m_writeQaPages = false; - bool m_redirectDocumentationToDevNull = false; - bool m_noLinkErrors = false; - bool m_autolinkErrors = false; - bool m_obsoleteLinks = false; - - QStringList m_defines; - QStringList m_includesPaths; - QStringList m_dependModules; - QStringList m_indexDirs; - QString m_currentDir; - QString m_previousCurrentDir; -}; - -QT_END_NAMESPACE - -#endif // QDOCGLOBALS_H diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp index 4b4712180..8ba71f17c 100644 --- a/src/qdoc/sections.cpp +++ b/src/qdoc/sections.cpp @@ -904,9 +904,14 @@ void Sections::distributeQmlNodeInDetailsVector(SectionVector &dv, Node *n) } } -void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n) +/*! + Distributes a node \a n into the correct place in the summary section vector \a sv. + Nodes that are sharing a comment are handled recursively - for recursion, the \a + sharing parameter is set to \c true. + */ +void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool sharing) { - if (n->isSharedCommentNode()) + if (n->isSharingComment() && !sharing) return; if (n->isQmlProperty() || n->isJsProperty()) { QmlPropertyNode *pn = static_cast<QmlPropertyNode *>(n); @@ -929,6 +934,14 @@ void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n) else sv[QmlMethods].insert(fn); } + } else if (n->isSharedCommentNode()) { + SharedCommentNode *scn = static_cast<SharedCommentNode*>(n); + if (scn->isPropertyGroup()) { + sv[QmlProperties].insert(scn); + } else { + for (auto child : scn->collective()) + distributeQmlNodeInSummaryVector(sv, child, true); + } } } @@ -1023,7 +1036,9 @@ void Sections::buildStdQmlTypeRefPageSections() ++c; continue; } - allMembers.add(classMap, n); + if (!n->isSharedCommentNode() || n->isPropertyGroup()) + allMembers.add(classMap, n); + distributeQmlNodeInSummaryVector(sv, n); distributeQmlNodeInDetailsVector(dv, n); ++c; diff --git a/src/qdoc/sections.h b/src/qdoc/sections.h index c2f07cf65..92c2cdd2b 100644 --- a/src/qdoc/sections.h +++ b/src/qdoc/sections.h @@ -233,7 +233,7 @@ class Sections void distributeNodeInSummaryVector(SectionVector &sv, Node *n); void distributeNodeInDetailsVector(SectionVector &dv, Node *n); void distributeQmlNodeInDetailsVector(SectionVector &dv, Node *n); - void distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n); + void distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool sharing = false); void initAggregate(SectionVector &v, Aggregate *aggregate); private: diff --git a/src/qdoc/webxmlgenerator.cpp b/src/qdoc/webxmlgenerator.cpp index ba1ad8389..05e1c9b42 100644 --- a/src/qdoc/webxmlgenerator.cpp +++ b/src/qdoc/webxmlgenerator.cpp @@ -782,7 +782,7 @@ void WebXMLGenerator::startLink(QXmlStreamWriter &writer, const Atom *atom, break; } } - // fall through + Q_FALLTHROUGH(); case Node::Page: writer.writeAttribute("page", fullName); break; @@ -792,8 +792,9 @@ void WebXMLGenerator::startLink(QXmlStreamWriter &writer, const Atom *atom, if (propertyNode->getters().size() > 0) writer.writeAttribute("getter", propertyNode->getters().at(0)->fullName()); } + break; default: - ; + break; } } inLink = true; diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html b/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html index 92103d867..fc05a8d14 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html @@ -31,6 +31,7 @@ <h2 id="classes">Classes</h2> <div class="table"><table class="annotated"> <tr class="odd topAlign"><td class="tblName"><p><a href="testqdoc-test.html">TestQDoc::Test</a></p></td><td class="tblDescr"><p>A class in a namespace</p></td></tr> +<tr class="even topAlign"><td class="tblName"><p><a href="testqdoc-testderived.html">TestQDoc::TestDerived</a></p></td><td class="tblDescr"><p>A derived class in a namespace</p></td></tr> </table></div> <!-- $$$TestCPP-description --> <a name="details"></a> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test-members.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test-members.html index 2c0b9b24f..a52123a32 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test-members.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test-members.html @@ -15,6 +15,7 @@ <li class="fn"><span class="name"><b><a href="testqdoc-test.html#inlineFunction">inlineFunction</a></b></span>()</li> <li class="fn"><span class="name"><b><a href="testqdoc-test.html#someFunction">someFunction</a></b></span>(int ) : int</li> <li class="fn"><span class="name"><b><a href="testqdoc-test.html#someFunctionDefaultArg">someFunctionDefaultArg</a></b></span>(int , bool )</li> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#virtualFun">virtualFun</a></b></span>()</li> </ul> </body> </html> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html index bf7ba3307..32fb9efa0 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html @@ -25,7 +25,8 @@ <!-- @@@Test --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <Test></span> -</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += testcpp</td></tr></table></div><ul> +</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += testcpp</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="testqdoc-testderived.html">TestQDoc::TestDerived</a></p> +</td></tr></table></div><ul> <li><a href="testqdoc-test-members.html">List of all members, including inherited members</a></li> <li><a href="testqdoc-test-obsolete.html">Obsolete members</a></li> </ul> @@ -35,6 +36,7 @@ <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html#inlineFunction">inlineFunction</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html#someFunction">someFunction</a></b>(int <i>v</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html#someFunctionDefaultArg">someFunctionDefaultArg</a></b>(int <i>i</i>, bool <i>b</i> = false)</td></tr> +<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html#virtualFun">virtualFun</a></b>()</td></tr> </table></div> <a name="macros"></a> <h2 id="macros">Macros</h2> @@ -61,6 +63,10 @@ <h3 class="fn" id="someFunctionDefaultArg"><a name="someFunctionDefaultArg"></a><span class="type">void</span> Test::<span class="name">someFunctionDefaultArg</span>(<span class="type">int</span> <i>i</i>, <span class="type">bool</span> <i>b</i> = false)</h3> <p>Function that takes a parameter <i>i</i> and <i>b</i>.</p> <!-- @@@someFunctionDefaultArg --> +<!-- $$$virtualFun[overload1]$$$virtualFun --> +<h3 class="fn" id="virtualFun"><a name="virtualFun"></a><code>[virtual] </code><span class="type">void</span> Test::<span class="name">virtualFun</span>()</h3> +<p>Function that must be reimplemented.</p> +<!-- @@@virtualFun --> </div> <div class="macros"> <h2>Macro Documentation</h2> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-testderived-members.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-testderived-members.html new file mode 100644 index 000000000..f5adf249c --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-testderived-members.html @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<!-- testcpp.cpp --> + <title>List of All Members for TestDerived | TestCPP</title> +</head> +<body> +<li>TestDerived</li> +<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div> +<h1 class="title">List of All Members for TestDerived</h1> +<p>This is the complete list of members for <a href="testqdoc-testderived.html">TestQDoc::TestDerived</a>, including inherited members.</p> +<ul> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#QDOCTEST_MACRO2">QDOCTEST_MACRO2</a></b></span>()</li> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#inlineFunction">inlineFunction</a></b></span>()</li> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#someFunction">someFunction</a></b></span>(int ) : int</li> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#someFunctionDefaultArg">someFunctionDefaultArg</a></b></span>(int , bool )</li> +<li class="fn"><span class="name"><b><a href="testqdoc-testderived.html#virtualFun">virtualFun</a></b></span>()</li> +</ul> +</body> +</html> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-testderived.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-testderived.html new file mode 100644 index 000000000..a5478fc66 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-testderived.html @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<!-- testcpp.cpp --> + <title>TestDerived Class | TestCPP</title> +</head> +<body> +<li>TestDerived</li> +<div class="sidebar"> +<div class="toc"> +<h3><a name="toc">Contents</a></h3> +<ul> +<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</a></li> +<li class="level1"><a href="#details">Detailed Description</a></li> +</ul> +</div> +<div class="sidebar-content" id="sidebar-content"></div></div> +<h1 class="title">TestDerived Class</h1> +<span class="small-subtitle">(<a href="testqdoc-testderived.html">TestQDoc::TestDerived</a>)<br/></span> +<!-- $$$TestDerived-brief --> +<p>A derived class in a namespace. <a href="#details">More...</a></p> +<!-- @@@TestDerived --> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <TestDerived></span> +</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += testcpp</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="testqdoc-test.html">TestQDoc::Test</a></td></tr></table></div><ul> +<li><a href="testqdoc-testderived-members.html">List of all members, including inherited members</a></li> +</ul> +<a name="reimplemented-public-functions"></a> +<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-testderived.html#virtualFun">virtualFun</a></b>() override</td></tr> +</table></div> +<a name="details"></a> +<!-- $$$TestDerived-description --> +<div class="descr"> +<h2 id="details">Detailed Description</h2> +</div> +<!-- @@@TestDerived --> +<div class="func"> +<h2>Member Function Documentation</h2> +<!-- $$$virtualFun[overload1]$$$virtualFun --> +<h3 class="fn" id="virtualFun"><a name="virtualFun"></a><code>[override virtual] </code><span class="type">void</span> TestDerived::<span class="name">virtualFun</span>()</h3> +<p>Reimplements: <a href="testqdoc-test.html#virtualFun">Test::virtualFun</a>().</p> +<!-- @@@virtualFun --> +</div> +</body> +</html> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html index baa0d9a65..94ef710fc 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html @@ -30,6 +30,7 @@ <h2 id="classes">Classes</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html">Test</a></b></td></tr> +<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-testderived.html">TestDerived</a></b></td></tr> </table></div> <a name="macros"></a> <h2 id="macros">Macros</h2> @@ -50,6 +51,9 @@ <h3> class <a href="testqdoc-test.html">Test</a></h3><!-- $$$Test-brief --> <p>A class in a namespace. <a href="testqdoc-test.html#details">More...</a></p> <!-- @@@Test --> +<h3> class <a href="testqdoc-testderived.html">TestDerived</a></h3><!-- $$$TestDerived-brief --> +<p>A derived class in a namespace. <a href="testqdoc-testderived.html#details">More...</a></p> +<!-- @@@TestDerived --> </div> <div class="macros"> <h2>Macro Documentation</h2> diff --git a/tests/auto/qdoc/generatedoutput/testcpp.cpp b/tests/auto/qdoc/generatedoutput/testcpp.cpp index 3ed4dc0bd..3277d496d 100644 --- a/tests/auto/qdoc/generatedoutput/testcpp.cpp +++ b/tests/auto/qdoc/generatedoutput/testcpp.cpp @@ -53,6 +53,12 @@ namespace TestQDoc { */ /*! + \class TestQDoc::TestDerived + \inmodule TestCPP + \brief A derived class in a namespace. +*/ + +/*! \macro QDOCTEST_MACRO \relates TestQDoc */ @@ -117,4 +123,20 @@ int Test::someFunction(int v) \brief An inline function, documented using the \CMDFN QDoc command. */ +/*! + Function that must be reimplemented. +*/ +void Test::virtualFun() +{ + return; +} + +/*! + \reimp +*/ +void TestDerived::virtualFun() +{ + return; +} + } // namespace TestQDoc diff --git a/tests/auto/qdoc/generatedoutput/testcpp.h b/tests/auto/qdoc/generatedoutput/testcpp.h index f39b6d284..733f9e751 100644 --- a/tests/auto/qdoc/generatedoutput/testcpp.h +++ b/tests/auto/qdoc/generatedoutput/testcpp.h @@ -39,6 +39,12 @@ public: void anotherObsoleteMember(); void deprecatedMember(); inline void inlineFunction() {}; + virtual void virtualFun(); +}; + +class TestDerived : public Test { +public: + void virtualFun() override; }; } // namespace TestQDoc diff --git a/tests/auto/qdoc/qdoc.pro b/tests/auto/qdoc/qdoc.pro index bb63be1f9..64a89cb14 100644 --- a/tests/auto/qdoc/qdoc.pro +++ b/tests/auto/qdoc/qdoc.pro @@ -2,5 +2,4 @@ TEMPLATE = subdirs SUBDIRS = \ generatedoutput \ - qdoccommandlineparser \ - qdocglobals + qdoccommandlineparser diff --git a/tests/auto/qdoc/qdocglobals/qdocglobals.pro b/tests/auto/qdoc/qdocglobals/qdocglobals.pro deleted file mode 100644 index fa7ddb8e0..000000000 --- a/tests/auto/qdoc/qdocglobals/qdocglobals.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -QT = core testlib -TARGET = tst_qdocglobals -INCLUDEPATH += $$PWD/../../../../src/qdoc - -HEADERS += $$PWD/../../../../src/qdoc/qdocglobals.h - -SOURCES += $$PWD/../../../../src/qdoc/qdocglobals.cpp \ - tst_qdocglobals.cpp diff --git a/tests/auto/qdoc/qdocglobals/tst_qdocglobals.cpp b/tests/auto/qdoc/qdocglobals/tst_qdocglobals.cpp deleted file mode 100644 index fca46911f..000000000 --- a/tests/auto/qdoc/qdocglobals/tst_qdocglobals.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdocglobals.h" - -#include <QtCore/qhash.h> -#include <QtCore/qstringlist.h> -#include <QtTest/QtTest> - -class testQDocGlobals : public QObject -{ - Q_OBJECT - -private slots: - void testClassMembersInitializeToFalseOrEmpty(); - void testEnableHighlighting(); - void testSetShowInternal(); - void testSetSingleExec(); - void testSetWriteQaPages(); - void testRedirectDocumentationToDevNull(); - void testSetNoLinkErrors(); - void testSetAutoLinkErrors(); - void testSetObsoleteLinks(); - - void testAddDefine(); - void testAddIncludePath(); - void testDependModules(); - void testAppendToIndexDirs(); - void testSetCurrentDir(); - void testPreviousCurrentDir(); -}; - -void testQDocGlobals::testClassMembersInitializeToFalseOrEmpty() -{ - QDocGlobals qdocTestGlobals; - QCOMPARE(qdocTestGlobals.highlighting(), false); - QCOMPARE(qdocTestGlobals.showInternal(), false); - QCOMPARE(qdocTestGlobals.singleExec(), false); - QCOMPARE(qdocTestGlobals.writeQaPages(), false); - QCOMPARE(qdocTestGlobals.redirectDocumentationToDevNull(), false); - QCOMPARE(qdocTestGlobals.noLinkErrors(), false); - QCOMPARE(qdocTestGlobals.autolinkErrors(), false); - QCOMPARE(qdocTestGlobals.obsoleteLinks(), false); - - QVERIFY(qdocTestGlobals.defines().isEmpty()); - QVERIFY(qdocTestGlobals.includesPaths().isEmpty()); - QVERIFY(qdocTestGlobals.dependModules().isEmpty()); - QVERIFY(qdocTestGlobals.indexDirs().isEmpty()); - QVERIFY(qdocTestGlobals.currentDir().isEmpty()); - QVERIFY(qdocTestGlobals.previousCurrentDir().isEmpty()); -} - -void testQDocGlobals::testEnableHighlighting() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.enableHighlighting(true); - QVERIFY(qdocTestGlobals.highlighting()); -} - -void testQDocGlobals::testSetShowInternal() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setShowInternal(true); - QVERIFY(qdocTestGlobals.showInternal()); -} - -void testQDocGlobals::testSetSingleExec() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setSingleExec(true); - QVERIFY(qdocTestGlobals.singleExec()); -} - -void testQDocGlobals::testSetWriteQaPages() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setWriteQaPages(true); - QVERIFY(qdocTestGlobals.writeQaPages()); -} - -void testQDocGlobals::testRedirectDocumentationToDevNull() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setRedirectDocumentationToDevNull(true); - QVERIFY(qdocTestGlobals.redirectDocumentationToDevNull()); -} - -void testQDocGlobals::testSetNoLinkErrors() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setNoLinkErrors(true); - QVERIFY(qdocTestGlobals.noLinkErrors()); -} - -void testQDocGlobals::testSetAutoLinkErrors() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setAutolinkErrors(true); - QVERIFY(qdocTestGlobals.autolinkErrors()); -} - -void testQDocGlobals::testSetObsoleteLinks() -{ - QDocGlobals qdocTestGlobals; - qdocTestGlobals.setObsoleteLinks(true); - QVERIFY(qdocTestGlobals.obsoleteLinks()); -} - -void testQDocGlobals::testAddDefine() -{ - QDocGlobals qdocTestGlobals; - QStringList defineTestList1 = { QStringLiteral("qtforpython") }; - QStringList defineTestList2 = { QStringLiteral("example") }; - QStringList expected; - expected << defineTestList1 << defineTestList2; - - qdocTestGlobals.addDefine(defineTestList1); - QCOMPARE(qdocTestGlobals.defines().size(), 1); - qdocTestGlobals.addDefine(defineTestList2); - QCOMPARE(qdocTestGlobals.defines().size(), 2); - QCOMPARE(qdocTestGlobals.defines(), expected); -} - -void testQDocGlobals::testAddIncludePath() -{ - QDocGlobals qdocTestGlobals; - QString testFlag = "-I"; - QString testPath0 = "/qt5/qtdoc/doc/."; - QString testPath1 = "/qt5/qtbase/mkspecs/linux-g++"; - QStringList expected = { "-I/qt5/qtdoc/doc/.", - "-I/qt5/qtbase/mkspecs/linux-g++" }; - - qdocTestGlobals.addIncludePath(testFlag, testPath0); - qdocTestGlobals.addIncludePath(testFlag, testPath1); - QStringList result = qdocTestGlobals.includesPaths(); - QCOMPARE(result, expected); -} - -void testQDocGlobals::testDependModules() -{ - QDocGlobals qdocTestGlobals; - QStringList expected = { "qdoc", "qmake", "qtcore", "qthelp", "qtqml" }; - - qdocTestGlobals.dependModules() = expected; - QCOMPARE(qdocTestGlobals.dependModules().size(), 5); - QCOMPARE(qdocTestGlobals.dependModules(), expected); -} - -void testQDocGlobals::testAppendToIndexDirs() -{ - QDocGlobals qdocTestGlobals; - QString testPath = "/qt5/qtbase/doc"; - QStringList expected; - expected << testPath; - - qdocTestGlobals.appendToIndexDirs(testPath); - QCOMPARE(qdocTestGlobals.indexDirs(), expected); -} - -void testQDocGlobals::testSetCurrentDir() -{ - QDocGlobals qdocTestGlobals; - QString expected = "/qt5/qtdoc/doc/config"; - - qdocTestGlobals.setCurrentDir(expected); - QCOMPARE(qdocTestGlobals.currentDir(), expected); -} - -void testQDocGlobals::testPreviousCurrentDir() -{ - QDocGlobals qdocTestGlobals; - QString expected = "/qt5/qtdoc/doc"; - - qdocTestGlobals.setCurrentDir(expected); - QCOMPARE(qdocTestGlobals.currentDir(), expected); -} - -QTEST_APPLESS_MAIN(testQDocGlobals) - -#include "tst_qdocglobals.moc" |