From 6586200d3043ba7915bc60695e2a1436a5cadfa3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 6 May 2009 12:11:59 +0200 Subject: Moved the QT_BEGIN_NAMESPACE macro to the right place in qsslcipher.cpp Task-number: 252298 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcipher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp index 505c662..7fec2df 100644 --- a/src/network/ssl/qsslcipher.cpp +++ b/src/network/ssl/qsslcipher.cpp @@ -64,9 +64,9 @@ #ifndef QT_NO_DEBUG_STREAM #include +#endif QT_BEGIN_NAMESPACE -#endif /*! Constructs an empty QSslCipher object. -- cgit v0.12 From b38874c55ec7d046c3ff3ba08599d52e004c0146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 6 May 2009 12:58:33 +0200 Subject: Optimize QCocoaView::registerDragTypes and mode switching in QtCreator. We were registering the types each time drag and drop was enabled, which caused slowdowns when for example switching between the Edit and Debug modes in QtCreator. Instead, register the types on first enable and also when the custom types change. Add check to draggingEntered() that disables the drag if WA_DropSiteRegistered is false. Reviewed-by: nrc --- src/gui/kernel/qcocoaview_mac.mm | 18 +++++++++++++----- src/gui/kernel/qcocoaview_mac_p.h | 3 ++- src/gui/kernel/qwidget_mac.mm | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index ff36ca1..4ceae3f 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -198,6 +198,7 @@ extern "C" { } composing = false; sendKeyEvents = true; + currentCustomTypes = 0; [self setHidden:YES]; return self; } @@ -212,10 +213,16 @@ extern "C" { object:self]; } --(void)registerDragTypes:(bool)accept +-(void)registerDragTypes { QMacCocoaAutoReleasePool pool; - if (accept) { + // Calling registerForDraggedTypes is slow, so only do it once for each widget + // or when the custom types change. + const QStringList& customTypes = qEnabledDraggedTypes(); + if (currentCustomTypes == 0 || *currentCustomTypes != customTypes) { + if (currentCustomTypes == 0) + currentCustomTypes = new QStringList(); + *currentCustomTypes = customTypes; const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, NSStringPboardType, @@ -227,13 +234,10 @@ extern "C" { NSFilesPromisePboardType, NSInkTextPboardType, NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; // Add custom types supported by the application. - const QStringList& customTypes = qEnabledDraggedTypes(); for (int i = 0; i < customTypes.size(); i++) { [supportedTypes addObject:reinterpret_cast(QCFString::toCFStringRef(customTypes[i]))]; } [self registerForDraggedTypes:supportedTypes]; - } else { - [self unregisterDraggedTypes]; } } @@ -282,6 +286,8 @@ extern "C" { - (NSDragOperation)draggingEntered:(id )sender { + if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false) + return NSDragOperationNone; [self addDropData:sender]; QMimeData *mimeData = dropData; if (QDragManager::self()->source()) @@ -414,6 +420,8 @@ extern "C" { - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + delete currentCustomTypes; + [self unregisterDraggedTypes]; [super dealloc]; } diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h index 9de94d5..983c762 100644 --- a/src/gui/kernel/qcocoaview_mac_p.h +++ b/src/gui/kernel/qcocoaview_mac_p.h @@ -83,6 +83,7 @@ Q_GUI_EXPORT bool composing; int composingLength; bool sendKeyEvents; + QStringList *currentCustomTypes; } - (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate; - (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate; @@ -91,7 +92,7 @@ Q_GUI_EXPORT - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender; - (void)draggingExited:(id < NSDraggingInfo >)sender; - (BOOL)performDragOperation:(id )sender; -- (void)registerDragTypes:(bool)accept; +- (void)registerDragTypes; - (void)removeDropData; - (void)addDropData:(id )sender; - (void)setSupportedActions:(NSDragOperation)actions; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3f89ff3..b315eaf 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4497,8 +4497,8 @@ void QWidgetPrivate::registerDropSite(bool on) SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on); #else NSView *view = qt_mac_nativeview_for(q); - if ([view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { - [static_cast(view) registerDragTypes:on]; + if (on && [view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { + [static_cast(view) registerDragTypes]; } #endif } -- cgit v0.12 From acd5ac35f26b075c48bc04a2db8064fe8bd4be90 Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 6 May 2009 13:11:08 +0200 Subject: Fixes broken last tab page handling in case the search was hidden. --- tools/assistant/tools/assistant/centralwidget.cpp | 46 ++++++++++++++++------- tools/assistant/tools/assistant/centralwidget.h | 2 +- tools/assistant/tools/assistant/mainwindow.cpp | 8 +++- tools/assistant/tools/assistant/mainwindow.h | 1 + 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 4390a10..ec54d0c 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -262,8 +262,9 @@ CentralWidget::~CentralWidget() QString zoomCount; QString currentPages; QLatin1Char separator('|'); - int i = m_searchWidget->isAttached() ? 1 : 0; + bool searchAttached = m_searchWidget->isAttached(); + int i = searchAttached ? 1 : 0; for (; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { @@ -274,6 +275,7 @@ CentralWidget::~CentralWidget() engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage); engine.setCustomValue(QLatin1String("LastShownPages"), currentPages); + engine.setCustomValue(QLatin1String("SearchWasAttached"), searchAttached); #if !defined(QT_NO_WEBKIT) engine.setCustomValue(QLatin1String("LastPagesZoomWebView"), zoomCount); #else @@ -418,7 +420,18 @@ void CentralWidget::setLastShownPages() setSourceInNewTab((*it), (*zIt).toFloat()); const QLatin1String lastTab("LastTabPage"); - tabWidget->setCurrentIndex(helpEngine->customValue(lastTab, 1).toInt()); + int tab = helpEngine->customValue(lastTab, 1).toInt(); + + const QLatin1String searchKey("SearchWasAttached"); + const bool searchIsAttached = m_searchWidget->isAttached(); + const bool searchWasAttached = helpEngine->customValue(searchKey).toBool(); + + if (searchWasAttached && !searchIsAttached) + tabWidget->setCurrentIndex(--tab); + else if (!searchWasAttached && searchIsAttached) + tabWidget->setCurrentIndex(++tab); + else + tabWidget->setCurrentIndex(tab); } bool CentralWidget::hasSelection() const @@ -978,22 +991,29 @@ void CentralWidget::updateBrowserFont() void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) { - if (!m_searchWidget) { - m_searchWidget = new SearchWidget(searchEngine, this); - connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, - SLOT(setSourceFromSearch(QUrl))); - connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, - SLOT(setSourceFromSearchInNewTab(QUrl))); - } - tabWidget->insertTab(0, m_searchWidget, tr("Search")); - m_searchWidget->setAttached(true); + if (m_searchWidget) + return; + + m_searchWidget = new SearchWidget(searchEngine, this); + connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, + SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, + SLOT(setSourceFromSearchInNewTab(QUrl))); } -void CentralWidget::activateSearchWidget() +void CentralWidget::activateSearchWidget(bool updateLastTabPage) { - if (!m_searchWidget->isAttached()) + if (!m_searchWidget) createSearchWidget(helpEngine->searchEngine()); + if (!m_searchWidget->isAttached()) { + tabWidget->insertTab(0, m_searchWidget, tr("Search")); + m_searchWidget->setAttached(true); + + if (updateLastTabPage) + lastTabPage++; + } + tabWidget->setCurrentWidget(m_searchWidget); m_searchWidget->setFocus(); } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 2c28091..e3ce200 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -118,7 +118,7 @@ public: void activateTab(bool onlyHelpViewer = false); void createSearchWidget(QHelpSearchEngine *searchEngine); - void activateSearchWidget(); + void activateSearchWidget(bool updateLastTabPage = false); void removeSearchWidget(); int availableHelpViewer() const; diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 426a828..52cbf45 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -126,6 +126,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); m_centralWidget->createSearchWidget(searchEngine); + m_centralWidget->activateSearchWidget(); QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); @@ -461,7 +462,7 @@ void MainWindow::setupActions() QKeySequence(tr("ALT+I"))); m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarks()), QKeySequence(tr("ALT+O"))); - m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()), + m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()), QKeySequence(tr("ALT+S"))); menu = menuBar()->addMenu(tr("&Go")); @@ -880,6 +881,11 @@ void MainWindow::showSearch() m_centralWidget->activateSearchWidget(); } +void MainWindow::showSearchWidget() +{ + m_centralWidget->activateSearchWidget(true); +} + void MainWindow::hideSearch() { m_centralWidget->removeSearchWidget(); diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 7d08a74..d7f5c69 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -92,6 +92,7 @@ public slots: void showIndex(); void showBookmarks(); void showSearch(); + void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); -- cgit v0.12 From 4258eb4c448f2e68fe5cd428f90e1af0c9268a00 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 6 May 2009 13:10:30 +0200 Subject: fixed a typo in QPrintDialog documentation --- src/gui/dialogs/qabstractprintdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qabstractprintdialog.cpp b/src/gui/dialogs/qabstractprintdialog.cpp index 0dc16c9..5ed8852 100644 --- a/src/gui/dialogs/qabstractprintdialog.cpp +++ b/src/gui/dialogs/qabstractprintdialog.cpp @@ -400,7 +400,7 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter) QAbstractPrintDialog::setEnabledOptions() and QAbstractPrintDialog::addEnabledOption() have no effect. - In Qt 4.4, it was possible to use the satic functions to show a sheet on + In Qt 4.4, it was possible to use the static functions to show a sheet on Mac OS X. This is no longer supported in Qt 4.5. If you want this functionality, use QPrintDialog::open(). -- cgit v0.12