diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-04-17 12:58:41 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2012-04-17 12:58:52 +0200 |
commit | 64255ef6502b1144f7b0aa4b2bf62803e0d4788b (patch) | |
tree | 29bf116bfda2ccf61057115690d14f85cc9b085b /src/widgets | |
parent | 4a9fb41a7947d0bb7a47a9625603a436df288b24 (diff) | |
parent | 7e0beba891cb963a1d535bd45b0be78b43b8d07f (diff) |
Merge remote-tracking branch 'origin/api_changes'
Change-Id: I964b0a6f5c38351fdfafb8a2a128a349ff8c89d1
Diffstat (limited to 'src/widgets')
76 files changed, 270 insertions, 4781 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 569a10653f..606b9b00f7 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -433,36 +433,45 @@ int QColorDialog::customCount() /*! \since 4.5 - Returns the custom color at the given \a index as a QRgb value. + Returns the custom color at the given \a index as a QColor value. */ -QRgb QColorDialog::customColor(int index) +QColor QColorDialog::customColor(int index) { - return QColorDialogOptions::customColor(index); + return QColor(QColorDialogOptions::customColor(index)); } /*! - Sets the custom color at \a index to the QRgb \a color value. + Sets the custom color at \a index to the QColor \a color value. \note This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog option. */ -void QColorDialog::setCustomColor(int index, QRgb color) +void QColorDialog::setCustomColor(int index, QColor color) { - QColorDialogOptions::setCustomColor(index, color); + QColorDialogOptions::setCustomColor(index, color.rgba()); } /*! - Sets the standard color at \a index to the QRgb \a color value. + \since 5.0 + + Returns the standard color at the given \a index as a QColor value. +*/ +QColor QColorDialog::standardColor(int index) +{ + return QColor(QColorDialogOptions::standardColor(index)); +} + +/*! + Sets the standard color at \a index to the QColor \a color value. \note This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog option. */ - -void QColorDialog::setStandardColor(int index, QRgb color) +void QColorDialog::setStandardColor(int index, QColor color) { - QColorDialogOptions::setStandardColor(index, color); + QColorDialogOptions::setStandardColor(index, color.rgba()); } static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v) diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index cfb54a7eb9..1daead3879 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -102,12 +102,11 @@ public: // obsolete static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = 0, QWidget *parent = 0); - // ### Qt 5: use QColor in signatures static int customCount(); - static QRgb customColor(int index); - static void setCustomColor(int index, QRgb color); - static void setStandardColor(int index, QRgb color); - + static QColor customColor(int index); + static void setCustomColor(int index, QColor color); + static QColor standardColor(int index); + static void setStandardColor(int index, QColor color); Q_SIGNALS: void currentColorChanged(const QColor &color); diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h index 7d3052a782..f20ff46d41 100644 --- a/src/widgets/dialogs/qdialog.h +++ b/src/widgets/dialogs/qdialog.h @@ -91,8 +91,8 @@ Q_SIGNALS: void rejected(); public Q_SLOTS: - void open(); - int exec(); + virtual void open(); + virtual int exec(); virtual void done(int); virtual void accept(); virtual void reject(); diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 5446eca383..a7ae4b366b 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -48,6 +48,8 @@ #include <qmessagebox.h> #include <qapplication.h> +#include <algorithm> + #ifdef Q_OS_WIN # include <QtCore/QVarLengthArray> # include <qt_windows.h> @@ -127,7 +129,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn bool QFileSystemModel::rmdir(const QModelIndex &index) const + \fn bool QFileSystemModel::rmdir(const QModelIndex &index) Removes the directory corresponding to the model item \a index in the file system model and \b{deletes the corresponding directory from the @@ -183,7 +185,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn bool QFileSystemModel::remove(const QModelIndex &index) const + \fn bool QFileSystemModel::remove(const QModelIndex &index) Removes the model item \a index from the file system model and \b{deletes the corresponding file from the file system}, returning true if successful. If the @@ -195,7 +197,7 @@ QT_BEGIN_NAMESPACE \sa rmdir() */ -bool QFileSystemModel::remove(const QModelIndex &aindex) const +bool QFileSystemModel::remove(const QModelIndex &aindex) { //### TODO optim QString path = filePath(aindex); @@ -1081,15 +1083,35 @@ public: r->fileName, Qt::CaseInsensitive) < 0; } case 1: + { // Directories go first - if (l->isDir() && !r->isDir()) - return true; - return l->size() < r->size(); + bool left = l->isDir(); + bool right = r->isDir(); + if (left ^ right) + return left; + + qint64 sizeDifference = l->size() - r->size(); + if (sizeDifference == 0) + return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0; + + return sizeDifference < 0; + } case 2: - return l->type() < r->type(); + { + int compare = QString::localeAwareCompare(l->type(), r->type()); + if (compare == 0) + return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0; + + return compare < 0; + } case 3: + { + if (l->lastModified() == r->lastModified()) + return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0; + return l->lastModified() < r->lastModified(); } + } Q_ASSERT(false); return false; } @@ -1129,7 +1151,7 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent i++; } QFileSystemModelSorter ms(column); - qStableSort(values.begin(), values.end(), ms); + std::sort(values.begin(), values.end(), ms); // First update the new visible list indexNode->visibleChildren.clear(); //No more dirty item we reset our internal dirty index @@ -1631,7 +1653,7 @@ bool QFileSystemModel::event(QEvent *event) return QAbstractItemModel::event(event); } -bool QFileSystemModel::rmdir(const QModelIndex &aindex) const +bool QFileSystemModel::rmdir(const QModelIndex &aindex) { QString path = filePath(aindex); QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func()); @@ -1963,8 +1985,7 @@ bool QFileSystemModelPrivate::filtersAcceptsNode(const QFileSystemNode *node) co const bool hideDot = (filters & QDir::NoDot); const bool hideDotDot = (filters & QDir::NoDotDot); - // Note that we match the behavior of entryList and not QFileInfo on this and this - // incompatibility won't be fixed until Qt 5 at least + // Note that we match the behavior of entryList and not QFileInfo on this. bool isDot = (node->fileName == QLatin1String(".")); bool isDotDot = (node->fileName == QLatin1String("..")); if ( (hideHidden && !(isDot || isDotDot) && node->isHidden()) diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h index 5a9139266d..875044e785 100644 --- a/src/widgets/dialogs/qfilesystemmodel.h +++ b/src/widgets/dialogs/qfilesystemmodel.h @@ -138,12 +138,12 @@ public: QDateTime lastModified(const QModelIndex &index) const; QModelIndex mkdir(const QModelIndex &parent, const QString &name); - bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const + bool rmdir(const QModelIndex &index); inline QString fileName(const QModelIndex &index) const; inline QIcon fileIcon(const QModelIndex &index) const; QFile::Permissions permissions(const QModelIndex &index) const; inline QFileInfo fileInfo(const QModelIndex &index) const; - bool remove(const QModelIndex &index) const; + bool remove(const QModelIndex &index); protected: QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = 0); diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 0e982140b5..3a02b91b09 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -315,7 +315,6 @@ public: #ifndef QT_NO_REGEXP QList<QRegExp> nameFilters; #endif - // ### Qt 5: resolvedSymLinks goes away QHash<QString, QString> resolvedSymLinks; QFileSystemNode root; diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 2b932b0724..ea33dc8d0b 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -369,7 +369,7 @@ void QMessageBoxPrivate::updateSize() label->setSizePolicy(policy); } - QFontMetrics fm(QApplication::font("QWorkspaceTitleBar")); + QFontMetrics fm(QApplication::font("QMdiSubWindowTitleBar")); int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit); if (windowTitleWidth > width) width = windowTitleWidth; diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 2c4c738681..49450be75b 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -335,7 +335,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); - const QFont font = QApplication::font("QWorkspaceTitleBar"); + const QFont font = QApplication::font("QMdiSubWindowTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 4ad8513050..5ac2269ff1 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -2305,7 +2305,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0); painter->save(); - painter->setFont(QApplication::font("QWorkspaceTitleBar")); + painter->setFont(QApplication::font("QMdiSubWindowTitleBar")); style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget); painter->restore(); if (setMask) diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index ee03f093c7..7931913545 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -325,7 +325,7 @@ void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *optio option->state &= ~QStyle::State_Active; option->titleBarState = Qt::WindowNoState; } - QFont windowTitleFont = QApplication::font("QWorkspaceTitleBar"); + QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar"); QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0); option->text = QFontMetrics(windowTitleFont).elidedText( windowData->windowTitle, Qt::ElideRight, textRect.width()); diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index ecba3e238f..125beab91b 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -402,6 +402,16 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event, return false; } +/*! + \internal + + This virtual method is reserved and will be used in Qt 5.1. +*/ +QSet<int> QAbstractItemDelegate::paintingRoles() const +{ + return QSet<int>(); +} + QT_END_NAMESPACE #endif // QT_NO_ITEMVIEWS diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h index 2c51dfcac8..89aa1915f6 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.h +++ b/src/widgets/itemviews/qabstractitemdelegate.h @@ -114,6 +114,8 @@ public: const QStyleOptionViewItem &option, const QModelIndex &index); + virtual QSet<int> paintingRoles() const; + Q_SIGNALS: void commitData(QWidget *editor); void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint = NoHint); diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index 5bdb74c56c..c3c79d35a3 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE class QColumnViewPreviewColumn : public QAbstractItemView { public: - QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(0) { + explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(0) { } void setPreviewWidget(QWidget *widget) { diff --git a/src/widgets/itemviews/qdatawidgetmapper.h b/src/widgets/itemviews/qdatawidgetmapper.h index e73d4b1044..3cb8f09510 100644 --- a/src/widgets/itemviews/qdatawidgetmapper.h +++ b/src/widgets/itemviews/qdatawidgetmapper.h @@ -66,7 +66,7 @@ class Q_WIDGETS_EXPORT QDataWidgetMapper: public QObject Q_PROPERTY(SubmitPolicy submitPolicy READ submitPolicy WRITE setSubmitPolicy) public: - QDataWidgetMapper(QObject *parent = 0); + explicit QDataWidgetMapper(QObject *parent = 0); ~QDataWidgetMapper(); void setModel(QAbstractItemModel *model); diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index e6376cef60..9b6b2368c9 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -130,7 +130,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionItem §io A header will emit sectionMoved() if the user moves a section, sectionResized() if the user resizes a section, and sectionClicked() as well as sectionHandleDoubleClicked() in response to mouse clicks. A header - will also emit sectionCountChanged() and sectionAutoResize(). + will also emit sectionCountChanged(). You can identify a section using the logicalIndex() and logicalIndexAt() functions, or by its index position, using the visualIndex() and @@ -282,18 +282,6 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionItem §io */ /*! - \fn void QHeaderView::sectionAutoResize(int logicalIndex, - QHeaderView::ResizeMode mode) - - This signal is emitted when a section is automatically resized. The - section's logical index is specified by \a logicalIndex, and the resize - mode by \a mode. - - \sa setResizeMode(), stretchLastSection() -*/ -// ### Qt 5: change to sectionAutoResized() - -/*! \fn void QHeaderView::geometriesChanged() \since 4.2 @@ -1195,7 +1183,7 @@ bool QHeaderView::highlightSections() const Sets the constraints on how the header can be resized to those described by the given \a mode. - \sa resizeMode(), length(), sectionResized(), sectionAutoResize() + \sa resizeMode(), length(), sectionResized() */ void QHeaderView::setResizeMode(ResizeMode mode) diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h index bf686e2925..0cea318953 100644 --- a/src/widgets/itemviews/qheaderview.h +++ b/src/widgets/itemviews/qheaderview.h @@ -191,7 +191,6 @@ Q_SIGNALS: void sectionDoubleClicked(int logicalIndex); void sectionCountChanged(int oldCount, int newCount); void sectionHandleDoubleClicked(int logicalIndex); - void sectionAutoResize(int logicalIndex, QHeaderView::ResizeMode mode); void geometriesChanged(); void sortIndicatorChanged(int logicalIndex, Qt::SortOrder order); diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp index 419c62ff65..bd9f4510f7 100644 --- a/src/widgets/itemviews/qitemdelegate.cpp +++ b/src/widgets/itemviews/qitemdelegate.cpp @@ -551,25 +551,9 @@ void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) con Q_UNUSED(editor); Q_UNUSED(index); #else - Q_D(const QItemDelegate); QVariant v = index.data(Qt::EditRole); QByteArray n = editor->metaObject()->userProperty().name(); - // ### Qt 5: remove - // A work-around for missing "USER true" in qdatetimeedit.h for - // QTimeEdit's time property and QDateEdit's date property. - // It only triggers if the default user property "dateTime" is - // reported for QTimeEdit and QDateEdit. - if (n == "dateTime") { - if (editor->inherits("QTimeEdit")) - n = "time"; - else if (editor->inherits("QDateEdit")) - n = "date"; - } - - // ### Qt 5: give QComboBox a USER property - if (n.isEmpty() && editor->inherits("QComboBox")) - n = d->editorFactory()->valuePropertyName(v.userType()); if (!n.isEmpty()) { if (!v.isValid()) v = QVariant(editor->property(n).userType(), (const void *)0); diff --git a/src/widgets/itemviews/qitemeditorfactory.h b/src/widgets/itemviews/qitemeditorfactory.h index aff8de3a4c..8bc1cc7df6 100644 --- a/src/widgets/itemviews/qitemeditorfactory.h +++ b/src/widgets/itemviews/qitemeditorfactory.h @@ -69,7 +69,7 @@ template <class T> class QItemEditorCreator : public QItemEditorCreatorBase { public: - inline QItemEditorCreator(const QByteArray &valuePropertyName); + inline explicit QItemEditorCreator(const QByteArray &valuePropertyName); inline QWidget *createWidget(QWidget *parent) const { return new T(parent); } inline QByteArray valuePropertyName() const { return propertyName; } diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index fdd6af06b9..d7e7cb3ebc 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -892,30 +892,6 @@ void QListView::startDrag(Qt::DropActions supportedActions) QAbstractItemView::startDrag(supportedActions); } -/*! - \internal - - Called whenever items from the view is dropped on the viewport. - The \a event provides additional information. -*/ -void QListView::internalDrop(QDropEvent *event) -{ - // ### Qt5: remove that function - Q_UNUSED(event); -} - -/*! - \internal - - Called whenever the user starts dragging items and the items are movable, - enabling internal dragging and dropping of items. -*/ -void QListView::internalDrag(Qt::DropActions supportedActions) -{ - // ### Qt5: remove that function - Q_UNUSED(supportedActions); -} - #endif // QT_NO_DRAGANDDROP /*! diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h index d278dec8c6..7b065b0585 100644 --- a/src/widgets/itemviews/qlistview.h +++ b/src/widgets/itemviews/qlistview.h @@ -160,9 +160,6 @@ protected: void dragLeaveEvent(QDragLeaveEvent *e); void dropEvent(QDropEvent *e); void startDrag(Qt::DropActions supportedActions); - - void internalDrop(QDropEvent *e); - void internalDrag(Qt::DropActions supportedActions); #endif // QT_NO_DRAGANDDROP QStyleOptionViewItem viewOptions() const; diff --git a/src/widgets/itemviews/qstandarditemmodel.h b/src/widgets/itemviews/qstandarditemmodel.h index e374665f20..767665fd94 100644 --- a/src/widgets/itemviews/qstandarditemmodel.h +++ b/src/widgets/itemviews/qstandarditemmodel.h @@ -66,7 +66,7 @@ class Q_WIDGETS_EXPORT QStandardItem { public: QStandardItem(); - QStandardItem(const QString &text); + explicit QStandardItem(const QString &text); QStandardItem(const QIcon &icon, const QString &text); explicit QStandardItem(int rows, int columns = 1); virtual ~QStandardItem(); diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 93893afaa8..119692531f 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -488,25 +488,9 @@ void QStyledItemDelegate::setEditorData(QWidget *editor, const QModelIndex &inde Q_UNUSED(editor); Q_UNUSED(index); #else - Q_D(const QStyledItemDelegate); QVariant v = index.data(Qt::EditRole); QByteArray n = editor->metaObject()->userProperty().name(); - // ### Qt 5: remove - // A work-around for missing "USER true" in qdatetimeedit.h for - // QTimeEdit's time property and QDateEdit's date property. - // It only triggers if the default user property "dateTime" is - // reported for QTimeEdit and QDateEdit. - if (n == "dateTime") { - if (editor->inherits("QTimeEdit")) - n = "time"; - else if (editor->inherits("QDateEdit")) - n = "date"; - } - - // ### Qt 5: give QComboBox a USER property - if (n.isEmpty() && editor->inherits("QComboBox")) - n = d->editorFactory()->valuePropertyName(v.userType()); if (!n.isEmpty()) { if (!v.isValid()) v = QVariant(editor->property(n).userType(), (const void *)0); diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index 3d08e204d1..0c6ed85fc9 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -84,7 +84,7 @@ class Q_WIDGETS_EXPORT QTableWidgetItem friend class QTableModel; public: enum ItemType { Type = 0, UserType = 1000 }; - QTableWidgetItem(int type = Type); + explicit QTableWidgetItem(int type = Type); explicit QTableWidgetItem(const QString &text, int type = Type); explicit QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type); QTableWidgetItem(const QTableWidgetItem &other); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index acc485c371..be78cdbf14 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1849,7 +1849,7 @@ void QTreeView::mousePressEvent(QMouseEvent *event) { Q_D(QTreeView); bool handled = false; - if (style()->styleHint(QStyle::SH_Q3ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress) + if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress) handled = d->expandOrCollapseItemAtPos(event->pos()); if (!handled && d->itemDecorationAt(event->pos()) == -1) QAbstractItemView::mousePressEvent(event); @@ -1866,7 +1866,7 @@ void QTreeView::mouseReleaseEvent(QMouseEvent *event) } else { if (state() == QAbstractItemView::DragSelectingState) setState(QAbstractItemView::NoState); - if (style()->styleHint(QStyle::SH_Q3ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease) + if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease) d->expandOrCollapseItemAtPos(event->pos()); } } diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index f8e3a375a4..e2d84825f0 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -2655,16 +2655,6 @@ QTreeWidgetItem *QTreeWidget::takeTopLevelItem(int index) } /*! - \internal -*/ -int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) -{ - Q_D(QTreeWidget); - d->treeModel()->executePendingSort(); - return d->treeModel()->rootItem->children.indexOf(item); -} - -/*! Returns the index of the given top-level \a item, or -1 if the item cannot be found. @@ -2900,26 +2890,6 @@ void QTreeWidget::sortItems(int column, Qt::SortOrder order) } /*! - \internal - - ### Qt 5: remove -*/ -void QTreeWidget::setSortingEnabled(bool enable) -{ - QTreeView::setSortingEnabled(enable); -} - -/*! - \internal - - ### Qt 5: remove -*/ -bool QTreeWidget::isSortingEnabled() const -{ - return QTreeView::isSortingEnabled(); -} - -/*! Starts editing the \a item in the given \a column if it is editable. */ diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h index c9654d3e8e..7420894dfb 100644 --- a/src/widgets/itemviews/qtreewidget.h +++ b/src/widgets/itemviews/qtreewidget.h @@ -69,7 +69,7 @@ class Q_WIDGETS_EXPORT QTreeWidgetItem public: enum ItemType { Type = 0, UserType = 1000 }; explicit QTreeWidgetItem(int type = Type); - QTreeWidgetItem(const QStringList &strings, int type = Type); + explicit QTreeWidgetItem(const QStringList &strings, int type = Type); explicit QTreeWidgetItem(QTreeWidget *view, int type = Type); QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type = Type); QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type = Type); @@ -277,7 +277,6 @@ public: void insertTopLevelItem(int index, QTreeWidgetItem *item); void addTopLevelItem(QTreeWidgetItem *item); QTreeWidgetItem *takeTopLevelItem(int index); - int indexOfTopLevelItem(QTreeWidgetItem *item); // ### Qt 5: remove me int indexOfTopLevelItem(QTreeWidgetItem *item) const; void insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items); @@ -300,8 +299,6 @@ public: int sortColumn() const; void sortItems(int column, Qt::SortOrder order); - void setSortingEnabled(bool enable); - bool isSortingEnabled() const; void editItem(QTreeWidgetItem *item, int column = 0); void openPersistentEditor(QTreeWidgetItem *item, int column = 0); diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index f450d13a39..c4f7995087 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -879,7 +879,7 @@ QString QAction::statusTip() const the action. The text may contain rich text. There is no default "What's This?" text. - \sa QWhatsThis Q3StyleSheet + \sa QWhatsThis */ void QAction::setWhatsThis(const QString &whatsthis) { diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index e82f5c1531..99500998db 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -556,10 +556,6 @@ void QApplicationPrivate::process_cmdline() \sa arguments() */ -QApplication::QApplication(int &argc, char **argv) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) -{ Q_D(QApplication); d->construct(); } - QApplication::QApplication(int &argc, char **argv, int _internal) : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) { Q_D(QApplication); d->construct(); } @@ -582,10 +578,6 @@ QApplication::QApplication(int &argc, char **argv, int _internal) \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0 */ -QApplication::QApplication(int &argc, char **argv, bool GUIenabled ) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000)) -{ Q_D(QApplication); d->construct(); } - QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal) : QGuiApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal)) { Q_D(QApplication); d->construct();} @@ -601,10 +593,6 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern be greater than zero and \a argv must contain at least one valid character string. */ -QApplication::QApplication(int &argc, char **argv, Type type) - : QGuiApplication(*new QApplicationPrivate(argc, argv, type, 0x040000)) -{ Q_D(QApplication); d->construct(); } - QApplication::QApplication(int &argc, char **argv, Type type , int _internal) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, _internal)) { Q_D(QApplication); d->construct(); } diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 31d228ddd5..206692e6d4 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -96,11 +96,9 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication public: -#ifndef qdoc QApplication(int &argc, char **argv, int = ApplicationFlags); QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); QApplication(int &argc, char **argv, Type, int = ApplicationFlags); -#endif virtual ~QApplication(); static Type type(); @@ -223,13 +221,6 @@ protected: bool event(QEvent *); bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); - -#if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) - QApplication(int &argc, char **argv); - QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled); - QApplication(int &argc, char **argv, Type); -#endif - private: Q_DISABLE_COPY(QApplication) Q_DECLARE_PRIVATE(QApplication) @@ -242,7 +233,6 @@ private: friend class QWidgetPrivate; friend class QWidgetWindow; friend class QETWidget; - friend class Q3AccelManager; friend class QTranslator; friend class QWidgetAnimator; #ifndef QT_NO_SHORTCUT diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index fa84e86f29..0651d5bf44 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -282,7 +282,6 @@ void QApplicationPrivate::initializeWidgetPaletteHash() setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "QHeaderView"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "Q3Header"); setPossiblePalette(platformTheme->palette(QPlatformTheme::ItemViewPalette), "QAbstractItemView"); setPossiblePalette(platformTheme->palette(QPlatformTheme::MessageBoxLabelPelette), "QMessageBoxLabel"); setPossiblePalette(platformTheme->palette(QPlatformTheme::TabBarPalette), "QTabBar"); @@ -317,10 +316,8 @@ void QApplicationPrivate::initializeWidgetFontHash() fontHash->insert(QByteArrayLiteral("QTitleBar"), *font); if (const QFont *font = theme->font(QPlatformTheme::StatusBarFont)) fontHash->insert(QByteArrayLiteral("QStatusBar"), *font); - if (const QFont *font = theme->font(QPlatformTheme::MdiSubWindowTitleFont)) { - fontHash->insert(QByteArrayLiteral("QWorkspaceTitleBar"), *font); + if (const QFont *font = theme->font(QPlatformTheme::MdiSubWindowTitleFont)) fontHash->insert(QByteArrayLiteral("QMdiSubWindowTitleBar"), *font); - } if (const QFont *font = theme->font(QPlatformTheme::DockWidgetTitleFont)) fontHash->insert(QByteArrayLiteral("QDockWidgetTitle"), *font); if (const QFont *font = theme->font(QPlatformTheme::PushButtonFont)) @@ -331,10 +328,8 @@ void QApplicationPrivate::initializeWidgetFontHash() fontHash->insert(QByteArrayLiteral("QAbstractItemView"), *font); if (const QFont *font = theme->font(QPlatformTheme::ListViewFont)) fontHash->insert(QByteArrayLiteral("QListViewFont"), *font); - if (const QFont *font = theme->font(QPlatformTheme::HeaderViewFont)) { + if (const QFont *font = theme->font(QPlatformTheme::HeaderViewFont)) fontHash->insert(QByteArrayLiteral("QHeaderViewFont"), *font); - fontHash->insert(QByteArrayLiteral("Q3Header"), *font); - } if (const QFont *font = theme->font(QPlatformTheme::ListBoxFont)) fontHash->insert(QByteArrayLiteral("QListBox"), *font); if (const QFont *font = theme->font(QPlatformTheme::ComboMenuItemFont)) diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h index aac46ef1ec..9b1dace5ed 100644 --- a/src/widgets/kernel/qboxlayout.h +++ b/src/widgets/kernel/qboxlayout.h @@ -84,6 +84,7 @@ public: void insertSpacerItem(int index, QSpacerItem *spacerItem); void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = 0); void insertLayout(int index, QLayout *layout, int stretch = 0); + void insertItem(int index, QLayoutItem *); int spacing() const; void setSpacing(int spacing); @@ -107,9 +108,6 @@ public: QLayoutItem *takeAt(int); int count() const; void setGeometry(const QRect&); -protected: - // ### Qt 5: make public - void insertItem(int index, QLayoutItem *); private: Q_DISABLE_COPY(QBoxLayout) diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index 3607d88d9e..c81158e0cd 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -167,9 +167,9 @@ public: return item; } - void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) { + void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const { if (index < things.count()) { - QGridBox *b = things.at(index); + const QGridBox *b = things.at(index); int toRow = b->toRow(rr); int toCol = b->toCol(cc); *row = b->row; @@ -779,7 +779,7 @@ void QGridLayoutPrivate::setupLayoutData(int hSpacing, int vSpacing) adjacent to which and compute the spacings correctly. */ QVarLengthArray<QGridBox *> grid(rr * cc); - qMemSet(grid.data(), 0, rr * cc * sizeof(QGridBox *)); + memset(grid.data(), 0, rr * cc * sizeof(QGridBox *)); /* Initialize 'sizes' and 'grid' data structures, and insert @@ -1347,9 +1347,9 @@ QLayoutItem *QGridLayout::takeAt(int index) \sa itemAtPosition(), itemAt() */ -void QGridLayout::getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) +void QGridLayout::getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const { - Q_D(QGridLayout); + Q_D(const QGridLayout); d->getItemPosition(index, row, column, rowSpan, columnSpan); } diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h index 02789b7794..930fdf4511 100644 --- a/src/widgets/kernel/qgridlayout.h +++ b/src/widgets/kernel/qgridlayout.h @@ -120,7 +120,7 @@ public: void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = 0); void setDefaultPositioning(int n, Qt::Orientation orient); - void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan); + void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan) const; protected: void addItem(QLayoutItem *); diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 541350c35c..8c4e988411 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -527,6 +527,19 @@ bool QLayout::isEmpty() const /*! \reimp */ +QSizePolicy::ControlTypes QLayout::controlTypes() const +{ + if (count() == 0) + return QSizePolicy::DefaultType; + QSizePolicy::ControlTypes types; + for (int i = count() - 1; i >= 0; --i) + types |= itemAt(i)->controlTypes(); + return types; +} + +/*! + \reimp +*/ void QLayout::setGeometry(const QRect &r) { Q_D(QLayout); diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h index 5524443ab1..9a13922cb1 100644 --- a/src/widgets/kernel/qlayout.h +++ b/src/widgets/kernel/qlayout.h @@ -131,6 +131,7 @@ public: virtual int indexOf(QWidget *) const; virtual int count() const = 0; bool isEmpty() const; + QSizePolicy::ControlTypes controlTypes() const; int totalHeightForWidth(int w) const; QSize totalMinimumSize() const; diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 814b807b82..8e08f5f39f 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -414,17 +414,6 @@ int QLayoutItem::heightForWidth(int /* w */) const */ QSizePolicy::ControlTypes QLayoutItem::controlTypes() const { - // ### Qt 5: This function should probably be virtual instead - if (const QWidget *widget = const_cast<QLayoutItem*>(this)->widget()) { - return widget->sizePolicy().controlType(); - } else if (const QLayout *layout = const_cast<QLayoutItem*>(this)->layout()) { - if (layout->count() == 0) - return QSizePolicy::DefaultType; - QSizePolicy::ControlTypes types; - for (int i = layout->count() - 1; i >= 0; --i) - types |= layout->itemAt(i)->controlTypes(); - return types; - } return QSizePolicy::DefaultType; } @@ -688,6 +677,11 @@ bool QWidgetItem::isEmpty() const return wid->isHidden() || wid->isWindow(); } +QSizePolicy::ControlTypes QWidgetItem::controlTypes() const +{ + return wid->sizePolicy().controlType(); +} + /*! \class QWidgetItemV2 \internal diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h index 76aae6f794..dacbf1ea68 100644 --- a/src/widgets/kernel/qlayoutitem.h +++ b/src/widgets/kernel/qlayoutitem.h @@ -83,7 +83,7 @@ public: Qt::Alignment alignment() const { return align; } void setAlignment(Qt::Alignment a); - QSizePolicy::ControlTypes controlTypes() const; + virtual QSizePolicy::ControlTypes controlTypes() const; protected: Qt::Alignment align; @@ -135,7 +135,7 @@ public: bool hasHeightForWidth() const; int heightForWidth(int) const; - + QSizePolicy::ControlTypes controlTypes() const; protected: QWidget *wid; }; diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 9b40063e65..0d2e7716e5 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -477,6 +477,38 @@ void QStackedLayout::setGeometry(const QRect &rect) } /*! + \reimp +*/ +bool QStackedLayout::hasHeightForWidth() const +{ + const int n = count(); + + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + if (item->hasHeightForWidth()) + return true; + } + } + return false; +} + +/*! + \reimp +*/ +int QStackedLayout::heightForWidth(int width) const +{ + const int n = count(); + + int hfw = 0; + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + hfw = qMax(hfw, item->heightForWidth(width)); + } + } + return hfw; +} + +/*! \enum QStackedLayout::StackingMode \since 4.4 diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h index e54efa886e..fa77341c52 100644 --- a/src/widgets/kernel/qstackedlayout.h +++ b/src/widgets/kernel/qstackedlayout.h @@ -94,6 +94,8 @@ public: QLayoutItem *itemAt(int) const; QLayoutItem *takeAt(int); void setGeometry(const QRect &rect); + bool hasHeightForWidth() const; + int heightForWidth(int width) const; Q_SIGNALS: void widgetRemoved(int index); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index ddab66944e..9abba54390 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2892,7 +2892,7 @@ void QWidget::showNormal() \sa setEnabled() enabled */ -bool QWidget::isEnabledTo(QWidget* ancestor) const +bool QWidget::isEnabledTo(const QWidget *ancestor) const { const QWidget * w = this; while (!w->testAttribute(Qt::WA_ForceDisabled) @@ -3868,13 +3868,13 @@ void QWidget::setFixedHeight(int h) \sa mapFrom() mapToParent() mapToGlobal() underMouse() */ -QPoint QWidget::mapTo(QWidget * parent, const QPoint & pos) const +QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const { QPoint p = pos; if (parent) { const QWidget * w = this; while (w != parent) { - Q_ASSERT_X(w, "QWidget::mapTo(QWidget *parent, const QPoint &pos)", + Q_ASSERT_X(w, "QWidget::mapTo(const QWidget *parent, const QPoint &pos)", "parent must be in parent hierarchy"); p = w->mapToParent(p); w = w->parentWidget(); @@ -3892,13 +3892,13 @@ QPoint QWidget::mapTo(QWidget * parent, const QPoint & pos) const \sa mapTo() mapFromParent() mapFromGlobal() underMouse() */ -QPoint QWidget::mapFrom(QWidget * parent, const QPoint & pos) const +QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const { QPoint p(pos); if (parent) { const QWidget * w = this; while (w != parent) { - Q_ASSERT_X(w, "QWidget::mapFrom(QWidget *parent, const QPoint &pos)", + Q_ASSERT_X(w, "QWidget::mapFrom(const QWidget *parent, const QPoint &pos)", "parent must be in parent hierarchy"); p = w->mapFromParent(p); @@ -5136,7 +5136,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP paintEngine->d_func()->systemClip = QRegion(); } q->setAttribute(Qt::WA_WState_InPaintEvent, false); - if (q->paintingActive() && !q->testAttribute(Qt::WA_PaintOutsidePaintEvent)) + if (q->paintingActive()) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); if (paintEngine && paintEngine->autoDestruct()) { @@ -7571,7 +7571,7 @@ bool QWidget::close() \sa show() hide() isVisible() */ -bool QWidget::isVisibleTo(QWidget* ancestor) const +bool QWidget::isVisibleTo(const QWidget *ancestor) const { if (!ancestor) return isVisible(); @@ -8438,7 +8438,7 @@ void QWidget::mouseReleaseEvent(QMouseEvent *event) void QWidget::mouseDoubleClickEvent(QMouseEvent *event) { - Q_UNUSED(event) + Q_UNUSED(event); } #ifndef QT_NO_WHEELEVENT diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 64042ccc36..b7a5e26690 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -243,7 +243,7 @@ public: void setWindowModality(Qt::WindowModality windowModality); bool isEnabled() const; - bool isEnabledTo(QWidget*) const; + bool isEnabledTo(const QWidget *) const; bool isEnabledToTLW() const; public Q_SLOTS: @@ -306,8 +306,8 @@ public: QPoint mapFromGlobal(const QPoint &) const; QPoint mapToParent(const QPoint &) const; QPoint mapFromParent(const QPoint &) const; - QPoint mapTo(QWidget *, const QPoint &) const; - QPoint mapFrom(QWidget *, const QPoint &) const; + QPoint mapTo(const QWidget *, const QPoint &) const; + QPoint mapFrom(const QWidget *, const QPoint &) const; QWidget *window() const; QWidget *nativeParentWidget() const; @@ -505,8 +505,7 @@ public: bool restoreGeometry(const QByteArray &geometry); void adjustSize(); bool isVisible() const; - bool isVisibleTo(QWidget*) const; - // ### Qt 5: bool isVisibleTo(_const_ QWidget *) const + bool isVisibleTo(const QWidget *) const; inline bool isHidden() const; bool isMinimized() const; diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 6b6dd12703..a8175455b2 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -441,12 +441,12 @@ static inline QRect positionTopLevelWindow(QRect geometry, const QScreen *screen void QWidgetPrivate::show_sys() { Q_Q(QWidget); - q->setAttribute(Qt::WA_Mapped); QWindow *window = q->windowHandle(); if (q->testAttribute(Qt::WA_DontShowOnScreen)) { invalidateBuffer(q->rect()); + q->setAttribute(Qt::WA_Mapped); if (q->isWindow() && q->windowModality() != Qt::NonModal && window) { // add our window to the modal window list QGuiApplicationPrivate::showModalWindow(window); @@ -488,7 +488,6 @@ void QWidgetPrivate::show_sys() void QWidgetPrivate::hide_sys() { Q_Q(QWidget); - q->setAttribute(Qt::WA_Mapped, false); QWindow *window = q->windowHandle(); @@ -501,6 +500,7 @@ void QWidgetPrivate::hide_sys() } deactivateWidgetCleanup(); + if (!q->isWindow()) { QWidget *p = q->parentWidget(); if (p &&p->isVisible()) { @@ -509,8 +509,13 @@ void QWidgetPrivate::hide_sys() return; } - if (window) - window->setVisible(false); + invalidateBuffer(q->rect()); + + if (q->testAttribute(Qt::WA_DontShowOnScreen)) { + q->setAttribute(Qt::WA_Mapped, false); + } else if (window) { + window->setVisible(false); + } } void QWidgetPrivate::setMaxWindowState_helper() diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index f9361cc357..2c9ad14bcf 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -869,29 +869,7 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) static inline bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra) { - if (!tlw || !tlwExtra) - return true; - -#ifdef Q_WS_X11 - // Delay the sync until we get an Expose event from X11 (initial show). - // Qt::WA_Mapped is set to true, but the actual mapping has not yet occurred. - // However, we must repaint immediately regardless of the state if someone calls repaint(). - if (tlwExtra->waitingForMapNotify && !tlwExtra->inRepaint) - return true; -#endif - - if (!tlw->testAttribute(Qt::WA_Mapped)) - return true; - - if (!tlw->isVisible() -#ifndef Q_WS_X11 - // If we're minimized on X11, WA_Mapped will be false and we - // will return in the case above. Some window managers on X11 - // sends us the PropertyNotify to change the minimized state - // *AFTER* we've received the expose event, which is baaad. - || tlw->isMinimized() -#endif - ) + if (!tlw || !tlwExtra || !tlw->testAttribute(Qt::WA_Mapped) || !tlw->isVisible()) return true; return false; @@ -1297,6 +1275,9 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn) return; Q_Q(QWidget); + if (discardSyncRequest(q, maybeTopData())) + return; + if (q->testAttribute(Qt::WA_StaticContents)) { if (!extra) createExtra(); @@ -1335,7 +1316,7 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn) QWidgetBackingStore::unflushPaint(q, toBePainted); #endif - if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive()) + if (q->paintingActive()) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); } diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index 81847681e4..f6817cec8a 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -184,12 +184,4 @@ void qRegisterWidgetsVariant() } Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant) -void qUnregisterWidgetsVariant() -{ - QVariantPrivate::unregisterHandler(QModulesPrivate::Widgets); - qMetaTypeWidgetsHelper = 0; -} -Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant) - - QT_END_NAMESPACE diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 3cccc52311..d124ec768a 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -152,15 +152,6 @@ bool QWidgetWindow::event(QEvent *event) handleDragEvent(event); break; - case QEvent::Map: - m_widget->setAttribute(Qt::WA_Mapped); - m_widget->d_func()->syncBackingStore(); - return true; - - case QEvent::Unmap: - m_widget->setAttribute(Qt::WA_Mapped, false); - return true; - case QEvent::Expose: handleExposeEvent(static_cast<QExposeEvent *>(event)); return true; @@ -447,7 +438,13 @@ void QWidgetWindow::handleDragEvent(QEvent *event) void QWidgetWindow::handleExposeEvent(QExposeEvent *event) { - m_widget->d_func()->syncBackingStore(event->region()); + if (isExposed()) { + m_widget->setAttribute(Qt::WA_Mapped); + if (!event->region().isNull()) + m_widget->d_func()->syncBackingStore(event->region()); + } else { + m_widget->setAttribute(Qt::WA_Mapped, false); + } } void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event) diff --git a/src/widgets/styles/qcleanlooksstyle.cpp b/src/widgets/styles/qcleanlooksstyle.cpp index 67b3c59b29..d617ee7e6f 100644 --- a/src/widgets/styles/qcleanlooksstyle.cpp +++ b/src/widgets/styles/qcleanlooksstyle.cpp @@ -3906,7 +3906,6 @@ void QCleanlooksStyle::polish(QWidget *widget) #ifndef QT_NO_SPINBOX || qobject_cast<QAbstractSpinBox *>(widget) #endif - || (widget->inherits("QWorkspaceChild")) || (widget->inherits("QDockSeparator")) || (widget->inherits("QDockWidgetSeparator")) ) { @@ -3953,7 +3952,6 @@ void QCleanlooksStyle::unpolish(QWidget *widget) #ifndef QT_NO_SPINBOX || qobject_cast<QAbstractSpinBox *>(widget) #endif - || (widget->inherits("QWorkspaceChild")) || (widget->inherits("QDockSeparator")) || (widget->inherits("QDockWidgetSeparator")) ) { diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 68d80931f6..b2b1d3fec5 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -460,9 +460,6 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q } p->restore(); break; - case PE_Q3DockWindowSeparator: - proxy()->drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget); - break; case PE_IndicatorToolBarSeparator: { QPoint p1, p2; @@ -3571,69 +3568,6 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl } break; #endif // QT_NO_GROUPBOX -#ifndef QT_NO_WORKSPACE - case CC_MdiControls: - { - QStyleOptionButton btnOpt; - btnOpt.QStyleOption::operator=(*opt); - btnOpt.state &= ~State_MouseOver; - int bsx = 0; - int bsy = 0; - if (opt->subControls & QStyle::SC_MdiCloseButton) { - if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) { - btnOpt.state |= State_Sunken; - btnOpt.state &= ~State_Raised; - bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); - bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); - } else { - btnOpt.state |= State_Raised; - btnOpt.state &= ~State_Sunken; - bsx = 0; - bsy = 0; - } - btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget); - proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); - QPixmap pm = standardIcon(SP_TitleBarCloseButton).pixmap(16, 16); - proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); - } - if (opt->subControls & QStyle::SC_MdiNormalButton) { - if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) { - btnOpt.state |= State_Sunken; - btnOpt.state &= ~State_Raised; - bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); - bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); - } else { - btnOpt.state |= State_Raised; - btnOpt.state &= ~State_Sunken; - bsx = 0; - bsy = 0; - } - btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget); - proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); - QPixmap pm = standardIcon(SP_TitleBarNormalButton).pixmap(16, 16); - proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); - } - if (opt->subControls & QStyle::SC_MdiMinButton) { - if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) { - btnOpt.state |= State_Sunken; - btnOpt.state &= ~State_Raised; - bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); - bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); - } else { - btnOpt.state |= State_Raised; - btnOpt.state &= ~State_Sunken; - bsx = 0; - bsy = 0; - } - btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget); - proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); - QPixmap pm = standardIcon(SP_TitleBarMinButton).pixmap(16, 16); - proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); - } - } - break; -#endif // QT_NO_WORKSPACE - default: qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc); } @@ -4106,10 +4040,8 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex } int frameWidth = 0; - if (!(widget && widget->inherits("Q3GroupBox")) - && ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)) { + if ((groupBox->features & QStyleOptionFrameV2::Flat) == 0) frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox, widget); - } ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin, -frameWidth, -frameWidth); break; @@ -4160,50 +4092,6 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex break; } #endif // QT_NO_GROUPBOX -#ifndef QT_NO_WORKSPACE - case CC_MdiControls: - { - int numSubControls = 0; - if (opt->subControls & SC_MdiCloseButton) - ++numSubControls; - if (opt->subControls & SC_MdiMinButton) - ++numSubControls; - if (opt->subControls & SC_MdiNormalButton) - ++numSubControls; - if (numSubControls == 0) - break; - - int buttonWidth = opt->rect.width()/ numSubControls - 1; - int offset = 0; - switch (sc) { - case SC_MdiCloseButton: - // Only one sub control, no offset needed. - if (numSubControls == 1) - break; - offset += buttonWidth + 2; - //FALL THROUGH - case SC_MdiNormalButton: - // No offset needed if - // 1) There's only one sub control - // 2) We have a close button and a normal button (offset already added in SC_MdiClose) - if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton))) - break; - if (opt->subControls & SC_MdiNormalButton) - offset += buttonWidth; - break; - default: - break; - } - - // Subtract one pixel if we only have one sub control. At this point - // buttonWidth is the actual width + 1 pixel margin, but we don't want the - // margin when there are no other controllers. - if (numSubControls == 1) - --buttonWidth; - ret = QRect(offset, 0, buttonWidth, opt->rect.height()); - break; - } -#endif // QT_NO_WORKSPACE default: qWarning("QCommonStyle::subControlRect: Case %d not handled", cc); } @@ -4233,10 +4121,6 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_DialogButtonsButtonHeight: ret = int(QStyleHelper::dpiScaled(30.)); break; - case PM_CheckListControllerSize: - case PM_CheckListButtonSize: - ret = int(QStyleHelper::dpiScaled(16.)); - break; case PM_TitleBarHeight: { if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) { @@ -4711,7 +4595,6 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_MenuBar: case CT_Menu: case CT_MenuBarItem: - case CT_Q3Header: case CT_Slider: case CT_ProgressBar: case CT_TabBarTab: @@ -4756,7 +4639,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget break; #endif // QT_NO_GROUPBOX - case SH_Q3ListViewExpand_SelectMouseType: + case SH_ListViewExpand_SelectMouseType: case SH_TabBar_SelectMouseType: ret = QEvent::MouseButtonPress; break; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8496abab91..05bd90abef 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2145,20 +2145,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW else ret = sz.height(); break; } - case PM_CheckListButtonSize: { - switch (d->aquaSizeConstrain(opt, widget)) { - case QAquaSizeUnknown: - case QAquaSizeLarge: - GetThemeMetric(kThemeMetricCheckBoxWidth, &ret); - break; - case QAquaSizeMini: - GetThemeMetric(kThemeMetricMiniCheckBoxWidth, &ret); - break; - case QAquaSizeSmall: - GetThemeMetric(kThemeMetricSmallCheckBoxWidth, &ret); - break; - } - break; } case PM_DialogButtonsButtonWidth: { QSize sz; ret = d->aquaSizeConstrain(opt, 0, QStyle::CT_PushButton, QSize(-1, -1), &sz); @@ -2198,8 +2184,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW if (widget && (widget->isWindow() || !widget->parentWidget() || (qobject_cast<const QMainWindow*>(widget->parentWidget()) && static_cast<QMainWindow *>(widget->parentWidget())->centralWidget() == widget)) - && (qobject_cast<const QAbstractScrollArea *>(widget) - || widget->inherits("QWorkspaceChild"))) + && qobject_cast<const QAbstractScrollArea *>(widget)) ret = 0; else #endif @@ -2561,12 +2546,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = Qt::AlignTop; break; case SH_ScrollView_FrameOnlyAroundContents: - if (w && (w->isWindow() || !w->parentWidget() || w->parentWidget()->isWindow()) - && (w->inherits("QWorkspaceChild") - )) - ret = true; - else - ret = QWindowsStyle::styleHint(sh, opt, w, hret); + ret = QWindowsStyle::styleHint(sh, opt, w, hret); break; case SH_Menu_FillScreenWithScroll: ret = false; @@ -2583,7 +2563,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_ScrollBar_StopMouseOverSlider: ret = true; break; - case SH_Q3ListViewExpand_SelectMouseType: + case SH_ListViewExpand_SelectMouseType: ret = QEvent::MouseButtonRelease; break; case SH_TabBar_SelectMouseType: @@ -3094,8 +3074,6 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->restore(); break; } case PE_IndicatorViewItemCheck: - case PE_Q3CheckListExclusiveIndicator: - case PE_Q3CheckListIndicator: case PE_IndicatorRadioButton: case PE_IndicatorCheckBox: { bool drawColorless = (!(opt->state & State_Active)) @@ -3108,8 +3086,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai bdi.adornment = kThemeDrawIndicatorOnly; if (opt->state & State_HasFocus) bdi.adornment |= kThemeAdornmentFocus; - bool isRadioButton = (pe == PE_Q3CheckListExclusiveIndicator - || pe == PE_IndicatorRadioButton); + bool isRadioButton = (pe == PE_IndicatorRadioButton); switch (d->aquaSizeConstrain(opt, w)) { case QAquaSizeUnknown: case QAquaSizeLarge: @@ -3137,11 +3114,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai bdi.value = kThemeButtonOn; else bdi.value = kThemeButtonOff; - HIRect macRect; - if (pe == PE_Q3CheckListExclusiveIndicator || pe == PE_Q3CheckListIndicator) - macRect = qt_hirectForQRect(opt->rect); - else - macRect = qt_hirectForQRect(opt->rect); + HIRect macRect = qt_hirectForQRect(opt->rect); if (!drawColorless) HIThemeDrawButton(&macRect, &bdi, cg, kHIThemeOrientationNormal, 0); else @@ -4931,35 +4904,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } break; - case CC_Q3ListView: - if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { - if (lv->subControls & SC_Q3ListView) - QWindowsStyle::drawComplexControl(cc, lv, p, widget); - if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) { - int y = lv->rect.y(); - int h = lv->rect.height(); - int x = lv->rect.right() - 10; - for (int i = 1; i < lv->items.size() && y < h; ++i) { - QStyleOptionQ3ListViewItem item = lv->items.at(i); - if (y + item.height > 0 && (item.childCount > 0 - || (item.features & (QStyleOptionQ3ListViewItem::Expandable - | QStyleOptionQ3ListViewItem::Visible)) - == (QStyleOptionQ3ListViewItem::Expandable - | QStyleOptionQ3ListViewItem::Visible))) { - QStyleOption treeOpt(0); - treeOpt.rect.setRect(x, y + item.height / 2 - 4, 9, 9); - treeOpt.palette = lv->palette; - treeOpt.state = lv->state; - treeOpt.state |= State_Children; - if (item.state & State_Open) - treeOpt.state |= State_Open; - proxy()->drawPrimitive(PE_IndicatorBranch, &treeOpt, p, widget); - } - y += item.totalHeight; - } - } - } - break; case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { QStyleOptionSpinBox newSB = *sb; diff --git a/src/widgets/styles/qmotifstyle.cpp b/src/widgets/styles/qmotifstyle.cpp index 331b70f153..f02771ab61 100644 --- a/src/widgets/styles/qmotifstyle.cpp +++ b/src/widgets/styles/qmotifstyle.cpp @@ -346,41 +346,6 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP const QWidget *w) const { switch(pe) { - case PE_Q3CheckListExclusiveIndicator: - if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { - if (lv->items.isEmpty()) - return; - - if (lv->state & State_Enabled) - p->setPen(QPen(opt->palette.text().color())); - else - p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text))); - QPolygon a; - - int cx = opt->rect.width()/2 - 1; - int cy = opt->rect.height()/2; - int e = opt->rect.width()/2 - 1; - for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work - a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e); - p->drawPolygon(a); - e--; - } - if (opt->state & State_On) { - if (lv->state & State_Enabled) - p->setPen(QPen(opt->palette.text().color())); - else - p->setPen(QPen(lv->palette.color(QPalette::Disabled, - QPalette::Text))); - QBrush saveBrush = p->brush(); - p->setBrush(opt->palette.text()); - e = e - 2; - a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e); - p->drawPolygon(a); - p->setBrush(saveBrush); - } - } - break; - case PE_FrameTabWidget: case PE_FrameWindow: qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, proxy()->pixelMetric(PM_DefaultFrameWidth)); @@ -1672,105 +1637,6 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple break; } #endif - case CC_Q3ListView: - if (opt->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) { - int i; - if (opt->subControls & SC_Q3ListView) - QCommonStyle::drawComplexControl(cc, opt, p, widget); - if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { - QStyleOptionQ3ListViewItem item = lv->items.at(0); - int y = opt->rect.y(); - int c; - QPolygon dotlines; - if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) { - c = 2; - dotlines.resize(2); - dotlines[0] = QPoint(opt->rect.right(), opt->rect.top()); - dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom()); - } else { - int linetop = 0, linebot = 0; - // each branch needs at most two lines, ie. four end points - dotlines.resize(item.childCount * 4); - c = 0; - - // skip the stuff above the exposed rectangle - for (i = 1; i < lv->items.size(); ++i) { - QStyleOptionQ3ListViewItem child = lv->items.at(i); - if (child.height + y > 0) - break; - y += child.totalHeight; - } - - int bx = opt->rect.width() / 2; - - // paint stuff in the magical area - while (i < lv->items.size() && y < lv->rect.height()) { - QStyleOptionQ3ListViewItem child = lv->items.at(i); - if (child.features & QStyleOptionQ3ListViewItem::Visible) { - int lh; - if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine)) - lh = child.height; - else - lh = p->fontMetrics().height() + 2 * lv->itemMargin; - lh = qMax(lh, QApplication::globalStrut().height()); - if (lh % 2 > 0) - lh++; - linebot = y + lh/2; - if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) && - child.height > 0) { - // needs a box - p->setPen(opt->palette.text().color()); - p->drawRect(bx-4, linebot-4, 9, 9); - QPolygon a; - if ((child.state & State_Open)) - a.setPoints(3, bx-2, linebot-2, - bx, linebot+2, - bx+2, linebot-2); //Qt::RightArrow - else - a.setPoints(3, bx-2, linebot-2, - bx+2, linebot, - bx-2, linebot+2); //Qt::DownArrow - p->setBrush(opt->palette.text()); - p->drawPolygon(a); - p->setBrush(Qt::NoBrush); - // dotlinery - dotlines[c++] = QPoint(bx, linetop); - dotlines[c++] = QPoint(bx, linebot - 5); - dotlines[c++] = QPoint(bx + 5, linebot); - dotlines[c++] = QPoint(opt->rect.width(), linebot); - linetop = linebot + 5; - } else { - // just dotlinery - dotlines[c++] = QPoint(bx+1, linebot); - dotlines[c++] = QPoint(opt->rect.width(), linebot); - } - y += child.totalHeight; - } - ++i; - } - - // Expand line height to edge of rectangle if there's any - // visible child below - while (i < lv->items.size() && lv->items.at(i).height <= 0) - ++i; - if (i < lv->items.size()) - linebot = opt->rect.height(); - - if (linetop < linebot) { - dotlines[c++] = QPoint(bx, linetop); - dotlines[c++] = QPoint(bx, linebot); - } - } - - int line; // index into dotlines - p->setPen(opt->palette.text().color()); - if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) { - p->drawLine(dotlines[line].x(), dotlines[line].y(), - dotlines[line+1].x(), dotlines[line+1].y()); - } - } - break; } - default: QCommonStyle::drawComplexControl(cc, opt, p, widget); break; @@ -2123,20 +1989,6 @@ QMotifStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidge break; } - case SE_Q3DockWindowHandleRect: - if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) { - if (!dw->docked || !dw->closeEnabled) - rect.setRect(0, 0, opt->rect.width(), opt->rect.height()); - else { - if (dw->state == State_Horizontal) - rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15); - else - rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2); - } - rect = visualRect(dw->direction, dw->rect, rect); - } - break; - case SE_ProgressBarLabel: case SE_ProgressBarGroove: case SE_ProgressBarContents: diff --git a/src/widgets/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp index 79893f066d..cae015ff82 100644 --- a/src/widgets/styles/qplastiquestyle.cpp +++ b/src/widgets/styles/qplastiquestyle.cpp @@ -83,7 +83,6 @@ static const int blueFrameWidth = 2; // with of line edit focus frame #include <qtoolbar.h> #include <qtoolbox.h> #include <qtoolbutton.h> -#include <qworkspace.h> #include <qprocess.h> #include <qvarlengtharray.h> #include <limits.h> @@ -5629,10 +5628,8 @@ void QPlastiqueStyle::polish(QWidget *widget) widget->setAttribute(Qt::WA_Hover); } - if (widget->inherits("QWorkspaceTitleBar") - || widget->inherits("QDockSeparator") - || widget->inherits("QDockWidgetSeparator") - || widget->inherits("Q3DockWindowResizeHandle")) { + if (widget->inherits("QDockSeparator") + || widget->inherits("QDockWidgetSeparator")) { widget->setAttribute(Qt::WA_Hover); } @@ -5685,10 +5682,8 @@ void QPlastiqueStyle::unpolish(QWidget *widget) widget->setAttribute(Qt::WA_Hover, false); } - if (widget->inherits("QWorkspaceTitleBar") - || widget->inherits("QDockSeparator") - || widget->inherits("QDockWidgetSeparator") - || widget->inherits("Q3DockWindowResizeHandle")) { + if (widget->inherits("QDockSeparator") + || widget->inherits("QDockWidgetSeparator")) { widget->setAttribute(Qt::WA_Hover, false); } diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index db387fecec..d78a2ee2fb 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -596,8 +596,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PE_IndicatorCheckBox On/off indicator, for example, a QCheckBox. \value PE_IndicatorRadioButton Exclusive on/off indicator, for example, a QRadioButton. - \value PE_Q3DockWindowSeparator Item separator for Qt 3 compatible dock window - and toolbar contents. \value PE_IndicatorDockWidgetResizeHandle Resize handle for dock windows. \value PE_Frame Generic frame @@ -619,16 +617,10 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PE_FrameWindow Frame around a MDI window or a docking window. - \value PE_Q3Separator Qt 3 compatible generic separator. - \value PE_IndicatorMenuCheckMark Check mark used in a menu. \value PE_IndicatorProgressChunk Section of a progress bar indicator; see also QProgressBar. - \value PE_Q3CheckListController Qt 3 compatible controller part of a list view item. - \value PE_Q3CheckListIndicator Qt 3 compatible checkbox part of a list view item. - \value PE_Q3CheckListExclusiveIndicator Qt 3 compatible radio button part of a list view item. - \value PE_IndicatorBranch Lines used to represent the branch of a tree in a tree view. \value PE_IndicatorToolBarHandle The handle of a toolbar. \value PE_IndicatorToolBarSeparator The separator in a toolbar. @@ -740,9 +732,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \row \li \l State_On \li Indicates the indicator is checked. \row \li \l PE_IndicatorRadioButton \li \l QStyleOptionButton \li \l State_On \li Indicates that a radio button is selected. - \row \li{1,3} \l PE_Q3CheckListExclusiveIndicator, \l PE_Q3CheckListIndicator - \li{1,3} \l QStyleOptionQ3ListView \li \l State_On - \li Indicates whether or not the controller is selected. \row \li \l State_NoChange \li Indicates a "tri-state" controller. \row \li \l State_Enabled \li Indicates the controller is enabled. \row \li{1,4} \l PE_IndicatorBranch \li{1,4} \l QStyleOption @@ -760,9 +749,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \row \li \l PE_IndicatorToolBarHandle \li \l QStyleOption \li \l State_Horizontal \li Indicates that the window handle is horizontal instead of vertical. - \row \li \l PE_Q3DockWindowSeparator \li \l QStyleOption - \li \l State_Horizontal \li Indicates that the separator is horizontal - instead of vertical. \row \li \l PE_IndicatorSpinPlus, \l PE_IndicatorSpinMinus, \l PE_IndicatorSpinUp, \l PE_IndicatorSpinDown, \li \l QStyleOptionSpinBox @@ -826,8 +812,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value CE_MenuHMargin The horizontal extra space on the left/right of a menu. \value CE_MenuVMargin The vertical extra space on the top/bottom of a menu. - \value CE_Q3DockWindowEmptyArea The empty area of a QDockWidget. - \value CE_ToolBoxTab The toolbox's tab and label within a QToolBox. \value CE_SizeGrip Window resize handle; see also QSizeGrip. @@ -988,22 +972,11 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_SpinBoxLayoutItem Area that counts for the parent layout. - \value SE_Q3DockWindowHandleRect Area for the tear-off handle. - \value SE_ProgressBarGroove Area for the groove. \value SE_ProgressBarContents Area for the progress indicator. \value SE_ProgressBarLabel Area for the text label. \value SE_ProgressBarLayoutItem Area that counts for the parent layout. - \omitvalue SE_DialogButtonAccept - \omitvalue SE_DialogButtonReject - \omitvalue SE_DialogButtonApply - \omitvalue SE_DialogButtonHelp - \omitvalue SE_DialogButtonAll - \omitvalue SE_DialogButtonRetry - \omitvalue SE_DialogButtonAbort - \omitvalue SE_DialogButtonIgnore - \omitvalue SE_DialogButtonCustom \omitvalue SE_ViewItemCheckIndicator \value SE_FrameContents Area for a frame's contents. @@ -1087,7 +1060,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \row \li \l SE_RadioButtonContents \li \l QStyleOptionButton \row \li \l SE_RadioButtonFocusRect \li \l QStyleOptionButton \row \li \l SE_ComboBoxFocusRect \li \l QStyleOptionComboBox - \row \li \l SE_Q3DockWindowHandleRect \li \l QStyleOptionQ3DockWindow \row \li \l SE_ProgressBarGroove \li \l QStyleOptionProgressBar \row \li \l SE_ProgressBarContents \li \l QStyleOptionProgressBar \row \li \l SE_ProgressBarLabel \li \l QStyleOptionProgressBar @@ -1107,7 +1079,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value CC_Slider A slider, like QSlider. \value CC_ToolButton A tool button, like QToolButton. \value CC_TitleBar A Title bar, like those used in QMdiSubWindow. - \value CC_Q3ListView Used for drawing the Q3ListView class. \value CC_GroupBox A group box, like QGroupBox. \value CC_Dial A dial, like QDial. \value CC_MdiControls The minimize, close, and normal @@ -1157,7 +1128,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SC_ToolButton Tool button (see also QToolButton). \value SC_ToolButtonMenu Sub-control for opening a popup menu in a - tool button; see also Q3PopupMenu. + tool button. \value SC_TitleBarSysMenu System menu button (i.e., restore, close, etc.). \value SC_TitleBarMinButton Minimize button. @@ -1169,9 +1140,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SC_TitleBarUnshadeButton Unshade button. \value SC_TitleBarContextHelpButton Context Help button. - \value SC_Q3ListView The list view area. - \value SC_Q3ListViewExpand Expand item (i.e., show/hide child items). - \value SC_DialHandle The handle of the dial (i.e. what you use to control the dial). \value SC_DialGroove The groove for the dial. \value SC_DialTickmarks The tickmarks for the dial. @@ -1189,7 +1157,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, in the menu bar. \value SC_All Special value that matches all sub-controls. - \omitvalue SC_Q3ListViewBranch \omitvalue SC_CustomBase \sa ComplexControl @@ -1257,9 +1224,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \row \li \l{CC_TitleBar} \li \l QStyleOptionTitleBar \li \l State_Enabled \li Set if the title bar is enabled. - \row \li \l{CC_Q3ListView} \li \l QStyleOptionQ3ListView - \li \l State_Enabled \li Set if the list view is enabled. - \endtable \sa drawPrimitive(), drawControl() @@ -1418,11 +1382,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_MenuTearoffHeight Height of a tear off area in a QMenu. \value PM_MenuDesktopFrameWidth The frame width for the menu on the desktop. - \value PM_CheckListButtonSize Area (width/height) of the - checkbox/radio button in a Q3CheckListItem. - \value PM_CheckListControllerSize Area (width/height) of the - controller in a Q3CheckListItem. - \omitvalue PM_DialogButtonsSeparator \omitvalue PM_DialogButtonsButtonWidth \omitvalue PM_DialogButtonsButtonHeight @@ -1520,11 +1479,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value CT_CheckBox A check box, like QCheckBox. \value CT_ComboBox A combo box, like QComboBox. \omitvalue CT_DialogButtons - \value CT_Q3DockWindow A Q3DockWindow. \value CT_HeaderSection A header section, like QHeader. \value CT_LineEdit A line edit, like QLineEdit. \value CT_Menu A menu, like QMenu. - \value CT_Q3Header A Qt 3 header section, like Q3Header. \value CT_MenuBar A menu bar, like QMenuBar. \value CT_MenuBarItem A menu bar item, like the buttons in a QMenuBar. \value CT_MenuItem A menu item, like QMenuItem. @@ -1575,7 +1532,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \row \li \l CT_ToolButton \li \l QStyleOptionToolButton \row \li \l CT_ComboBox \li \l QStyleOptionComboBox \row \li \l CT_Splitter \li \l QStyleOption - \row \li \l CT_Q3DockWindow \li \l QStyleOptionQ3DockWindow \row \li \l CT_ProgressBar \li \l QStyleOptionProgressBar \row \li \l CT_MenuItem \li \l QStyleOptionMenuItem \endtable @@ -1712,7 +1668,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_TabBar_SelectMouseType Which type of mouse event should cause a tab to be selected. - \value SH_Q3ListViewExpand_SelectMouseType Which type of mouse event should + \value SH_ListViewExpand_SelectMouseType Which type of mouse event should cause a list view expansion to be selected. \value SH_TabBar_PreferNoArrows Whether a tab bar should suggest a size diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 42bd8763d2..aebfea3620 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -136,12 +136,6 @@ public: enum PrimitiveElement { - PE_Q3CheckListController, - PE_Q3CheckListExclusiveIndicator, - PE_Q3CheckListIndicator, - PE_Q3DockWindowSeparator, - PE_Q3Separator, - PE_Frame, PE_FrameDefaultButton, PE_FrameDockWidget, @@ -243,7 +237,6 @@ public: CE_HeaderSection, CE_HeaderLabel, - CE_Q3DockWindowEmptyArea, CE_ToolBoxTab, CE_SizeGrip, CE_Splitter, @@ -297,23 +290,10 @@ public: SE_SliderFocusRect, - SE_Q3DockWindowHandleRect, - SE_ProgressBarGroove, SE_ProgressBarContents, SE_ProgressBarLabel, - // ### Qt 6: These values are unused; eliminate them - SE_DialogButtonAccept, - SE_DialogButtonReject, - SE_DialogButtonApply, - SE_DialogButtonHelp, - SE_DialogButtonAll, - SE_DialogButtonAbort, - SE_DialogButtonIgnore, - SE_DialogButtonRetry, - SE_DialogButtonCustom, - SE_ToolBoxTabContents, SE_HeaderLabel, @@ -383,7 +363,6 @@ public: CC_Slider, CC_ToolButton, CC_TitleBar, - CC_Q3ListView, CC_Dial, CC_GroupBox, CC_MdiControls, @@ -431,10 +410,6 @@ public: SC_TitleBarContextHelpButton = 0x00000080, SC_TitleBarLabel = 0x00000100, - SC_Q3ListView = 0x00000001, - SC_Q3ListViewBranch = 0x00000002, - SC_Q3ListViewExpand = 0x00000004, - SC_DialGroove = 0x00000001, SC_DialHandle = 0x00000002, SC_DialTickmarks = 0x00000004, @@ -514,8 +489,6 @@ public: PM_IndicatorHeight, PM_ExclusiveIndicatorWidth, PM_ExclusiveIndicatorHeight, - PM_CheckListButtonSize, - PM_CheckListControllerSize, PM_DialogButtonsSeparator, PM_DialogButtonsButtonWidth, @@ -596,7 +569,6 @@ public: CT_ToolButton, CT_ComboBox, CT_Splitter, - CT_Q3DockWindow, CT_ProgressBar, CT_MenuItem, CT_MenuBarItem, @@ -605,7 +577,6 @@ public: CT_TabBarTab, CT_Slider, CT_ScrollBar, - CT_Q3Header, CT_LineEdit, CT_SpinBox, CT_SizeGrip, @@ -669,7 +640,7 @@ public: SH_ToolBox_SelectedPageTitleBold, SH_TabBar_PreferNoArrows, SH_ScrollBar_LeftClickAbsolutePosition, - SH_Q3ListViewExpand_SelectMouseType, + SH_ListViewExpand_SelectMouseType, SH_UnderlineShortcut, SH_SpinBox_AnimateButton, SH_SpinBox_KeyPressAutoRepeatRate, diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index d72ba1bac5..0b0c6e2393 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -136,12 +136,6 @@ QT_BEGIN_NAMESPACE \value SO_ComplexCustomBase Reserved for custom QStyleOptions; all custom complex controls values must be above this value - Some style options are defined for various Qt3Support controls: - - \value SO_Q3DockWindow \l QStyleOptionQ3DockWindow - \value SO_Q3ListView \l QStyleOptionQ3ListView - \value SO_Q3ListViewItem \l QStyleOptionQ3ListViewItem - \sa type */ @@ -2233,382 +2227,6 @@ QStyleOptionSpinBox::QStyleOptionSpinBox(int version) #endif // QT_NO_SPINBOX /*! - \class QStyleOptionQ3ListViewItem - \brief The QStyleOptionQ3ListViewItem class is used to describe an - item drawn in a Q3ListView. - - \inmodule QtWidgets - - This class is used for drawing the compatibility Q3ListView's - items. \b {It is not recommended for new classes}. - - QStyleOptionQ3ListViewItem contains all the information that - QStyle functions need to draw the Q3ListView items. - - For performance reasons, the access to the member variables is - direct (i.e., using the \c . or \c -> operator). This low-level feel - makes the structures straightforward to use and emphasizes that - these are simply parameters used by the style functions. - - For an example demonstrating how style options can be used, see - the \l {widgets/styles}{Styles} example. - - \sa QStyleOption, QStyleOptionQ3ListView, Q3ListViewItem -*/ - -/*! - \enum QStyleOptionQ3ListViewItem::Q3ListViewItemFeature - - This enum describes the features a list view item can have. - - \value None A standard item. - \value Expandable The item has children that can be shown. - \value MultiLine The item is more than one line tall. - \value Visible The item is visible. - \value ParentControl The item's parent is a type of item control (Q3CheckListItem::Controller). - - \sa features, Q3ListViewItem::isVisible(), Q3ListViewItem::multiLinesEnabled(), - Q3ListViewItem::isExpandable() -*/ - -/*! - Constructs a QStyleOptionQ3ListViewItem, initializing the members - variables to their default values. -*/ - -QStyleOptionQ3ListViewItem::QStyleOptionQ3ListViewItem() - : QStyleOption(Version, SO_Q3ListViewItem), features(None), height(0), totalHeight(0), - itemY(0), childCount(0) -{ -} - -/*! - \internal -*/ -QStyleOptionQ3ListViewItem::QStyleOptionQ3ListViewItem(int version) - : QStyleOption(version, SO_Q3ListViewItem), features(None), height(0), totalHeight(0), - itemY(0), childCount(0) -{ -} - -/*! - \fn QStyleOptionQ3ListViewItem::QStyleOptionQ3ListViewItem(const QStyleOptionQ3ListViewItem &other) - - Constructs a copy of the \a other style option. -*/ - -/*! - \enum QStyleOptionQ3ListViewItem::StyleOptionType - - This enum is used to hold information about the type of the style option, and - is defined for each QStyleOption subclass. - - \value Type The type of style option provided (\l{SO_Q3ListViewItem} for this class). - - The type is used internally by QStyleOption, its subclasses, and - qstyleoption_cast() to determine the type of style option. In - general you do not need to worry about this unless you want to - create your own QStyleOption subclass and your own styles. - - \sa StyleOptionVersion -*/ - -/*! - \enum QStyleOptionQ3ListViewItem::StyleOptionVersion - - This enum is used to hold information about the version of the style option, and - is defined for each QStyleOption subclass. - - \value Version 1 - - The version is used by QStyleOption subclasses to implement - extensions without breaking compatibility. If you use - qstyleoption_cast(), you normally do not need to check it. - - \sa StyleOptionType -*/ - -/*! - \variable QStyleOptionQ3ListViewItem::features - \brief the features for this item - - This variable is a bitwise OR of the features of the item. The deafult value is \l None. - - \sa Q3ListViewItemFeature -*/ - -/*! - \variable QStyleOptionQ3ListViewItem::height - \brief the height of the item - - This doesn't include the height of the item's children. The default height is 0. - - \sa Q3ListViewItem::height() -*/ - -/*! - \variable QStyleOptionQ3ListViewItem::totalHeight - \brief the total height of the item, including its children - - The default total height is 0. - - \sa Q3ListViewItem::totalHeight() -*/ - -/*! - \variable QStyleOptionQ3ListViewItem::itemY - \brief the Y-coordinate for the item - - The default value is 0. - - \sa Q3ListViewItem::itemPos() -*/ - -/*! - \variable QStyleOptionQ3ListViewItem::childCount - \brief the number of children the item has -*/ - -/*! - \class QStyleOptionQ3ListView - \brief The QStyleOptionQ3ListView class is used to describe the - parameters for drawing a Q3ListView. - - \inmodule QtWidgets - - This class is used for drawing the compatibility Q3ListView. \b - {It is not recommended for new classes}. - - QStyleOptionQ3ListView contains all the information that QStyle - functions need to draw Q3ListView. - - For performance reasons, the access to the member variables is - direct (i.e., using the \c . or \c -> operator). This low-level feel - makes the structures straightforward to use and emphasizes that - these are simply parameters used by the style functions. - - For an example demonstrating how style options can be used, see - the \l {widgets/styles}{Styles} example. - - \sa QStyleOptionComplex, Q3ListView, QStyleOptionQ3ListViewItem -*/ - -/*! - Creates a QStyleOptionQ3ListView, initializing the members - variables to their default values. -*/ - -QStyleOptionQ3ListView::QStyleOptionQ3ListView() - : QStyleOptionComplex(Version, SO_Q3ListView), viewportBGRole(QPalette::Base), - sortColumn(0), itemMargin(0), treeStepSize(0), rootIsDecorated(false) -{ -} - -/*! - \internal -*/ -QStyleOptionQ3ListView::QStyleOptionQ3ListView(int version) - : QStyleOptionComplex(version, SO_Q3ListView), viewportBGRole(QPalette::Base), - sortColumn(0), itemMargin(0), treeStepSize(0), rootIsDecorated(false) -{ -} - -/*! - \fn QStyleOptionQ3ListView::QStyleOptionQ3ListView(const QStyleOptionQ3ListView &other) - - Constructs a copy of the \a other style option. -*/ - -/*! - \enum QStyleOptionQ3ListView::StyleOptionType - - This enum is used to hold information about the type of the style option, and - is defined for each QStyleOption subclass. - - \value Type The type of style option provided (\l{SO_Q3ListView} for this class). - - The type is used internally by QStyleOption, its subclasses, and - qstyleoption_cast() to determine the type of style option. In - general you do not need to worry about this unless you want to - create your own QStyleOption subclass and your own styles. - - \sa StyleOptionVersion -*/ - -/*! - \enum QStyleOptionQ3ListView::StyleOptionVersion - - This enum is used to hold information about the version of the style option, and - is defined for each QStyleOption subclass. - - \value Version 1 - - The version is used by QStyleOption subclasses to implement - extensions without breaking compatibility. If you use - qstyleoption_cast(), you normally do not need to check it. - - \sa StyleOptionType -*/ - -/*! - \variable QStyleOptionQ3ListView::items - \brief a list of items in the Q3ListView - - This is a list of \l {QStyleOptionQ3ListViewItem}s. The first item - can be used for most of the calculation that are needed for - drawing a list view. Any additional items are the children of - this first item, which may be used for additional information. - - \sa QStyleOptionQ3ListViewItem -*/ - -/*! - \variable QStyleOptionQ3ListView::viewportPalette - \brief the palette of Q3ListView's viewport - - By default, the application's default palette is used. -*/ - -/*! - \variable QStyleOptionQ3ListView::viewportBGRole - \brief the background role of Q3ListView's viewport - - The default value is QPalette::Base. - - \sa QWidget::backgroundRole() -*/ - -/*! - \variable QStyleOptionQ3ListView::sortColumn - \brief the sort column of the list view - - The default value is 0. - - \sa Q3ListView::sortColumn() -*/ - -/*! - \variable QStyleOptionQ3ListView::itemMargin - \brief the margin for items in the list view - - The default value is 0. - - \sa Q3ListView::itemMargin() -*/ - -/*! - \variable QStyleOptionQ3ListView::treeStepSize - \brief the number of pixel to offset children items from their - parents - - The default value is 0. - - \sa Q3ListView::treeStepSize() -*/ - -/*! - \variable QStyleOptionQ3ListView::rootIsDecorated - \brief whether root items are decorated - - The default value is false. - - \sa Q3ListView::rootIsDecorated() -*/ - -/*! - \class QStyleOptionQ3DockWindow - \brief The QStyleOptionQ3DockWindow class is used to describe the - parameters for drawing various parts of a Q3DockWindow. - - \inmodule QtWidgets - - This class is used for drawing the old Q3DockWindow and its - parts. \b {It is not recommended for new classes}. - - QStyleOptionQ3DockWindow contains all the information that QStyle - functions need to draw Q3DockWindow and its parts. - - For performance reasons, the access to the member variables is - direct (i.e., using the \c . or \c -> operator). This low-level feel - makes the structures straightforward to use and emphasizes that - these are simply parameters used by the style functions. - - For an example demonstrating how style options can be used, see - the \l {widgets/styles}{Styles} example. - - \sa QStyleOption, Q3DockWindow -*/ - -/*! - Constructs a QStyleOptionQ3DockWindow, initializing the member - variables to their default values. -*/ - -QStyleOptionQ3DockWindow::QStyleOptionQ3DockWindow() - : QStyleOption(Version, SO_Q3DockWindow), docked(false), closeEnabled(false) -{ -} - -/*! - \internal -*/ -QStyleOptionQ3DockWindow::QStyleOptionQ3DockWindow(int version) - : QStyleOption(version, SO_Q3DockWindow), docked(false), closeEnabled(false) -{ -} - -/*! - \fn QStyleOptionQ3DockWindow::QStyleOptionQ3DockWindow(const QStyleOptionQ3DockWindow &other) - - Constructs a copy of the \a other style option. -*/ - -/*! - \enum QStyleOptionQ3DockWindow::StyleOptionType - - This enum is used to hold information about the type of the style option, and - is defined for each QStyleOption subclass. - - \value Type The type of style option provided (\l{SO_Q3DockWindow} for this class). - - The type is used internally by QStyleOption, its subclasses, and - qstyleoption_cast() to determine the type of style option. In - general you do not need to worry about this unless you want to - create your own QStyleOption subclass and your own styles. - - \sa StyleOptionVersion -*/ - -/*! - \enum QStyleOptionQ3DockWindow::StyleOptionVersion - - This enum is used to hold information about the version of the style option, and - is defined for each QStyleOption subclass. - - \value Version 1 - - The version is used by QStyleOption subclasses to implement - extensions without breaking compatibility. If you use - qstyleoption_cast(), you normally do not need to check it. - - \sa StyleOptionType -*/ - -/*! - \variable QStyleOptionQ3DockWindow::docked - \brief whether the dock window is currently docked - - The default value is false. -*/ - -/*! - \variable QStyleOptionQ3DockWindow::closeEnabled - \brief whether the dock window has a close button - - The default value is false. -*/ - -/*! \class QStyleOptionDockWidget \brief The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget. @@ -4376,12 +3994,8 @@ QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) debug << "SO_ToolBox"; break; case QStyleOption::SO_Header: debug << "SO_Header"; break; - case QStyleOption::SO_Q3DockWindow: - debug << "SO_Q3DockWindow"; break; case QStyleOption::SO_DockWidget: debug << "SO_DockWidget"; break; - case QStyleOption::SO_Q3ListViewItem: - debug << "SO_Q3ListViewItem"; break; case QStyleOption::SO_ViewItem: debug << "SO_ViewItem"; break; case QStyleOption::SO_TabWidgetFrame: @@ -4400,8 +4014,6 @@ QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) debug << "SO_ToolButton"; break; case QStyleOption::SO_ComboBox: debug << "SO_ComboBox"; break; - case QStyleOption::SO_Q3ListView: - debug << "SO_Q3ListView"; break; case QStyleOption::SO_TitleBar: debug << "SO_TitleBar"; break; case QStyleOption::SO_CustomBase: diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 677a48ec20..588898637f 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -68,12 +68,12 @@ class Q_WIDGETS_EXPORT QStyleOption public: enum OptionType { SO_Default, SO_FocusRect, SO_Button, SO_Tab, SO_MenuItem, - SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header, SO_Q3DockWindow, - SO_DockWidget, SO_Q3ListViewItem, SO_ViewItem, SO_TabWidgetFrame, + SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header, + SO_DockWidget, SO_ViewItem, SO_TabWidgetFrame, SO_TabBarBase, SO_RubberBand, SO_ToolBar, SO_GraphicsItem, SO_Complex = 0xf0000, SO_Slider, SO_SpinBox, SO_ToolButton, SO_ComboBox, - SO_Q3ListView, SO_TitleBar, SO_GroupBox, SO_SizeGrip, + SO_TitleBar, SO_GroupBox, SO_SizeGrip, SO_CustomBase = 0xf00, SO_ComplexCustomBase = 0xf000000 @@ -363,47 +363,6 @@ protected: QStyleOptionMenuItem(int version); }; -class Q_WIDGETS_EXPORT QStyleOptionQ3ListViewItem : public QStyleOption -{ -public: - enum StyleOptionType { Type = SO_Q3ListViewItem }; - enum StyleOptionVersion { Version = 1 }; - - enum Q3ListViewItemFeature { None = 0x00, Expandable = 0x01, MultiLine = 0x02, Visible = 0x04, - ParentControl = 0x08 }; - Q_DECLARE_FLAGS(Q3ListViewItemFeatures, Q3ListViewItemFeature) - - Q3ListViewItemFeatures features; - int height; - int totalHeight; - int itemY; - int childCount; - - QStyleOptionQ3ListViewItem(); - QStyleOptionQ3ListViewItem(const QStyleOptionQ3ListViewItem &other) : QStyleOption(Version, Type) { *this = other; } - -protected: - QStyleOptionQ3ListViewItem(int version); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionQ3ListViewItem::Q3ListViewItemFeatures) - -class Q_WIDGETS_EXPORT QStyleOptionQ3DockWindow : public QStyleOption -{ -public: - enum StyleOptionType { Type = SO_Q3DockWindow }; - enum StyleOptionVersion { Version = 1 }; - - bool docked; - bool closeEnabled; - - QStyleOptionQ3DockWindow(); - QStyleOptionQ3DockWindow(const QStyleOptionQ3DockWindow &other) : QStyleOption(Version, Type) { *this = other; } - -protected: - QStyleOptionQ3DockWindow(int version); -}; - class Q_WIDGETS_EXPORT QStyleOptionDockWidget : public QStyleOption { public: @@ -585,27 +544,6 @@ protected: }; #endif // QT_NO_SPINBOX -class Q_WIDGETS_EXPORT QStyleOptionQ3ListView : public QStyleOptionComplex -{ -public: - enum StyleOptionType { Type = SO_Q3ListView }; - enum StyleOptionVersion { Version = 1 }; - - QList<QStyleOptionQ3ListViewItem> items; - QPalette viewportPalette; - QPalette::ColorRole viewportBGRole; - int sortColumn; - int itemMargin; - int treeStepSize; - bool rootIsDecorated; - - QStyleOptionQ3ListView(); - QStyleOptionQ3ListView(const QStyleOptionQ3ListView &other) : QStyleOptionComplex(Version, Type) { *this = other; } - -protected: - QStyleOptionQ3ListView(int version); -}; - class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex { public: diff --git a/src/widgets/styles/qwindowscestyle.cpp b/src/widgets/styles/qwindowscestyle.cpp index 5bd2de290a..49d4e74aaf 100644 --- a/src/widgets/styles/qwindowscestyle.cpp +++ b/src/widgets/styles/qwindowscestyle.cpp @@ -264,14 +264,13 @@ void QWindowsCEStyle::drawPrimitive(PrimitiveElement element, const QStyleOption option->rect.x() + 1, option->rect.y() + option->rect.height() - 1); //fall through... } - case PE_IndicatorViewItemCheck: - case PE_Q3CheckListIndicator: { + case PE_IndicatorViewItemCheck: { if (!doRestore) { painter->save(); doRestore = true; } int arrowSize= 2; - if (element == PE_Q3CheckListIndicator || element == PE_IndicatorViewItemCheck) { + if (element == PE_IndicatorViewItemCheck) { QLinearGradient linearGradient(QPoint(option->rect.x(),option->rect.y()), QPoint(option->rect.x()+option->rect.width(), option->rect.y()+option->rect.height())); linearGradient.setColorAt(0, windowsCECheckBoxGradientColorBegin); diff --git a/src/widgets/styles/qwindowsmobilestyle.cpp b/src/widgets/styles/qwindowsmobilestyle.cpp index 30269751ca..863bd1aa62 100644 --- a/src/widgets/styles/qwindowsmobilestyle.cpp +++ b/src/widgets/styles/qwindowsmobilestyle.cpp @@ -4875,13 +4875,12 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp } //fall through... } - case PE_IndicatorViewItemCheck: - case PE_Q3CheckListIndicator: { + case PE_IndicatorViewItemCheck: { if (!doRestore) { painter->save(); doRestore = true; } - if (element == PE_Q3CheckListIndicator || element == PE_IndicatorViewItemCheck) { + if (element == PE_IndicatorViewItemCheck) { painter->setPen(option->palette.shadow().color()); if (option->state & State_NoChange) painter->setBrush(option->palette.brush(QPalette::Button)); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 1cd53c8073..97721da297 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1461,12 +1461,11 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->setPen(opt->palette.text().color()); } // Fall through! case PE_IndicatorViewItemCheck: - case PE_Q3CheckListIndicator: if (!doRestore) { p->save(); doRestore = true; } - if (pe == PE_Q3CheckListIndicator || pe == PE_IndicatorViewItemCheck) { + if (pe == PE_IndicatorViewItemCheck) { const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt); p->setPen(itemViewOpt && itemViewOpt->showDecorationSelected diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 67895980b2..801c7f7e5c 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1208,9 +1208,9 @@ void QWindowsXPStyle::polish(QWidget *widget) || qobject_cast<QAbstractSpinBox*>(widget) || qobject_cast<QSpinBox*>(widget) #endif // QT_NO_SPINBOX - || widget->inherits("QWorkspaceChild") - || widget->inherits("Q3TitleBar")) + ) { widget->setAttribute(Qt::WA_Hover); + } #ifndef QT_NO_RUBBERBAND if (qobject_cast<QRubberBand*>(widget)) { @@ -1280,9 +1280,9 @@ void QWindowsXPStyle::unpolish(QWidget *widget) || qobject_cast<QAbstractSpinBox*>(widget) || qobject_cast<QSpinBox*>(widget) #endif // QT_NO_SPINBOX - || widget->inherits("QWorkspaceChild") - || widget->inherits("Q3TitleBar")) + ) { widget->setAttribute(Qt::WA_Hover, false); + } QWindowsStyle::unpolish(widget); } @@ -1852,14 +1852,6 @@ case PE_Frame: } break; - case PE_Q3DockWindowSeparator: - themeNumber = QWindowsXPStylePrivate::ToolBarTheme; - if (flags & State_Horizontal) - partId = TP_SEPARATOR; - else - partId = TP_SEPARATORVERT; - break; - case PE_FrameWindow: if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(option)) { @@ -3268,63 +3260,6 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } break; -#ifndef QT_NO_WORKSPACE - case CC_MdiControls: - { - QRect buttonRect; - XPThemeData theme(widget, p, QWindowsXPStylePrivate::WindowTheme, WP_MDICLOSEBUTTON, CBS_NORMAL); - - if (option->subControls & SC_MdiCloseButton) { - buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget); - if (theme.isValid()) { - theme.partId = WP_MDICLOSEBUTTON; - theme.rect = buttonRect; - if (!(flags & State_Enabled)) - theme.stateId = CBS_INACTIVE; - else if (flags & State_Sunken && (option->activeSubControls & SC_MdiCloseButton)) - theme.stateId = CBS_PUSHED; - else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiCloseButton)) - theme.stateId = CBS_HOT; - else - theme.stateId = CBS_NORMAL; - d->drawBackground(theme); - } - } - if (option->subControls & SC_MdiNormalButton) { - buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget); - if (theme.isValid()) { - theme.partId = WP_MDIRESTOREBUTTON; - theme.rect = buttonRect; - if (!(flags & State_Enabled)) - theme.stateId = CBS_INACTIVE; - else if (flags & State_Sunken && (option->activeSubControls & SC_MdiNormalButton)) - theme.stateId = CBS_PUSHED; - else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiNormalButton)) - theme.stateId = CBS_HOT; - else - theme.stateId = CBS_NORMAL; - d->drawBackground(theme); - } - } - if (option->subControls & QStyle::SC_MdiMinButton) { - buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget); - if (theme.isValid()) { - theme.partId = WP_MDIMINBUTTON; - theme.rect = buttonRect; - if (!(flags & State_Enabled)) - theme.stateId = CBS_INACTIVE; - else if (flags & State_Sunken && (option->activeSubControls & SC_MdiMinButton)) - theme.stateId = CBS_PUSHED; - else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiMinButton)) - theme.stateId = CBS_HOT; - else - theme.stateId = CBS_NORMAL; - d->drawBackground(theme); - } - } - } - break; -#endif //QT_NO_WORKSPACE #ifndef QT_NO_DIAL case CC_Dial: if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) @@ -3712,44 +3647,6 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl } } break; -#ifndef QT_NO_WORKSPACE - case CC_MdiControls: - { - int numSubControls = 0; - if (option->subControls & SC_MdiCloseButton) - ++numSubControls; - if (option->subControls & SC_MdiMinButton) - ++numSubControls; - if (option->subControls & SC_MdiNormalButton) - ++numSubControls; - if (numSubControls == 0) - break; - - int buttonWidth = option->rect.width()/ numSubControls; - int offset = 0; - switch (subControl) { - case SC_MdiCloseButton: - // Only one sub control, no offset needed. - if (numSubControls == 1) - break; - offset += buttonWidth; - //FALL THROUGH - case SC_MdiNormalButton: - // No offset needed if - // 1) There's only one sub control - // 2) We have a close button and a normal button (offset already added in SC_MdiClose) - if (numSubControls == 1 || (numSubControls == 2 && !(option->subControls & SC_MdiMinButton))) - break; - if (option->subControls & SC_MdiNormalButton) - offset += buttonWidth; - break; - default: - break; - } - rect = QRect(offset, 0, buttonWidth, option->rect.height()); - break; - } -#endif // QT_NO_WORKSPACE default: rect = visualRect(option->direction, option->rect, diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index 596e8a994a..a8be439695 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -51,8 +51,6 @@ testcocoon { load(testcocoon) } -DEFINES += Q_INTERNAL_QAPP_SRC - INCLUDEPATH += ../3rdparty/harfbuzz/src win32:!contains(QT_CONFIG, directwrite) { diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index a960ce8d9c..dc96321599 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1489,6 +1489,16 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport) Q_UNUSED(viewport); } +/*! + \internal + + This method is reserved for future use. +*/ +QSize QAbstractScrollArea::viewportSizeHint() const +{ + return QSize(); +} + QT_END_NAMESPACE #include "moc_qabstractscrollarea.cpp" diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index f155f52920..2f1168a4f1 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -122,6 +122,8 @@ protected: virtual void scrollContentsBy(int dx, int dy); + virtual QSize viewportSizeHint() const; + private: Q_DECLARE_PRIVATE(QAbstractScrollArea) Q_DISABLE_COPY(QAbstractScrollArea) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 3d0996a9f5..5e808c1ab5 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1549,6 +1549,7 @@ void QDateTimeEdit::mousePressEvent(QMouseEvent *event) QTimeEdit::QTimeEdit(QWidget *parent) : QDateTimeEdit(QDATETIMEEDIT_TIME_MIN, QVariant::Time, parent) { + connect(this, SIGNAL(timeChanged(QTime)), SIGNAL(userTimeChanged(QTime))); } /*! @@ -1561,6 +1562,15 @@ QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent) { } +/*! + \fn void QTimeEdit::userTimeChanged(const QTime &time) + + This signal only exists to fully implement the time Q_PROPERTY on the class. + Normally timeChanged should be used instead. + + \internal +*/ + /*! \class QDateEdit @@ -1603,6 +1613,7 @@ QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent) QDateEdit::QDateEdit(QWidget *parent) : QDateTimeEdit(QDATETIMEEDIT_DATE_INITIAL, QVariant::Date, parent) { + connect(this, SIGNAL(dateChanged(QDate)), SIGNAL(userDateChanged(QDate))); } /*! @@ -1615,6 +1626,15 @@ QDateEdit::QDateEdit(const QDate &date, QWidget *parent) { } +/*! + \fn void QDateEdit::userDateChanged(const QDate &date) + + This signal only exists to fully implement the date Q_PROPERTY on the class. + Normally dateChanged should be used instead. + + \internal +*/ + // --- QDateTimeEditPrivate --- diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h index 9a57175716..07fc2b04fb 100644 --- a/src/widgets/widgets/qdatetimeedit.h +++ b/src/widgets/widgets/qdatetimeedit.h @@ -168,8 +168,8 @@ public: bool event(QEvent *event); Q_SIGNALS: - void dateTimeChanged(const QDateTime &date); - void timeChanged(const QTime &date); + void dateTimeChanged(const QDateTime &dateTime); + void timeChanged(const QTime &time); void dateChanged(const QDate &date); public Q_SLOTS: @@ -205,17 +205,25 @@ private: class Q_WIDGETS_EXPORT QTimeEdit : public QDateTimeEdit { Q_OBJECT + Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY userTimeChanged USER true) public: QTimeEdit(QWidget *parent = 0); QTimeEdit(const QTime &time, QWidget *parent = 0); + +Q_SIGNALS: + void userTimeChanged(const QTime &time); }; class Q_WIDGETS_EXPORT QDateEdit : public QDateTimeEdit { Q_OBJECT + Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY userDateChanged USER true) public: QDateEdit(QWidget *parent = 0); QDateEdit(const QDate &date, QWidget *parent = 0); + +Q_SIGNALS: + void userDateChanged(const QDate &date); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 36fba72963..eb483ac0fe 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -357,7 +357,7 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c if (qobject_cast<QMacStyle *>(widgets.at(0)->style())) titleBarHeight -= 4; #endif - const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar")); + const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1); const int n = widgets.size(); diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 9f17d2e63c..e98df595d1 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -190,7 +190,6 @@ private: friend class QMenuBar; friend class QMenuBarPrivate; friend class QTornOffMenu; - friend class Q3PopupMenu; friend class QComboBox; friend class QAction; friend class QToolButtonPrivate; diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index 9617d6de58..5406f5dcf5 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -49,54 +49,12 @@ QT_BEGIN_NAMESPACE -/** - QStackedLayout does not support height for width (simply because it does not reimplement - heightForWidth() and hasHeightForWidth()). That is not possible to fix without breaking - binary compatibility. (QLayout is subject to multiple inheritance). - However, we can fix QStackedWidget by simply using a modified version of QStackedLayout - that reimplements the hfw-related functions: - */ -class QStackedLayoutHFW : public QStackedLayout -{ -public: - QStackedLayoutHFW(QWidget *parent = 0) : QStackedLayout(parent) {} - bool hasHeightForWidth() const; - int heightForWidth(int width) const; -}; - -bool QStackedLayoutHFW::hasHeightForWidth() const -{ - const int n = count(); - - for (int i = 0; i < n; ++i) { - if (QLayoutItem *item = itemAt(i)) { - if (item->hasHeightForWidth()) - return true; - } - } - return false; -} - -int QStackedLayoutHFW::heightForWidth(int width) const -{ - const int n = count(); - - int hfw = 0; - for (int i = 0; i < n; ++i) { - if (QLayoutItem *item = itemAt(i)) { - hfw = qMax(hfw, item->heightForWidth(width)); - } - } - return hfw; -} - - class QStackedWidgetPrivate : public QFramePrivate { Q_DECLARE_PUBLIC(QStackedWidget) public: QStackedWidgetPrivate():layout(0){} - QStackedLayoutHFW *layout; + QStackedLayout *layout; bool blockChildAdd; }; @@ -180,7 +138,7 @@ QStackedWidget::QStackedWidget(QWidget *parent) : QFrame(*new QStackedWidgetPrivate, parent) { Q_D(QStackedWidget); - d->layout = new QStackedLayoutHFW(this); + d->layout = new QStackedLayout(this); connect(d->layout, SIGNAL(widgetRemoved(int)), this, SIGNAL(widgetRemoved(int))); connect(d->layout, SIGNAL(currentChanged(int)), this, SIGNAL(currentChanged(int))); } diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index f4d289241a..7b5b3b6559 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -429,7 +429,7 @@ void QTabBarPrivate::layoutTabs() tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height()); x += sz.width(); maxHeight = qMax(maxHeight, sz.height()); - sz = minimumTabSizeHint(i); + sz = q->minimumTabSizeHint(i); tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height()); minx += sz.width(); tabChain[tabChainIndex].init(); @@ -454,7 +454,7 @@ void QTabBarPrivate::layoutTabs() tabList[i].maxRect = QRect(0, y, sz.width(), sz.height()); y += sz.height(); maxWidth = qMax(maxWidth, sz.width()); - sz = minimumTabSizeHint(i); + sz = q->minimumTabSizeHint(i); tabList[i].minRect = QRect(0, miny, sz.width(), sz.height()); miny += sz.height(); tabChain[tabChainIndex].init(); @@ -1296,13 +1296,18 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text) return ret; } -QSize QTabBarPrivate::minimumTabSizeHint(int index) +/*! + Returns the minimum tab size hint for the tab at position \a index. + \since Qt 5.0 +*/ + +QSize QTabBar::minimumTabSizeHint(int index) const { - Q_Q(QTabBar); - Tab &tab = tabList[index]; + Q_D(const QTabBar); + QTabBarPrivate::Tab &tab = const_cast<QTabBarPrivate::Tab&>(d->tabList[index]); QString oldText = tab.text; - tab.text = computeElidedText(elideMode, oldText); - QSize size = q->tabSizeHint(index); + tab.text = computeElidedText(d->elideMode, oldText); + QSize size = tabSizeHint(index); tab.text = oldText; return size; } diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index 85586f5e57..2698213d07 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -178,6 +178,7 @@ Q_SIGNALS: protected: virtual QSize tabSizeHint(int index) const; + virtual QSize minimumTabSizeHint(int index) const; virtual void tabInserted(int index); virtual void tabRemoved(int index); virtual void tabLayoutChange(); diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index c907b48eeb..aa9db38677 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -165,8 +165,6 @@ public: inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } void setCurrentNextEnabledIndex(int offset); - QSize minimumTabSizeHint(int index); - QToolButton* rightB; // right or bottom QToolButton* leftB; // left or top diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h index 26d9243eb9..4e8d4d4583 100644 --- a/src/widgets/widgets/qtabwidget.h +++ b/src/widgets/widgets/qtabwidget.h @@ -175,7 +175,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int)) Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int)) void setUpLayout(bool = false); - friend class Q3TabDialog; }; #endif // QT_NO_TABWIDGET diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 050730ec2a..261b96f8af 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -139,7 +139,7 @@ public: // re-imlemented from QTextEditPrivate virtual QUrl resolveUrl(const QUrl &url) const; inline QUrl resolveUrl(const QString &url) const - { return resolveUrl(QUrl::fromEncoded(url.toUtf8())); } + { return resolveUrl(QUrl(url)); } #ifdef QT_KEYPAD_NAVIGATION void keypadMove(bool next); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 86b87b3998..217fda61dc 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -2453,7 +2453,7 @@ void QTextEdit::setText(const QString &text) if (d->textFormat == Qt::AutoText) format = Qt::mightBeRichText(text) ? Qt::RichText : Qt::PlainText; #ifndef QT_NO_TEXTHTMLPARSER - if (format == Qt::RichText || format == Qt::LogText) + if (format == Qt::RichText) setHtml(text); else #endif diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index 5380fb798c..0847263645 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -336,7 +336,7 @@ void QWidgetResizeHandler::setMouseCursor(MousePosition m) QObjectList children = widget->children(); for (int i = 0; i < children.size(); ++i) { if (QWidget *w = qobject_cast<QWidget*>(children.at(i))) { - if (!w->testAttribute(Qt::WA_SetCursor) && !w->inherits("QWorkspaceTitleBar")) { + if (!w->testAttribute(Qt::WA_SetCursor)) { w->setCursor(Qt::ArrowCursor); } } diff --git a/src/widgets/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp deleted file mode 100644 index 36c589be1c..0000000000 --- a/src/widgets/widgets/qworkspace.cpp +++ /dev/null @@ -1,3341 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qworkspace.h" -#ifndef QT_NO_WORKSPACE -#include "qapplication.h" -#include "qbitmap.h" -#include "qcursor.h" -#include "qdesktopwidget.h" -#include "qevent.h" -#include "qhash.h" -#include "qicon.h" -#include "qimage.h" -#include "qlabel.h" -#include "qlayout.h" -#include "qmenubar.h" -#include "qmenu.h" -#include "qpainter.h" -#include "qpointer.h" -#include "qscrollbar.h" -#include "qstyle.h" -#include "qstyleoption.h" -#include "qelapsedtimer.h" -#include "qtooltip.h" -#include "qdebug.h" -#include <private/qwidget_p.h> -#include <private/qwidgetresizehandler_p.h> -#include <private/qlayoutengine_p.h> - -QT_BEGIN_NAMESPACE - -class QWorkspaceTitleBarPrivate; - - -/************************************************************** -* QMDIControl -* -* Used for displaying MDI controls in a maximized MDI window -* -*/ -class QMDIControl : public QWidget -{ - Q_OBJECT -signals: - void _q_minimize(); - void _q_restore(); - void _q_close(); - -public: - QMDIControl(QWidget *widget); - -private: - QSize sizeHint() const; - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void leaveEvent(QEvent *event); - bool event(QEvent *event); - void initStyleOption(QStyleOptionComplex *option) const; - QStyle::SubControl activeControl; //control locked by pressing and holding the mouse - QStyle::SubControl hoverControl; //previously active hover control, used for tracking repaints -}; - -bool QMDIControl::event(QEvent *event) -{ - if (event->type() == QEvent::ToolTip) { - QStyleOptionComplex opt; - initStyleOption(&opt); -#ifndef QT_NO_TOOLTIP - QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); - QStyle::SubControl ctrl = style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, - helpEvent->pos(), this); - if (ctrl == QStyle::SC_MdiCloseButton) - QToolTip::showText(helpEvent->globalPos(), QWorkspace::tr("Close"), this); - else if (ctrl == QStyle::SC_MdiMinButton) - QToolTip::showText(helpEvent->globalPos(), QWorkspace::tr("Minimize"), this); - else if (ctrl == QStyle::SC_MdiNormalButton) - QToolTip::showText(helpEvent->globalPos(), QWorkspace::tr("Restore Down"), this); - else - QToolTip::hideText(); -#endif // QT_NO_TOOLTIP - } - return QWidget::event(event); -} - -void QMDIControl::initStyleOption(QStyleOptionComplex *option) const -{ - option->initFrom(this); - option->subControls = QStyle::SC_All; - option->activeSubControls = QStyle::SC_None; -} - -QMDIControl::QMDIControl(QWidget *widget) - : QWidget(widget), activeControl(QStyle::SC_None), - hoverControl(QStyle::SC_None) -{ - setObjectName(QLatin1String("qt_maxcontrols")); - setFocusPolicy(Qt::NoFocus); - setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - setMouseTracking(true); -} - -QSize QMDIControl::sizeHint() const -{ - ensurePolished(); - QStyleOptionComplex opt; - initStyleOption(&opt); - QSize size(48, 16); - return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, this); -} - -void QMDIControl::mousePressEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - event->ignore(); - return; - } - QStyleOptionComplex opt; - initStyleOption(&opt); - QStyle::SubControl ctrl = style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, - event->pos(), this); - activeControl = ctrl; - update(); -} - -void QMDIControl::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - event->ignore(); - return; - } - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QStyle::SubControl under_mouse = style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, - event->pos(), this); - if (under_mouse == activeControl) { - switch (activeControl) { - case QStyle::SC_MdiCloseButton: - emit _q_close(); - break; - case QStyle::SC_MdiNormalButton: - emit _q_restore(); - break; - case QStyle::SC_MdiMinButton: - emit _q_minimize(); - break; - default: - break; - } - } - activeControl = QStyle::SC_None; - update(); -} - -void QMDIControl::leaveEvent(QEvent * /*event*/) -{ - hoverControl = QStyle::SC_None; - update(); -} - -void QMDIControl::mouseMoveEvent(QMouseEvent *event) -{ - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QStyle::SubControl under_mouse = style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, - event->pos(), this); - //test if hover state changes - if (hoverControl != under_mouse) { - hoverControl = under_mouse; - update(); - } -} - -void QMDIControl::paintEvent(QPaintEvent *) -{ - QPainter p(this); - QStyleOptionComplex opt; - initStyleOption(&opt); - if (activeControl == hoverControl) { - opt.activeSubControls = activeControl; - opt.state |= QStyle::State_Sunken; - } else if (hoverControl != QStyle::SC_None && (activeControl == QStyle::SC_None)) { - opt.activeSubControls = hoverControl; - opt.state |= QStyle::State_MouseOver; - } - style()->drawComplexControl(QStyle::CC_MdiControls, &opt, &p, this); -} - -class QWorkspaceTitleBar : public QWidget -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWorkspaceTitleBar) - Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise) - Q_PROPERTY(bool movable READ isMovable WRITE setMovable) - -public: - QWorkspaceTitleBar (QWidget *w, QWidget *parent, Qt::WindowFlags f = 0); - ~QWorkspaceTitleBar(); - - bool isActive() const; - bool usesActiveColor() const; - - bool isMovable() const; - void setMovable(bool); - - bool autoRaise() const; - void setAutoRaise(bool); - - QWidget *window() const; - bool isTool() const; - - QSize sizeHint() const; - void initStyleOption(QStyleOptionTitleBar *option) const; - -public slots: - void setActive(bool); - -signals: - void doActivate(); - void doNormal(); - void doClose(); - void doMaximize(); - void doMinimize(); - void doShade(); - void showOperationMenu(); - void popupOperationMenu(const QPoint&); - void doubleClicked(); - -protected: - bool event(QEvent *); -#ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); -#endif - void mousePressEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); - void paintEvent(QPaintEvent *p); - -private: - Q_DISABLE_COPY(QWorkspaceTitleBar) -}; - - -class QWorkspaceTitleBarPrivate : public QWidgetPrivate -{ - Q_DECLARE_PUBLIC(QWorkspaceTitleBar) -public: - QWorkspaceTitleBarPrivate() - : - lastControl(QStyle::SC_None), - act(0), window(0), movable(1), pressed(0), autoraise(0), moving(0) - { - } - - Qt::WindowFlags flags; - QStyle::SubControl buttonDown; - QStyle::SubControl lastControl; - QPoint moveOffset; - bool act :1; - QPointer<QWidget> window; - bool movable :1; - bool pressed :1; - bool autoraise :1; - bool moving : 1; - - int titleBarState() const; - void readColors(); -}; - -inline int QWorkspaceTitleBarPrivate::titleBarState() const -{ - Q_Q(const QWorkspaceTitleBar); - uint state = window ? window->windowState() : static_cast<Qt::WindowStates>(Qt::WindowNoState); - state |= uint((act && q->isActiveWindow()) ? QStyle::State_Active : QStyle::State_None); - return (int)state; -} - -void QWorkspaceTitleBar::initStyleOption(QStyleOptionTitleBar *option) const -{ - Q_D(const QWorkspaceTitleBar); - option->initFrom(this); - //################ - if (d->window && (d->flags & Qt::WindowTitleHint)) { - option->text = d->window->windowTitle(); - QIcon icon = d->window->windowIcon(); - QSize s = icon.actualSize(QSize(64, 64)); - option->icon = icon.pixmap(s); - } - option->subControls = QStyle::SC_All; - option->activeSubControls = QStyle::SC_None; - option->titleBarState = d->titleBarState(); - option->titleBarFlags = d->flags; - option->state &= ~QStyle::State_MouseOver; -} - -QWorkspaceTitleBar::QWorkspaceTitleBar(QWidget *w, QWidget *parent, Qt::WindowFlags f) - : QWidget(*new QWorkspaceTitleBarPrivate, parent, Qt::FramelessWindowHint) -{ - Q_D(QWorkspaceTitleBar); - if (f == 0 && w) - f = w->windowFlags(); - d->flags = f; - d->window = w; - d->buttonDown = QStyle::SC_None; - d->act = 0; - if (w) { - if (w->maximumSize() != QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)) - d->flags &= ~Qt::WindowMaximizeButtonHint; - setWindowTitle(w->windowTitle()); - } - - d->readColors(); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - setMouseTracking(true); - setAutoRaise(style()->styleHint(QStyle::SH_TitleBar_AutoRaise, 0, this)); -} - -QWorkspaceTitleBar::~QWorkspaceTitleBar() -{ -} - - -#ifdef Q_WS_WIN -static inline QRgb colorref2qrgb(COLORREF col) -{ - return qRgb(GetRValue(col),GetGValue(col),GetBValue(col)); -} -#endif - -void QWorkspaceTitleBarPrivate::readColors() -{ - Q_Q(QWorkspaceTitleBar); - QPalette pal = q->palette(); - - bool colorsInitialized = false; - -#ifdef Q_WS_WIN // ask system properties on windows -#ifndef SPI_GETGRADIENTCAPTIONS -#define SPI_GETGRADIENTCAPTIONS 0x1008 -#endif -#ifndef COLOR_GRADIENTACTIVECAPTION -#define COLOR_GRADIENTACTIVECAPTION 27 -#endif -#ifndef COLOR_GRADIENTINACTIVECAPTION -#define COLOR_GRADIENTINACTIVECAPTION 28 -#endif - if (QApplication::desktopSettingsAware()) { - pal.setColor(QPalette::Active, QPalette::Highlight, colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION))); - pal.setColor(QPalette::Inactive, QPalette::Highlight, colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION))); - pal.setColor(QPalette::Active, QPalette::HighlightedText, colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT))); - pal.setColor(QPalette::Inactive, QPalette::HighlightedText, colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT))); - - colorsInitialized = true; - BOOL gradient = false; - SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &gradient, 0); - - if (gradient) { - pal.setColor(QPalette::Active, QPalette::Base, colorref2qrgb(GetSysColor(COLOR_GRADIENTACTIVECAPTION))); - pal.setColor(QPalette::Inactive, QPalette::Base, colorref2qrgb(GetSysColor(COLOR_GRADIENTINACTIVECAPTION))); - } else { - pal.setColor(QPalette::Active, QPalette::Base, pal.color(QPalette::Active, QPalette::Highlight)); - pal.setColor(QPalette::Inactive, QPalette::Base, pal.color(QPalette::Inactive, QPalette::Highlight)); - } - } -#endif // Q_WS_WIN - if (!colorsInitialized) { - pal.setColor(QPalette::Active, QPalette::Highlight, - pal.color(QPalette::Active, QPalette::Highlight)); - pal.setColor(QPalette::Active, QPalette::Base, - pal.color(QPalette::Active, QPalette::Highlight)); - pal.setColor(QPalette::Inactive, QPalette::Highlight, - pal.color(QPalette::Inactive, QPalette::Dark)); - pal.setColor(QPalette::Inactive, QPalette::Base, - pal.color(QPalette::Inactive, QPalette::Dark)); - pal.setColor(QPalette::Inactive, QPalette::HighlightedText, - pal.color(QPalette::Inactive, QPalette::Window)); - } - - q->setPalette(pal); - q->setActive(act); -} - -void QWorkspaceTitleBar::mousePressEvent(QMouseEvent *e) -{ - Q_D(QWorkspaceTitleBar); - if (!d->act) - emit doActivate(); - if (e->button() == Qt::LeftButton) { - if (style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, 0) - && !rect().adjusted(5, 5, -5, 0).contains(e->pos())) { - // propagate border events to the QWidgetResizeHandler - e->ignore(); - return; - } - - d->pressed = true; - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QStyle::SubControl ctrl = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, - e->pos(), this); - switch (ctrl) { - case QStyle::SC_TitleBarSysMenu: - if (d->flags & Qt::WindowSystemMenuHint) { - d->buttonDown = QStyle::SC_None; - static QElapsedTimer *t = 0; - static QWorkspaceTitleBar *tc = 0; - if (!t) - t = new QElapsedTimer; - if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) { - emit showOperationMenu(); - t->start(); - tc = this; - } else { - tc = 0; - emit doClose(); - return; - } - } - break; - - case QStyle::SC_TitleBarShadeButton: - case QStyle::SC_TitleBarUnshadeButton: - if (d->flags & Qt::WindowShadeButtonHint) - d->buttonDown = ctrl; - break; - - case QStyle::SC_TitleBarNormalButton: - d->buttonDown = ctrl; - break; - - case QStyle::SC_TitleBarMinButton: - if (d->flags & Qt::WindowMinimizeButtonHint) - d->buttonDown = ctrl; - break; - - case QStyle::SC_TitleBarMaxButton: - if (d->flags & Qt::WindowMaximizeButtonHint) - d->buttonDown = ctrl; - break; - - case QStyle::SC_TitleBarCloseButton: - if (d->flags & Qt::WindowSystemMenuHint) - d->buttonDown = ctrl; - break; - - case QStyle::SC_TitleBarLabel: - d->buttonDown = ctrl; - d->moveOffset = mapToParent(e->pos()); - break; - - default: - break; - } - update(); - } else { - d->pressed = false; - } -} - -#ifndef QT_NO_CONTEXTMENU -void QWorkspaceTitleBar::contextMenuEvent(QContextMenuEvent *e) -{ - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QStyle::SubControl ctrl = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, e->pos(), - this); - if(ctrl == QStyle::SC_TitleBarLabel || ctrl == QStyle::SC_TitleBarSysMenu) { - e->accept(); - emit popupOperationMenu(e->globalPos()); - } else { - e->ignore(); - } -} -#endif // QT_NO_CONTEXTMENU - -void QWorkspaceTitleBar::mouseReleaseEvent(QMouseEvent *e) -{ - Q_D(QWorkspaceTitleBar); - if (!d->window) { - // could have been deleted as part of a double click event on the sysmenu - return; - } - if (e->button() == Qt::LeftButton && d->pressed) { - if (style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, 0) - && !rect().adjusted(5, 5, -5, 0).contains(e->pos())) { - // propagate border events to the QWidgetResizeHandler - e->ignore(); - d->buttonDown = QStyle::SC_None; - d->pressed = false; - return; - } - e->accept(); - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QStyle::SubControl ctrl = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, - e->pos(), this); - - if (d->pressed) { - update(); - d->pressed = false; - d->moving = false; - } - if (ctrl == d->buttonDown) { - d->buttonDown = QStyle::SC_None; - switch(ctrl) { - case QStyle::SC_TitleBarShadeButton: - case QStyle::SC_TitleBarUnshadeButton: - if(d->flags & Qt::WindowShadeButtonHint) - emit doShade(); - break; - - case QStyle::SC_TitleBarNormalButton: - if(d->flags & Qt::WindowMinMaxButtonsHint) - emit doNormal(); - break; - - case QStyle::SC_TitleBarMinButton: - if(d->flags & Qt::WindowMinimizeButtonHint) { - if (d->window && d->window->isMinimized()) - emit doNormal(); - else - emit doMinimize(); - } - break; - - case QStyle::SC_TitleBarMaxButton: - if(d->flags & Qt::WindowMaximizeButtonHint) { - if(d->window && d->window->isMaximized()) - emit doNormal(); - else - emit doMaximize(); - } - break; - - case QStyle::SC_TitleBarCloseButton: - if(d->flags & Qt::WindowSystemMenuHint) { - d->buttonDown = QStyle::SC_None; - emit doClose(); - return; - } - break; - - default: - break; - } - } - } else { - e->ignore(); - } -} - -void QWorkspaceTitleBar::mouseMoveEvent(QMouseEvent *e) -{ - Q_D(QWorkspaceTitleBar); - e->ignore(); - if ((e->buttons() & Qt::LeftButton) && style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, 0) - && !rect().adjusted(5, 5, -5, 0).contains(e->pos()) && !d->pressed) { - // propagate border events to the QWidgetResizeHandler - return; - } - - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QStyle::SubControl under_mouse = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, - e->pos(), this); - if(under_mouse != d->lastControl) { - d->lastControl = under_mouse; - update(); - } - - switch (d->buttonDown) { - case QStyle::SC_None: - break; - case QStyle::SC_TitleBarSysMenu: - break; - case QStyle::SC_TitleBarLabel: - if (d->buttonDown == QStyle::SC_TitleBarLabel && d->movable && d->pressed) { - if (d->moving || (d->moveOffset - mapToParent(e->pos())).manhattanLength() >= 4) { - d->moving = true; - QPoint p = mapFromGlobal(e->globalPos()); - - QWidget *parent = d->window ? d->window->parentWidget() : 0; - if(parent && parent->inherits("QWorkspaceChild")) { - QWidget *workspace = parent->parentWidget(); - p = workspace->mapFromGlobal(e->globalPos()); - if (!workspace->rect().contains(p)) { - if (p.x() < 0) - p.rx() = 0; - if (p.y() < 0) - p.ry() = 0; - if (p.x() > workspace->width()) - p.rx() = workspace->width(); - if (p.y() > workspace->height()) - p.ry() = workspace->height(); - } - } - - QPoint pp = p - d->moveOffset; - if (!parentWidget()->isMaximized()) - parentWidget()->move(pp); - } - } - e->accept(); - break; - default: - break; - } -} - -bool QWorkspaceTitleBar::isTool() const -{ - Q_D(const QWorkspaceTitleBar); - return (d->flags & Qt::WindowType_Mask) == Qt::Tool; -} - -// from qwidget.cpp -extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*); - -void QWorkspaceTitleBar::paintEvent(QPaintEvent *) -{ - Q_D(QWorkspaceTitleBar); - QStyleOptionTitleBar opt; - initStyleOption(&opt); - opt.subControls = QStyle::SC_TitleBarLabel; - opt.activeSubControls = d->buttonDown; - - if (d->window && (d->flags & Qt::WindowTitleHint)) { - QString title = qt_setWindowTitle_helperHelper(opt.text, d->window); - int maxw = style()->subControlRect(QStyle::CC_TitleBar, &opt, QStyle::SC_TitleBarLabel, - this).width(); - opt.text = fontMetrics().elidedText(title, Qt::ElideRight, maxw); - } - - if (d->flags & Qt::WindowSystemMenuHint) { - opt.subControls |= QStyle::SC_TitleBarSysMenu | QStyle::SC_TitleBarCloseButton; - if (d->window && (d->flags & Qt::WindowShadeButtonHint)) { - if (d->window->isMinimized()) - opt.subControls |= QStyle::SC_TitleBarUnshadeButton; - else - opt.subControls |= QStyle::SC_TitleBarShadeButton; - } - if (d->window && (d->flags & Qt::WindowMinMaxButtonsHint)) { - if(d->window && d->window->isMinimized()) - opt.subControls |= QStyle::SC_TitleBarNormalButton; - else - opt.subControls |= QStyle::SC_TitleBarMinButton; - } - if (d->window && (d->flags & Qt::WindowMaximizeButtonHint) && !d->window->isMaximized()) - opt.subControls |= QStyle::SC_TitleBarMaxButton; - } - - QStyle::SubControl under_mouse = QStyle::SC_None; - under_mouse = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, - mapFromGlobal(QCursor::pos()), this); - if ((d->buttonDown == under_mouse) && d->pressed) { - opt.state |= QStyle::State_Sunken; - } else if( autoRaise() && under_mouse != QStyle::SC_None && !d->pressed) { - opt.activeSubControls = under_mouse; - opt.state |= QStyle::State_MouseOver; - } - opt.palette.setCurrentColorGroup(usesActiveColor() ? QPalette::Active : QPalette::Inactive); - - QPainter p(this); - style()->drawComplexControl(QStyle::CC_TitleBar, &opt, &p, this); -} - -void QWorkspaceTitleBar::mouseDoubleClickEvent(QMouseEvent *e) -{ - Q_D(QWorkspaceTitleBar); - if (e->button() != Qt::LeftButton) { - e->ignore(); - return; - } - e->accept(); - QStyleOptionTitleBar opt; - initStyleOption(&opt); - switch (style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, e->pos(), this)) { - case QStyle::SC_TitleBarLabel: - emit doubleClicked(); - break; - - case QStyle::SC_TitleBarSysMenu: - if (d->flags & Qt::WindowSystemMenuHint) - emit doClose(); - break; - - default: - break; - } -} - -void QWorkspaceTitleBar::leaveEvent(QEvent *) -{ - Q_D(QWorkspaceTitleBar); - d->lastControl = QStyle::SC_None; - if(autoRaise() && !d->pressed) - update(); -} - -void QWorkspaceTitleBar::enterEvent(QEvent *) -{ - Q_D(QWorkspaceTitleBar); - if(autoRaise() && !d->pressed) - update(); - QEvent e(QEvent::Leave); - QApplication::sendEvent(parentWidget(), &e); -} - -void QWorkspaceTitleBar::setActive(bool active) -{ - Q_D(QWorkspaceTitleBar); - if (d->act == active) - return ; - - d->act = active; - update(); -} - -bool QWorkspaceTitleBar::isActive() const -{ - Q_D(const QWorkspaceTitleBar); - return d->act; -} - -bool QWorkspaceTitleBar::usesActiveColor() const -{ - return (isActive() && isActiveWindow()) || - (!window() && QWidget::window()->isActiveWindow()); -} - -QWidget *QWorkspaceTitleBar::window() const -{ - Q_D(const QWorkspaceTitleBar); - return d->window; -} - -bool QWorkspaceTitleBar::event(QEvent *e) -{ - Q_D(QWorkspaceTitleBar); - if (e->type() == QEvent::ApplicationPaletteChange) { - d->readColors(); - } else if (e->type() == QEvent::WindowActivate - || e->type() == QEvent::WindowDeactivate) { - if (d->act) - update(); - } - return QWidget::event(e); -} - -void QWorkspaceTitleBar::setMovable(bool b) -{ - Q_D(QWorkspaceTitleBar); - d->movable = b; -} - -bool QWorkspaceTitleBar::isMovable() const -{ - Q_D(const QWorkspaceTitleBar); - return d->movable; -} - -void QWorkspaceTitleBar::setAutoRaise(bool b) -{ - Q_D(QWorkspaceTitleBar); - d->autoraise = b; -} - -bool QWorkspaceTitleBar::autoRaise() const -{ - Q_D(const QWorkspaceTitleBar); - return d->autoraise; -} - -QSize QWorkspaceTitleBar::sizeHint() const -{ - ensurePolished(); - QStyleOptionTitleBar opt; - initStyleOption(&opt); - QRect menur = style()->subControlRect(QStyle::CC_TitleBar, &opt, - QStyle::SC_TitleBarSysMenu, this); - return QSize(menur.width(), style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt, this)); -} - -/*! - \class QWorkspace - \obsolete - \brief The QWorkspace widget provides a workspace window that can be - used in an MDI application. - - \inmodule QtWidgets - - This class is deprecated. Use QMdiArea instead. - - Multiple Document Interface (MDI) applications are typically - composed of a main window containing a menu bar, a toolbar, and - a central QWorkspace widget. The workspace itself is used to display - a number of child windows, each of which is a widget. - - The workspace itself is an ordinary Qt widget. It has a standard - constructor that takes a parent widget. - Workspaces can be placed in any layout, but are typically given - as the central widget in a QMainWindow: - - \snippet doc/src/snippets/code/src_gui_widgets_qworkspace.cpp 0 - - Child windows (MDI windows) are standard Qt widgets that are - inserted into the workspace with addWindow(). As with top-level - widgets, you can call functions such as show(), hide(), - showMaximized(), and setWindowTitle() on a child window to change - its appearance within the workspace. You can also provide widget - flags to determine the layout of the decoration or the behavior of - the widget itself. - - To change or retrieve the geometry of a child window, you must - operate on its parentWidget(). The parentWidget() provides - access to the decorated frame that contains the child window - widget. When a child window is maximised, its decorated frame - is hidden. If the top-level widget contains a menu bar, it will display - the maximised window's operations menu to the left of the menu - entries, and the window's controls to the right. - - A child window becomes active when it gets the keyboard focus, - or when setFocus() is called. The user can activate a window by moving - focus in the usual ways, for example by clicking a window or by pressing - Tab. The workspace emits a signal windowActivated() when the active - window changes, and the function activeWindow() returns a pointer to the - active child window, or 0 if no window is active. - - The convenience function windowList() returns a list of all child - windows. This information could be used in a popup menu - containing a list of windows, for example. This feature is also - available as part of the \l{Window Menu} Solution. - - QWorkspace provides two built-in layout strategies for child - windows: cascade() and tile(). Both are slots so you can easily - connect menu entries to them. - - \table - \row \li \inlineimage mdi-cascade.png - \li \inlineimage mdi-tile.png - \endtable - - If you want your users to be able to work with child windows - larger than the visible workspace area, set the scrollBarsEnabled - property to true. - - \sa QDockWidget, {MDI Example} -*/ - - -class QWorkspaceChild : public QWidget -{ - Q_OBJECT - - friend class QWorkspacePrivate; - friend class QWorkspace; - friend class QWorkspaceTitleBar; - -public: - QWorkspaceChild(QWidget* window, QWorkspace* parent=0, Qt::WindowFlags flags = 0); - ~QWorkspaceChild(); - - void setActive(bool); - bool isActive() const; - - void adjustToFullscreen(); - - QWidget* windowWidget() const; - QWidget* iconWidget() const; - - void doResize(); - void doMove(); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - - QSize baseSize() const; - - int frameWidth() const; - - void show(); - - bool isWindowOrIconVisible() const; - -signals: - void showOperationMenu(); - void popupOperationMenu(const QPoint&); - -public slots: - void activate(); - void showMinimized(); - void showMaximized(); - void showNormal(); - void showShaded(); - void internalRaise(); - void titleBarDoubleClicked(); - -protected: - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void childEvent(QChildEvent*); - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); - bool eventFilter(QObject *, QEvent *); - - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); - -private: - void updateMask(); - - Q_DISABLE_COPY(QWorkspaceChild) - - QWidget *childWidget; - QWidgetResizeHandler *widgetResizeHandler; - QWorkspaceTitleBar *titlebar; - QPointer<QWorkspaceTitleBar> iconw; - QSize windowSize; - QSize shadeRestore; - QSize shadeRestoreMin; - bool act :1; - bool shademode :1; -}; - -int QWorkspaceChild::frameWidth() const -{ - return contentsRect().left(); -} - - - -class QWorkspacePrivate : public QWidgetPrivate { - Q_DECLARE_PUBLIC(QWorkspace) -public: - QWorkspaceChild* active; - QList<QWorkspaceChild *> windows; - QList<QWorkspaceChild *> focus; - QList<QWidget *> icons; - QWorkspaceChild* maxWindow; - QRect maxRestore; - QPointer<QMDIControl> maxcontrols; - QPointer<QMenuBar> maxmenubar; - QHash<int, const char*> shortcutMap; - - int px; - int py; - QWidget *becomeActive; - QPointer<QLabel> maxtools; - QString topTitle; - - QMenu *popup, *toolPopup; - enum WSActs { RestoreAct, MoveAct, ResizeAct, MinimizeAct, MaximizeAct, CloseAct, StaysOnTopAct, ShadeAct, NCountAct }; - QAction *actions[NCountAct]; - - QScrollBar *vbar, *hbar; - QWidget *corner; - int yoffset, xoffset; - QBrush background; - - void init(); - void insertIcon(QWidget* w); - void removeIcon(QWidget* w); - void place(QWidget*); - - QWorkspaceChild* findChild(QWidget* w); - void showMaximizeControls(); - void hideMaximizeControls(); - void activateWindow(QWidget* w, bool change_focus = true); - void hideChild(QWorkspaceChild *c); - void showWindow(QWidget* w); - void maximizeWindow(QWidget* w); - void minimizeWindow(QWidget* w); - void normalizeWindow(QWidget* w); - - QRect updateWorkspace(); - -private: - void _q_normalizeActiveWindow(); - void _q_minimizeActiveWindow(); - void _q_showOperationMenu(); - void _q_popupOperationMenu(const QPoint&); - void _q_operationMenuActivated(QAction *); - void _q_scrollBarChanged(); - void _q_updateActions(); - bool inTitleChange; -}; - -static bool isChildOf(QWidget * child, QWidget * parent) -{ - if (!parent || !child) - return false; - QWidget * w = child; - while(w && w != parent) - w = w->parentWidget(); - return w != 0; -} - -/*! - Constructs a workspace with the given \a parent. -*/ -QWorkspace::QWorkspace(QWidget *parent) - : QWidget(*new QWorkspacePrivate, parent, 0) -{ - Q_D(QWorkspace); - d->init(); -} - - -/*! - \internal -*/ -void -QWorkspacePrivate::init() -{ - Q_Q(QWorkspace); - - maxcontrols = 0; - active = 0; - maxWindow = 0; - maxtools = 0; - px = 0; - py = 0; - becomeActive = 0; - popup = new QMenu(q); - toolPopup = new QMenu(q); - popup->setObjectName(QLatin1String("qt_internal_mdi_popup")); - toolPopup->setObjectName(QLatin1String("qt_internal_mdi_tool_popup")); - - actions[QWorkspacePrivate::RestoreAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarNormalButton, 0, q)), - QWorkspace::tr("&Restore"), q); - actions[QWorkspacePrivate::MoveAct] = new QAction(QWorkspace::tr("&Move"), q); - actions[QWorkspacePrivate::ResizeAct] = new QAction(QWorkspace::tr("&Size"), q); - actions[QWorkspacePrivate::MinimizeAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarMinButton, 0, q)), - QWorkspace::tr("Mi&nimize"), q); - actions[QWorkspacePrivate::MaximizeAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarMaxButton, 0, q)), - QWorkspace::tr("Ma&ximize"), q); - actions[QWorkspacePrivate::CloseAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, q)), - QWorkspace::tr("&Close") -#ifndef QT_NO_SHORTCUT - + QLatin1Char('\t') - + QKeySequence(Qt::CTRL+Qt::Key_F4).toString(QKeySequence::NativeText) -#endif - ,q); - QObject::connect(actions[QWorkspacePrivate::CloseAct], SIGNAL(triggered()), q, SLOT(closeActiveWindow())); - actions[QWorkspacePrivate::StaysOnTopAct] = new QAction(QWorkspace::tr("Stay on &Top"), q); - actions[QWorkspacePrivate::StaysOnTopAct]->setChecked(true); - actions[QWorkspacePrivate::ShadeAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarShadeButton, 0, q)), - QWorkspace::tr("Sh&ade"), q); - - QObject::connect(popup, SIGNAL(aboutToShow()), q, SLOT(_q_updateActions())); - QObject::connect(popup, SIGNAL(triggered(QAction*)), q, SLOT(_q_operationMenuActivated(QAction*))); - popup->addAction(actions[QWorkspacePrivate::RestoreAct]); - popup->addAction(actions[QWorkspacePrivate::MoveAct]); - popup->addAction(actions[QWorkspacePrivate::ResizeAct]); - popup->addAction(actions[QWorkspacePrivate::MinimizeAct]); - popup->addAction(actions[QWorkspacePrivate::MaximizeAct]); - popup->addSeparator(); - popup->addAction(actions[QWorkspacePrivate::CloseAct]); - - QObject::connect(toolPopup, SIGNAL(aboutToShow()), q, SLOT(_q_updateActions())); - QObject::connect(toolPopup, SIGNAL(triggered(QAction*)), q, SLOT(_q_operationMenuActivated(QAction*))); - toolPopup->addAction(actions[QWorkspacePrivate::MoveAct]); - toolPopup->addAction(actions[QWorkspacePrivate::ResizeAct]); - toolPopup->addAction(actions[QWorkspacePrivate::StaysOnTopAct]); - toolPopup->addSeparator(); - toolPopup->addAction(actions[QWorkspacePrivate::ShadeAct]); - toolPopup->addAction(actions[QWorkspacePrivate::CloseAct]); - -#ifndef QT_NO_SHORTCUT - // Set up shortcut bindings (id -> slot), most used first - QList <QKeySequence> shortcuts = QKeySequence::keyBindings(QKeySequence::NextChild); - foreach (const QKeySequence &seq, shortcuts) - shortcutMap.insert(q->grabShortcut(seq), "activateNextWindow"); - - shortcuts = QKeySequence::keyBindings(QKeySequence::PreviousChild); - foreach (const QKeySequence &seq, shortcuts) - shortcutMap.insert(q->grabShortcut(seq), "activatePreviousWindow"); - - shortcuts = QKeySequence::keyBindings(QKeySequence::Close); - foreach (const QKeySequence &seq, shortcuts) - shortcutMap.insert(q->grabShortcut(seq), "closeActiveWindow"); - - shortcutMap.insert(q->grabShortcut(QKeySequence(QLatin1String("ALT+-"))), "_q_showOperationMenu"); -#endif // QT_NO_SHORTCUT - - q->setBackgroundRole(QPalette::Dark); - q->setAutoFillBackground(true); - q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - - hbar = vbar = 0; - corner = 0; - xoffset = yoffset = 0; - - q->window()->installEventFilter(q); - - inTitleChange = false; - updateWorkspace(); -} - -/*! - Destroys the workspace and frees any allocated resources. -*/ - -QWorkspace::~QWorkspace() -{ -} - -/*! \reimp */ -QSize QWorkspace::sizeHint() const -{ - QSize s(QApplication::desktop()->size()); - return QSize(s.width()*2/3, s.height()*2/3); -} - - - -/*! - \property QWorkspace::background - \brief the workspace's background -*/ -QBrush QWorkspace::background() const -{ - Q_D(const QWorkspace); - if (d->background.style() == Qt::NoBrush) - return palette().dark(); - return d->background; -} - -void QWorkspace::setBackground(const QBrush &background) -{ - Q_D(QWorkspace); - d->background = background; - setAttribute(Qt::WA_OpaquePaintEvent, background.style() == Qt::NoBrush); - update(); -} - -/*! - Adds widget \a w as new sub window to the workspace. If \a flags - are non-zero, they will override the flags set on the widget. - - Returns the widget used for the window frame. - - To remove the widget \a w from the workspace, simply call - setParent() with the new parent (or 0 to make it a stand-alone - window). -*/ -QWidget * QWorkspace::addWindow(QWidget *w, Qt::WindowFlags flags) -{ - Q_D(QWorkspace); - if (!w) - return 0; - - w->setAutoFillBackground(true); - - QWidgetPrivate::adjustFlags(flags); - -#if 0 - bool wasMaximized = w->isMaximized(); - bool wasMinimized = w->isMinimized(); -#endif - bool hasSize = w->testAttribute(Qt::WA_Resized); - int x = w->x(); - int y = w->y(); - bool hasPos = w->testAttribute(Qt::WA_Moved); - if (!hasSize && w->sizeHint().isValid()) - w->adjustSize(); - - QWorkspaceChild* child = new QWorkspaceChild(w, this, flags); - child->setObjectName(QLatin1String("qt_workspacechild")); - child->installEventFilter(this); - - connect(child, SIGNAL(popupOperationMenu(QPoint)), - this, SLOT(_q_popupOperationMenu(QPoint))); - connect(child, SIGNAL(showOperationMenu()), - this, SLOT(_q_showOperationMenu())); - d->windows.append(child); - if (child->isVisibleTo(this)) - d->focus.append(child); - child->internalRaise(); - - if (!hasPos) - d->place(child); - if (!hasSize) - child->adjustSize(); - if (hasPos) - child->move(x, y); - - return child; - -#if 0 - if (wasMaximized) - w->showMaximized(); - else if (wasMinimized) - w->showMinimized(); - else if (!hasBeenHidden) - d->activateWindow(w); - - d->updateWorkspace(); - return child; -#endif -} - -/*! \reimp */ -void QWorkspace::childEvent(QChildEvent * e) -{ - Q_D(QWorkspace); - if (e->removed()) { - if (d->windows.removeAll(static_cast<QWorkspaceChild*>(e->child()))) { - d->focus.removeAll(static_cast<QWorkspaceChild*>(e->child())); - if (d->maxWindow == e->child()) - d->maxWindow = 0; - d->updateWorkspace(); - } - } -} - -/*! \reimp */ -#ifndef QT_NO_WHEELEVENT -void QWorkspace::wheelEvent(QWheelEvent *e) -{ - Q_D(QWorkspace); - if (!scrollBarsEnabled()) - return; - // the scroll bars are children of the workspace, so if we receive - // a wheel event we redirect to the scroll bars using a direct event - // call, /not/ using sendEvent() because if the scroll bar ignores the - // event QApplication::sendEvent() will propagate the event to the parent widget, - // which is us, who /just/ sent it. - if (d->vbar && d->vbar->isVisible() && !(e->modifiers() & Qt::AltModifier)) - d->vbar->event(e); - else if (d->hbar && d->hbar->isVisible()) - d->hbar->event(e); -} -#endif - -void QWorkspacePrivate::activateWindow(QWidget* w, bool change_focus) -{ - Q_Q(QWorkspace); - if (!w) { - active = 0; - emit q->windowActivated(0); - return; - } - if (!q->isVisible()) { - becomeActive = w; - return; - } - - if (active && active->windowWidget() == w) { - if (!isChildOf(q->focusWidget(), w)) // child window does not have focus - active->setActive(true); - return; - } - - active = 0; - // First deactivate all other workspace clients - QList<QWorkspaceChild *>::Iterator it(windows.begin()); - while (it != windows.end()) { - QWorkspaceChild* c = *it; - ++it; - if (c->windowWidget() == w) - active = c; - else - c->setActive(false); - } - - if (!active) - return; - - // Then activate the new one, so the focus is stored correctly - active->setActive(true); - - if (!active) - return; - - if (maxWindow && maxWindow != active && active->windowWidget() && - (active->windowWidget()->windowFlags() & Qt::WindowMaximizeButtonHint)) - active->showMaximized(); - - active->internalRaise(); - - if (change_focus) { - int from = focus.indexOf(active); - if (from >= 0) - focus.move(from, focus.size() - 1); - } - - updateWorkspace(); - emit q->windowActivated(w); -} - - -/*! - Returns a pointer to the widget corresponding to the active child - window, or 0 if no window is active. - - \sa setActiveWindow() -*/ -QWidget* QWorkspace::activeWindow() const -{ - Q_D(const QWorkspace); - return d->active? d->active->windowWidget() : 0; -} - -/*! - Makes the child window that contains \a w the active child window. - - \sa activeWindow() -*/ -void QWorkspace::setActiveWindow(QWidget *w) -{ - Q_D(QWorkspace); - d->activateWindow(w, true); - if (w && w->isMinimized()) - w->setWindowState(w->windowState() & ~Qt::WindowMinimized); -} - -void QWorkspacePrivate::place(QWidget *w) -{ - Q_Q(QWorkspace); - - QList<QWidget *> widgets; - for (QList<QWorkspaceChild *>::Iterator it(windows.begin()); it != windows.end(); ++it) - if (*it != w) - widgets.append(*it); - - int overlap, minOverlap = 0; - int possible; - - QRect r1(0, 0, 0, 0); - QRect r2(0, 0, 0, 0); - QRect maxRect = q->rect(); - int x = maxRect.left(), y = maxRect.top(); - QPoint wpos(maxRect.left(), maxRect.top()); - - bool firstPass = true; - - do { - if (y + w->height() > maxRect.bottom()) { - overlap = -1; - } else if(x + w->width() > maxRect.right()) { - overlap = -2; - } else { - overlap = 0; - - r1.setRect(x, y, w->width(), w->height()); - - QWidget *l; - QList<QWidget *>::Iterator it(widgets.begin()); - while (it != widgets.end()) { - l = *it; - ++it; - - if (maxWindow == l) - r2 = QStyle::visualRect(q->layoutDirection(), maxRect, maxRestore); - else - r2 = QStyle::visualRect(q->layoutDirection(), maxRect, - QRect(l->x(), l->y(), l->width(), l->height())); - - if (r2.intersects(r1)) { - r2.setCoords(qMax(r1.left(), r2.left()), - qMax(r1.top(), r2.top()), - qMin(r1.right(), r2.right()), - qMin(r1.bottom(), r2.bottom()) - ); - - overlap += (r2.right() - r2.left()) * - (r2.bottom() - r2.top()); - } - } - } - - if (overlap == 0) { - wpos = QPoint(x, y); - break; - } - - if (firstPass) { - firstPass = false; - minOverlap = overlap; - } else if (overlap >= 0 && overlap < minOverlap) { - minOverlap = overlap; - wpos = QPoint(x, y); - } - - if (overlap > 0) { - possible = maxRect.right(); - if (possible - w->width() > x) possible -= w->width(); - - QWidget *l; - QList<QWidget *>::Iterator it(widgets.begin()); - while (it != widgets.end()) { - l = *it; - ++it; - if (maxWindow == l) - r2 = QStyle::visualRect(q->layoutDirection(), maxRect, maxRestore); - else - r2 = QStyle::visualRect(q->layoutDirection(), maxRect, - QRect(l->x(), l->y(), l->width(), l->height())); - - if((y < r2.bottom()) && (r2.top() < w->height() + y)) { - if(r2.right() > x) - possible = possible < r2.right() ? - possible : r2.right(); - - if(r2.left() - w->width() > x) - possible = possible < r2.left() - w->width() ? - possible : r2.left() - w->width(); - } - } - - x = possible; - } else if (overlap == -2) { - x = maxRect.left(); - possible = maxRect.bottom(); - - if (possible - w->height() > y) possible -= w->height(); - - QWidget *l; - QList<QWidget *>::Iterator it(widgets.begin()); - while (it != widgets.end()) { - l = *it; - ++it; - if (maxWindow == l) - r2 = QStyle::visualRect(q->layoutDirection(), maxRect, maxRestore); - else - r2 = QStyle::visualRect(q->layoutDirection(), maxRect, - QRect(l->x(), l->y(), l->width(), l->height())); - - if(r2.bottom() > y) - possible = possible < r2.bottom() ? - possible : r2.bottom(); - - if(r2.top() - w->height() > y) - possible = possible < r2.top() - w->height() ? - possible : r2.top() - w->height(); - } - - y = possible; - } - } - while(overlap != 0 && overlap != -1); - - QRect resultRect = w->geometry(); - resultRect.moveTo(wpos); - w->setGeometry(QStyle::visualRect(q->layoutDirection(), maxRect, resultRect)); - updateWorkspace(); -} - - -void QWorkspacePrivate::insertIcon(QWidget* w) -{ - Q_Q(QWorkspace); - if (!w || icons.contains(w)) - return; - icons.append(w); - if (w->parentWidget() != q) { - w->setParent(q, 0); - w->move(0,0); - } - QRect cr = updateWorkspace(); - int x = 0; - int y = cr.height() - w->height(); - - QList<QWidget *>::Iterator it(icons.begin()); - while (it != icons.end()) { - QWidget* i = *it; - ++it; - if (x > 0 && x + i->width() > cr.width()){ - x = 0; - y -= i->height(); - } - - if (i != w && - i->geometry().intersects(QRect(x, y, w->width(), w->height()))) - x += i->width(); - } - w->move(x, y); - - if (q->isVisibleTo(q->parentWidget())) { - w->show(); - w->lower(); - } - updateWorkspace(); -} - - -void QWorkspacePrivate::removeIcon(QWidget* w) -{ - if (icons.removeAll(w)) - w->hide(); -} - - -/*! \reimp */ -void QWorkspace::resizeEvent(QResizeEvent *) -{ - Q_D(QWorkspace); - if (d->maxWindow) { - d->maxWindow->adjustToFullscreen(); - if (d->maxWindow->windowWidget()) - d->maxWindow->windowWidget()->overrideWindowState(Qt::WindowMaximized); - } - d->updateWorkspace(); -} - -/*! \reimp */ -void QWorkspace::showEvent(QShowEvent *e) -{ - Q_D(QWorkspace); - if (d->maxWindow) - d->showMaximizeControls(); - QWidget::showEvent(e); - if (d->becomeActive) { - d->activateWindow(d->becomeActive); - d->becomeActive = 0; - } else if (d->windows.count() > 0 && !d->active) { - d->activateWindow(d->windows.first()->windowWidget()); - } - -// // force a frame repaint - this is a workaround for what seems to be a bug -// // introduced when changing the QWidget::show() implementation. Might be -// // a windows bug as well though. -// for (int i = 0; i < d->windows.count(); ++i) { -// QWorkspaceChild* c = d->windows.at(i); -// c->update(c->rect()); -// } - - d->updateWorkspace(); -} - -/*! \reimp */ -void QWorkspace::hideEvent(QHideEvent *) -{ - Q_D(QWorkspace); - if (!isVisible()) - d->hideMaximizeControls(); -} - -/*! \reimp */ -void QWorkspace::paintEvent(QPaintEvent *) -{ - Q_D(QWorkspace); - - if (d->background.style() != Qt::NoBrush) { - QPainter p(this); - p.fillRect(0, 0, width(), height(), d->background); - } -} - -void QWorkspacePrivate::minimizeWindow(QWidget* w) -{ - QWorkspaceChild* c = findChild(w); - - if (!w || !(w->windowFlags() & Qt::WindowMinimizeButtonHint)) - return; - - if (c) { - bool wasMax = false; - if (c == maxWindow) { - wasMax = true; - maxWindow = 0; - hideMaximizeControls(); - for (QList<QWorkspaceChild *>::Iterator it(windows.begin()); it != windows.end(); ++it) { - QWorkspaceChild* c = *it; - if (c->titlebar) - c->titlebar->setMovable(true); - c->widgetResizeHandler->setActive(true); - } - } - c->hide(); - if (wasMax) - c->setGeometry(maxRestore); - if (!focus.contains(c)) - focus.append(c); - insertIcon(c->iconWidget()); - - if (!maxWindow) - activateWindow(w); - - updateWorkspace(); - - w->overrideWindowState(Qt::WindowMinimized); - c->overrideWindowState(Qt::WindowMinimized); - } -} - -void QWorkspacePrivate::normalizeWindow(QWidget* w) -{ - Q_Q(QWorkspace); - QWorkspaceChild* c = findChild(w); - if (!w) - return; - if (c) { - w->overrideWindowState(Qt::WindowNoState); - hideMaximizeControls(); - if (!maxmenubar || q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q) || !maxWindow) { - if (w->minimumSize() != w->maximumSize()) - c->widgetResizeHandler->setActive(true); - if (c->titlebar) - c->titlebar->setMovable(true); - } - w->overrideWindowState(Qt::WindowNoState); - c->overrideWindowState(Qt::WindowNoState); - - if (c == maxWindow) { - c->setGeometry(maxRestore); - maxWindow = 0; - } else { - if (c->iconw) - removeIcon(c->iconw->parentWidget()); - c->show(); - } - - hideMaximizeControls(); - for (QList<QWorkspaceChild *>::Iterator it(windows.begin()); it != windows.end(); ++it) { - QWorkspaceChild* c = *it; - if (c->titlebar) - c->titlebar->setMovable(true); - if (c->childWidget && c->childWidget->minimumSize() != c->childWidget->maximumSize()) - c->widgetResizeHandler->setActive(true); - } - activateWindow(w, true); - updateWorkspace(); - } -} - -void QWorkspacePrivate::maximizeWindow(QWidget* w) -{ - Q_Q(QWorkspace); - QWorkspaceChild* c = findChild(w); - - if (!w || !(w->windowFlags() & Qt::WindowMaximizeButtonHint)) - return; - - if (!c || c == maxWindow) - return; - - bool updatesEnabled = q->updatesEnabled(); - q->setUpdatesEnabled(false); - - if (c->iconw && icons.contains(c->iconw->parentWidget())) - normalizeWindow(w); - QRect r(c->geometry()); - QWorkspaceChild *oldMaxWindow = maxWindow; - maxWindow = c; - - showMaximizeControls(); - - c->adjustToFullscreen(); - c->show(); - c->internalRaise(); - if (oldMaxWindow != c) { - if (oldMaxWindow) { - oldMaxWindow->setGeometry(maxRestore); - oldMaxWindow->overrideWindowState(Qt::WindowNoState); - if(oldMaxWindow->windowWidget()) - oldMaxWindow->windowWidget()->overrideWindowState(Qt::WindowNoState); - } - maxRestore = r; - } - - activateWindow(w); - - if(!maxmenubar || q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) { - if (!active && becomeActive) { - active = (QWorkspaceChild*)becomeActive->parentWidget(); - active->setActive(true); - becomeActive = 0; - emit q->windowActivated(active->windowWidget()); - } - c->widgetResizeHandler->setActive(false); - if (c->titlebar) - c->titlebar->setMovable(false); - } - updateWorkspace(); - - w->overrideWindowState(Qt::WindowMaximized); - c->overrideWindowState(Qt::WindowMaximized); - q->setUpdatesEnabled(updatesEnabled); -} - -void QWorkspacePrivate::showWindow(QWidget* w) -{ - if (w->isMinimized() && (w->windowFlags() & Qt::WindowMinimizeButtonHint)) - minimizeWindow(w); - else if ((maxWindow || w->isMaximized()) && w->windowFlags() & Qt::WindowMaximizeButtonHint) - maximizeWindow(w); - else if (w->windowFlags() & Qt::WindowMaximizeButtonHint) - normalizeWindow(w); - else - w->parentWidget()->show(); - if (maxWindow) - maxWindow->internalRaise(); - updateWorkspace(); -} - - -QWorkspaceChild* QWorkspacePrivate::findChild(QWidget* w) -{ - QList<QWorkspaceChild *>::Iterator it(windows.begin()); - while (it != windows.end()) { - QWorkspaceChild* c = *it; - ++it; - if (c->windowWidget() == w) - return c; - } - return 0; -} - -/*! - Returns a list of all visible or minimized child windows. If \a - order is CreationOrder (the default), the windows are listed in - the order in which they were inserted into the workspace. If \a - order is StackingOrder, the windows are listed in their stacking - order, with the topmost window as the last item in the list. -*/ -QWidgetList QWorkspace::windowList(WindowOrder order) const -{ - Q_D(const QWorkspace); - QWidgetList windows; - if (order == StackingOrder) { - QObjectList cl = children(); - for (int i = 0; i < cl.size(); ++i) { - QWorkspaceChild *c = qobject_cast<QWorkspaceChild*>(cl.at(i)); - if (c && c->isWindowOrIconVisible()) - windows.append(c->windowWidget()); - } - } else { - QList<QWorkspaceChild *>::ConstIterator it(d->windows.begin()); - while (it != d->windows.end()) { - QWorkspaceChild* c = *it; - ++it; - if (c && c->isWindowOrIconVisible()) - windows.append(c->windowWidget()); - } - } - return windows; -} - - -/*! \reimp */ -bool QWorkspace::event(QEvent *e) -{ -#ifndef QT_NO_SHORTCUT - Q_D(QWorkspace); - if (e->type() == QEvent::Shortcut) { - QShortcutEvent *se = static_cast<QShortcutEvent *>(e); - const char *theSlot = d->shortcutMap.value(se->shortcutId(), 0); - if (theSlot) - QMetaObject::invokeMethod(this, theSlot); - } else -#endif - if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut){ - return true; - } - return QWidget::event(e); -} - -/*! \reimp */ -bool QWorkspace::eventFilter(QObject *o, QEvent * e) -{ - Q_D(QWorkspace); - static QElapsedTimer* t = 0; - static QWorkspace* tc = 0; - if (o == d->maxtools) { - switch (e->type()) { - case QEvent::MouseButtonPress: - { - QMenuBar* b = (QMenuBar*)o->parent(); - if (!t) - t = new QElapsedTimer; - if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) { - if (isRightToLeft()) { - QPoint p = b->mapToGlobal(QPoint(b->x() + b->width(), b->y() + b->height())); - p.rx() -= d->popup->sizeHint().width(); - d->_q_popupOperationMenu(p); - } else { - d->_q_popupOperationMenu(b->mapToGlobal(QPoint(b->x(), b->y() + b->height()))); - } - t->start(); - tc = this; - } else { - tc = 0; - closeActiveWindow(); - } - return true; - } - default: - break; - } - return QWidget::eventFilter(o, e); - } - switch (e->type()) { - case QEvent::HideToParent: - break; - case QEvent::ShowToParent: - if (QWorkspaceChild *c = qobject_cast<QWorkspaceChild*>(o)) - if (!d->focus.contains(c)) - d->focus.append(c); - d->updateWorkspace(); - break; - case QEvent::WindowTitleChange: - if (!d->inTitleChange) { - if (o == window()) - d->topTitle = window()->windowTitle(); - if (d->maxWindow && d->maxWindow->windowWidget() && d->topTitle.size()) { - d->inTitleChange = true; - window()->setWindowTitle(tr("%1 - [%2]") - .arg(d->topTitle).arg(d->maxWindow->windowWidget()->windowTitle())); - d->inTitleChange = false; - } - } - break; - - case QEvent::ModifiedChange: - if (o == d->maxWindow) - window()->setWindowModified(d->maxWindow->isWindowModified()); - break; - - case QEvent::Close: - if (o == window()) - { - QList<QWorkspaceChild *>::Iterator it(d->windows.begin()); - while (it != d->windows.end()) { - QWorkspaceChild* c = *it; - ++it; - if (c->shademode) - c->showShaded(); - } - } else if (qobject_cast<QWorkspaceChild*>(o)) { - d->popup->hide(); - } - d->updateWorkspace(); - break; - default: - break; - } - return QWidget::eventFilter(o, e); -} - -static QMenuBar *findMenuBar(QWidget *w) -{ - // don't search recursively to avoid finding a menu bar of a - // mainwindow that happens to be a workspace window (like - // a mainwindow in designer) - QList<QObject *> children = w->children(); - for (int i = 0; i < children.count(); ++i) { - QMenuBar *bar = qobject_cast<QMenuBar *>(children.at(i)); - if (bar) - return bar; - } - return 0; -} - -void QWorkspacePrivate::showMaximizeControls() -{ - Q_Q(QWorkspace); - Q_ASSERT(maxWindow); - - // merge windowtitle and modified state - if (!topTitle.size()) - topTitle = q->window()->windowTitle(); - - if (maxWindow->windowWidget()) { - QString docTitle = maxWindow->windowWidget()->windowTitle(); - if (topTitle.size() && docTitle.size()) { - inTitleChange = true; - q->window()->setWindowTitle(QWorkspace::tr("%1 - [%2]").arg(topTitle).arg(docTitle)); - inTitleChange = false; - } - q->window()->setWindowModified(maxWindow->windowWidget()->isWindowModified()); - } - - if (!q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) { - QMenuBar* b = 0; - - // Do a breadth-first search first on every parent, - QWidget* w = q->parentWidget(); - while (w) { - b = findMenuBar(w); - if (b) - break; - w = w->parentWidget(); - } - - // last attempt. - if (!b) - b = findMenuBar(q->window()); - - if (!b) - return; - - if (!maxcontrols) { - maxmenubar = b; - maxcontrols = new QMDIControl(b); - QObject::connect(maxcontrols, SIGNAL(_q_minimize()), - q, SLOT(_q_minimizeActiveWindow())); - QObject::connect(maxcontrols, SIGNAL(_q_restore()), - q, SLOT(_q_normalizeActiveWindow())); - QObject::connect(maxcontrols, SIGNAL(_q_close()), - q, SLOT(closeActiveWindow())); - } - - b->setCornerWidget(maxcontrols); - if (b->isVisible()) - maxcontrols->show(); - if (!active && becomeActive) { - active = (QWorkspaceChild*)becomeActive->parentWidget(); - active->setActive(true); - becomeActive = 0; - emit q->windowActivated(active->windowWidget()); - } - if (active) { - if (!maxtools) { - maxtools = new QLabel(q->window()); - maxtools->setObjectName(QLatin1String("qt_maxtools")); - maxtools->installEventFilter(q); - } - if (active->windowWidget() && !active->windowWidget()->windowIcon().isNull()) { - QIcon icon = active->windowWidget()->windowIcon(); - int iconSize = maxcontrols->size().height(); - maxtools->setPixmap(icon.pixmap(QSize(iconSize, iconSize))); - } else { - QPixmap pm = q->style()->standardPixmap(QStyle::SP_TitleBarMenuButton, 0, q); - if (pm.isNull()) { - pm = QPixmap(14,14); - pm.fill(Qt::black); - } - maxtools->setPixmap(pm); - } - b->setCornerWidget(maxtools, Qt::TopLeftCorner); - if (b->isVisible()) - maxtools->show(); - } - } -} - - -void QWorkspacePrivate::hideMaximizeControls() -{ - Q_Q(QWorkspace); - if (maxmenubar && !q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) { - if (maxmenubar) { - maxmenubar->setCornerWidget(0, Qt::TopLeftCorner); - maxmenubar->setCornerWidget(0, Qt::TopRightCorner); - } - if (maxcontrols) { - maxcontrols->deleteLater(); - maxcontrols = 0; - } - if (maxtools) { - maxtools->deleteLater(); - maxtools = 0; - } - } - - //unmerge the title bar/modification state - if (topTitle.size()) { - inTitleChange = true; - q->window()->setWindowTitle(topTitle); - inTitleChange = false; - } - q->window()->setWindowModified(false); -} - -/*! - Closes the child window that is currently active. - - \sa closeAllWindows() -*/ -void QWorkspace::closeActiveWindow() -{ - Q_D(QWorkspace); - if (d->maxWindow && d->maxWindow->windowWidget()) - d->maxWindow->windowWidget()->close(); - else if (d->active && d->active->windowWidget()) - d->active->windowWidget()->close(); - d->updateWorkspace(); -} - -/*! - Closes all child windows. - - If any child window fails to accept the close event, the remaining windows - will remain open. - - \sa closeActiveWindow() -*/ -void QWorkspace::closeAllWindows() -{ - Q_D(QWorkspace); - bool did_close = true; - QList<QWorkspaceChild *>::const_iterator it = d->windows.constBegin(); - while (it != d->windows.constEnd() && did_close) { - QWorkspaceChild *c = *it; - ++it; - if (c->windowWidget() && !c->windowWidget()->isHidden()) - did_close = c->windowWidget()->close(); - } -} - -void QWorkspacePrivate::_q_normalizeActiveWindow() -{ - if (maxWindow) - maxWindow->showNormal(); - else if (active) - active->showNormal(); -} - -void QWorkspacePrivate::_q_minimizeActiveWindow() -{ - if (maxWindow) - maxWindow->showMinimized(); - else if (active) - active->showMinimized(); -} - -void QWorkspacePrivate::_q_showOperationMenu() -{ - Q_Q(QWorkspace); - if (!active || !active->windowWidget()) - return; - Q_ASSERT((active->windowWidget()->windowFlags() & Qt::WindowSystemMenuHint)); - QPoint p; - QMenu *popup = (active->titlebar && active->titlebar->isTool()) ? toolPopup : this->popup; - if (q->isRightToLeft()) { - p = QPoint(active->windowWidget()->mapToGlobal(QPoint(active->windowWidget()->width(),0))); - p.rx() -= popup->sizeHint().width(); - } else { - p = QPoint(active->windowWidget()->mapToGlobal(QPoint(0,0))); - } - if (!active->isVisible()) { - p = active->iconWidget()->mapToGlobal(QPoint(0,0)); - p.ry() -= popup->sizeHint().height(); - } - _q_popupOperationMenu(p); -} - -void QWorkspacePrivate::_q_popupOperationMenu(const QPoint& p) -{ - if (!active || !active->windowWidget() || !(active->windowWidget()->windowFlags() & Qt::WindowSystemMenuHint)) - return; - if (active->titlebar && active->titlebar->isTool()) - toolPopup->popup(p); - else - popup->popup(p); -} - -void QWorkspacePrivate::_q_updateActions() -{ - Q_Q(QWorkspace); - for (int i = 1; i < NCountAct-1; i++) { - bool enable = active != 0; - actions[i]->setEnabled(enable); - } - - if (!active || !active->windowWidget()) - return; - - QWidget *windowWidget = active->windowWidget(); - bool canResize = windowWidget->maximumSize() != windowWidget->minimumSize(); - actions[QWorkspacePrivate::ResizeAct]->setEnabled(canResize); - actions[QWorkspacePrivate::MinimizeAct]->setEnabled((windowWidget->windowFlags() & Qt::WindowMinimizeButtonHint)); - actions[QWorkspacePrivate::MaximizeAct]->setEnabled((windowWidget->windowFlags() & Qt::WindowMaximizeButtonHint) && canResize); - - if (active == maxWindow) { - actions[QWorkspacePrivate::MoveAct]->setEnabled(false); - actions[QWorkspacePrivate::ResizeAct]->setEnabled(false); - actions[QWorkspacePrivate::MaximizeAct]->setEnabled(false); - actions[QWorkspacePrivate::RestoreAct]->setEnabled(true); - } else if (active->isVisible()){ - actions[QWorkspacePrivate::RestoreAct]->setEnabled(false); - } else { - actions[QWorkspacePrivate::MoveAct]->setEnabled(false); - actions[QWorkspacePrivate::ResizeAct]->setEnabled(false); - actions[QWorkspacePrivate::MinimizeAct]->setEnabled(false); - actions[QWorkspacePrivate::RestoreAct]->setEnabled(true); - } - if (active->shademode) { - actions[QWorkspacePrivate::ShadeAct]->setIcon( - QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarUnshadeButton, 0, q))); - actions[QWorkspacePrivate::ShadeAct]->setText(QWorkspace::tr("&Unshade")); - } else { - actions[QWorkspacePrivate::ShadeAct]->setIcon( - QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarShadeButton, 0, q))); - actions[QWorkspacePrivate::ShadeAct]->setText(QWorkspace::tr("Sh&ade")); - } - actions[QWorkspacePrivate::StaysOnTopAct]->setEnabled(!active->shademode && canResize); - actions[QWorkspacePrivate::StaysOnTopAct]->setChecked( - (active->windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint)); -} - -void QWorkspacePrivate::_q_operationMenuActivated(QAction *action) -{ - if (!active) - return; - if(action == actions[QWorkspacePrivate::RestoreAct]) { - active->showNormal(); - } else if(action == actions[QWorkspacePrivate::MoveAct]) { - active->doMove(); - } else if(action == actions[QWorkspacePrivate::ResizeAct]) { - if (active->shademode) - active->showShaded(); - active->doResize(); - } else if(action == actions[QWorkspacePrivate::MinimizeAct]) { - active->showMinimized(); - } else if(action == actions[QWorkspacePrivate::MaximizeAct]) { - active->showMaximized(); - } else if(action == actions[QWorkspacePrivate::ShadeAct]) { - active->showShaded(); - } else if(action == actions[QWorkspacePrivate::StaysOnTopAct]) { - if(QWidget* w = active->windowWidget()) { - if ((w->windowFlags() & Qt::WindowStaysOnTopHint)) { - w->overrideWindowFlags(w->windowFlags() & ~Qt::WindowStaysOnTopHint); - } else { - w->overrideWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint); - w->parentWidget()->raise(); - } - } - } -} - - -void QWorkspacePrivate::hideChild(QWorkspaceChild *c) -{ - Q_Q(QWorkspace); - -// bool updatesEnabled = q->updatesEnabled(); -// q->setUpdatesEnabled(false); - focus.removeAll(c); - QRect restore; - if (maxWindow == c) - restore = maxRestore; - if (active == c) { - q->setFocus(); - q->activatePreviousWindow(); - } - if (active == c) - activateWindow(0); - if (maxWindow == c) { - hideMaximizeControls(); - maxWindow = 0; - } - c->hide(); - if (!restore.isEmpty()) - c->setGeometry(restore); -// q->setUpdatesEnabled(updatesEnabled); -} - -/*! - Gives the input focus to the next window in the list of child - windows. - - \sa activatePreviousWindow() -*/ -void QWorkspace::activateNextWindow() -{ - Q_D(QWorkspace); - - if (d->focus.isEmpty()) - return; - if (!d->active) { - if (d->focus.first()) - d->activateWindow(d->focus.first()->windowWidget(), false); - return; - } - - int a = d->focus.indexOf(d->active) + 1; - - a = a % d->focus.count(); - - if (d->focus.at(a)) - d->activateWindow(d->focus.at(a)->windowWidget(), false); - else - d->activateWindow(0); -} - -/*! - Gives the input focus to the previous window in the list of child - windows. - - \sa activateNextWindow() -*/ -void QWorkspace::activatePreviousWindow() -{ - Q_D(QWorkspace); - - if (d->focus.isEmpty()) - return; - if (!d->active) { - if (d->focus.last()) - d->activateWindow(d->focus.first()->windowWidget(), false); - else - d->activateWindow(0); - return; - } - - int a = d->focus.indexOf(d->active) - 1; - if (a < 0) - a = d->focus.count()-1; - - if (d->focus.at(a)) - d->activateWindow(d->focus.at(a)->windowWidget(), false); - else - d->activateWindow(0); -} - - -/*! - \fn void QWorkspace::windowActivated(QWidget* w) - - This signal is emitted when the child window \a w becomes active. - Note that \a w can be 0, and that more than one signal may be - emitted for a single activation event. - - \sa activeWindow(), windowList() -*/ - -/*! - Arranges all the child windows in a cascade pattern. - - \sa tile(), arrangeIcons() -*/ -void QWorkspace::cascade() -{ - Q_D(QWorkspace); - blockSignals(true); - if (d->maxWindow) - d->maxWindow->showNormal(); - - if (d->vbar) { - d->vbar->blockSignals(true); - d->vbar->setValue(0); - d->vbar->blockSignals(false); - d->hbar->blockSignals(true); - d->hbar->setValue(0); - d->hbar->blockSignals(false); - d->_q_scrollBarChanged(); - } - - const int xoffset = 13; - const int yoffset = 20; - - // make a list of all relevant mdi clients - QList<QWorkspaceChild *> widgets; - QList<QWorkspaceChild *>::Iterator it(d->windows.begin()); - QWorkspaceChild* wc = 0; - - for (it = d->focus.begin(); it != d->focus.end(); ++it) { - wc = *it; - if (wc->windowWidget()->isVisibleTo(this) && !(wc->titlebar && wc->titlebar->isTool())) - widgets.append(wc); - } - - int x = 0; - int y = 0; - - it = widgets.begin(); - while (it != widgets.end()) { - QWorkspaceChild *child = *it; - ++it; - - QSize prefSize = child->windowWidget()->sizeHint().expandedTo(qSmartMinSize(child->windowWidget())); - if (!prefSize.isValid()) - prefSize = child->windowWidget()->size(); - prefSize = prefSize.expandedTo(qSmartMinSize(child->windowWidget())); - if (prefSize.isValid()) - prefSize += QSize(child->baseSize().width(), child->baseSize().height()); - - int w = prefSize.width(); - int h = prefSize.height(); - - child->showNormal(); - if (y + h > height()) - y = 0; - if (x + w > width()) - x = 0; - child->setGeometry(x, y, w, h); - x += xoffset; - y += yoffset; - child->internalRaise(); - } - d->updateWorkspace(); - blockSignals(false); -} - -/*! - Arranges all child windows in a tile pattern. - - \sa cascade(), arrangeIcons() -*/ -void QWorkspace::tile() -{ - Q_D(QWorkspace); - blockSignals(true); - QWidget *oldActive = d->active ? d->active->windowWidget() : 0; - if (d->maxWindow) - d->maxWindow->showNormal(); - - if (d->vbar) { - d->vbar->blockSignals(true); - d->vbar->setValue(0); - d->vbar->blockSignals(false); - d->hbar->blockSignals(true); - d->hbar->setValue(0); - d->hbar->blockSignals(false); - d->_q_scrollBarChanged(); - } - - int rows = 1; - int cols = 1; - int n = 0; - QWorkspaceChild* c; - - QList<QWorkspaceChild *>::Iterator it(d->windows.begin()); - while (it != d->windows.end()) { - c = *it; - ++it; - if (!c->windowWidget()->isHidden() - && !(c->windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint) - && !c->iconw) - n++; - } - - while (rows * cols < n) { - if (cols <= rows) - cols++; - else - rows++; - } - int add = cols * rows - n; - bool* used = new bool[cols*rows]; - for (int i = 0; i < rows*cols; i++) - used[i] = false; - - int row = 0; - int col = 0; - int w = width() / cols; - int h = height() / rows; - - it = d->windows.begin(); - while (it != d->windows.end()) { - c = *it; - ++it; - if (c->iconw || c->windowWidget()->isHidden() || (c->titlebar && c->titlebar->isTool())) - continue; - if (!row && !col) { - w -= c->baseSize().width(); - h -= c->baseSize().height(); - } - if ((c->windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint)) { - QPoint p = c->pos(); - if (p.x()+c->width() < 0) - p.setX(0); - if (p.x() > width()) - p.setX(width() - c->width()); - if (p.y() + 10 < 0) - p.setY(0); - if (p.y() > height()) - p.setY(height() - c->height()); - - if (p != c->pos()) - c->QWidget::move(p); - } else { - c->showNormal(); - used[row*cols+col] = true; - QSize sz(w, h); - QSize bsize(c->baseSize()); - sz = sz.expandedTo(c->windowWidget()->minimumSize()).boundedTo(c->windowWidget()->maximumSize()); - sz += bsize; - - if ( add ) { - if (sz.height() == h + bsize.height()) // no relevant constrains - sz.rheight() *= 2; - used[(row+1)*cols+col] = true; - add--; - } - - c->setGeometry(col*w + col*bsize.width(), row*h + row*bsize.height(), sz.width(), sz.height()); - - while(row < rows && col < cols && used[row*cols+col]) { - col++; - if (col == cols) { - col = 0; - row++; - } - } - } - } - delete [] used; - - d->activateWindow(oldActive); - d->updateWorkspace(); - blockSignals(false); -} - -/*! - Arranges all iconified windows at the bottom of the workspace. - - \sa cascade(), tile() -*/ -void QWorkspace::arrangeIcons() -{ - Q_D(QWorkspace); - - QRect cr = d->updateWorkspace(); - int x = 0; - int y = -1; - - QList<QWidget *>::Iterator it(d->icons.begin()); - while (it != d->icons.end()) { - QWidget* i = *it; - if (y == -1) - y = cr.height() - i->height(); - if (x > 0 && x + i->width() > cr.width()) { - x = 0; - y -= i->height(); - } - i->move(x, y); - x += i->width(); - ++it; - } - d->updateWorkspace(); -} - - -QWorkspaceChild::QWorkspaceChild(QWidget* window, QWorkspace *parent, Qt::WindowFlags flags) - : QWidget(parent, - Qt::FramelessWindowHint | Qt::SubWindow) -{ - setAttribute(Qt::WA_DeleteOnClose); - setAttribute(Qt::WA_NoMousePropagation); - setMouseTracking(true); - act = false; - iconw = 0; - shademode = false; - titlebar = 0; - setAutoFillBackground(true); - - setBackgroundRole(QPalette::Window); - if (window) { - flags |= (window->windowFlags() & Qt::MSWindowsOwnDC); - if (flags) - window->setParent(this, flags & ~Qt::WindowType_Mask); - else - window->setParent(this); - } - - if (window && (flags & (Qt::WindowTitleHint - | Qt::WindowSystemMenuHint - | Qt::WindowMinimizeButtonHint - | Qt::WindowMaximizeButtonHint - | Qt::WindowContextHelpButtonHint))) { - titlebar = new QWorkspaceTitleBar(window, this, flags); - connect(titlebar, SIGNAL(doActivate()), - this, SLOT(activate())); - connect(titlebar, SIGNAL(doClose()), - window, SLOT(close())); - connect(titlebar, SIGNAL(doMinimize()), - this, SLOT(showMinimized())); - connect(titlebar, SIGNAL(doNormal()), - this, SLOT(showNormal())); - connect(titlebar, SIGNAL(doMaximize()), - this, SLOT(showMaximized())); - connect(titlebar, SIGNAL(popupOperationMenu(QPoint)), - this, SIGNAL(popupOperationMenu(QPoint))); - connect(titlebar, SIGNAL(showOperationMenu()), - this, SIGNAL(showOperationMenu())); - connect(titlebar, SIGNAL(doShade()), - this, SLOT(showShaded())); - connect(titlebar, SIGNAL(doubleClicked()), - this, SLOT(titleBarDoubleClicked())); - } - - setMinimumSize(128, 0); - int fw = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); - setContentsMargins(fw, fw, fw, fw); - - childWidget = window; - if (!childWidget) - return; - - setWindowTitle(childWidget->windowTitle()); - - QPoint p; - QSize s; - QSize cs; - - bool hasBeenResized = childWidget->testAttribute(Qt::WA_Resized); - - if (!hasBeenResized) - cs = childWidget->sizeHint().expandedTo(childWidget->minimumSizeHint()).expandedTo(childWidget->minimumSize()).boundedTo(childWidget->maximumSize()); - else - cs = childWidget->size(); - - windowSize = cs; - - int th = titlebar ? titlebar->sizeHint().height() : 0; - if (titlebar) { - if (!childWidget->windowIcon().isNull()) - titlebar->setWindowIcon(childWidget->windowIcon()); - - if (style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) - th -= contentsRect().y(); - - p = QPoint(contentsRect().x(), - th + contentsRect().y()); - s = QSize(cs.width() + 2*frameWidth(), - cs.height() + 2*frameWidth() + th); - } else { - p = QPoint(contentsRect().x(), contentsRect().y()); - s = QSize(cs.width() + 2*frameWidth(), - cs.height() + 2*frameWidth()); - } - - childWidget->move(p); - resize(s); - - childWidget->installEventFilter(this); - - widgetResizeHandler = new QWidgetResizeHandler(this, window); - widgetResizeHandler->setSizeProtection(!parent->scrollBarsEnabled()); - widgetResizeHandler->setFrameWidth(frameWidth()); - connect(widgetResizeHandler, SIGNAL(activate()), - this, SLOT(activate())); - if (!style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) - widgetResizeHandler->setExtraHeight(th + contentsRect().y() - 2*frameWidth()); - else - widgetResizeHandler->setExtraHeight(th + contentsRect().y() - frameWidth()); - if (childWidget->minimumSize() == childWidget->maximumSize()) - widgetResizeHandler->setActive(QWidgetResizeHandler::Resize, false); - setBaseSize(baseSize()); -} - -QWorkspaceChild::~QWorkspaceChild() -{ - QWorkspace *workspace = qobject_cast<QWorkspace*>(parentWidget()); - if (iconw) { - if (workspace) - workspace->d_func()->removeIcon(iconw->parentWidget()); - delete iconw->parentWidget(); - } - - if (workspace) { - workspace->d_func()->focus.removeAll(this); - if (workspace->d_func()->active == this) - workspace->activatePreviousWindow(); - if (workspace->d_func()->active == this) - workspace->d_func()->activateWindow(0); - if (workspace->d_func()->maxWindow == this) { - workspace->d_func()->hideMaximizeControls(); - workspace->d_func()->maxWindow = 0; - } - } -} - -void QWorkspaceChild::moveEvent(QMoveEvent *) -{ - ((QWorkspace*)parentWidget())->d_func()->updateWorkspace(); -} - -void QWorkspaceChild::resizeEvent(QResizeEvent *) -{ - bool wasMax = isMaximized(); - QRect r = contentsRect(); - QRect cr; - - updateMask(); - - if (titlebar) { - int th = titlebar->sizeHint().height(); - QRect tbrect(0, 0, width(), th); - if (!style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) - tbrect = QRect(r.x(), r.y(), r.width(), th); - titlebar->setGeometry(tbrect); - - if (style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) - th -= frameWidth(); - cr = QRect(r.x(), r.y() + th + (shademode ? (frameWidth() * 3) : 0), - r.width(), r.height() - th); - } else { - cr = r; - } - - if (!childWidget) - return; - - bool doContentsResize = (windowSize == childWidget->size() - || !(childWidget->testAttribute(Qt::WA_Resized) && childWidget->testAttribute(Qt::WA_PendingResizeEvent)) - ||childWidget->isMaximized()); - - windowSize = cr.size(); - childWidget->move(cr.topLeft()); - if (doContentsResize) - childWidget->resize(cr.size()); - ((QWorkspace*)parentWidget())->d_func()->updateWorkspace(); - - if (wasMax) { - overrideWindowState(Qt::WindowMaximized); - childWidget->overrideWindowState(Qt::WindowMaximized); - } -} - -QSize QWorkspaceChild::baseSize() const -{ - int th = titlebar ? titlebar->sizeHint().height() : 0; - if (style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) - th -= frameWidth(); - return QSize(2*frameWidth(), 2*frameWidth() + th); -} - -QSize QWorkspaceChild::sizeHint() const -{ - if (!childWidget) - return QWidget::sizeHint() + baseSize(); - - QSize prefSize = windowWidget()->sizeHint().expandedTo(windowWidget()->minimumSizeHint()); - prefSize = prefSize.expandedTo(windowWidget()->minimumSize()).boundedTo(windowWidget()->maximumSize()); - prefSize += baseSize(); - - return prefSize; -} - -QSize QWorkspaceChild::minimumSizeHint() const -{ - if (!childWidget) - return QWidget::minimumSizeHint() + baseSize(); - QSize s = childWidget->minimumSize(); - if (s.isEmpty()) - s = childWidget->minimumSizeHint(); - return s + baseSize(); -} - -void QWorkspaceChild::activate() -{ - ((QWorkspace*)parentWidget())->d_func()->activateWindow(windowWidget()); -} - -bool QWorkspaceChild::eventFilter(QObject * o, QEvent * e) -{ - if (!isActive() - && (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::FocusIn)) { - if (iconw) { - ((QWorkspace*)parentWidget())->d_func()->normalizeWindow(windowWidget()); - if (iconw) { - ((QWorkspace*)parentWidget())->d_func()->removeIcon(iconw->parentWidget()); - delete iconw->parentWidget(); - iconw = 0; - } - } - activate(); - } - - // for all widgets except the window, that's the only thing we - // process, and if we have no childWidget we skip totally - if (o != childWidget || childWidget == 0) - return false; - - switch (e->type()) { - case QEvent::ShowToParent: - if (((QWorkspace*)parentWidget())->d_func()->focus.indexOf(this) < 0) - ((QWorkspace*)parentWidget())->d_func()->focus.append(this); - - if (windowWidget() && (windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint)) { - internalRaise(); - show(); - } - ((QWorkspace*)parentWidget())->d_func()->showWindow(windowWidget()); - break; - case QEvent::WindowStateChange: { - if (static_cast<QWindowStateChangeEvent*>(e)->isOverride()) - break; - Qt::WindowStates state = windowWidget()->windowState(); - - if (state & Qt::WindowMinimized) { - ((QWorkspace*)parentWidget())->d_func()->minimizeWindow(windowWidget()); - } else if (state & Qt::WindowMaximized) { - if (windowWidget()->maximumSize().isValid() && - (windowWidget()->maximumWidth() < parentWidget()->width() || - windowWidget()->maximumHeight() < parentWidget()->height())) { - windowWidget()->resize(windowWidget()->maximumSize()); - windowWidget()->overrideWindowState(Qt::WindowNoState); - if (titlebar) - titlebar->update(); - break; - } - if ((windowWidget()->windowFlags() & Qt::WindowMaximizeButtonHint)) - ((QWorkspace*)parentWidget())->d_func()->maximizeWindow(windowWidget()); - else - ((QWorkspace*)parentWidget())->d_func()->normalizeWindow(windowWidget()); - } else { - ((QWorkspace*)parentWidget())->d_func()->normalizeWindow(windowWidget()); - if (iconw) { - ((QWorkspace*)parentWidget())->d_func()->removeIcon(iconw->parentWidget()); - delete iconw->parentWidget(); - } - } - } break; - case QEvent::HideToParent: - { - QWidget * w = iconw; - if (w && (w = w->parentWidget())) { - ((QWorkspace*)parentWidget())->d_func()->removeIcon(w); - delete w; - } - ((QWorkspace*)parentWidget())->d_func()->hideChild(this); - } break; - case QEvent::WindowIconChange: - { - QWorkspace* ws = (QWorkspace*)parentWidget(); - if (ws->d_func()->maxtools && ws->d_func()->maxWindow == this) { - int iconSize = ws->d_func()->maxtools->size().height(); - ws->d_func()->maxtools->setPixmap(childWidget->windowIcon().pixmap(QSize(iconSize, iconSize))); - } - } - // fall through - case QEvent::WindowTitleChange: - setWindowTitle(windowWidget()->windowTitle()); - if (titlebar) - titlebar->update(); - if (iconw) - iconw->update(); - break; - case QEvent::ModifiedChange: - setWindowModified(windowWidget()->isWindowModified()); - if (titlebar) - titlebar->update(); - if (iconw) - iconw->update(); - break; - case QEvent::Resize: - { - QResizeEvent* re = (QResizeEvent*)e; - if (re->size() != windowSize && !shademode) { - resize(re->size() + baseSize()); - childWidget->update(); //workaround - } - } - break; - - case QEvent::WindowDeactivate: - if (titlebar && titlebar->isActive()) { - update(); - } - break; - - case QEvent::WindowActivate: - if (titlebar && titlebar->isActive()) { - update(); - } - break; - - default: - break; - } - - return QWidget::eventFilter(o, e); -} - -void QWorkspaceChild::childEvent(QChildEvent* e) -{ - if (e->type() == QEvent::ChildRemoved && e->child() == childWidget) { - childWidget = 0; - if (iconw) { - ((QWorkspace*)parentWidget())->d_func()->removeIcon(iconw->parentWidget()); - delete iconw->parentWidget(); - } - close(); - } -} - - -void QWorkspaceChild::doResize() -{ - widgetResizeHandler->doResize(); -} - -void QWorkspaceChild::doMove() -{ - widgetResizeHandler->doMove(); -} - -void QWorkspaceChild::enterEvent(QEvent *) -{ -} - -void QWorkspaceChild::leaveEvent(QEvent *) -{ -#ifndef QT_NO_CURSOR - if (!widgetResizeHandler->isButtonDown()) - setCursor(Qt::ArrowCursor); -#endif -} - -void QWorkspaceChild::paintEvent(QPaintEvent *) -{ - QPainter p(this); - QStyleOptionFrame opt; - opt.rect = rect(); - opt.palette = palette(); - opt.state = QStyle::State_None; - opt.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); - opt.midLineWidth = 1; - - if (titlebar && titlebar->isActive() && isActiveWindow()) - opt.state |= QStyle::State_Active; - - style()->drawPrimitive(QStyle::PE_FrameWindow, &opt, &p, this); -} - -void QWorkspaceChild::changeEvent(QEvent *ev) -{ - if(ev->type() == QEvent::StyleChange) { - resizeEvent(0); - if (iconw) { - QFrame *frame = qobject_cast<QFrame*>(iconw->parentWidget()); - Q_ASSERT(frame); - if (!style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) { - frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - frame->resize(196+2*frame->frameWidth(), 20 + 2*frame->frameWidth()); - } else { - frame->resize(196, 20); - } - } - updateMask(); - } - QWidget::changeEvent(ev); -} - -void QWorkspaceChild::setActive(bool b) -{ - if (!childWidget) - return; - - bool hasFocus = isChildOf(window()->focusWidget(), this); - if (act == b && (act == hasFocus)) - return; - - act = b; - - if (titlebar) - titlebar->setActive(act); - if (iconw) - iconw->setActive(act); - update(); - - QList<QWidget*> wl = childWidget->findChildren<QWidget*>(); - if (act) { - for (int i = 0; i < wl.size(); ++i) { - QWidget *w = wl.at(i); - w->removeEventFilter(this); - } - if (!hasFocus) { - QWidget *lastfocusw = childWidget->focusWidget(); - if (lastfocusw && lastfocusw->focusPolicy() != Qt::NoFocus) { - lastfocusw->setFocus(); - } else if (childWidget->focusPolicy() != Qt::NoFocus) { - childWidget->setFocus(); - } else { - // find something, anything, that accepts focus, and use that. - for (int i = 0; i < wl.size(); ++i) { - QWidget *w = wl.at(i); - if(w->focusPolicy() != Qt::NoFocus) { - w->setFocus(); - hasFocus = true; - break; - } - } - if (!hasFocus) - setFocus(); - } - } - } else { - for (int i = 0; i < wl.size(); ++i) { - QWidget *w = wl.at(i); - w->removeEventFilter(this); - w->installEventFilter(this); - } - } -} - -bool QWorkspaceChild::isActive() const -{ - return act; -} - -QWidget* QWorkspaceChild::windowWidget() const -{ - return childWidget; -} - -bool QWorkspaceChild::isWindowOrIconVisible() const -{ - return childWidget && (!isHidden() || (iconw && !iconw->isHidden())); -} - -void QWorkspaceChild::updateMask() -{ - QStyleOptionTitleBar titleBarOptions; - titleBarOptions.rect = rect(); - titleBarOptions.titleBarFlags = windowFlags(); - titleBarOptions.titleBarState = windowState(); - - QStyleHintReturnMask frameMask; - if (style()->styleHint(QStyle::SH_WindowFrame_Mask, &titleBarOptions, this, &frameMask)) { - setMask(frameMask.region); - } else if (!mask().isEmpty()) { - clearMask(); - } - - if (iconw) { - QFrame *frame = qobject_cast<QFrame *>(iconw->parentWidget()); - Q_ASSERT(frame); - - titleBarOptions.rect = frame->rect(); - titleBarOptions.titleBarFlags = frame->windowFlags(); - titleBarOptions.titleBarState = frame->windowState() | Qt::WindowMinimized; - if (style()->styleHint(QStyle::SH_WindowFrame_Mask, &titleBarOptions, frame, &frameMask)) { - frame->setMask(frameMask.region); - } else if (!frame->mask().isEmpty()) { - frame->clearMask(); - } - } -} - -QWidget* QWorkspaceChild::iconWidget() const -{ - if (!iconw) { - QWorkspaceChild* that = (QWorkspaceChild*) this; - - QFrame* frame = new QFrame(that, Qt::Window); - QVBoxLayout *vbox = new QVBoxLayout(frame); - vbox->setMargin(0); - QWorkspaceTitleBar *tb = new QWorkspaceTitleBar(windowWidget(), frame); - vbox->addWidget(tb); - tb->setObjectName(QLatin1String("_workspacechild_icon_")); - QStyleOptionTitleBar opt; - tb->initStyleOption(&opt); - int th = style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt, tb); - int iconSize = style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this); - if (!style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) { - frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - frame->resize(iconSize+2*frame->frameWidth(), th+2*frame->frameWidth()); - } else { - frame->resize(iconSize, th); - } - - that->iconw = tb; - that->updateMask(); - iconw->setActive(isActive()); - - connect(iconw, SIGNAL(doActivate()), - this, SLOT(activate())); - connect(iconw, SIGNAL(doClose()), - windowWidget(), SLOT(close())); - connect(iconw, SIGNAL(doNormal()), - this, SLOT(showNormal())); - connect(iconw, SIGNAL(doMaximize()), - this, SLOT(showMaximized())); - connect(iconw, SIGNAL(popupOperationMenu(QPoint)), - this, SIGNAL(popupOperationMenu(QPoint))); - connect(iconw, SIGNAL(showOperationMenu()), - this, SIGNAL(showOperationMenu())); - connect(iconw, SIGNAL(doubleClicked()), - this, SLOT(titleBarDoubleClicked())); - } - if (windowWidget()) { - iconw->setWindowTitle(windowWidget()->windowTitle()); - } - return iconw->parentWidget(); -} - -void QWorkspaceChild::showMinimized() -{ - windowWidget()->setWindowState(Qt::WindowMinimized | (windowWidget()->windowState() & ~Qt::WindowMaximized)); -} - -void QWorkspaceChild::showMaximized() -{ - windowWidget()->setWindowState(Qt::WindowMaximized | (windowWidget()->windowState() & ~Qt::WindowMinimized)); -} - -void QWorkspaceChild::showNormal() -{ - windowWidget()->setWindowState(windowWidget()->windowState() & ~(Qt::WindowMinimized|Qt::WindowMaximized)); -} - -void QWorkspaceChild::showShaded() -{ - if (!titlebar) - return; - ((QWorkspace*)parentWidget())->d_func()->activateWindow(windowWidget()); - QWidget* w = windowWidget(); - if (shademode) { - w->overrideWindowState(Qt::WindowNoState); - overrideWindowState(Qt::WindowNoState); - - shademode = false; - resize(shadeRestore.expandedTo(minimumSizeHint())); - setMinimumSize(shadeRestoreMin); - style()->polish(this); - } else { - shadeRestore = size(); - shadeRestoreMin = minimumSize(); - setMinimumHeight(0); - shademode = true; - w->overrideWindowState(Qt::WindowMinimized); - overrideWindowState(Qt::WindowMinimized); - - if (style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar)) - resize(width(), titlebar->height()); - else - resize(width(), titlebar->height() + 2*frameWidth() + 1); - style()->polish(this); - } - titlebar->update(); -} - -void QWorkspaceChild::titleBarDoubleClicked() -{ - if (!windowWidget()) - return; - if (iconw) - showNormal(); - else if (windowWidget()->windowFlags() & Qt::WindowShadeButtonHint) - showShaded(); - else if (windowWidget()->windowFlags() & Qt::WindowMaximizeButtonHint) - showMaximized(); -} - -void QWorkspaceChild::adjustToFullscreen() -{ - if (!childWidget) - return; - - if(!((QWorkspace*)parentWidget())->d_func()->maxmenubar || style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, this)) { - setGeometry(parentWidget()->rect()); - } else { - int fw = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); - bool noBorder = style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar); - int th = titlebar ? titlebar->sizeHint().height() : 0; - int w = parentWidget()->width() + 2*fw; - int h = parentWidget()->height() + (noBorder ? fw : 2*fw) + th; - w = qMax(w, childWidget->minimumWidth()); - h = qMax(h, childWidget->minimumHeight()); - setGeometry(-fw, (noBorder ? 0 : -fw) - th, w, h); - } - childWidget->overrideWindowState(Qt::WindowMaximized); - overrideWindowState(Qt::WindowMaximized); -} - -void QWorkspaceChild::internalRaise() -{ - - QWidget *stackUnderWidget = 0; - if (!windowWidget() || (windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint) == 0) { - - QList<QWorkspaceChild *>::Iterator it(((QWorkspace*)parent())->d_func()->windows.begin()); - while (it != ((QWorkspace*)parent())->d_func()->windows.end()) { - QWorkspaceChild* c = *it; - ++it; - if (c->windowWidget() && - !c->windowWidget()->isHidden() && - (c->windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint)) { - if (stackUnderWidget) - c->stackUnder(stackUnderWidget); - else - c->raise(); - stackUnderWidget = c; - } - } - } - - if (stackUnderWidget) { - if (iconw) - iconw->parentWidget()->stackUnder(stackUnderWidget); - stackUnder(stackUnderWidget); - } else { - if (iconw) - iconw->parentWidget()->raise(); - raise(); - } - -} - -void QWorkspaceChild::show() -{ - if (childWidget && childWidget->isHidden()) - childWidget->show(); - QWidget::show(); -} - -bool QWorkspace::scrollBarsEnabled() const -{ - Q_D(const QWorkspace); - return d->vbar != 0; -} - -/*! - \property QWorkspace::scrollBarsEnabled - \brief whether the workspace provides scroll bars - - If this property is true, the workspace will provide scroll bars if any - of the child windows extend beyond the edges of the visible - workspace. The workspace area will automatically increase to - contain child windows if they are resized beyond the right or - bottom edges of the visible area. - - If this property is false (the default), resizing child windows - out of the visible area of the workspace is not permitted, although - it is still possible to position them partially outside the visible area. -*/ -void QWorkspace::setScrollBarsEnabled(bool enable) -{ - Q_D(QWorkspace); - if ((d->vbar != 0) == enable) - return; - - d->xoffset = d->yoffset = 0; - if (enable) { - d->vbar = new QScrollBar(Qt::Vertical, this); - d->vbar->setObjectName(QLatin1String("vertical scrollbar")); - connect(d->vbar, SIGNAL(valueChanged(int)), this, SLOT(_q_scrollBarChanged())); - d->hbar = new QScrollBar(Qt::Horizontal, this); - d->hbar->setObjectName(QLatin1String("horizontal scrollbar")); - connect(d->hbar, SIGNAL(valueChanged(int)), this, SLOT(_q_scrollBarChanged())); - d->corner = new QWidget(this); - d->corner->setBackgroundRole(QPalette::Window); - d->corner->setObjectName(QLatin1String("qt_corner")); - d->updateWorkspace(); - } else { - delete d->vbar; - delete d->hbar; - delete d->corner; - d->vbar = d->hbar = 0; - d->corner = 0; - } - - QList<QWorkspaceChild *>::Iterator it(d->windows.begin()); - while (it != d->windows.end()) { - QWorkspaceChild *child = *it; - ++it; - child->widgetResizeHandler->setSizeProtection(!enable); - } -} - -QRect QWorkspacePrivate::updateWorkspace() -{ - Q_Q(QWorkspace); - QRect cr(q->rect()); - - if (q->scrollBarsEnabled() && !maxWindow) { - corner->raise(); - vbar->raise(); - hbar->raise(); - if (maxWindow) - maxWindow->internalRaise(); - - QRect r(0, 0, 0, 0); - QList<QWorkspaceChild *>::Iterator it(windows.begin()); - while (it != windows.end()) { - QWorkspaceChild *child = *it; - ++it; - if (!child->isHidden()) - r = r.united(child->geometry()); - } - vbar->blockSignals(true); - hbar->blockSignals(true); - - int hsbExt = hbar->sizeHint().height(); - int vsbExt = vbar->sizeHint().width(); - - - bool showv = yoffset || yoffset + r.bottom() - q->height() + 1 > 0 || yoffset + r.top() < 0; - bool showh = xoffset || xoffset + r.right() - q->width() + 1 > 0 || xoffset + r.left() < 0; - - if (showh && !showv) - showv = yoffset + r.bottom() - q->height() + hsbExt + 1 > 0; - if (showv && !showh) - showh = xoffset + r.right() - q->width() + vsbExt + 1 > 0; - - if (!showh) - hsbExt = 0; - if (!showv) - vsbExt = 0; - - if (showv) { - vbar->setSingleStep(qMax(q->height() / 12, 30)); - vbar->setPageStep(q->height() - hsbExt); - vbar->setMinimum(qMin(0, yoffset + qMin(0, r.top()))); - vbar->setMaximum(qMax(0, yoffset + qMax(0, r.bottom() - q->height() + hsbExt + 1))); - vbar->setGeometry(q->width() - vsbExt, 0, vsbExt, q->height() - hsbExt); - vbar->setValue(yoffset); - vbar->show(); - } else { - vbar->hide(); - } - - if (showh) { - hbar->setSingleStep(qMax(q->width() / 12, 30)); - hbar->setPageStep(q->width() - vsbExt); - hbar->setMinimum(qMin(0, xoffset + qMin(0, r.left()))); - hbar->setMaximum(qMax(0, xoffset + qMax(0, r.right() - q->width() + vsbExt + 1))); - hbar->setGeometry(0, q->height() - hsbExt, q->width() - vsbExt, hsbExt); - hbar->setValue(xoffset); - hbar->show(); - } else { - hbar->hide(); - } - - if (showh && showv) { - corner->setGeometry(q->width() - vsbExt, q->height() - hsbExt, vsbExt, hsbExt); - corner->show(); - } else { - corner->hide(); - } - - vbar->blockSignals(false); - hbar->blockSignals(false); - - cr.setRect(0, 0, q->width() - vsbExt, q->height() - hsbExt); - } - - QList<QWidget *>::Iterator ii(icons.begin()); - while (ii != icons.end()) { - QWidget* w = *ii; - ++ii; - int x = w->x(); - int y = w->y(); - bool m = false; - if (x+w->width() > cr.width()) { - m = true; - x = cr.width() - w->width(); - } - if (y+w->height() > cr.height()) { - y = cr.height() - w->height(); - m = true; - } - if (m) { - if (QWorkspaceChild *child = qobject_cast<QWorkspaceChild*>(w)) - child->move(x, y); - else - w->move(x, y); - } - } - - return cr; - -} - -void QWorkspacePrivate::_q_scrollBarChanged() -{ - int ver = yoffset - vbar->value(); - int hor = xoffset - hbar->value(); - yoffset = vbar->value(); - xoffset = hbar->value(); - - QList<QWorkspaceChild *>::Iterator it(windows.begin()); - while (it != windows.end()) { - QWorkspaceChild *child = *it; - ++it; - // we do not use move() due to the reimplementation in QWorkspaceChild - child->setGeometry(child->x() + hor, child->y() + ver, child->width(), child->height()); - } - updateWorkspace(); -} - -/*! - \enum QWorkspace::WindowOrder - - Specifies the order in which child windows are returned from windowList(). - - \value CreationOrder The windows are returned in the order of their creation - \value StackingOrder The windows are returned in the order of their stacking -*/ - -/*!\reimp */ -void QWorkspace::changeEvent(QEvent *ev) -{ - Q_D(QWorkspace); - if(ev->type() == QEvent::StyleChange) { - if (isVisible() && d->maxWindow && d->maxmenubar) { - if(style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, this)) { - d->hideMaximizeControls(); //hide any visible maximized controls - d->showMaximizeControls(); //updates the modification state as well - } - } - } - QWidget::changeEvent(ev); -} - -QT_END_NAMESPACE - -#include "moc_qworkspace.cpp" - -#include "qworkspace.moc" - -#endif // QT_NO_WORKSPACE diff --git a/src/widgets/widgets/qworkspace.h b/src/widgets/widgets/qworkspace.h deleted file mode 100644 index 9c18f3fce0..0000000000 --- a/src/widgets/widgets/qworkspace.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWORKSPACE_H -#define QWORKSPACE_H - -#include <QtWidgets/qwidget.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_WORKSPACE - -class QAction; -class QWorkspaceChild; -class QShowEvent; -class QWorkspacePrivate; - -class Q_WIDGETS_EXPORT QWorkspace : public QWidget -{ - Q_OBJECT - Q_PROPERTY(bool scrollBarsEnabled READ scrollBarsEnabled WRITE setScrollBarsEnabled) - Q_PROPERTY(QBrush background READ background WRITE setBackground) - -public: - explicit QWorkspace(QWidget* parent=0); - ~QWorkspace(); - - enum WindowOrder { CreationOrder, StackingOrder }; - - QWidget* activeWindow() const; - QWidgetList windowList(WindowOrder order = CreationOrder) const; - - QWidget * addWindow(QWidget *w, Qt::WindowFlags flags = 0); - - QSize sizeHint() const; - - bool scrollBarsEnabled() const; - void setScrollBarsEnabled(bool enable); - - - void setBackground(const QBrush &background); - QBrush background() const; - -Q_SIGNALS: - void windowActivated(QWidget* w); - -public Q_SLOTS: - void setActiveWindow(QWidget *w); - void cascade(); - void tile(); - void arrangeIcons(); - void closeActiveWindow(); - void closeAllWindows(); - void activateNextWindow(); - void activatePreviousWindow(); - -protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *e); - void changeEvent(QEvent *); - void childEvent(QChildEvent *); - void resizeEvent(QResizeEvent *); - bool eventFilter(QObject *, QEvent *); - void showEvent(QShowEvent *e); - void hideEvent(QHideEvent *e); -#ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *e); -#endif - -private: - Q_DECLARE_PRIVATE(QWorkspace) - Q_DISABLE_COPY(QWorkspace) - Q_PRIVATE_SLOT(d_func(), void _q_normalizeActiveWindow()) - Q_PRIVATE_SLOT(d_func(), void _q_minimizeActiveWindow()) - Q_PRIVATE_SLOT(d_func(), void _q_showOperationMenu()) - Q_PRIVATE_SLOT(d_func(), void _q_popupOperationMenu(const QPoint&)) - Q_PRIVATE_SLOT(d_func(), void _q_operationMenuActivated(QAction *)) - Q_PRIVATE_SLOT(d_func(), void _q_updateActions()) - Q_PRIVATE_SLOT(d_func(), void _q_scrollBarChanged()) - - friend class QWorkspaceChild; -}; - -#endif // QT_NO_WORKSPACE - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QWORKSPACE_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 0875ecaa6b..c86bc1eff7 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -73,7 +73,6 @@ HEADERS += \ widgets/qwidgetresizehandler_p.h \ widgets/qfocusframe.h \ widgets/qscrollarea.h \ - widgets/qworkspace.h \ widgets/qwidgetanimator_p.h \ widgets/qwidgettextcontrol_p.h \ widgets/qwidgettextcontrol_p_p.h \ @@ -135,7 +134,6 @@ SOURCES += \ widgets/qwidgetresizehandler.cpp \ widgets/qfocusframe.cpp \ widgets/qscrollarea.cpp \ - widgets/qworkspace.cpp \ widgets/qwidgetanimator.cpp \ widgets/qwidgettextcontrol.cpp \ widgets/qwidgetlinecontrol.cpp \ |