diff --git a/share/qtcreator/translations/qtcreator_de.ts b/share/qtcreator/translations/qtcreator_de.ts index 6cefbd28134f92b0971e63d578f31f92db4b13a0..fb0e61db8074a2c8924f80bfe5de6fb47c39108f 100644 --- a/share/qtcreator/translations/qtcreator_de.ts +++ b/share/qtcreator/translations/qtcreator_de.ts @@ -2473,16 +2473,16 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 </context> <context> <name>CppFileSettingsPage</name> - <message> - <location filename="../../../src/plugins/cpptools/cpptoolsconstants.h" line="+52"/> - <source>File naming conventions</source> - <translation>Konventionen für die Bildung von Dateinamen</translation> - </message> <message> <location filename="../../../src/plugins/cpptools/cppfilesettingspage.ui"/> <source>Header suffix:</source> <translation>Endung für Header-Dateien:</translation> </message> + <message> + <location/> + <source>File naming conventions</source> + <translation>Konventionen für die Bildung von Dateinamen</translation> + </message> <message> <location/> <source>This determines how the file names of the class wizards are generated ("MyClass.h" versus "myclass.h").</source> @@ -4408,16 +4408,16 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen.</translation> </context> <context> <name>DebuggingHelperOptionPage</name> - <message> - <location filename="../../../src/plugins/debugger/debuggerplugin.cpp" line="-596"/> - <source>Debugging Helper</source> - <translation>Ausgabe-Hilfsbibliothek</translation> - </message> <message> <location filename="../../../src/plugins/debugger/dumperoptionpage.ui"/> <source>This will enable nice display of Qt and Standard Library objects in the Locals&Watchers view</source> <translation>Diese Einstellung ermöglicht die Anzeige von Qt- und Standardbibliotheksobjekten in der Ansicht "Lokale Variablen und Über&wachte Ausdrücke"</translation> </message> + <message> + <location/> + <source>Debugging Helper</source> + <translation>Ausgabe-Hilfsbibliothek</translation> + </message> <message> <location/> <source>Use debugging helper</source> @@ -5329,8 +5329,8 @@ Grund: %3</translation> <name>FilterSettingsPage</name> <message> <location filename="../../../src/plugins/help/filtersettingspage.ui"/> - <source>Filter:</source> - <translation>Filter:</translation> + <source>Filters</source> + <translation>Filter</translation> </message> <message> <location/> diff --git a/share/qtcreator/translations/qtcreator_it.ts b/share/qtcreator/translations/qtcreator_it.ts index a4d9c23f4c42db0035169fe99ebda10ba521563b..0469d8c1780d52538dc05311d51c5f9b0e93b730 100644 --- a/share/qtcreator/translations/qtcreator_it.ts +++ b/share/qtcreator/translations/qtcreator_it.ts @@ -2301,16 +2301,16 @@ p { </context> <context> <name>CppFileSettingsPage</name> - <message> - <location filename="../../../src/plugins/cpptools/cpptoolsconstants.h" line="+52"/> - <source>File naming conventions</source> - <translation>Convenzioni sul nome dei file</translation> - </message> <message> <location filename="../../../src/plugins/cpptools/cppfilesettingspage.ui"/> <source>Header suffix:</source> <translation>Estensione header:</translation> </message> + <message> + <location/> + <source>File naming conventions</source> + <translation>Convenzioni sul nome dei file</translation> + </message> <message> <location/> <source>This determines how the file names of the class wizards are generated ("MyClass.h" versus "myclass.h").</source> @@ -4058,16 +4058,16 @@ L'utilizzo di gdb 6.7 o successivi è fortemente consigliato.</translation> </context> <context> <name>DebuggingHelperOptionPage</name> - <message> - <location filename="../../../src/plugins/debugger/debuggerplugin.cpp" line="-596"/> - <source>Debugging Helper</source> - <translation>Helper del Debug</translation> - </message> <message> <location filename="../../../src/plugins/debugger/dumperoptionpage.ui"/> <source>This will enable nice display of Qt and Standard Library objects in the Locals&Watchers view</source> <translation>Marcando questa casella si abilita la visualizzazione dei tipi Qt e STL nella vista Variabili Locali & Osservazione</translation> </message> + <message> + <location/> + <source>Debugging Helper</source> + <translation>Helper del Debug</translation> + </message> <message> <location/> <source>Use debugging helper</source> @@ -4931,8 +4931,8 @@ Causa: %3</translation> <name>FilterSettingsPage</name> <message> <location filename="../../../src/plugins/help/filtersettingspage.ui"/> - <source>Filter:</source> - <translation>Filtro:</translation> + <source>Filters</source> + <translation>Filtri</translation> </message> <message> <location/> diff --git a/share/qtcreator/translations/qtcreator_ja.ts b/share/qtcreator/translations/qtcreator_ja.ts index 54b7559898b86c7d4a011af97c589e19f4cdbe17..610f9947cb19617e5cc5a52ceb398adefae75c05 100644 --- a/share/qtcreator/translations/qtcreator_ja.ts +++ b/share/qtcreator/translations/qtcreator_ja.ts @@ -2224,16 +2224,16 @@ background-image: url(:/core/images/welcomemode/feedback-bar-background.png); </context> <context> <name>CppFileSettingsPage</name> - <message> - <location filename="../../../src/plugins/cpptools/cpptoolsconstants.h" line="+51"/> - <source>File naming conventions</source> - <translation type="unfinished"></translation> - </message> <message> <location filename="../../../src/plugins/cpptools/cppfilesettingspage.ui"/> <source>Form</source> <translation type="unfinished">フォーム</translation> </message> + <message> + <location/> + <source>File naming conventions</source> + <translation type="unfinished"></translation> + </message> <message> <location/> <source>Header suffix:</source> @@ -3718,16 +3718,16 @@ Using gdb 6.7 or later is strongly recommended.</source> </context> <context> <name>DebuggingHelperOptionPage</name> - <message> - <location filename="../../../src/plugins/debugger/debuggerplugin.cpp" line="-596"/> - <source>Debugging Helper</source> - <translation type="unfinished"></translation> - </message> <message> <location filename="../../../src/plugins/debugger/dumperoptionpage.ui"/> <source>Form</source> <translation type="unfinished">フォーム</translation> </message> + <message> + <location/> + <source>Debugging Helper</source> + <translation type="unfinished"></translation> + </message> <message> <location/> <source>This will enable nice display of Qt and Standard Library objects in the Locals&Watchers view</source> @@ -4662,7 +4662,7 @@ Reason: %3</source> </message> <message> <location/> - <source>Filter:</source> + <source>Filters</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index f5a0edd66bc9c780cdf285e76e81a9c69dbc0e18..f77d9a0f3dec33e1b46a721f6b9022a63644a4b9 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -176,7 +176,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible scopes.clear(); foreach (Symbol *candidate, candidates) { if (ScopedSymbol *scoped = candidate->asScopedSymbol()) { - scopes.append(scoped->members()); + expand(scoped->members(), visibleScopes, &scopes); } } } diff --git a/src/plugins/duieditor/duieditor.cpp b/src/plugins/duieditor/duieditor.cpp index f6110625ddbe216b8270f93f4e0d2f77a5fa75be..d6ab9a135998c66f2df936281d0d11836a8469a4 100644 --- a/src/plugins/duieditor/duieditor.cpp +++ b/src/plugins/duieditor/duieditor.cpp @@ -294,8 +294,8 @@ protected: init(&decl, node); decl.text.fill(QLatin1Char(' '), _depth); - if (node->qualifiedObjectNameId) - decl.text.append(asString(node->qualifiedObjectNameId)); + if (node->qualifiedTypeNameId) + decl.text.append(asString(node->qualifiedTypeNameId)); else decl.text.append(QLatin1Char('?')); @@ -321,8 +321,8 @@ protected: decl.text.append(asString(node->qualifiedId)); decl.text.append(QLatin1String(": ")); - if (node->qualifiedObjectNameId) - decl.text.append(asString(node->qualifiedObjectNameId)); + if (node->qualifiedTypeNameId) + decl.text.append(asString(node->qualifiedTypeNameId)); else decl.text.append(QLatin1Char('?')); diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index ccff2bb67dc29c434275f33d9881b38a5727cf34..35c24b6cdd92fac788d8ea6f4bf72d9ba470d508 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -308,7 +308,7 @@ void GenericProject::setToolChainId(const QString &toolChainId) } else if (toolChainId == QLatin1String("msvc")) { const QString msvcVersion; // ### FIXME - m_toolChain = ToolChain::createMSVCToolChain(msvcVersion); + m_toolChain = ToolChain::createMSVCToolChain(msvcVersion, false); } else if (toolChainId == QLatin1String("wince")) { const QString msvcVersion, wincePlatform; // ### FIXME diff --git a/src/plugins/help/filtersettingspage.ui b/src/plugins/help/filtersettingspage.ui index 8a208e63c702405920fe1178566019c09b1bb56c..30770193a104675b0640c37aad05760fdeaf70e5 100644 --- a/src/plugins/help/filtersettingspage.ui +++ b/src/plugins/help/filtersettingspage.ui @@ -10,56 +10,78 @@ </rect> </property> <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" colspan="2" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Filter:</string> - </property> - </widget> - </item> - <item row="0" column="2" > - <widget class="QLabel" name="label_2" > - <property name="frameShape" > - <enum>QFrame::NoFrame</enum> - </property> - <property name="text" > - <string>Attributes:</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2" > - <widget class="QListWidget" name="filterWidget" /> - </item> - <item rowspan="2" row="1" column="2" > - <widget class="QTreeWidget" name="attributeWidget" > - <property name="showDropIndicator" stdset="0" > - <bool>false</bool> - </property> - <property name="rootIsDecorated" > - <bool>false</bool> - </property> - <property name="uniformRowHeights" > - <bool>true</bool> - </property> - <column> - <property name="text" > - <string>1</string> - </property> - </column> - </widget> - </item> - <item row="2" column="0" > - <widget class="QPushButton" name="filterAddButton" > - <property name="text" > - <string>Add</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QPushButton" name="filterRemoveButton" > - <property name="text" > - <string>Remove</string> + <item row="0" column="0" > + <widget class="QGroupBox" name="groupBox" > + <property name="title" > + <string>Filters</string> </property> + <layout class="QVBoxLayout" name="verticalLayout_2" > + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <widget class="QListWidget" name="filterWidget" /> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2" > + <property name="title" > + <string>Attributes</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QTreeWidget" name="attributeWidget" > + <property name="showDropIndicator" stdset="0" > + <bool>false</bool> + </property> + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + <property name="uniformRowHeights" > + <bool>true</bool> + </property> + <column> + <property name="text" > + <string>1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QPushButton" name="filterAddButton" > + <property name="text" > + <string>Add</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="filterRemoveButton" > + <property name="text" > + <string>Remove</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> </widget> </item> </layout> diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp index b61bb8d2bd969699f96ac8b29ddb02778b2e923d..c1af4f27f5b19a896327a5152b2e8f1ed0e94a90 100644 --- a/src/plugins/help/searchwidget.cpp +++ b/src/plugins/help/searchwidget.cpp @@ -62,11 +62,16 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) setFocusProxy(queryWidget); connect(queryWidget, SIGNAL(search()), this, SLOT(search())); - connect(resultWidget, SIGNAL(requestShowLink(const QUrl&)), - this, SIGNAL(requestShowLink(const QUrl&))); + connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this, + SIGNAL(requestShowLink(QUrl))); - connect(searchEngine, SIGNAL(searchingStarted()), this, SLOT(searchingStarted())); - connect(searchEngine, SIGNAL(searchingFinished(int)), this, SLOT(searchingFinished(int))); + connect(searchEngine, SIGNAL(searchingStarted()), this, + SLOT(searchingStarted())); + connect(searchEngine, SIGNAL(searchingFinished(int)), this, + SLOT(searchingFinished(int))); + + QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + browser->viewport()->installEventFilter(this); } SearchWidget::~SearchWidget() @@ -76,10 +81,6 @@ SearchWidget::~SearchWidget() void SearchWidget::zoomIn() { -#ifndef QT_CLUCENE_SUPPORT - return; -#endif - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); if (browser && zoomCount != 10) { zoomCount++; @@ -89,10 +90,6 @@ void SearchWidget::zoomIn() void SearchWidget::zoomOut() { -#ifndef QT_CLUCENE_SUPPORT - return; -#endif - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); if (browser && zoomCount != -5) { zoomCount--; @@ -102,10 +99,6 @@ void SearchWidget::zoomOut() void SearchWidget::resetZoom() { -#ifndef QT_CLUCENE_SUPPORT - return; -#endif - if (zoomCount == 0) return; @@ -133,6 +126,24 @@ void SearchWidget::searchingFinished(int hits) qApp->restoreOverrideCursor(); } +bool SearchWidget::eventFilter(QObject* o, QEvent *e) +{ + QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + if (browser && o == browser->viewport() + && e->type() == QEvent::MouseButtonRelease){ + QMouseEvent *me = static_cast<QMouseEvent*>(e); + QUrl link = resultWidget->linkAt(me->pos()); + if (!link.isEmpty() || link.isValid()) { + bool controlPressed = me->modifiers() & Qt::ControlModifier; + if((me->button() == Qt::LeftButton && controlPressed) + || (me->button() == Qt::MidButton)) { + emit requestShowLinkInNewTab(link); + } + } + } + return QWidget::eventFilter(o,e); +} + void SearchWidget::keyPressEvent(QKeyEvent *keyEvent) { if (keyEvent->key() == Qt::Key_Escape) @@ -144,7 +155,6 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) QMenu menu; QPoint point = contextMenuEvent->globalPos(); -#ifdef QT_CLUCENE_SUPPORT QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); if (!browser) return; @@ -155,22 +165,25 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) QUrl link = browser->anchorAt(point); - QAction *copyAction = menu.addAction(tr("&Copy") + - QString(QLatin1String("\t") + QString(QKeySequence(Qt::CTRL | Qt::Key_C)))); + QKeySequence keySeq(QKeySequence::Copy); + QAction *copyAction = menu.addAction(tr("&Copy") + QLatin1String("\t") + + keySeq.toString(QKeySequence::NativeText)); copyAction->setEnabled(QTextCursor(browser->textCursor()).hasSelection()); QAction *copyAnchorAction = menu.addAction(tr("Copy &Link Location")); copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid()); + keySeq = QKeySequence(Qt::CTRL); QAction *newTabAction = menu.addAction(tr("Open Link in New Tab") + - QString(QLatin1String("\t") + QString(QKeySequence(Qt::CTRL))) + + QLatin1String("\t") + keySeq.toString(QKeySequence::NativeText) + QLatin1String("LMB")); newTabAction->setEnabled(!link.isEmpty() && link.isValid()); menu.addSeparator(); + keySeq = QKeySequence::SelectAll; QAction *selectAllAction = menu.addAction(tr("Select All") + - QString(QLatin1String("\t") + QString(QKeySequence(Qt::CTRL | Qt::Key_A)))); + QLatin1String("\t") + keySeq.toString(QKeySequence::NativeText)); QAction *usedAction = menu.exec(mapToGlobal(contextMenuEvent->pos())); if (usedAction == copyAction) { @@ -191,19 +204,4 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) else if (usedAction == selectAllAction) { browser->selectAll(); } -#else - point = resultWidget->mapFromGlobal(point); - QUrl link = resultWidget->linkAt(point); - if (link.isEmpty() || !link.isValid()) - return; - - QAction *curTab = menu.addAction(tr("Open Link")); - QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - - QAction *action = menu.exec(mapToGlobal(contextMenuEvent->pos())); - if (curTab == action) - emit requestShowLink(link); - else if (newTab == action) - emit requestShowLinkInNewTab(link); -#endif } diff --git a/src/plugins/help/searchwidget.h b/src/plugins/help/searchwidget.h index 4a46815ba30086b1b349a36dda74195b3b968c50..a04b4fd542c51d6434c29edf9dfa7f82d3a16298 100644 --- a/src/plugins/help/searchwidget.h +++ b/src/plugins/help/searchwidget.h @@ -69,6 +69,7 @@ private slots: void searchingFinished(int hits); private: + bool eventFilter(QObject* o, QEvent *e); void keyPressEvent(QKeyEvent *keyEvent); void contextMenuEvent(QContextMenuEvent *contextMenuEvent); diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index f5e87f827ed5a0a54663f10b20018029676747d7..b6b7cce8a57e6a5a679f2938285a8d42d34ee796 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -52,7 +52,7 @@ QString ProjectExplorerSettingsPage::id() const QString ProjectExplorerSettingsPage::trName() const { - return tr("Build and Run Settings"); + return tr("Build and Run"); } QString ProjectExplorerSettingsPage::category() const diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.ui b/src/plugins/projectexplorer/projectexplorersettingspage.ui index d9104f52727ee8fd43b5bb63e3e5d9398f7a8633..f3cfc1fe74f2a8b6bae53ae285df26789411af7e 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.ui +++ b/src/plugins/projectexplorer/projectexplorersettingspage.ui @@ -6,15 +6,15 @@ <rect> <x>0</x> <y>0</y> - <width>541</width> - <height>358</height> + <width>296</width> + <height>152</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> - <string>Build Settings</string> + <string>Build and Run</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> @@ -24,15 +24,6 @@ </property> </widget> </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Run Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QCheckBox" name="buildProjectBeforeRunCheckBox"> <property name="text"> diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 650519a08c55c67fe41350def7415459104f7473..0095b6e5ba0e20458087e87a42c2cb36679ad85d 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -70,9 +70,9 @@ ToolChain *ToolChain::createMinGWToolChain(const QString &gcc, const QString &mi return new MinGWToolChain(gcc, mingwPath); } -ToolChain *ToolChain::createMSVCToolChain(const QString &name) +ToolChain *ToolChain::createMSVCToolChain(const QString &name, bool amd64 = false) { - return new MSVCToolChain(name); + return new MSVCToolChain(name, amd64); } ToolChain *ToolChain::createWinCEToolChain(const QString &name, const QString &platform) @@ -85,6 +85,7 @@ QStringList ToolChain::availableMSVCVersions() QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", QSettings::NativeFormat); QStringList versions = registry.allKeys(); +// qDebug() << "AVAILABLE MSVC VERSIONS:" << versions; return versions; } @@ -226,14 +227,15 @@ QString MinGWToolChain::makeCommand() const } -MSVCToolChain::MSVCToolChain(const QString &name) - : m_name(name), m_valuesSet(false) +MSVCToolChain::MSVCToolChain(const QString &name, bool amd64) + : m_name(name), m_valuesSet(false), m_amd64(amd64) { if (m_name.isEmpty()) { // Could be because system qt doesn't set this QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", QSettings::NativeFormat); - if (registry.allKeys().count()) - m_name = registry.allKeys().first(); + QStringList keys = registry.allKeys(); + if (keys.count()) + m_name = keys.first(); } } @@ -283,7 +285,12 @@ void MSVCToolChain::addToEnvironment(ProjectExplorer::Environment &env) return; QString path = registry.value(m_name).toString(); QString desc; - QString varsbat = path + "Common7\\Tools\\vsvars32.bat"; + QString varsbat; + if (m_amd64) + varsbat = path + "VC\\bin\\amd64\\vcvarsamd64.bat"; + else + varsbat = path + "Common7\\Tools\\vsvars32.bat"; +// qDebug() << varsbat; if (QFileInfo(varsbat).exists()) { QTemporaryFile tf(QDir::tempPath() + "\\XXXXXX.bat"); if (!tf.open()) @@ -378,8 +385,9 @@ void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env) { MSVCToolChain::addToEnvironment(env); QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", - QSettings::NativeFormat); + QSettings::NativeFormat); QString path = registry.value(m_name).toString(); + // Find MSVC path path += "/"; diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index 9356b7afe40bf7782207397e3cda09b7e0974599..86cc8b1b8b05c9e8899efd1dbf5417b549bb6ece 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -90,7 +90,7 @@ public: // Factory methods static ToolChain *createGccToolChain(const QString &gcc); static ToolChain *createMinGWToolChain(const QString &gcc, const QString &mingwPath); - static ToolChain *createMSVCToolChain(const QString &name); + static ToolChain *createMSVCToolChain(const QString &name, bool amd64); static ToolChain *createWinCEToolChain(const QString &name, const QString &platform); static QStringList availableMSVCVersions(); static QStringList supportedToolChains(); @@ -136,7 +136,7 @@ private: class MSVCToolChain : public ToolChain { public: - MSVCToolChain(const QString &name); + MSVCToolChain(const QString &name, bool amd64 = false); virtual QByteArray predefinedMacros(); virtual QList<HeaderPath> systemHeaderPaths(); virtual void addToEnvironment(ProjectExplorer::Environment &env); @@ -149,6 +149,7 @@ private: mutable QList<QPair<QString, QString> > m_values; mutable bool m_valuesSet; mutable ProjectExplorer::Environment m_lastEnvironment; + bool m_amd64; }; // TODO some stuff needs to be moved into here diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index a03e12b1fd1036622a4e04059e2be4d52b1ae711..2f4841741e446ab67897550490cff308595a8983 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -400,7 +400,7 @@ ProjectExplorer::ToolChain *Qt4Project::toolChain(const QString &buildConfigurat m_test = ToolChain::createMinGWToolChain(qmake_cxx, version->mingwDirectory()); //qDebug()<<"Mingw ToolChain"; } else if(t == ToolChain::MSVC) { - m_test = ToolChain::createMSVCToolChain(version->msvcVersion()); + m_test = ToolChain::createMSVCToolChain(version->msvcVersion(), version->isMSVC64Bit()); //qDebug()<<"MSVC ToolChain ("<<version->msvcVersion()<<")"; } else if(t == ToolChain::WINCE) { m_test = ToolChain::createWinCEToolChain(version->msvcVersion(), version->wincePlatform()); diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index 59efc8f678f520967c0b3e27daa78a938d71b0d8..e61904d1df8b79fff31cddb4a5ab02a8a2a50b6a 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -5,6 +5,7 @@ #include "qtversionmanager.h" #include <coreplugin/coreconstants.h> +#include <QtCore/QDebug> #include <QtCore/QDir> using namespace Qt4ProjectManager; @@ -254,25 +255,32 @@ void QtOptionsPageWidget::makeMingwVisible(bool visible) m_ui->mingwPath->setVisible(visible); } +void QtOptionsPageWidget::makeMSVCVisible(bool visible) +{ + m_ui->msvcLabel->setVisible(visible); + m_ui->msvcComboBox->setVisible(visible); + m_ui->msvcNotFoundLabel->setVisible(false); +} + void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) { - m_ui->msvcComboBox->setVisible(false); if (item) { int index = m_ui->qtdirList->indexOfTopLevelItem(item); m_ui->errorLabel->setText(""); ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType(); if (t == ProjectExplorer::ToolChain::MinGW) { - m_ui->msvcComboBox->setVisible(false); + makeMSVCVisible(false); makeMingwVisible(true); m_ui->mingwPath->setPath(m_versions.at(index)->mingwDirectory()); } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){ - m_ui->msvcComboBox->setVisible(false); + makeMSVCVisible(false); makeMingwVisible(false); QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions(); if (msvcEnvironments.count() == 0) { - } else if (msvcEnvironments.count() == 1) { + m_ui->msvcLabel->setVisible(true); + m_ui->msvcNotFoundLabel->setVisible(true); } else { - m_ui->msvcComboBox->setVisible(true); + makeMSVCVisible(true); bool block = m_ui->msvcComboBox->blockSignals(true); m_ui->msvcComboBox->clear(); foreach(const QString &msvcenv, msvcEnvironments) { @@ -284,7 +292,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) m_ui->msvcComboBox->blockSignals(block); } } else if (t == ProjectExplorer::ToolChain::INVALID) { - m_ui->msvcComboBox->setVisible(false); + makeMSVCVisible(false); makeMingwVisible(false); if (!m_versions.at(index)->isInstalled()) m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") @@ -292,14 +300,14 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) else m_ui->errorLabel->setText(tr("%1 is not a valid Qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); } else { //ProjectExplorer::ToolChain::GCC - m_ui->msvcComboBox->setVisible(false); + makeMSVCVisible(false); makeMingwVisible(false); m_ui->errorLabel->setText(tr("Found Qt version %1, using mkspec %2") .arg(m_versions.at(index)->qtVersionString(), m_versions.at(index)->mkspec())); } } else { - m_ui->msvcComboBox->setVisible(false); + makeMSVCVisible(false); makeMingwVisible(false); } } diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h index be4fee3d8fb0467d8882f57ce38109fd59b68e58..71e0a538e79b4e8d4e389f256ddd5e724c3e820e 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.h +++ b/src/plugins/qt4projectmanager/qtoptionspage.h @@ -72,6 +72,7 @@ private slots: void removeQtDir(); void updateState(); void makeMingwVisible(bool visible); + void makeMSVCVisible(bool visible); void onQtBrowsed(); void onMingwBrowsed(); void defaultChanged(int index); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 6905799ab0dcd82db5c1a93f7483cfd4d1d966cd..b743dd70c98fc61ecea796560373443cc2f5c9bf 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -45,6 +45,10 @@ #include <QtGui/QApplication> #include <QtGui/QDesktopServices> +#ifdef Q_OS_WIN32 +#include <windows.h> +#endif + using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; @@ -315,11 +319,11 @@ QtVersion::QtVersion(const QString &name, const QString &path, int id, bool isSy m_defaultConfigIsDebugAndRelease(true), m_hasDebuggingHelper(false) { - setPath(path); if (id == -1) m_id = getUniqueId(); else m_id = id; + setPath(path); } QtVersion::QtVersion(const QString &name, const QString &path) @@ -329,8 +333,8 @@ QtVersion::QtVersion(const QString &name, const QString &path) m_isSystemVersion(false), m_hasDebuggingHelper(false) { - setPath(path); m_id = getUniqueId(); + setPath(path); } QString QtVersion::name() const @@ -873,6 +877,21 @@ QString QtVersion::debuggingHelperLibrary() const } +bool QtVersion::isMSVC64Bit() const +{ + const QString make = qmakeCommand(); + qDebug() << make; + bool isAmd64 = false; +#ifdef Q_OS_WIN32 + DWORD binaryType = 0; + bool success = GetBinaryTypeW(make.utf16(), &binaryType) != 0; + if (success && binaryType == SCS_64BIT_BINARY) + isAmd64=true; +// qDebug() << "isAmd64:" << isAmd64 << binaryType; + return isAmd64; +#endif +} + QString QtVersion::buildDebuggingHelperLibrary() { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -888,7 +907,7 @@ QString QtVersion::buildDebuggingHelperLibrary() if (t == ProjectExplorer::ToolChain::MinGW) toolChain = ProjectExplorer::ToolChain::createMinGWToolChain("g++", mingwDirectory()); else if(t == ProjectExplorer::ToolChain::MSVC) - toolChain = ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion()); + toolChain = ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion(), isMSVC64Bit()); if (toolChain) { toolChain->addToEnvironment(env); delete toolChain; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index 35a1827dc658827e0c8171132190a9ad95ef7a52..4b2a495f7237219fc7d247872c84cf4c3fe18bd1 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -85,6 +85,7 @@ public: QString buildDebuggingHelperLibrary(); int uniqueId() const; + bool isMSVC64Bit() const; enum QmakeBuildConfig { diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/qt4projectmanager/qtversionmanager.ui index 9cf209006831cb33b271d4562dedde0f1fc7010c..3f9cc7303ac37d7566a173a4e349b2bb6aedbc14 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.ui +++ b/src/plugins/qt4projectmanager/qtversionmanager.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>811</width> - <height>505</height> + <width>577</width> + <height>477</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> @@ -16,8 +16,36 @@ <property name="title"> <string>Qt versions</string> </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="3"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" colspan="2"> + <widget class="QTreeWidget" name="qtdirList"> + <property name="uniformRowHeights"> + <bool>true</bool> + </property> + <property name="itemsExpandable"> + <bool>false</bool> + </property> + <property name="columnCount"> + <number>3</number> + </property> + <column> + <property name="text"> + <string>Name</string> + </property> + </column> + <column> + <property name="text"> + <string>Path</string> + </property> + </column> + <column> + <property name="text"> + <string>Debugging Helper</string> + </property> + </column> + </widget> + </item> + <item row="0" column="2"> <layout class="QVBoxLayout"> <property name="spacing"> <number>6</number> @@ -66,34 +94,6 @@ </item> </layout> </item> - <item row="0" column="0" colspan="3"> - <widget class="QTreeWidget" name="qtdirList"> - <property name="uniformRowHeights"> - <bool>true</bool> - </property> - <property name="itemsExpandable"> - <bool>false</bool> - </property> - <property name="columnCount"> - <number>3</number> - </property> - <column> - <property name="text"> - <string>Name</string> - </property> - </column> - <column> - <property name="text"> - <string>Path</string> - </property> - </column> - <column> - <property name="text"> - <string>Debugging Helper</string> - </property> - </column> - </widget> - </item> <item row="1" column="0"> <widget class="QLabel" name="versionNameLabel"> <property name="text"> @@ -101,7 +101,7 @@ </property> </widget> </item> - <item row="1" column="1" colspan="2"> + <item row="1" column="1"> <widget class="QLineEdit" name="nameEdit"/> </item> <item row="2" column="0"> @@ -111,6 +111,9 @@ </property> </widget> </item> + <item row="2" column="1"> + <widget class="Core::Utils::PathChooser" name="qtPath" native="true"/> + </item> <item row="3" column="0"> <widget class="QLabel" name="mingwLabel"> <property name="text"> @@ -118,33 +121,67 @@ </property> </widget> </item> - <item row="6" column="0" colspan="4"> - <widget class="QLabel" name="errorLabel"> + <item row="3" column="1"> + <widget class="Core::Utils::PathChooser" name="mingwPath" native="true"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="msvcLabel"> <property name="text"> - <string/> + <string>MSVC Version:</string> </property> </widget> </item> - <item row="4" column="1" colspan="2"> - <widget class="QComboBox" name="msvcComboBox"/> - </item> - <item row="2" column="1" colspan="2"> - <widget class="Core::Utils::PathChooser" name="qtPath" native="true"/> - </item> - <item row="3" column="1" colspan="2"> - <widget class="Core::Utils::PathChooser" name="mingwPath" native="true"/> + <item row="4" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <widget class="QComboBox" name="msvcComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="msvcNotFoundLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#ff0000;">Unable to detect MSVC version.</span></p></body></html></string> + </property> + </widget> + </item> + </layout> </item> - <item row="5" column="0"> + <item row="6" column="0"> <widget class="QLabel" name="label"> <property name="text"> <string>Debugging Helper:</string> </property> </widget> </item> - <item row="5" column="1" colspan="2"> + <item row="6" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QLabel" name="debuggingHelperStateLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> <string/> </property> @@ -166,11 +203,18 @@ </item> </layout> </item> + <item row="7" column="1"> + <widget class="QLabel" name="errorLabel"> + <property name="text"> + <string/> + </property> + </widget> + </item> </layout> </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> <widget class="QLabel" name="defaultLabel"> <property name="text"> diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 7a25b43c7fcf1cf5524550f7a3a007035fbef5f3..3ded8b3c8d84619a1bca22448c2ee8af5fd202ae 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -694,6 +694,66 @@ void BaseTextEditor::selectBlockDown() _q_matchParentheses(); } +void BaseTextEditor::copyLineUp() +{ + copyLineUpDown(true); +} + +void BaseTextEditor::copyLineDown() +{ + copyLineUpDown(false); +} + +void BaseTextEditor::copyLineUpDown(bool up) +{ + QTextCursor cursor = textCursor(); + QTextCursor move = cursor; + move.beginEditBlock(); + + bool hasSelection = cursor.hasSelection(); + + if (hasSelection) { + move.setPosition(cursor.selectionStart()); + move.movePosition(QTextCursor::StartOfBlock); + move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor); + move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + } else { + move.movePosition(QTextCursor::StartOfBlock); + move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + } + + QString text = move.selectedText(); + + if (up) { + move.setPosition(cursor.selectionStart()); + move.movePosition(QTextCursor::StartOfBlock); + move.insertBlock(); + move.movePosition(QTextCursor::Left); + } else { + move.movePosition(QTextCursor::EndOfBlock); + if (move.atBlockStart()) { + move.movePosition(QTextCursor::NextBlock); + move.insertBlock(); + move.movePosition(QTextCursor::Left); + } else { + move.insertBlock(); + } + } + + int start = move.position(); + move.clearSelection(); + move.insertText(text); + int end = move.position(); + + move.setPosition(start); + move.setPosition(end, QTextCursor::KeepAnchor); + + indent(document(), move, QChar::Null); + move.endEditBlock(); + + setTextCursor(move); +} + void BaseTextEditor::moveLineUp() { moveLineUpDown(true); diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index e45ab281f953b2faef8e59a4c162a12f9f3ebc82..612a9fe4efa2964b1c830f9ae18a8250e513842b 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -388,6 +388,9 @@ public slots: void moveLineUp(); void moveLineDown(); + void copyLineUp(); + void copyLineDown(); + void cleanWhitespace(); signals: @@ -513,6 +516,7 @@ private: void handleHomeKey(bool anchor); void handleBackspaceKey(); void moveLineUpDown(bool up); + void copyLineUpDown(bool up); void saveCurrentCursorPositionForNavigation(); void drawFoldingMarker(QPainter *painter, const QPalette &pal, diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 9aa4e1609b2253956520c2f58acf7ee5b7ea3270..3356dc50f09b917975361dff4e582a08f13a20b0 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -85,6 +85,8 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context, m_selectBlockDownAction = 0; m_moveLineUpAction = 0; m_moveLineDownAction = 0; + m_copyLineUpAction = 0; + m_copyLineDownAction = 0; m_contextId << Core::UniqueIDManager::instance()->uniqueIdentifier(context); @@ -251,6 +253,16 @@ void TextEditorActionHandler::createActions() command = am->registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down"))); connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown())); + + m_copyLineUpAction= new QAction(tr("Copy Line Up"), this); + command = am->registerAction(m_copyLineUpAction, Constants::COPY_LINE_UP, m_contextId); + command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Up"))); + connect(m_copyLineUpAction, SIGNAL(triggered()), this, SLOT(copyLineUp())); + + m_copyLineDownAction= new QAction(tr("Copy Line Down"), this); + command = am->registerAction(m_copyLineDownAction, Constants::COPY_LINE_DOWN, m_contextId); + command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Down"))); + connect(m_copyLineDownAction, SIGNAL(triggered()), this, SLOT(copyLineDown())); } bool TextEditorActionHandler::supportsAction(const QString & /*id */) const @@ -406,6 +418,8 @@ FUNCTION(selectBlockUp) FUNCTION(selectBlockDown) FUNCTION(moveLineUp) FUNCTION(moveLineDown) +FUNCTION(copyLineUp) +FUNCTION(copyLineDown) void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) { diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 1061b7a9674c6eaf60abe361477b981b0c33b893..c1140413681c01c50ec38c8c38254d7b8a106fb6 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -111,6 +111,8 @@ private slots: void selectBlockDown(); void moveLineUp(); void moveLineDown(); + void copyLineUp(); + void copyLineDown(); void updateCurrentEditor(Core::IEditor *editor); private: @@ -143,6 +145,8 @@ private: QAction *m_selectBlockDownAction; QAction *m_moveLineUpAction; QAction *m_moveLineDownAction; + QAction *m_copyLineUpAction; + QAction *m_copyLineDownAction; uint m_optionalActions; QPointer<BaseTextEditor> m_currentEditor; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 8278a224fc549c31ff299835d4484f5baa7478e0..2545fc66a34efc6d69f359be9fcbc12b6396f8cb 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -53,6 +53,8 @@ const char * const SELECT_BLOCK_UP = "TextEditor.SelectBlockUp"; const char * const SELECT_BLOCK_DOWN = "TextEditor.SelectBlockDown"; const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp"; const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown"; +const char * const COPY_LINE_UP = "TextEditor.CopyLineUp"; +const char * const COPY_LINE_DOWN = "TextEditor.CopyLineDown"; const char * const CUT_LINE = "TextEditor.CutLine"; const char * const DELETE_LINE = "TextEditor.DeleteLine"; const char * const DELETE_WORD = "TextEditor.DeleteWord"; diff --git a/src/shared/help/bookmarkmanager.cpp b/src/shared/help/bookmarkmanager.cpp index 626a9ccf8cc0b5f894f44b2f2f1e0ab99cf2b299..7052495fcef9f6979accf102bc671a7699cf342e 100644 --- a/src/shared/help/bookmarkmanager.cpp +++ b/src/shared/help/bookmarkmanager.cpp @@ -523,58 +523,57 @@ void BookmarkWidget::focusInEvent(QFocusEvent *e) bool BookmarkWidget::eventFilter(QObject *object, QEvent *e) { - if (object == this && e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent*>(e); + if ((object == this) || (object == treeView->viewport())) { QModelIndex index = treeView->currentIndex(); - switch (ke->key()) { + if (e->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast<QKeyEvent*>(e); if (index.isValid() && searchField->text().isEmpty()) { - case Qt::Key_F2: { - const QModelIndex& source = filterBookmarkModel->mapToSource(index); - QStandardItem *item = - bookmarkManager->treeBookmarkModel()->itemFromIndex(source); + if (ke->key() == Qt::Key_F2) { + QStandardItem *item = bookmarkManager->treeBookmarkModel() + ->itemFromIndex(filterBookmarkModel->mapToSource(index)); if (item) { item->setEditable(true); treeView->edit(index); item->setEditable(false); } - } break; - - case Qt::Key_Delete: { + } else if (ke->key() == Qt::Key_Delete) { bookmarkManager->removeBookmarkItem(treeView, filterBookmarkModel->mapToSource(index)); - } break; + } } - case Qt::Key_Up: - case Qt::Key_Down: - treeView->subclassKeyPressEvent(ke); - break; - - case Qt::Key_Enter: { - case Qt::Key_Return: - index = treeView->selectionModel()->currentIndex(); - if (index.isValid()) { - QString data = index.data(Qt::UserRole + 10).toString(); - if (!data.isEmpty() && data != QLatin1String("Folder")) - emit requestShowLink(data); - } - } break; + switch (ke->key()) { + default: break; + case Qt::Key_Up: { + case Qt::Key_Down: + treeView->subclassKeyPressEvent(ke); + } break; - case Qt::Key_Escape: - emit escapePressed(); - break; + case Qt::Key_Enter: { + case Qt::Key_Return: + index = treeView->selectionModel()->currentIndex(); + if (index.isValid()) { + QString data = index.data(Qt::UserRole + 10).toString(); + if (!data.isEmpty() && data != QLatin1String("Folder")) + emit requestShowLink(data); + } + } break; - default: - break; - } - } - else if (object == treeView->viewport() && e->type() == QEvent::MouseButtonRelease) { - const QModelIndex& index = treeView->currentIndex(); - QMouseEvent *me = static_cast<QMouseEvent*>(e); - if (index.isValid() && (me->button() == Qt::MidButton)) { - QString data = index.data(Qt::UserRole + 10).toString(); - if (!data.isEmpty() && data != QLatin1String("Folder")) - Help::Internal::CentralWidget::instance()->setSourceInNewTab(data); + case Qt::Key_Escape: { + emit escapePressed(); + } break; + } + } else if (e->type() == QEvent::MouseButtonRelease) { + if (index.isValid()) { + QMouseEvent *me = static_cast<QMouseEvent*>(e); + bool controlPressed = me->modifiers() & Qt::ControlModifier; + if(((me->button() == Qt::LeftButton) && controlPressed) + || (me->button() == Qt::MidButton)) { + QString data = index.data(Qt::UserRole + 10).toString(); + if (!data.isEmpty() && data != QLatin1String("Folder")) + Help::Internal::CentralWidget::instance()->setSourceInNewTab(data); + } + } } } return QWidget::eventFilter(object, e); diff --git a/src/shared/help/contentwindow.cpp b/src/shared/help/contentwindow.cpp index 1e69effb365c969a0e63771f2e10071242d6f43e..ca722034333915a02b925ac4c52e2d2ed33f288f 100644 --- a/src/shared/help/contentwindow.cpp +++ b/src/shared/help/contentwindow.cpp @@ -104,19 +104,26 @@ void ContentWindow::keyPressEvent(QKeyEvent *e) bool ContentWindow::eventFilter(QObject *o, QEvent *e) { - if (m_contentWidget && o == m_contentWidget->viewport() && e->type() - == QEvent::MouseButtonRelease) { + if (m_contentWidget && o == m_contentWidget->viewport() + && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast<QMouseEvent*>(e); - if (m_contentWidget->indexAt(me->pos()).isValid() - && me->button() == Qt::LeftButton) { - itemClicked(m_contentWidget->currentIndex()); - } else if (m_contentWidget->indexAt(me->pos()).isValid() - && me->button() == Qt::MidButton) { - QHelpContentModel *contentModel = - qobject_cast<QHelpContentModel*>(m_contentWidget->model()); - QHelpContentItem *itm = - contentModel->contentItemAt(m_contentWidget->currentIndex()); - Help::Internal::CentralWidget::instance()->setSourceInNewTab(itm->url()); + QModelIndex index = m_contentWidget->indexAt(me->pos()); + QItemSelectionModel *sm = m_contentWidget->selectionModel(); + + Qt::MouseButtons button = me->button(); + if (index.isValid() && (sm && sm->isSelected(index))) { + if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier)) + || (button == Qt::MidButton)) { + QHelpContentModel *contentModel = + qobject_cast<QHelpContentModel*>(m_contentWidget->model()); + if (contentModel) { + QHelpContentItem *itm = contentModel->contentItemAt(index); + if (itm && !isPdfFile(itm)) + Help::Internal::CentralWidget::instance()->setSourceInNewTab(itm->url()); + } + } else if (button == Qt::LeftButton) { + itemClicked(index); + } } } return QWidget::eventFilter(o, e); @@ -127,16 +134,19 @@ void ContentWindow::showContextMenu(const QPoint &pos) if (!m_contentWidget->indexAt(pos).isValid()) return; - QMenu menu; - QAction *curTab = menu.addAction(tr("Open Link")); - QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - menu.move(m_contentWidget->mapToGlobal(pos)); - QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); QHelpContentItem *itm = contentModel->contentItemAt(m_contentWidget->currentIndex()); + QMenu menu; + QAction *curTab = menu.addAction(tr("Open Link")); + QAction *newTab = menu.addAction(tr("Open Link in New Tab")); + if (isPdfFile(itm)) + newTab->setEnabled(false); + + menu.move(m_contentWidget->mapToGlobal(pos)); + QAction *action = menu.exec(); if (curTab == action) emit linkActivated(itm->url()); @@ -146,12 +156,18 @@ void ContentWindow::showContextMenu(const QPoint &pos) void ContentWindow::itemClicked(const QModelIndex &index) { - if (!index.isValid()) - return; QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_contentWidget->model()); - QHelpContentItem *itm = - contentModel->contentItemAt(index); - if (itm) - emit linkActivated(itm->url()); + + if (contentModel) { + QHelpContentItem *itm = contentModel->contentItemAt(index); + if (itm) + emit linkActivated(itm->url()); + } +} + +bool ContentWindow::isPdfFile(QHelpContentItem *item) const +{ + const QString &path = item->url().path(); + return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive); } diff --git a/src/shared/help/contentwindow.h b/src/shared/help/contentwindow.h index 86a21197473e5ff0da3be52b2e38467864e7a94d..81eee24e57f5090f01ae1923f974be11e7b4a7bf 100644 --- a/src/shared/help/contentwindow.h +++ b/src/shared/help/contentwindow.h @@ -37,6 +37,7 @@ QT_BEGIN_NAMESPACE class QHelpEngine; +class QHelpContentItem; class QHelpContentWidget; QT_END_NAMESPACE @@ -65,6 +66,7 @@ private: void focusInEvent(QFocusEvent *e); void keyPressEvent(QKeyEvent *e); bool eventFilter(QObject *o, QEvent *e); + bool isPdfFile(QHelpContentItem *item) const; QHelpEngine *m_helpEngine; QHelpContentWidget *m_contentWidget; diff --git a/src/shared/help/helpviewer.cpp b/src/shared/help/helpviewer.cpp index 150658ca9db4696423300bc904a794728e325eb2..fc87db977605a1d21f752572d3d754bb6960ce3b 100644 --- a/src/shared/help/helpviewer.cpp +++ b/src/shared/help/helpviewer.cpp @@ -146,6 +146,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op, class HelpPage : public QWebPage { + friend class HelpViewer; public: HelpPage(Help::Internal::CentralWidget *central, QHelpEngine *engine, QObject *parent); @@ -158,11 +159,17 @@ protected: private: Help::Internal::CentralWidget *centralWidget; QHelpEngine *helpEngine; + Qt::MouseButtons m_pressedButtons; + Qt::KeyboardModifiers m_keyboardModifiers; }; HelpPage::HelpPage(Help::Internal::CentralWidget *central, QHelpEngine *engine, QObject *parent) - : QWebPage(parent), centralWidget(central), helpEngine(engine) -{ + : QWebPage(parent) + , centralWidget(central) + , helpEngine(engine) + , m_pressedButtons(Qt::NoButton) + , m_keyboardModifiers(Qt::NoModifier) +{ } QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) @@ -184,14 +191,18 @@ static bool isLocalUrl(const QUrl &url) } bool HelpPage::acceptNavigationRequest(QWebFrame *, - const QNetworkRequest &request, QWebPage::NavigationType) + const QNetworkRequest &request, QWebPage::NavigationType type) { const QUrl &url = request.url(); if (isLocalUrl(url)) { - if (url.path().endsWith(QLatin1String("pdf"))) { - QString fileName = url.toString(); - fileName = QDir::tempPath() + QDir::separator() + fileName.right - (fileName.length() - fileName.lastIndexOf(QChar('/'))); + const QString& path = url.path(); + if (path.endsWith(QLatin1String(".pdf"))) { + const int lastDash = path.lastIndexOf(QChar('/')); + QString fileName = QDir::tempPath() + QDir::separator(); + if (lastDash < 0) + fileName += path; + else + fileName += path.mid(lastDash + 1, path.length()); QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { @@ -201,6 +212,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, QDesktopServices::openUrl(QUrl(tmpFile.fileName())); return false; } + + if (type == QWebPage::NavigationTypeLinkClicked + && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { + HelpViewer* viewer = centralWidget->newEmptyTab(); + if (viewer) + centralWidget->setSource(url); + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; + return false; + } return true; } @@ -209,7 +231,10 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, } HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *parent) - : QWebView(parent), helpEngine(engine), parentWidget(parent) + : QWebView(parent) + , helpEngine(engine) + , parentWidget(parent) + , multiTabsAllowed(true) { setPage(new HelpPage(parent, helpEngine, this)); settings()->setAttribute(QWebSettings::PluginsEnabled, false); @@ -219,8 +244,10 @@ HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *paren QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); action->setText(tr("Open Link in New Tab")); - if (!parent) + if (!parent) { + multiTabsAllowed = false; action->setVisible(false); + } pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); @@ -306,6 +333,16 @@ void HelpViewer::actionChanged() emit forwardAvailable(a->isEnabled()); } +void HelpViewer::mousePressEvent(QMouseEvent *event) +{ + HelpPage *currentPage = static_cast<HelpPage*>(page()); + if ((currentPage != 0) && multiTabsAllowed) { + currentPage->m_pressedButtons = event->buttons(); + currentPage->m_keyboardModifiers = event->modifiers(); + } + QWebView::mousePressEvent(event); +} + #else // !defined(QT_NO_WEBKIT) HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *parent) diff --git a/src/shared/help/helpviewer.h b/src/shared/help/helpviewer.h index 8ed876032b40b632d71a818bf49c0581cdd5acaa..b240d3ce9006a184bfbd1ed7a711af1779c3ea59 100644 --- a/src/shared/help/helpviewer.h +++ b/src/shared/help/helpviewer.h @@ -102,6 +102,7 @@ Q_SIGNALS: protected: virtual void wheelEvent(QWheelEvent *); void mouseReleaseEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *event); private Q_SLOTS: void actionChanged(); @@ -110,6 +111,7 @@ private: QHelpEngine *helpEngine; Help::Internal::CentralWidget* parentWidget; QUrl homeUrl; + bool multiTabsAllowed; }; #else diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp index fd01473e1eba5cf4a50b980e85246e945efd38e0..1b79ed00ae8aba6f78596baf543f551b9fdf48ae 100644 --- a/src/shared/help/indexwindow.cpp +++ b/src/shared/help/indexwindow.cpp @@ -108,10 +108,9 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e) m_indexWidget->setCurrentIndex(idx); break; case Qt::Key_Escape: - emit escapePressed(); + emit escapePressed(); break; - default: - ; + default: ; // stop complaining } } else if (obj == m_indexWidget && e->type() == QEvent::ContextMenu) { QContextMenuEvent *ctxtEvent = static_cast<QContextMenuEvent*>(e); @@ -126,42 +125,18 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e) if (curTab == action) m_indexWidget->activateCurrentItem(); else if (newTab == action) { - QHelpIndexModel *model = - qobject_cast<QHelpIndexModel*>(m_indexWidget->model()); - QString keyword = model->data(idx, Qt::DisplayRole).toString(); - if (model) { - QMap<QString, QUrl> links = model->linksForKeyword(keyword); - if (links.count() == 1) { - Help::Internal::CentralWidget::instance()-> - setSourceInNewTab(links.constBegin().value()); - } else { - TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) { - Help::Internal::CentralWidget::instance()->setSourceInNewTab(tc.link()); - } - } - } + open(m_indexWidget, idx); } } } else if (m_indexWidget && obj == m_indexWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e); QModelIndex idx = m_indexWidget->indexAt(mouseEvent->pos()); - if (idx.isValid() && mouseEvent->button()==Qt::MidButton) { - QHelpIndexModel *model = - qobject_cast<QHelpIndexModel*>(m_indexWidget->model()); - QString keyword = model->data(idx, Qt::DisplayRole).toString(); - if (model) { - QMap<QString, QUrl> links = model->linksForKeyword(keyword); - if (links.count() > 1) { - TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) { - Help::Internal::CentralWidget::instance()->setSourceInNewTab(tc.link()); - } - } else if (links.count() == 1) { - Help::Internal::CentralWidget::instance()-> - setSourceInNewTab(links.constBegin().value()); - } + if (idx.isValid()) { + Qt::MouseButtons button = mouseEvent->button(); + if (((button == Qt::LeftButton) && (mouseEvent->modifiers() & Qt::ControlModifier)) + || (button == Qt::MidButton)) { + open(m_indexWidget, idx); } } } @@ -198,3 +173,28 @@ void IndexWindow::focusInEvent(QFocusEvent *e) m_searchLineEdit->setFocus(); } } + +void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) +{ + QHelpIndexModel *model = qobject_cast<QHelpIndexModel*>(indexWidget->model()); + if (model) { + QString keyword = model->data(index, Qt::DisplayRole).toString(); + QMap<QString, QUrl> links = model->linksForKeyword(keyword); + + QUrl url; + if (links.count() > 1) { + TopicChooser tc(this, keyword, links); + if (tc.exec() == QDialog::Accepted) + url = tc.link(); + } else if (links.count() == 1) { + url = links.constBegin().value(); + } else { + return; + } + + if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive)) + Help::Internal::CentralWidget::instance()->setSource(url); + else + Help::Internal::CentralWidget::instance()->setSourceInNewTab(url); + } +} diff --git a/src/shared/help/indexwindow.h b/src/shared/help/indexwindow.h index 6cb8b86932402d7e386c674753682443bab6c4e6..21d32fbf0eb103d94fa20f2e532f7158119ca4d3 100644 --- a/src/shared/help/indexwindow.h +++ b/src/shared/help/indexwindow.h @@ -38,6 +38,7 @@ QT_BEGIN_NAMESPACE class QHelpIndexWidget; class QHelpEngine; +class QModelIndex; QT_END_NAMESPACE @@ -69,6 +70,7 @@ private slots: private: bool eventFilter(QObject *obj, QEvent *e); void focusInEvent(QFocusEvent *e); + void open(QHelpIndexWidget* indexWidget, const QModelIndex &index); QLineEdit *m_searchLineEdit; QHelpIndexWidget *m_indexWidget;