diff options
author | axis <qt-info@nokia.com> | 2010-02-23 15:23:05 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2010-02-23 15:23:05 (GMT) |
commit | f67062af3a076468442c29127cb48bb13937ce0e (patch) | |
tree | a12cd4c644fb528dd5f95cb58559732a0b8b6311 /tools | |
parent | a670009fd378d48ff891602ec31204614e8a476f (diff) | |
parent | c15307e9e916aa613096275919ca91deba64454f (diff) | |
download | Qt-f67062af3a076468442c29127cb48bb13937ce0e.zip Qt-f67062af3a076468442c29127cb48bb13937ce0e.tar.gz Qt-f67062af3a076468442c29127cb48bb13937ce0e.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts:
mkspecs/features/symbian/qt.prf
qmake/Makefile.unix
qmake/Makefile.win32
qmake/Makefile.win32-g++
qmake/Makefile.win32-g++-sh
qmake/generators/symbian/initprojectdeploy_symbian.cpp
src/src.pro
Diffstat (limited to 'tools')
86 files changed, 1719 insertions, 3322 deletions
diff --git a/tools/assistant/lib/qclucenefieldnames.cpp b/tools/assistant/lib/qclucenefieldnames.cpp index 1a94291..5c3a474 100644 --- a/tools/assistant/lib/qclucenefieldnames.cpp +++ b/tools/assistant/lib/qclucenefieldnames.cpp @@ -43,7 +43,6 @@ QT_BEGIN_NAMESPACE -namespace qt { namespace fulltextsearch { namespace clucene { const QString AttributeField(QLatin1String("attribute")); @@ -54,6 +53,5 @@ const QString TitleField(QLatin1String("title")); const QString TitleTokenizedField(QLatin1String("titleTokenized")); } // namespace clucene } // namespace fulltextsearch -} // namespace qt QT_END_NAMESPACE diff --git a/tools/assistant/lib/qclucenefieldnames_p.h b/tools/assistant/lib/qclucenefieldnames_p.h index ae13515..a611382 100644 --- a/tools/assistant/lib/qclucenefieldnames_p.h +++ b/tools/assistant/lib/qclucenefieldnames_p.h @@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE -namespace qt { namespace fulltextsearch { namespace clucene { extern const QString AttributeField; @@ -58,7 +57,6 @@ namespace clucene { extern const QString TitleTokenizedField; } // namespace clucene } // namespace fulltextsearch -} // namespace qt QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchengine.cpp b/tools/assistant/lib/qhelpsearchengine.cpp index 7c2635d..9914efa 100644 --- a/tools/assistant/lib/qhelpsearchengine.cpp +++ b/tools/assistant/lib/qhelpsearchengine.cpp @@ -63,9 +63,9 @@ QT_BEGIN_NAMESPACE #if defined(QT_CLUCENE_SUPPORT) - using namespace qt::fulltextsearch::clucene; + using namespace fulltextsearch::clucene; #else - using namespace qt::fulltextsearch::std; + using namespace fulltextsearch::std; #endif class QHelpSearchEnginePrivate : public QObject @@ -195,7 +195,7 @@ private: QHelpSearchQueryWidget *queryWidget; QHelpSearchResultWidget *resultWidget; - qt::fulltextsearch::QHelpSearchIndexReader *indexReader; + fulltextsearch::QHelpSearchIndexReader *indexReader; QHelpSearchIndexWriter *indexWriter; QPointer<QHelpEngineCore> helpEngine; diff --git a/tools/assistant/lib/qhelpsearchindexreader.cpp b/tools/assistant/lib/qhelpsearchindexreader.cpp index 92d7658..e79fca6 100644 --- a/tools/assistant/lib/qhelpsearchindexreader.cpp +++ b/tools/assistant/lib/qhelpsearchindexreader.cpp @@ -43,8 +43,7 @@ QT_BEGIN_NAMESPACE -namespace qt { - namespace fulltextsearch { +namespace fulltextsearch { QHelpSearchIndexReader::QHelpSearchIndexReader() : QThread() @@ -100,7 +99,6 @@ QList<QHelpSearchEngine::SearchHit> QHelpSearchIndexReader::hits(int start, } - } // namespace fulltextsearch -} // namespace qt +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp index ee6dcfb..c2274c4 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp @@ -58,9 +58,8 @@ QT_BEGIN_NAMESPACE -namespace qt { - namespace fulltextsearch { - namespace clucene { +namespace fulltextsearch { +namespace clucene { QHelpSearchIndexReaderClucene::QHelpSearchIndexReaderClucene() : QHelpSearchIndexReader() @@ -476,8 +475,7 @@ void QHelpSearchIndexReaderClucene::boostSearchHits(const QHelpEngineCore &engin } } - } // namespace clucene - } // namespace fulltextsearch -} // namespace qt +} // namespace clucene +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h b/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h index 04c0088..7f53733 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h +++ b/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h @@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE -namespace qt { namespace fulltextsearch { namespace clucene { @@ -109,7 +108,6 @@ private: } // namespace clucene } // namespace fulltextsearch -} // namespace qt QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexreader_default.cpp b/tools/assistant/lib/qhelpsearchindexreader_default.cpp index d2241a5..11a50d9 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_default.cpp +++ b/tools/assistant/lib/qhelpsearchindexreader_default.cpp @@ -52,9 +52,8 @@ QT_BEGIN_NAMESPACE -namespace qt { - namespace fulltextsearch { - namespace std { +namespace fulltextsearch { +namespace std { namespace { QStringList split( const QString &str ) @@ -607,8 +606,7 @@ void QHelpSearchIndexReaderDefault::run() emit searchingFinished(hitList.count()); } - } // namespace std - } // namespace fulltextsearch -} // namespace qt +} // namespace std +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexreader_default_p.h b/tools/assistant/lib/qhelpsearchindexreader_default_p.h index 8c80608..b30fa4b 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_default_p.h +++ b/tools/assistant/lib/qhelpsearchindexreader_default_p.h @@ -64,9 +64,8 @@ QT_BEGIN_NAMESPACE struct Entry; struct PosEntry; -namespace qt { - namespace fulltextsearch { - namespace std { +namespace fulltextsearch { +namespace std { class Reader { @@ -127,9 +126,8 @@ private: Reader m_reader; }; - } // namespace std - } // namespace fulltextsearch -} // namespace qt +} // namespace std +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexreader_p.h b/tools/assistant/lib/qhelpsearchindexreader_p.h index b309f46..4d27c0f 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_p.h +++ b/tools/assistant/lib/qhelpsearchindexreader_p.h @@ -66,8 +66,7 @@ QT_BEGIN_NAMESPACE class QHelpEngineCore; -namespace qt { - namespace fulltextsearch { +namespace fulltextsearch { class QHelpSearchIndexReader : public QThread { @@ -100,8 +99,7 @@ private: virtual void run()=0; }; - } // namespace fulltextsearch -} // namespace qt +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index 6e49e54..d9dcec5 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -64,9 +64,8 @@ QT_BEGIN_NAMESPACE -namespace qt { - namespace fulltextsearch { - namespace clucene { +namespace fulltextsearch { +namespace clucene { // taken from qtexthtmlparser static const struct QTextHtmlEntity @@ -893,8 +892,7 @@ void QHelpSearchIndexWriter::closeIndexWriter(QCLuceneIndexWriter *writer) #endif } - } // namespace clucene - } // namespace fulltextsearch -} // namespace qt +} // namespace clucene +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h b/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h index 91b8abd..db1e533 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h @@ -69,9 +69,8 @@ QT_BEGIN_NAMESPACE class QCLuceneIndexWriter; -namespace qt { - namespace fulltextsearch { - namespace clucene { +namespace fulltextsearch { +namespace clucene { class QHelpSearchIndexWriter : public QThread { @@ -116,9 +115,9 @@ private: QString m_indexFilesFolder; }; - } // namespace clucene - } // namespace fulltextsearch } // namespace clucene +} // namespace fulltextsearch + QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexwriter_default.cpp b/tools/assistant/lib/qhelpsearchindexwriter_default.cpp index 6d09fb8..cb3e49c 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_default.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_default.cpp @@ -55,9 +55,8 @@ QT_BEGIN_NAMESPACE -namespace qt { - namespace fulltextsearch { - namespace std { +namespace fulltextsearch { +namespace std { Writer::Writer(const QString &path) : indexPath(path) @@ -379,8 +378,7 @@ QString QHelpSearchIndexWriter::removeNamespace(const QString namespaces, return value; } - } // namespace std - } // namespace fulltextsearch -} // namespace qt +} // namespace std +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchindexwriter_default_p.h b/tools/assistant/lib/qhelpsearchindexwriter_default_p.h index b222203..625cb84 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_default_p.h +++ b/tools/assistant/lib/qhelpsearchindexwriter_default_p.h @@ -65,9 +65,8 @@ QT_BEGIN_NAMESPACE -namespace qt { - namespace fulltextsearch { - namespace std { +namespace fulltextsearch { +namespace std { class Writer { @@ -123,9 +122,8 @@ private: QString m_indexFilesFolder; }; - } // namespace std - } // namespace fulltextsearch -} // namespace qt +} // namespace std +} // namespace fulltextsearch QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 4677458..cd343bd 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -21,6 +21,7 @@ HEADERS += aboutdialog.h \ bookmarkfiltermodel.h \ bookmarkitem.h \ bookmarkmanager.h \ + bookmarkmanagerwidget.h \ bookmarkmodel.h \ centralwidget.h \ cmdlineparser.h \ @@ -49,6 +50,7 @@ SOURCES += aboutdialog.cpp \ bookmarkfiltermodel.cpp \ bookmarkitem.cpp \ bookmarkmanager.cpp \ + bookmarkmanagerwidget.cpp \ bookmarkmodel.cpp \ centralwidget.cpp \ cmdlineparser.cpp \ @@ -72,6 +74,7 @@ SOURCES += aboutdialog.cpp \ ../shared/collectionconfiguration.cpp \ FORMS += bookmarkdialog.ui \ + bookmarkmanagerwidget.ui \ bookmarkwidget.ui \ filternamedialog.ui \ installdialog.ui \ diff --git a/tools/assistant/tools/assistant/bookmarkdialog.cpp b/tools/assistant/tools/assistant/bookmarkdialog.cpp index c053b62..8b195c1 100644 --- a/tools/assistant/tools/assistant/bookmarkdialog.cpp +++ b/tools/assistant/tools/assistant/bookmarkdialog.cpp @@ -105,6 +105,11 @@ BookmarkDialog::~BookmarkDialog() TRACE_OBJ } +bool BookmarkDialog::isRootItem(const QModelIndex &index) const +{ + return !bookmarkTreeModel->parent(index).isValid(); +} + bool BookmarkDialog::eventFilter(QObject *object, QEvent *event) { TRACE_OBJ @@ -115,9 +120,12 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *event) QKeyEvent *ke = static_cast<QKeyEvent*>(event); switch (ke->key()) { case Qt::Key_F2: { - bookmarkModel->setItemsEditable(true); - ui.treeView->edit(ui.treeView->currentIndex()); - bookmarkModel->setItemsEditable(false); + const QModelIndex &index = ui.treeView->currentIndex(); + if (!isRootItem(index)) { + bookmarkModel->setItemsEditable(true); + ui.treeView->edit(index); + bookmarkModel->setItemsEditable(false); + } } break; default: break; } @@ -212,13 +220,17 @@ void BookmarkDialog::textChanged(const QString& text) void BookmarkDialog::customContextMenuRequested(const QPoint &point) { TRACE_OBJ + const QModelIndex &index = ui.treeView->currentIndex(); + if (isRootItem(index)) + return; // check if we go to rename the "Bookmarks Menu", bail + QMenu menu(QLatin1String(""), this); QAction *renameItem = menu.addAction(tr("Rename Folder")); QAction *picked = menu.exec(ui.treeView->mapToGlobal(point)); if (picked == renameItem) { bookmarkModel->setItemsEditable(true); - ui.treeView->edit(ui.treeView->currentIndex()); + ui.treeView->edit(index); bookmarkModel->setItemsEditable(false); } } diff --git a/tools/assistant/tools/assistant/bookmarkdialog.h b/tools/assistant/tools/assistant/bookmarkdialog.h index ba38c7a..e177af6 100644 --- a/tools/assistant/tools/assistant/bookmarkdialog.h +++ b/tools/assistant/tools/assistant/bookmarkdialog.h @@ -58,6 +58,7 @@ public: ~BookmarkDialog(); private: + bool isRootItem(const QModelIndex &index) const; bool eventFilter(QObject *object, QEvent *event); private slots: diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index 8fba811..70f562e 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -41,6 +41,7 @@ #include "tracer.h" #include "bookmarkmanager.h" +#include "bookmarkmanagerwidget.h" #include "bookmarkdialog.h" #include "bookmarkfiltermodel.h" #include "bookmarkitem.h" @@ -48,15 +49,11 @@ #include "centralwidget.h" #include "helpenginewrapper.h" -#include <QtGui/QFileDialog> #include <QtGui/QMenu> #include <QtGui/QKeyEvent> #include <QtGui/QMessageBox> #include <QtGui/QSortFilterProxyModel> -#include <QFile> -#include "xbelsupport.h" - QT_BEGIN_NAMESPACE // -- BookmarkManager::BookmarkWidget @@ -163,6 +160,7 @@ BookmarkManager::BookmarkManager() , bookmarkModel(new BookmarkModel) , bookmarkWidget(new BookmarkWidget) , bookmarkTreeView(new BookmarkTreeView) + , bookmarkManagerWidget(0) { TRACE_OBJ bookmarkWidget->installEventFilter(this); @@ -187,6 +185,10 @@ BookmarkManager::BookmarkManager() connect(&HelpEngineWrapper::instance(), SIGNAL(setupFinished()), this, SLOT(setupFinished())); + connect(bookmarkModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, + SLOT(refeshBookmarkMenu())); + connect(bookmarkModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, + SLOT(refeshBookmarkMenu())); connect(bookmarkModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(refeshBookmarkMenu())); } @@ -194,7 +196,9 @@ BookmarkManager::BookmarkManager() BookmarkManager::~BookmarkManager() { TRACE_OBJ + delete bookmarkManagerWidget; HelpEngineWrapper::instance().setBookmarks(bookmarkModel->bookmarks()); + delete bookmarkModel; } void BookmarkManager::removeItem(const QModelIndex &index) @@ -323,10 +327,8 @@ void BookmarkManager::setupFinished() void BookmarkManager::addBookmark() { TRACE_OBJ - if (CentralWidget *widget = CentralWidget::instance()) { - showBookmarkDialog(widget->currentTitle(), - widget->currentSource().toString()); - } + if (CentralWidget *widget = CentralWidget::instance()) + addBookmark(widget->currentTitle(), widget->currentSource().toString()); } void BookmarkManager::removeBookmark() @@ -335,10 +337,21 @@ void BookmarkManager::removeBookmark() removeItem(bookmarkTreeView->currentIndex()); } -//void BookmarkManager::manageBookmarks() -//{ -// TRACE_OBJ -//} +void BookmarkManager::manageBookmarks() +{ + TRACE_OBJ + if (bookmarkManagerWidget == 0) { + bookmarkManagerWidget = new BookmarkManagerWidget(bookmarkModel); + connect(bookmarkManagerWidget, SIGNAL(setSource(QUrl)), this, + SIGNAL(setSource(QUrl))); + connect(bookmarkManagerWidget, SIGNAL(setSourceInNewTab(QUrl)) + , this, SIGNAL(setSourceInNewTab(QUrl))); + connect(bookmarkManagerWidget, SIGNAL(managerWidgetAboutToClose()) + , this, SLOT(managerWidgetAboutToClose())); + } + bookmarkManagerWidget->show(); + bookmarkManagerWidget->raise(); +} void BookmarkManager::refeshBookmarkMenu() { @@ -348,10 +361,8 @@ void BookmarkManager::refeshBookmarkMenu() bookmarkMenu->clear(); - //bookmarkMenu->addAction(tr("Manage Bookmarks..."), this, - // SLOT(manageBookmarks())); - bookmarkMenu->addAction(tr("Import..."), this, SLOT(importBookmarks())); - bookmarkMenu->addAction(tr("Export..."), this, SLOT(exportBookmarks())); + bookmarkMenu->addAction(tr("Manage Bookmarks..."), this, + SLOT(manageBookmarks())); bookmarkMenu->addAction(tr("Add Bookmark..."), this, SLOT(addBookmark()), QKeySequence(tr("Ctrl+D"))); bookmarkMenu->addSeparator(); @@ -375,42 +386,6 @@ void BookmarkManager::renameBookmark(const QModelIndex &index) bookmarkModel->setItemsEditable(false); } -void BookmarkManager::importBookmarks() -{ - TRACE_OBJ - const QString &fileName = QFileDialog::getOpenFileName(0, tr("Open File"), - QDir::currentPath(), tr("Files (*.xbel)")); - - if (fileName.isEmpty()) - return; - - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - XbelReader reader(bookmarkModel); - reader.readFromFile(&file); - } -} - -void BookmarkManager::exportBookmarks() -{ - TRACE_OBJ - QString fileName = QFileDialog::getSaveFileName(0, tr("Save File"), - QLatin1String("untitled.xbel"), tr("Files (*.xbel)")); - - const QLatin1String suffix(".xbel"); - if (!fileName.endsWith(suffix)) - fileName.append(suffix); - - QFile file(fileName); - if (file.open(QIODevice::WriteOnly)) { - XbelWriter writer(bookmarkModel); - writer.writeToFile(&file); - } else { - QMessageBox::information(bookmarkTreeView, tr("Qt Assistant"), - tr("Unable to save bookmarks."), tr("OK")); - } -} - void BookmarkManager::setSourceFromAction(QAction *action) { TRACE_OBJ @@ -484,6 +459,12 @@ void BookmarkManager::focusInEvent() bookmarkTreeView->setCurrentIndex(index); } +void BookmarkManager::managerWidgetAboutToClose() +{ + delete bookmarkManagerWidget; + bookmarkManagerWidget = 0; +} + void BookmarkManager::textChanged(const QString &text) { TRACE_OBJ diff --git a/tools/assistant/tools/assistant/bookmarkmanager.h b/tools/assistant/tools/assistant/bookmarkmanager.h index 88342d5..c26dad8 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.h +++ b/tools/assistant/tools/assistant/bookmarkmanager.h @@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE +class BookmarkManagerWidget; class BookmarkModel; class BookmarkFilterModel; class QKeyEvent; @@ -90,17 +91,15 @@ private slots: void addBookmark(); void removeBookmark(); -// void manageBookmarks(); + void manageBookmarks(); void refeshBookmarkMenu(); void renameBookmark(const QModelIndex &index); - void importBookmarks(); - void exportBookmarks(); - void setSourceFromAction(QAction *action); void setSourceFromIndex(const QModelIndex &index, bool newTab = false); void focusInEvent(); + void managerWidgetAboutToClose(); void textChanged(const QString &text); void customContextMenuRequested(const QPoint &point); @@ -118,6 +117,7 @@ private: BookmarkWidget *bookmarkWidget; BookmarkTreeView *bookmarkTreeView; + BookmarkManagerWidget *bookmarkManagerWidget; }; class BookmarkManager::BookmarkWidget : public QWidget diff --git a/tools/assistant/tools/assistant/bookmarkmanagerwidget.cpp b/tools/assistant/tools/assistant/bookmarkmanagerwidget.cpp new file mode 100644 index 0000000..65df6be --- /dev/null +++ b/tools/assistant/tools/assistant/bookmarkmanagerwidget.cpp @@ -0,0 +1,321 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bookmarkmanagerwidget.h" +#include "bookmarkitem.h" +#include "bookmarkmodel.h" +#include "tracer.h" +#include "xbelsupport.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QFile> +#include <QtCore/QUrl> + +#include <QtGui/QCloseEvent> +#include <QtGui/QFileDialog> +#include <QtGui/QKeySequence> +#include <QtGui/QMessageBox> +#include <QtGui/QShortcut> + +QT_BEGIN_NAMESPACE + +namespace { + #define TR(x) QCoreApplication::translate("BookmarkManager", x) +} + +BookmarkManagerWidget::BookmarkManagerWidget(BookmarkModel *sourceModel, + QWidget *parent) + : QWidget(parent) + , bookmarkModel(sourceModel) +{ + TRACE_OBJ + ui.setupUi(this); + + ui.treeView->setModel(bookmarkModel); + + ui.treeView->expandAll(); + ui.treeView->installEventFilter(this); + ui.treeView->viewport()->installEventFilter(this); + ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu); + + connect(ui.treeView, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(customContextMenuRequested(QPoint))); + + connect(ui.remove, SIGNAL(clicked()), this, SLOT(removeItem())); + connect(ui.lineEdit, SIGNAL(textChanged(QString)), this, + SLOT(textChanged(QString))); + new QShortcut(QKeySequence::Find, ui.lineEdit, SLOT(setFocus())); + + importExportMenu.addAction(tr("Import..."), this, SLOT(importBookmarks())); + importExportMenu.addAction(tr("Export..."), this, SLOT(exportBookmarks())); + ui.importExport->setMenu(&importExportMenu); + + new QShortcut(QKeySequence::FindNext, this, SLOT(findNext())); + new QShortcut(QKeySequence::FindPrevious, this, SLOT(findPrevious())); + + connect(bookmarkModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, + SLOT(refeshBookmarkCache())); + connect(bookmarkModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, + SLOT(refeshBookmarkCache())); + connect(bookmarkModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, + SLOT(refeshBookmarkCache())); + + ui.treeView->setCurrentIndex(ui.treeView->indexAt(QPoint(2, 2))); +} + +BookmarkManagerWidget::~BookmarkManagerWidget() +{ + TRACE_OBJ +} + +void BookmarkManagerWidget::closeEvent(QCloseEvent *event) +{ + TRACE_OBJ + event->accept(); + emit managerWidgetAboutToClose(); +} + +void BookmarkManagerWidget::renameItem(const QModelIndex &index) +{ + TRACE_OBJ + // check if we should rename the "Bookmarks Menu", bail + if (!bookmarkModel->parent(index).isValid()) + return; + + bookmarkModel->setItemsEditable(true); + ui.treeView->edit(index); + bookmarkModel->setItemsEditable(false); +} + +static int nextIndex(int current, int count, bool forward) +{ + TRACE_OBJ + if (current >= 0) + return (forward ? (current + 1) : ((current - 1) + count)) % count; + return 0; +} + +void BookmarkManagerWidget::selectNextIndex(bool direction) const +{ + QModelIndex current = ui.treeView->currentIndex(); + if (current.isValid() && !cache.isEmpty()) { + current = cache.at(nextIndex(cache.indexOf(current), cache.count(), + direction)); + } + ui.treeView->setCurrentIndex(current); +} + +bool BookmarkManagerWidget::eventFilter(QObject *object, QEvent *event) +{ + TRACE_OBJ + if (object != ui.treeView && object != ui.treeView->viewport()) + return QWidget::eventFilter(object, event); + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast<QKeyEvent*>(event); + switch (ke->key()) { + case Qt::Key_F2: { + renameItem(ui.treeView->currentIndex()); + } break; + + case Qt::Key_Delete: { + removeItem(ui.treeView->currentIndex()); + } break; + + default: break; + } + } + + if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *me = static_cast<QMouseEvent*>(event); + switch (me->button()) { + case Qt::LeftButton: { + if (me->modifiers() & Qt::ControlModifier) + setSourceFromIndex(ui.treeView->currentIndex(), true); + } break; + + case Qt::MidButton: { + setSourceFromIndex(ui.treeView->currentIndex(), true); + } break; + + default: break; + } + } + return QObject::eventFilter(object, event); +} + +void BookmarkManagerWidget::findNext() +{ + TRACE_OBJ + selectNextIndex(true); +} + +void BookmarkManagerWidget::findPrevious() +{ + TRACE_OBJ + selectNextIndex(false); +} + +void BookmarkManagerWidget::importBookmarks() +{ + TRACE_OBJ + const QString &fileName = QFileDialog::getOpenFileName(0, TR("Open File"), + QDir::currentPath(), TR("Files (*.xbel)")); + + if (fileName.isEmpty()) + return; + + QFile file(fileName); + if (file.open(QIODevice::ReadOnly)) { + XbelReader reader(bookmarkModel); + reader.readFromFile(&file); + } +} + +void BookmarkManagerWidget::exportBookmarks() +{ + TRACE_OBJ + QString fileName = QFileDialog::getSaveFileName(0, TR("Save File"), + QLatin1String("untitled.xbel"), TR("Files (*.xbel)")); + + const QLatin1String suffix(".xbel"); + if (!fileName.endsWith(suffix)) + fileName.append(suffix); + + QFile file(fileName); + if (file.open(QIODevice::WriteOnly)) { + XbelWriter writer(bookmarkModel); + writer.writeToFile(&file); + } else { + QMessageBox::information(this, TR("Qt Assistant"), + TR("Unable to save bookmarks."), TR("OK")); + } +} + +void BookmarkManagerWidget::refeshBookmarkCache() +{ + TRACE_OBJ + cache.clear(); + + const QString &text = ui.lineEdit->text(); + if (!text.isEmpty()) + cache = bookmarkModel->indexListFor(text); +} + +void BookmarkManagerWidget::textChanged(const QString &/*text*/) +{ + TRACE_OBJ + refeshBookmarkCache(); + if (!cache.isEmpty()) + ui.treeView->setCurrentIndex(cache.at(0)); +} + +void BookmarkManagerWidget::removeItem(const QModelIndex &index) +{ + TRACE_OBJ + QModelIndex current = index.isValid() ? index : ui.treeView->currentIndex(); + if (!bookmarkModel->parent(current).isValid()) + return; // check if we should delete the "Bookmarks Menu", bail + + if (bookmarkModel->hasChildren(current)) { + int value = QMessageBox::question(this, TR("Remove"), TR("You are going" + "to delete a Folder, this will also<br> remove it's content. Are " + "you sure to continue?"), + QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); + if (value == QMessageBox::Cancel) + return; + } + bookmarkModel->removeItem(current); +} + +void BookmarkManagerWidget::customContextMenuRequested(const QPoint &point) +{ + TRACE_OBJ + const QModelIndex &index = ui.treeView->indexAt(point); + if (!index.isValid()) + return; + + // check if we should open the menu on "Bookmarks Menu", bail + if (!bookmarkModel->parent(index).isValid()) + return; + + QAction *remove = 0; + QAction *rename = 0; + QAction *showItem = 0; + QAction *showItemInNewTab = 0; + + QMenu menu(QLatin1String("")); + if (bookmarkModel->data(index, UserRoleFolder).toBool()) { + remove = menu.addAction(TR("Delete Folder")); + rename = menu.addAction(TR("Rename Folder")); + } else { + showItem = menu.addAction(TR("Show Bookmark")); + showItemInNewTab = menu.addAction(TR("Show Bookmark in New Tab")); + menu.addSeparator(); + remove = menu.addAction(TR("Delete Bookmark")); + rename = menu.addAction(TR("Rename Bookmark")); + } + + QAction *pickedAction = menu.exec(ui.treeView->mapToGlobal(point)); + if (pickedAction == rename) + renameItem(index); + else if (pickedAction == remove) + removeItem(index); + else if (pickedAction == showItem || pickedAction == showItemInNewTab) + setSourceFromIndex(index, pickedAction == showItemInNewTab); +} + +void +BookmarkManagerWidget::setSourceFromIndex(const QModelIndex &index, bool newTab) +{ + TRACE_OBJ + if (bookmarkModel->data(index, UserRoleFolder).toBool()) + return; + + const QVariant &data = bookmarkModel->data(index, UserRoleUrl); + if (data.canConvert<QUrl>()) { + if (newTab) + emit setSourceInNewTab(data.toUrl()); + else + emit setSource(data.toUrl()); + } +} + +QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/expressionquerywidget.h b/tools/assistant/tools/assistant/bookmarkmanagerwidget.h index 5bba5c3..94384a6 100644 --- a/tools/qmldebugger/standalone/expressionquerywidget.h +++ b/tools/assistant/tools/assistant/bookmarkmanagerwidget.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the Qt Assistant of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,68 +38,65 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef EXPRESSIONQUERYWIDGET_H -#define EXPRESSIONQUERYWIDGET_H +#ifndef BOOKMARKMANAGERWIDGET_H +#define BOOKMARKMANAGERWIDGET_H -#include <QWidget> +#include "ui_bookmarkmanagerwidget.h" -#include <private/qmldebug_p.h> +#include <QtCore/QPersistentModelIndex> + +#include <QtGui/QMenu> QT_BEGIN_NAMESPACE -class QGroupBox; -class QTextEdit; -class QLineEdit; -class QPushButton; +class BookmarkModel; +class QCloseEvent; +class QString; -class ExpressionQueryWidget : public QWidget +class BookmarkManagerWidget : public QWidget { Q_OBJECT public: - enum Mode { - SeparateEntryMode, - ShellMode - }; - - ExpressionQueryWidget(Mode mode = SeparateEntryMode, QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - void clear(); + BookmarkManagerWidget(BookmarkModel *bookmarkModel, QWidget *parent = 0); + ~BookmarkManagerWidget(); protected: - bool eventFilter(QObject *obj, QEvent *event); + void closeEvent(QCloseEvent *event); + +signals: + void setSource(const QUrl &url); + void setSourceInNewTab(const QUrl &url); -public slots: - void setCurrentObject(const QmlDebugObjectReference &obj); + void managerWidgetAboutToClose(); + +private: + void renameItem(const QModelIndex &index); + void selectNextIndex(bool direction) const; + bool eventFilter(QObject *object, QEvent *event); private slots: - void executeExpression(); - void showResult(); + void findNext(); + void findPrevious(); + + void importBookmarks(); + void exportBookmarks(); + + void refeshBookmarkCache(); + void textChanged(const QString &text); + + void removeItem(const QModelIndex &index = QModelIndex()); + + void customContextMenuRequested(const QPoint &point); + void setSourceFromIndex(const QModelIndex &index, bool newTab = false); private: - void appendPrompt(); - void checkCurrentContext(); - void showCurrentContext(); - void updateTitle(); - - Mode m_mode; - - QmlEngineDebug *m_client; - QmlDebugExpressionQuery *m_query; - QTextEdit *m_textEdit; - QLineEdit *m_lineEdit; - QPushButton *m_button; - QString m_prompt; - QString m_expr; - QString m_lastExpr; - - QString m_title; - - QmlDebugObjectReference m_currObject; - QmlDebugObjectReference m_objectAtLastFocus; + QMenu importExportMenu; + Ui::BookmarkManagerWidget ui; + QList<QPersistentModelIndex> cache; + + BookmarkModel *bookmarkModel; }; QT_END_NAMESPACE -#endif - +#endif // BOOKMARKMANAGERWIDGET_H
\ No newline at end of file diff --git a/tools/assistant/tools/assistant/bookmarkmanagerwidget.ui b/tools/assistant/tools/assistant/bookmarkmanagerwidget.ui new file mode 100644 index 0000000..dc965d9 --- /dev/null +++ b/tools/assistant/tools/assistant/bookmarkmanagerwidget.ui @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>BookmarkManagerWidget</class> + <widget class="QWidget" name="BookmarkManagerWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>517</width> + <height>348</height> + </rect> + </property> + <property name="windowTitle"> + <string>Manage Bookmarks</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <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> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Search:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + </layout> + </item> + <item> + <widget class="QTreeView" name="treeView"> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <property name="showDropIndicator" stdset="0"> + <bool>true</bool> + </property> + <property name="dragEnabled"> + <bool>true</bool> + </property> + <property name="autoExpandDelay"> + <number>1000</number> + </property> + <property name="uniformRowHeights"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <attribute name="headerDefaultSectionSize"> + <number>225</number> + </attribute> + <attribute name="headerMinimumSectionSize"> + <number>50</number> + </attribute> + <attribute name="headerDefaultSectionSize"> + <number>225</number> + </attribute> + <attribute name="headerMinimumSectionSize"> + <number>50</number> + </attribute> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="remove"> + <property name="text"> + <string>Remove</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="importExport"> + <property name="text"> + <string>Import and Backup</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_5"> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>pushButton_5</sender> + <signal>clicked()</signal> + <receiver>BookmarkManagerWidget</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel"> + <x>445</x> + <y>328</y> + </hint> + <hint type="destinationlabel"> + <x>340</x> + <y>313</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/assistant/tools/assistant/bookmarkmodel.cpp b/tools/assistant/tools/assistant/bookmarkmodel.cpp index c785f16..e446ff0 100644 --- a/tools/assistant/tools/assistant/bookmarkmodel.cpp +++ b/tools/assistant/tools/assistant/bookmarkmodel.cpp @@ -79,6 +79,9 @@ BookmarkModel::bookmarks() const void BookmarkModel::setBookmarks(const QByteArray &bookmarks) { + beginResetModel(); + + delete rootItem; folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon); bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png")); @@ -115,6 +118,8 @@ BookmarkModel::setBookmarks(const QByteArray &bookmarks) setupCache(root); cache.insert(static_cast<BookmarkItem*> (root.internalPointer()), root); + + endResetModel(); } void @@ -220,9 +225,9 @@ BookmarkModel::flags(const QModelIndex &index) const if (m_editable) defaultFlags |= Qt::ItemIsEditable; - if (itemFromIndex(index) && index.data(UserRoleFolder).toBool() - && index.column() > 0) { - defaultFlags &= ~Qt::ItemIsEditable; + if (itemFromIndex(index) && index.data(UserRoleFolder).toBool()) { + if (index.column() > 0) + return defaultFlags &~ Qt::ItemIsEditable; return defaultFlags | Qt::ItemIsDropEnabled; } @@ -241,11 +246,13 @@ BookmarkModel::data(const QModelIndex &index, int role) const return QLatin1String(""); return item->data(index.column()); } break; + case Qt::DecorationRole: { if (index.column() == 0) return index.data(UserRoleFolder).toBool() ? folderIcon : bookmarkIcon; } break; + default:; return item->data(role); } @@ -299,6 +306,18 @@ BookmarkModel::itemFromIndex(const QModelIndex &index) const return rootItem; } +QList<QPersistentModelIndex> +BookmarkModel::indexListFor(const QString &label) const +{ + QList<QPersistentModelIndex> hits; + const QModelIndexList &list = collectItems(QModelIndex()); + foreach(const QModelIndex &index, list) { + if (index.data().toString().contains(label, Qt::CaseInsensitive)) + hits.prepend(index); // list is reverse sorted + } + return hits; +} + bool BookmarkModel::insertRows(int position, int rows, const QModelIndex &parent) { diff --git a/tools/assistant/tools/assistant/bookmarkmodel.h b/tools/assistant/tools/assistant/bookmarkmodel.h index 6b2a0b8..6469258 100644 --- a/tools/assistant/tools/assistant/bookmarkmodel.h +++ b/tools/assistant/tools/assistant/bookmarkmodel.h @@ -84,6 +84,7 @@ public: QModelIndex indexFromItem(BookmarkItem *item) const; BookmarkItem *itemFromIndex(const QModelIndex &index) const; + QList<QPersistentModelIndex> indexListFor(const QString &label) const; bool insertRows(int position, int rows, const QModelIndex &parent); bool removeRows(int position, int rows, const QModelIndex &parent); diff --git a/tools/assistant/tools/assistant/bookmarkwidget.ui b/tools/assistant/tools/assistant/bookmarkwidget.ui index 3015740..a31a277 100644 --- a/tools/assistant/tools/assistant/bookmarkwidget.ui +++ b/tools/assistant/tools/assistant/bookmarkwidget.ui @@ -14,6 +14,9 @@ <string>Bookmarks</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="margin"> + <number>4</number> + </property> <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index dd91326..f56e9e3 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -310,7 +310,7 @@ void CentralWidget::setLastShownPages() { TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - const QStringList lastShownPageList = helpEngine.lastShownPages(); + const QStringList &lastShownPageList = helpEngine.lastShownPages(); const int pageCount = lastShownPageList.count(); if (pageCount == 0) { if (usesDefaultCollection) @@ -333,9 +333,10 @@ void CentralWidget::setLastShownPages() for (int curTab = 0; curTab < pageCount; ++curTab) { const QString &curFile = lastShownPageList.at(curTab); - if (helpEngine.findFile(curFile).isValid()) + if (helpEngine.findFile(curFile).isValid() + || curFile == QLatin1String("about:blank")) { setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat()); - else if (curTab + searchIsAttached <= tabToShow) + } else if (curTab + searchIsAttached <= tabToShow) --tabToShow; } @@ -514,15 +515,12 @@ void CentralWidget::setGlobalActions(const QList<QAction*> &actions) void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) { TRACE_OBJ - HelpViewer *viewer; - -#if defined(QT_NO_WEBKIT) - viewer = currentHelpViewer(); - if (viewer && viewer->launchedWithExternalApp(url)) - return; -#endif + if (HelpViewer *viewer = currentHelpViewer()) { + if (viewer->launchWithExternalApp(url)) + return; + } - viewer = new HelpViewer(this, zoom); + HelpViewer *viewer = new HelpViewer(this, zoom); viewer->installEventFilter(this); viewer->setSource(url); viewer->setFocus(Qt::OtherFocusReason); diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 8597f6b..9b06400 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -39,13 +39,25 @@ ** ****************************************************************************/ #include "helpviewer.h" +#include "helpenginewrapper.h" #include "tracer.h" #include <QtCore/QCoreApplication> +#include <QtCore/QFileInfo> +#include <QtCore/QStringBuilder> +#include <QtCore/QTemporaryFile> #include <QtCore/QUrl> +#include <QtGui/QDesktopServices> + QT_BEGIN_NAMESPACE +QString AbstractHelpViewer::AboutBlank = + QCoreApplication::translate("HelpViewer", "<title>about:blank</title>"); + +QString AbstractHelpViewer::LocalHelpFile = QLatin1String("qthelp://" + "com.trolltech.com.assistantinternal-1.0.0/assistant/assistant.html"); + QString AbstractHelpViewer::PageNotFoundMessage = QCoreApplication::translate("HelpViewer", "<title>Error 404...</title><div " "align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'" @@ -76,7 +88,38 @@ bool AbstractHelpViewer::canOpenPage(const QString &url) TRACE_OBJ return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) - || url == QLatin1String("blank"); + || url == QLatin1String("about:blank"); +} + +bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url) +{ + TRACE_OBJ + if (isLocalUrl(url)) { + const HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + const QUrl &resolvedUrl = helpEngine.findFile(url); + if (!resolvedUrl.isValid()) + return false; + + const QString& path = resolvedUrl.path(); + if (!canOpenPage(path)) { + QTemporaryFile tmpTmpFile; + if (!tmpTmpFile.open()) + return false; + + const QString &extension = QFileInfo(path).completeSuffix(); + QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".") + % extension); + if (!actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) + return false; + + actualTmpFile.write(helpEngine.fileData(resolvedUrl)); + actualTmpFile.close(); + return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName())); + } + } else if (url.scheme() == QLatin1String("http")) { + return QDesktopServices::openUrl(url); + } + return false; } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index fe860fd..0bfe904 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -64,9 +64,13 @@ public: virtual void resetScale() = 0; virtual qreal scale() const = 0; + static QString AboutBlank; + static QString LocalHelpFile; static QString PageNotFoundMessage; + static bool isLocalUrl(const QUrl &url); static bool canOpenPage(const QString &url); + static bool launchWithExternalApp(const QUrl &url); }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index 1e439dc..bba2850 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ #include "helpviewer_qtb.h" -#include "helpviewer_qwv.h" #if defined(QT_NO_WEBKIT) @@ -47,15 +46,12 @@ #include "helpenginewrapper.h" #include "tracer.h" -#include <QtCore/QDir> #include <QtCore/QStringBuilder> #include <QtGui/QContextMenuEvent> #include <QtGui/QMenu> #include <QtGui/QClipboard> #include <QtGui/QApplication> -#include <QtGui/QMessageBox> -#include <QtGui/QDesktopServices> QT_BEGIN_NAMESPACE @@ -136,62 +132,28 @@ void HelpViewer::resetScale() void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ - bool help = url.toString() == QLatin1String("help"); - if (url.isValid() && !help) { - if (launchedWithExternalApp(url)) + const QString &string = url.toString(); + if (url.isValid() && string != QLatin1String("help")) { + if (launchWithExternalApp(url)) return; - QUrl u = helpEngine.findFile(url); - if (u.isValid()) { - QTextBrowser::setSource(u); + const QUrl &resolvedUrl = helpEngine.findFile(url); + if (resolvedUrl.isValid()) { + QTextBrowser::setSource(resolvedUrl); return; - } + } } - if (help) { - QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal-1.0.0/assistant/assistant.html"))); - } else { + if (string != QLatin1String("help")) { QTextBrowser::setSource(url); - setHtml(PageNotFoundMessage.arg(url.toString())); + setHtml(string == QLatin1String("about:blank") ? AboutBlank + : PageNotFoundMessage.arg(url.toString())); emit sourceChanged(url); + } else { + QTextBrowser::setSource(LocalHelpFile); } } -bool HelpViewer::launchedWithExternalApp(const QUrl &url) -{ - TRACE_OBJ - const bool canOpen = canOpenPage(url.path()); - if (!isLocalUrl(url) || !canOpen) { - bool launched = false; - if (!canOpen && url.scheme() == QLatin1String("qthelp")) { - const QString& path = url.path(); - 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)) { - tmpFile.write(helpEngine.fileData(url)); - tmpFile.close(); - } - launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName())); - } else { - launched = QDesktopServices::openUrl(url); - } - - if (!launched) { - QMessageBox::information(this, tr("Help"), - tr("Unable to launch external application.\n"), tr("OK")); - } - return true; - } - return false; -} - QVariant HelpViewer::loadResource(int type, const QUrl &name) { TRACE_OBJ diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h index 9a9a8fd..5b38870 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -38,14 +38,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#ifndef HELPVIEWERQTB_H +#define HELPVIEWERQTB_H #include <QtCore/qglobal.h> #if defined(QT_NO_WEBKIT) -#ifndef HELPVIEWERQTB_H -#define HELPVIEWERQTB_H - #include "helpviewer.h" #include <QtCore/QUrl> @@ -82,8 +81,6 @@ public: inline bool hasSelection() const { return textCursor().hasSelection(); } - bool launchedWithExternalApp(const QUrl &url); - public Q_SLOTS: void home(); @@ -114,6 +111,6 @@ private: QT_END_NAMESPACE -#endif // HELPVIEWERQTB_H - #endif // QT_NO_WEBKIT + +#endif // HELPVIEWERQTB_H diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index eec5a35..9bb66e1 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "helpviewer_qwv.h" #if !defined(QT_NO_WEBKIT) @@ -49,10 +50,8 @@ #include <QtCore/QFileInfo> #include <QtCore/QString> #include <QtCore/QStringBuilder> -#include <QtCore/QTemporaryFile> #include <QtCore/QTimer> -#include <QtGui/QDesktopServices> #include <QtGui/QWheelEvent> #include <QtNetwork/QNetworkAccessManager> @@ -211,45 +210,27 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, const QNetworkRequest &request, QWebPage::NavigationType type) { TRACE_OBJ - const QUrl &url = request.url(); const bool closeNewTab = closeNewTabIfNeeded; closeNewTabIfNeeded = false; - if (AbstractHelpViewer::isLocalUrl(url)) { - const QString& path = url.path(); - if (!AbstractHelpViewer::canOpenPage(path)) { - QTemporaryFile tmpTmpFile; - if (!tmpTmpFile.open()) - return false; - const QString &extension = QFileInfo(path).completeSuffix(); - QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".") - % extension); - if (actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) { - actualTmpFile.write(HelpEngineWrapper::instance().fileData(url)); - actualTmpFile.close(); - QDesktopServices::openUrl(QUrl(actualTmpFile.fileName())); - } - - if (closeNewTab) - QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab"); + const QUrl &url = request.url(); + if (AbstractHelpViewer::launchWithExternalApp(url)) { + if (closeNewTab) + QMetaObject::invokeMethod(centralWidget, "closeTab"); + return false; + } + + if (type == QWebPage::NavigationTypeLinkClicked + && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { + if (HelpViewer* viewer = centralWidget->newEmptyTab()) + centralWidget->setSource(url); + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; return false; - } - - if (type == QWebPage::NavigationTypeLinkClicked - && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton)) { - HelpViewer* viewer = centralWidget->newEmptyTab(); - if (viewer) - CentralWidget::instance()->setSource(url); - m_pressedButtons = Qt::NoButton; - m_keyboardModifiers = Qt::NoModifier; - return false; - } - return true; } - QDesktopServices::openUrl(url); - return false; + return true; } // -- HelpViewer @@ -337,12 +318,7 @@ void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ loadFinished = false; - if (url.toString() == QLatin1String("help")) { - load(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal-1.0.0/assistant/assistant.html"))); - } else { - load(url); - } + load(url.toString() == QLatin1String("help") ? LocalHelpFile : url); } void HelpViewer::home() diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index f326f8a..fbfbaac 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -39,13 +39,13 @@ ** ****************************************************************************/ +#ifndef HELPVIEWERQWV_H +#define HELPVIEWERQWV_H + #include <QtCore/qglobal.h> #if !defined(QT_NO_WEBKIT) -#ifndef HELPVIEWERQWV_H -#define HELPVIEWERQWV_H - #include "helpviewer.h" #include <QtGui/QAction> @@ -120,6 +120,6 @@ private: QT_END_NAMESPACE -#endif // HELPVIEWERQWV_H - #endif // !QT_NO_WEBKIT + +#endif // HELPVIEWERQWV_H diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 243183c..91de7c2 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -3,8 +3,8 @@ DESTDIR = ../.. CONFIG += console flat CONFIG -= moc qt -DEFINES = UNICODE QT_NODLL QT_NO_CODECS QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_LITE_COMPONENT QT_NO_STL QT_NO_COMPRESS QT_BUILD_QMAKE QT_NO_THREAD QT_NO_QOBJECT _CRT_SECURE_NO_DEPRECATE - +DEFINES = UNICODE QT_NODLL QT_NO_CODECS QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_LITE_COMPONENT QT_NO_STL QT_NO_COMPRESS QT_NO_THREAD QT_NO_QOBJECT _CRT_SECURE_NO_DEPRECATE +DEFINES += QT_BOOTSTRAPPED win32 : LIBS += -lole32 -ladvapi32 win32-msvc.net | win32-msvc2* : QMAKE_CXXFLAGS += /EHsc @@ -27,6 +27,7 @@ INCPATH += $$QT_SOURCE_TREE/src/corelib/arch/generic \ $$QT_SOURCE_TREE/src/corelib/global \ $$QT_BUILD_TREE/include \ $$QT_BUILD_TREE/include/QtCore \ + $$QT_BUILD_TREE/tools/shared HEADERS = configureapp.h environment.h tools.h\ $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.h \ @@ -58,7 +59,11 @@ HEADERS = configureapp.h environment.h tools.h\ $$QT_SOURCE_TREE/src/corelib/tools/qstring.h \ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.h \ $$QT_SOURCE_TREE/src/corelib/tools/qstringmatcher.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables_p.h + $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables_p.h \ + $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.h \ + $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils_p.h \ + $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.h \ + $$QT_SOURCE_TREE/tools/shared/windows/registry.h SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ @@ -102,7 +107,11 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qpoint.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qrect.cpp \ $$QT_SOURCE_TREE/src/corelib/kernel/qmetatype.cpp \ - $$QT_SOURCE_TREE/src/corelib/global/qmalloc.cpp + $$QT_SOURCE_TREE/src/corelib/global/qmalloc.cpp \ + $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.cpp \ + $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils.cpp \ + $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \ + $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp win32:SOURCES += $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7154fd4..8c2a015 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -247,7 +247,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "PHONON" ] = "auto"; dictionary[ "PHONON_BACKEND" ] = "yes"; dictionary[ "MULTIMEDIA" ] = "yes"; - dictionary[ "AUDIO_BACKEND" ] = "yes"; + dictionary[ "AUDIO_BACKEND" ] = "auto"; dictionary[ "DIRECTSHOW" ] = "no"; dictionary[ "WEBKIT" ] = "auto"; dictionary[ "DECLARATIVE" ] = "auto"; @@ -961,6 +961,7 @@ void Configure::parseCmdLine() if(i==argCount) break; qmakeDefines += "QT_NAMESPACE="+configCmdLine.at(i); + dictionary[ "QT_NAMESPACE" ] = configCmdLine.at(i); } else if( configCmdLine.at(i) == "-qtlibinfix" ) { ++i; if(i==argCount) @@ -2067,6 +2068,52 @@ bool Configure::checkAvailability(const QString &part) available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-g++"); } else if (part == "DECLARATIVE") { available = QFile::exists(sourcePath + "/src/declarative/qml/qmlcomponent.h"); + } else if (part == "AUDIO_BACKEND") { + available = true; + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { + QString epocRoot = Environment::symbianEpocRoot(); + const QDir epocRootDir(epocRoot); + if (epocRootDir.exists()) { + QStringList paths; + paths << "epoc32/release/armv5/lib/mmfdevsound.dso" + << "epoc32/release/armv5/lib/mmfdevsound.lib" + << "epoc32/release/winscw/udeb/mmfdevsound.dll" + << "epoc32/release/winscw/udeb/mmfdevsound.lib" + << "epoc32/include/mmf/server/sounddevice.h"; + + QStringList::iterator i = paths.begin(); + while (i != paths.end()) { + const QString &path = epocRoot + *i; + if (QFile::exists(path)) + i = paths.erase(i); + else + ++i; + } + + available = (paths.size() == 0); + if (!available) { + if (epocRoot.isNull() || epocRoot == "") + epocRoot = "<empty string>"; + cout << endl + << "The QtMultimedia audio backend will not be built because required" << endl + << "support for CMMFDevSound was not found in the SDK." << endl + << "The SDK which was examined was located at the following path:" << endl + << " " << epocRoot << endl + << "The following required files were missing from the SDK:" << endl; + QString path; + foreach (path, paths) + cout << " " << path << endl; + cout << endl; + } + } else { + cout << endl + << "The SDK root was determined to be '" << epocRoot << "'." << endl + << "This directory was not found, so the SDK could not be checked for" << endl + << "CMMFDevSound support. The QtMultimedia audio backend will therefore" << endl + << "not be built." << endl << endl; + available = false; + } + } } return available; @@ -2155,6 +2202,8 @@ void Configure::autoDetection() dictionary["WEBKIT"] = checkAvailability("WEBKIT") ? "yes" : "no"; if (dictionary["DECLARATIVE"] == "auto") dictionary["DECLARATIVE"] = checkAvailability("DECLARATIVE") ? "yes" : "no"; + if (dictionary["AUDIO_BACKEND"] == "auto") + dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no"; // Qt/WinCE remote test application if (dictionary["CETEST"] == "auto") @@ -2267,24 +2316,31 @@ void Configure::generateBuildKey() QString build32Key = buildKey + "Windows " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" "); QString build64Key = buildKey + "Windows x64 " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" "); + QString buildSymbianKey = buildKey + "Symbian " + build_options.join(" ") + " " + build_defines.join(" "); build32Key = build32Key.simplified(); build64Key = build64Key.simplified(); - build32Key.prepend("# define "); - build64Key.prepend("# define "); + buildSymbianKey = buildSymbianKey.simplified(); + build32Key.prepend("# define "); + build64Key.prepend("# define "); + buildSymbianKey.prepend("# define "); - QString buildkey = // Debug builds - "#if (defined(_DEBUG) || defined(DEBUG))\n" - "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" + QString buildkey = "#if defined(__SYMBIAN32__)\n" + + buildSymbianKey + "\"\n" + "#else\n" + // Debug builds + "# if (defined(_DEBUG) || defined(DEBUG))\n" + "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" + build64Key.arg("debug") + "\"\n" - "# else\n" + "# else\n" + build32Key.arg("debug") + "\"\n" - "# endif\n" - "#else\n" + "# endif\n" + "# else\n" // Release builds - "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" + "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" + build64Key.arg("release") + "\"\n" - "# else\n" + "# else\n" + build32Key.arg("release") + "\"\n" + "# endif\n" "# endif\n" "#endif\n"; @@ -2792,6 +2848,9 @@ void Configure::generateCachefile() if(!dictionary["ARM_FPU_TYPE"].isEmpty()) { configStream<<"MMP_RULES += \"ARMFPU "<< dictionary["ARM_FPU_TYPE"]<< "\""; } + if (!dictionary["QT_NAMESPACE"].isEmpty()) { + configStream << "#namespaces" << endl << "QT_NAMESPACE = " << dictionary["QT_NAMESPACE"] << endl; + } configStream.flush(); configFile.close(); diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index af6f9e5..e93f9a0 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -60,6 +60,8 @@ using namespace std; #include <qt_windows.h> #endif +#include <symbian/epocroot.h> // from tools/shared +#include <windows/registry.h> // from tools/shared QT_BEGIN_NAMESPACE @@ -97,126 +99,6 @@ CompilerInfo *Environment::compilerInfo(Compiler compiler) } /*! - Returns the path part of a registry key. - Ei. - For a key - "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" - it returns - "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\" -*/ -QString Environment::keyPath(const QString &rKey) -{ - int idx = rKey.lastIndexOf(QLatin1Char('\\')); - if (idx == -1) - return QString(); - return rKey.left(idx + 1); -} - -/*! - Returns the name part of a registry key. - Ei. - For a key - "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" - it returns - "ProductDir" -*/ -QString Environment::keyName(const QString &rKey) -{ - int idx = rKey.lastIndexOf(QLatin1Char('\\')); - if (idx == -1) - return rKey; - - QString res(rKey.mid(idx + 1)); - if (res == "Default" || res == ".") - res = ""; - return res; -} - -/*! - Returns a registry keys value in string form. - If the registry key does not exist, or cannot be accessed, a - QString() is returned. -*/ -QString Environment::readRegistryKey(HKEY parentHandle, const QString &rSubkey) -{ -#ifndef Q_OS_WIN32 - return QString(); -#else - QString rSubkeyName = keyName(rSubkey); - QString rSubkeyPath = keyPath(rSubkey); - - HKEY handle = 0; - LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, KEY_READ, &handle); - if (res != ERROR_SUCCESS) - return QString(); - - // get the size and type of the value - DWORD dataType; - DWORD dataSize; - res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize); - if (res != ERROR_SUCCESS) { - RegCloseKey(handle); - return QString(); - } - - // get the value - QByteArray data(dataSize, 0); - res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, 0, - reinterpret_cast<unsigned char*>(data.data()), &dataSize); - if (res != ERROR_SUCCESS) { - RegCloseKey(handle); - return QString(); - } - - QString result; - switch (dataType) { - case REG_EXPAND_SZ: - case REG_SZ: { - result = QString::fromWCharArray(((const wchar_t *)data.constData())); - break; - } - - case REG_MULTI_SZ: { - QStringList l; - int i = 0; - for (;;) { - QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i); - i += s.length() + 1; - - if (s.isEmpty()) - break; - l.append(s); - } - result = l.join(", "); - break; - } - - case REG_NONE: - case REG_BINARY: { - result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); - break; - } - - case REG_DWORD_BIG_ENDIAN: - case REG_DWORD: { - Q_ASSERT(data.size() == sizeof(int)); - int i; - memcpy((char*)&i, data.constData(), sizeof(int)); - result = QString::number(i); - break; - } - - default: - qWarning("QSettings: unknown data %d type in windows registry", dataType); - break; - } - - RegCloseKey(handle); - return result; -#endif -} - -/*! Returns the qmakespec for the compiler detected on the system. */ QString Environment::detectQMakeSpec() @@ -579,4 +461,10 @@ bool Environment::rmdir(const QString &name) return result; } +QString Environment::symbianEpocRoot() +{ + // Call function defined in tools/shared/symbian/epocroot.h + return ::epocRoot(); +} + QT_END_NAMESPACE diff --git a/tools/configure/environment.h b/tools/configure/environment.h index 2d0eafd..b1cbe3a 100644 --- a/tools/configure/environment.h +++ b/tools/configure/environment.h @@ -71,13 +71,12 @@ public: static bool cpdir(const QString &srcDir, const QString &destDir); static bool rmdir(const QString &name); + static QString symbianEpocRoot(); + private: static Compiler detectedCompiler; static CompilerInfo *compilerInfo(Compiler compiler); - static QString keyPath(const QString &rKey); - static QString keyName(const QString &rKey); - static QString readRegistryKey(HKEY parentHandle, const QString &rSubkey); }; diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp index aea2713..c4625af 100644 --- a/tools/configure/tools.cpp +++ b/tools/configure/tools.cpp @@ -146,6 +146,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString if (products == 'B') { dictionary["EDITION"] = "Evaluation"; dictionary["QT_EDITION"] = "QT_EDITION_EVALUATION"; + licenseType = "Evaluation"; } } @@ -212,7 +213,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString } // Override for evaluation licenses - if (dictionary["Edition"] == "Evaluation") + if (dictionary["EDITION"] == "Evaluation") dictionary["LICENSE_EXTENSION"] = "-EVALUATION"; if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/.LICENSE")) { diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp index c15942f..859f239 100644 --- a/tools/designer/src/lib/shared/qtresourceview.cpp +++ b/tools/designer/src/lib/shared/qtresourceview.cpp @@ -664,6 +664,8 @@ QString QtResourceView::selectedResource() const void QtResourceView::selectResource(const QString &resource) { + if (resource.isEmpty()) + return; QFileInfo fi(resource); QDir dir = fi.absoluteDir(); if (fi.isDir()) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 3a30027..543c405 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -48,6 +48,8 @@ #include <iostream> +QT_USE_NAMESPACE + static int usage(const QStringList &args) { Q_UNUSED(args); diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp index 6f34c2b..33276e6 100644 --- a/tools/linguist/lupdate/qscript.cpp +++ b/tools/linguist/lupdate/qscript.cpp @@ -40,6 +40,26 @@ ** ****************************************************************************/ + +#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 + +#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 + +#include <translator.h> + +#include <QtCore/qdebug.h> +#include <QtCore/qnumeric.h> +#include <QtCore/qstring.h> +#include <QtCore/qtextcodec.h> +#include <QtCore/qvariant.h> + +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +QT_BEGIN_NAMESPACE + class QScriptGrammar { public: @@ -174,7 +194,6 @@ public: } }; - const char *const QScriptGrammar::spell [] = { "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue", "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", @@ -747,26 +766,6 @@ const int QScriptGrammar::action_check [] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - -#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 - -#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 - -#include <translator.h> - -#include <QtCore/qdebug.h> -#include <QtCore/qnumeric.h> -#include <QtCore/qstring.h> -#include <QtCore/qtextcodec.h> -#include <QtCore/qvariant.h> - -#include <ctype.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -QT_BEGIN_NAMESPACE - static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, const QString &extracomment, bool plural, const QString &fileName, int lineNo) diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro deleted file mode 100644 index 679cae6..0000000 --- a/tools/qmldebugger/qmldebugger.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = standalone - diff --git a/tools/qmldebugger/standalone/canvasframerate.cpp b/tools/qmldebugger/standalone/canvasframerate.cpp deleted file mode 100644 index 1bf7bf6..0000000 --- a/tools/qmldebugger/standalone/canvasframerate.cpp +++ /dev/null @@ -1,581 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QtCore/qdebug.h> -#include <QtCore/qstringlist.h> -#include <QtCore/qdatastream.h> -#include <QtCore/qmargins.h> - -#include <QtGui/qapplication.h> -#include <QtGui/qpainter.h> -#include <QtGui/qtooltip.h> -#include <QtGui/qslider.h> -#include <QtGui/qscrollbar.h> -#include <QtGui/qspinbox.h> -#include <QtGui/qgroupbox.h> -#include <QtGui/qboxlayout.h> -#include <QtGui/qlabel.h> -#include <QtGui/qlineedit.h> -#include <QtGui/qpushbutton.h> -#include <QtGui/qtabwidget.h> - -#include <QResizeEvent> -#include <QShowEvent> - -#include <private/qmldebugclient_p.h> -#include "canvasframerate.h" - -QT_BEGIN_NAMESPACE - -class QLineGraph : public QWidget -{ -Q_OBJECT -public: - QLineGraph(QAbstractSlider *slider, QWidget * = 0); - - void setPosition(int); - -public slots: - void addSample(int, int, int, bool); - void setResolutionForHeight(int); - void clear(); - -protected: - virtual void paintEvent(QPaintEvent *); - virtual void mouseMoveEvent(QMouseEvent *); - virtual void leaveEvent(QEvent *); - virtual void wheelEvent(QWheelEvent *event); - -private slots: - void sliderChanged(int); - -private: - void updateSlider(); - void drawSample(QPainter *, int, const QRect &, QList<QRect> *); - void drawTime(QPainter *, const QRect &); - QRect findContainingRect(const QList<QRect> &rects, const QPoint &pos) const; - struct Sample { - int sample[3]; - bool isBreak; - }; - QList<Sample> _samples; - - QAbstractSlider *slider; - int position; - int samplesPerWidth; - int resolutionForHeight; - bool ignoreScroll; - QMargins graphMargins; - - QList<QRect> rectsPaintTime; // time to do a paintEvent() - QList<QRect> rectsTimeBetween; // time between frames - QRect highlightedBar; -}; - -QLineGraph::QLineGraph(QAbstractSlider *slider, QWidget *parent) -: QWidget(parent), slider(slider), position(-1), samplesPerWidth(99), resolutionForHeight(50), - ignoreScroll(false), graphMargins(65, 10, 71, 35) -{ - setMouseTracking(true); - - slider->setMaximum(0); - slider->setMinimum(0); - slider->setSingleStep(1); - - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); -} - -void QLineGraph::sliderChanged(int v) -{ - if(ignoreScroll) - return; - - if (v == slider->maximum()) - position = -1; - else - position = v; - - update(); - - // update highlightedRect - QPoint pos = mapFromGlobal(QCursor::pos()); - if (geometry().contains(pos)) { - QMouseEvent *me = new QMouseEvent(QEvent::MouseMove, pos, - Qt::NoButton, Qt::NoButton, Qt::NoModifier); - QApplication::postEvent(this, me); - } -} - -void QLineGraph::clear() -{ - _samples.clear(); - rectsPaintTime.clear(); - rectsTimeBetween.clear(); - highlightedBar = QRect(); - position = -1; - - updateSlider(); - update(); -} - -void QLineGraph::updateSlider() -{ - ignoreScroll = true; - slider->setMaximum(qMax(0, _samples.count() - samplesPerWidth - 1)); - - if(position == -1) { - slider->setValue(slider->maximum()); - } else { - slider->setValue(position); - } - ignoreScroll = false; -} - -void QLineGraph::addSample(int a, int b, int d, bool isBreak) -{ - Sample s; - s.isBreak = isBreak; - s.sample[0] = a; - s.sample[1] = b; - s.sample[2] = d; - _samples << s; - updateSlider(); - update(); -} - -void QLineGraph::setPosition(int p) -{ - sliderChanged(p); -} - -void QLineGraph::drawTime(QPainter *p, const QRect &rect) -{ - if(_samples.isEmpty()) - return; - - int first = position; - if(first == -1) - first = qMax(0, _samples.count() - samplesPerWidth - 1); - int last = qMin(_samples.count() - 1, first + samplesPerWidth); - - qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); - - int t = 0; - - for(int ii = first; ii <= last; ++ii) { - int sampleTime = _samples.at(ii).sample[2] / 1000; - if(sampleTime != t) { - - int xEnd = rect.left() + scaleX * (ii - first); - p->drawLine(xEnd, rect.bottom(), xEnd, rect.bottom() + 7); - - QRect text(xEnd - 30, rect.bottom() + 10, 60, 30); - - p->drawText(text, Qt::AlignHCenter | Qt::AlignTop, QString::number(_samples.at(ii).sample[2])); - - t = sampleTime; - } - } - -} - -void QLineGraph::drawSample(QPainter *p, int s, const QRect &rect, QList<QRect> *record) -{ - if(_samples.isEmpty()) - return; - - int first = position; - if(first == -1) - first = qMax(0, _samples.count() - samplesPerWidth - 1); - int last = qMin(_samples.count() - 1, first + samplesPerWidth); - - qreal scaleY = qreal(rect.height()) / resolutionForHeight; - qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); - - int xEnd; - int lastXEnd = rect.left(); - - p->save(); - p->setPen(Qt::NoPen); - for(int ii = first + 1; ii <= last; ++ii) { - - xEnd = rect.left() + scaleX * (ii - first); - int yEnd = rect.bottom() - _samples.at(ii).sample[s] * scaleY; - - if (!(s == 0 && _samples.at(ii).isBreak)) { - QRect bar(lastXEnd, yEnd, scaleX, _samples.at(ii).sample[s] * scaleY); - record->append(bar); - p->drawRect(bar); - } - - lastXEnd = xEnd; - } - p->restore(); -} - -void QLineGraph::paintEvent(QPaintEvent *) -{ - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - - QRect r(graphMargins.left(), graphMargins.top(), - width() - graphMargins.right(), height() - graphMargins.bottom()); - - p.save(); - p.rotate(-90); - p.translate(-r.height()/2 - r.width()/2 - graphMargins.right(), -r.height()/2); - p.drawText(r, Qt::AlignCenter, tr("Frame rate")); - p.restore(); - - p.setBrush(QColor("lightsteelblue")); - rectsTimeBetween.clear(); - drawSample(&p, 0, r, &rectsTimeBetween); - - p.setBrush(QColor("pink")); - rectsPaintTime.clear(); - drawSample(&p, 1, r, &rectsPaintTime); - - if (!highlightedBar.isNull()) { - p.setBrush(Qt::darkGreen); - p.drawRect(highlightedBar); - } - - p.setBrush(Qt::NoBrush); - p.drawRect(r); - - slider->setGeometry(x() + r.x(), slider->y(), r.width(), slider->height()); - - for(int ii = 0; ii <= resolutionForHeight; ++ii) { - int y = 1 + r.bottom() - ii * r.height() / resolutionForHeight; - - if((ii % 10) == 0) { - p.drawLine(r.left() - 20, y, r.left(), y); - QRect text(r.left() - 20 - 53, y - 10, 50, 20); - p.drawText(text, Qt::AlignRight | Qt::AlignVCenter, QString::number(ii)); - } else { - p.drawLine(r.left() - 7, y, r.left(), y); - } - } - - drawTime(&p, r); -} - -void QLineGraph::mouseMoveEvent(QMouseEvent *event) -{ - QPoint pos = event->pos(); - - QRect rect = findContainingRect(rectsPaintTime, pos); - if (rect.isNull()) - rect = findContainingRect(rectsTimeBetween, pos); - - if (!highlightedBar.isNull()) - update(highlightedBar.adjusted(-1, -1, 1, 1)); - highlightedBar = rect; - - if (!rect.isNull()) { - QRect graph(graphMargins.left(), graphMargins.top(), - width() - graphMargins.right(), height() - graphMargins.bottom()); - qreal scaleY = qreal(graph.height()) / resolutionForHeight; - QToolTip::showText(event->globalPos(), QString::number(qRound(rect.height() / scaleY)), this, rect); - update(rect.adjusted(-1, -1, 1, 1)); - } -} - -void QLineGraph::leaveEvent(QEvent *) -{ - if (!highlightedBar.isNull()) { - QRect bar = highlightedBar.adjusted(-1, -1, 1, 1); - highlightedBar = QRect(); - update(bar); - } -} - -void QLineGraph::wheelEvent(QWheelEvent *event) -{ - QWheelEvent we(QPoint(0,0), event->delta(), event->buttons(), event->modifiers(), event->orientation()); - QApplication::sendEvent(slider, &we); -} - -void QLineGraph::setResolutionForHeight(int resolution) -{ - resolutionForHeight = resolution; - update(); -} - -QRect QLineGraph::findContainingRect(const QList<QRect> &rects, const QPoint &pos) const -{ - for (int i=0; i<rects.count(); i++) { - if (rects[i].contains(pos)) - return rects[i]; - } - return QRect(); -} - - -class GraphWindow : public QWidget -{ - Q_OBJECT -public: - GraphWindow(QWidget *parent = 0); - - virtual QSize sizeHint() const; - -public slots: - void addSample(int, int, int, bool); - void setResolutionForHeight(int); - void clear(); - -private: - QLineGraph *m_graph; -}; - -GraphWindow::GraphWindow(QWidget *parent) - : QWidget(parent) -{ - QSlider *scroll = new QSlider(Qt::Horizontal); - scroll->setFocusPolicy(Qt::WheelFocus); - m_graph = new QLineGraph(scroll); - - setFocusPolicy(Qt::WheelFocus); - setFocusProxy(scroll); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 5, 0); - layout->setSpacing(0); - layout->addWidget(m_graph, 2); - layout->addWidget(new QLabel(tr("Total time elapsed (ms)")), 0, Qt::AlignHCenter); - layout->addWidget(scroll); -} - -void GraphWindow::addSample(int a, int b, int d, bool isBreak) -{ - m_graph->addSample(a, b, d, isBreak); -} - -void GraphWindow::setResolutionForHeight(int res) -{ - m_graph->setResolutionForHeight(res); -} - -void GraphWindow::clear() -{ - m_graph->clear(); -} - -QSize GraphWindow::sizeHint() const -{ - return QSize(400, 220); -} - - -class CanvasFrameRatePlugin : public QmlDebugClient -{ - Q_OBJECT -public: - CanvasFrameRatePlugin(QmlDebugConnection *client); - -signals: - void sample(int, int, int, bool); - -protected: - virtual void messageReceived(const QByteArray &); - -private: - int lb; - int ld; -}; - -CanvasFrameRatePlugin::CanvasFrameRatePlugin(QmlDebugConnection *client) -: QmlDebugClient(QLatin1String("CanvasFrameRate"), client), lb(-1) -{ -} - -void CanvasFrameRatePlugin::messageReceived(const QByteArray &data) -{ - QByteArray rwData = data; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - int b; int c; int d; bool isBreak; - stream >> b >> c >> d >> isBreak; - - if (lb != -1) - emit sample(c, lb, ld, isBreak); - - lb = b; - ld = d; -} - -CanvasFrameRate::CanvasFrameRate(QWidget *parent) -: QWidget(parent), - m_plugin(0) -{ - m_tabs = new QTabWidget(this); - - QHBoxLayout *bottom = new QHBoxLayout; - bottom->setMargin(0); - bottom->setSpacing(10); - - m_res = new QSpinBox; - m_res->setRange(30, 200); - m_res->setValue(m_res->minimum()); - m_res->setSingleStep(10); - m_res->setSuffix(QLatin1String("ms")); - bottom->addWidget(new QLabel(tr("Resolution:"))); - bottom->addWidget(m_res); - - bottom->addStretch(); - - m_clearButton = new QPushButton(tr("Clear")); - connect(m_clearButton, SIGNAL(clicked()), SLOT(clearGraph())); - bottom->addWidget(m_clearButton); - - QPushButton *pb = new QPushButton(tr("New Graph"), this); - connect(pb, SIGNAL(clicked()), this, SLOT(newTab())); - bottom->addWidget(pb); - - m_group = new QGroupBox(tr("Enabled")); - m_group->setCheckable(true); - m_group->setChecked(false); - connect(m_group, SIGNAL(toggled(bool)), SLOT(enabledToggled(bool))); - - QVBoxLayout *groupLayout = new QVBoxLayout(m_group); - groupLayout->setContentsMargins(5, 0, 5, 0); - groupLayout->setSpacing(2); - groupLayout->addWidget(m_tabs); - groupLayout->addLayout(bottom); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 10, 0, 0); - layout->setSpacing(0); - layout->addWidget(m_group); - setLayout(layout); -} - -void CanvasFrameRate::reset(QmlDebugConnection *conn) -{ - delete m_plugin; - m_plugin = 0; - - QWidget *w; - for (int i=0; i<m_tabs->count(); i++) { - w = m_tabs->widget(i); - m_tabs->removeTab(i); - delete w; - } - - if (conn) { - connect(conn, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - SLOT(connectionStateChanged(QAbstractSocket::SocketState))); - if (conn->state() == QAbstractSocket::ConnectedState) - handleConnected(conn); - } -} - -void CanvasFrameRate::connectionStateChanged(QAbstractSocket::SocketState state) -{ - if (state == QAbstractSocket::UnconnectedState) { - delete m_plugin; - m_plugin = 0; - } else if (state == QAbstractSocket::ConnectedState) { - handleConnected(qobject_cast<QmlDebugConnection*>(sender())); - } -} - -void CanvasFrameRate::handleConnected(QmlDebugConnection *conn) -{ - delete m_plugin; - m_plugin = new CanvasFrameRatePlugin(conn); - enabledToggled(m_group->isChecked()); - newTab(); -} - -void CanvasFrameRate::setSizeHint(const QSize &size) -{ - m_sizeHint = size; -} - -QSize CanvasFrameRate::sizeHint() const -{ - return m_sizeHint; -} - -void CanvasFrameRate::clearGraph() -{ - if (m_tabs->count()) { - GraphWindow *w = qobject_cast<GraphWindow*>(m_tabs->currentWidget()); - if (w) - w->clear(); - } -} - -void CanvasFrameRate::newTab() -{ - if (!m_plugin) - return; - - if (m_tabs->count()) { - QWidget *w = m_tabs->widget(m_tabs->count() - 1); - QObject::disconnect(m_plugin, SIGNAL(sample(int,int,int,bool)), - w, SLOT(addSample(int,int,int,bool))); - } - - int count = m_tabs->count(); - - GraphWindow *graph = new GraphWindow; - graph->setResolutionForHeight(m_res->value()); - connect(m_plugin, SIGNAL(sample(int,int,int,bool)), - graph, SLOT(addSample(int,int,int,bool))); - connect(m_res, SIGNAL(valueChanged(int)), - graph, SLOT(setResolutionForHeight(int))); - - QString name = QLatin1String("Graph ") + QString::number(count + 1); - m_tabs->addTab(graph, name); - m_tabs->setCurrentIndex(count); -} - -void CanvasFrameRate::enabledToggled(bool checked) -{ - if (m_plugin) - static_cast<QmlDebugClient *>(m_plugin)->setEnabled(checked); -} - -QT_END_NAMESPACE - -#include "canvasframerate.moc" diff --git a/tools/qmldebugger/standalone/canvasframerate.h b/tools/qmldebugger/standalone/canvasframerate.h deleted file mode 100644 index b31d607..0000000 --- a/tools/qmldebugger/standalone/canvasframerate.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef CANVASFRAMERATE_H -#define CANVASFRAMERATE_H - -#include <QtCore/qpointer.h> -#include <QtGui/qwidget.h> - -#include <private/qmldebugclient_p.h> - -QT_BEGIN_NAMESPACE - -class QTabWidget; -class QSlider; -class QGroupBox; -class QLabel; -class QSpinBox; -class QPushButton; - -class CanvasFrameRatePlugin; - -class CanvasFrameRate : public QWidget -{ - Q_OBJECT -public: - CanvasFrameRate(QWidget *parent = 0); - - void reset(QmlDebugConnection *conn); - - void setSizeHint(const QSize &); - virtual QSize sizeHint() const; - -private slots: - void clearGraph(); - void newTab(); - void enabledToggled(bool); - void connectionStateChanged(QAbstractSocket::SocketState state); - -private: - void handleConnected(QmlDebugConnection *conn); - - QGroupBox *m_group; - QTabWidget *m_tabs; - QSpinBox *m_res; - QPushButton *m_clearButton; - CanvasFrameRatePlugin *m_plugin; - QSize m_sizeHint; -}; - -QT_END_NAMESPACE - -#endif // CANVASFRAMERATE_H - diff --git a/tools/qmldebugger/standalone/engine.cpp b/tools/qmldebugger/standalone/engine.cpp deleted file mode 100644 index 894f97d..0000000 --- a/tools/qmldebugger/standalone/engine.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QVBoxLayout> -#include <QHBoxLayout> -#include <QSplitter> -#include <QTabWidget> -#include <QFile> - -#include <private/qmlenginedebug_p.h> -#include <private/qmldebugclient_p.h> -#include <QtDeclarative/qmlcomponent.h> -#include <QtDeclarative/qmlgraphicsitem.h> -#include <private/qmldebugservice_p.h> - -#include "engine.h" -#include "objectpropertiesview.h" -#include "expressionquerywidget.h" -#include "objecttree.h" -#include "watchtable.h" - -QT_BEGIN_NAMESPACE - - -class DebuggerEngineItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name CONSTANT); - Q_PROPERTY(int engineId READ engineId CONSTANT); - -public: - DebuggerEngineItem(const QString &name, int id) - : m_name(name), m_engineId(id) {} - - QString name() const { return m_name; } - int engineId() const { return m_engineId; } - -private: - QString m_name; - int m_engineId; -}; - -EnginePane::EnginePane(QmlDebugConnection *conn, QWidget *parent) -: QWidget(parent), m_client(new QmlEngineDebug(conn, this)), m_engines(0), m_context(0), m_watchTableModel(0), m_exprQueryWidget(0) -{ - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - - QFile enginesFile(":/engines.qml"); - enginesFile.open(QFile::ReadOnly); - Q_ASSERT(enginesFile.isOpen()); - - m_engineView = new QmlView(this); - m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); - m_engineView->setContentResizable(true); - m_engineView->setQml(enginesFile.readAll()); - m_engineView->execute(); - m_engineView->setFixedHeight(100); - QObject::connect(m_engineView->root(), SIGNAL(engineClicked(int)), - this, SLOT(engineSelected(int))); - QObject::connect(m_engineView->root(), SIGNAL(refreshEngines()), - this, SLOT(refreshEngines())); - - m_engineView->setVisible(false); - layout->addWidget(m_engineView); - - QSplitter *splitter = new QSplitter; - - m_objTree = new ObjectTree(m_client, this); - m_propertiesView = new ObjectPropertiesView(m_client); - m_watchTableModel = new WatchTableModel(m_client, this); - - m_watchTableView = new WatchTableView(m_watchTableModel); - m_watchTableView->setModel(m_watchTableModel); - WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel); - m_watchTableView->setHorizontalHeader(header); - - connect(m_objTree, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), - m_propertiesView, SLOT(reload(QmlDebugObjectReference))); - connect(m_objTree, SIGNAL(expressionWatchRequested(QmlDebugObjectReference,QString)), - m_watchTableModel, SLOT(expressionWatchRequested(QmlDebugObjectReference,QString))); - - connect(m_propertiesView, SIGNAL(activated(QmlDebugObjectReference,QmlDebugPropertyReference)), - m_watchTableModel, SLOT(togglePropertyWatch(QmlDebugObjectReference,QmlDebugPropertyReference))); - - connect(m_watchTableModel, SIGNAL(watchCreated(QmlDebugWatch*)), - m_propertiesView, SLOT(watchCreated(QmlDebugWatch*))); - - connect(m_watchTableView, SIGNAL(objectActivated(int)), - m_objTree, SLOT(setCurrentObject(int))); - - m_exprQueryWidget = new ExpressionQueryWidget(ExpressionQueryWidget::SeparateEntryMode, m_client); - connect(m_objTree, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), - m_exprQueryWidget, SLOT(setCurrentObject(QmlDebugObjectReference))); - - QSplitter *propertiesTab = new QSplitter(Qt::Vertical); - propertiesTab->addWidget(m_propertiesView); - propertiesTab->addWidget(m_exprQueryWidget); - propertiesTab->setStretchFactor(0, 2); - propertiesTab->setStretchFactor(1, 1); - - m_tabs = new QTabWidget(this); - m_tabs->addTab(propertiesTab, tr("Properties")); - m_tabs->addTab(m_watchTableView, tr("Watched")); - - splitter->addWidget(m_objTree); - splitter->addWidget(m_tabs); - splitter->setStretchFactor(1, 2); - layout->addWidget(splitter); -} - -void EnginePane::engineSelected(int id) -{ - qWarning() << "Engine selected" << id; - queryContext(id); -} - -void EnginePane::queryContext(int id) -{ - if (m_context) { - delete m_context; - m_context = 0; - } - - m_context = m_client->queryRootContexts(QmlDebugEngineReference(id), this); - if (!m_context->isWaiting()) - contextChanged(); - else - QObject::connect(m_context, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(contextChanged())); -} - -void EnginePane::contextChanged() -{ - //dump(m_context->rootContext(), 0); - - foreach (const QmlDebugObjectReference &object, m_context->rootContext().objects()) - m_objTree->reload(object.debugId()); - - delete m_context; m_context = 0; -} - -void EnginePane::refreshEngines() -{ - if (m_engines) - return; - - m_engines = m_client->queryAvailableEngines(this); - if (!m_engines->isWaiting()) - enginesChanged(); - else - QObject::connect(m_engines, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(enginesChanged())); -} - -void EnginePane::enginesChanged() -{ - qDeleteAll(m_engineItems); - m_engineItems.clear(); - - QList<QmlDebugEngineReference> engines = m_engines->engines(); - delete m_engines; m_engines = 0; - - if (engines.isEmpty()) - qWarning("qmldebugger: no engines found!"); - - for (int ii = 0; ii < engines.count(); ++ii) - m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), - engines.at(ii).debugId()); - - m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); - - m_engineView->setVisible(m_engineItems.count() > 1); - if (m_engineItems.count() == 1) - engineSelected(qobject_cast<DebuggerEngineItem*>(m_engineItems.at(0))->engineId()); -} - - -#include "engine.moc" - -QT_END_NAMESPACE - diff --git a/tools/qmldebugger/standalone/engine.h b/tools/qmldebugger/standalone/engine.h deleted file mode 100644 index ee706624..0000000 --- a/tools/qmldebugger/standalone/engine.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef ENGINE_H -#define ENGINE_H - -#include <QWidget> -#include <QtCore/qpointer.h> -#include <QtDeclarative/qmlengine.h> -#include <QtDeclarative/qmlcontext.h> -#include <QtDeclarative/qmlview.h> -#include <private/qmldebug_p.h> - -QT_BEGIN_NAMESPACE - -class ObjectPropertiesView; -class QmlDebugConnection; -class QmlDebugPropertyReference; -class QmlDebugWatch; -class ObjectTree; -class WatchTableModel; -class WatchTableView; -class ExpressionQueryWidget; - -class QTabWidget; - -class EnginePane : public QWidget -{ -Q_OBJECT -public: - EnginePane(QmlDebugConnection *, QWidget *parent = 0); - -public slots: - void refreshEngines(); - -private slots: - void enginesChanged(); - - void queryContext(int); - void contextChanged(); - - void engineSelected(int); - -private: - QmlEngineDebug *m_client; - QmlDebugEnginesQuery *m_engines; - QmlDebugRootContextQuery *m_context; - - ObjectTree *m_objTree; - QTabWidget *m_tabs; - WatchTableView *m_watchTableView; - WatchTableModel *m_watchTableModel; - ExpressionQueryWidget *m_exprQueryWidget; - - QmlView *m_engineView; - QList<QObject *> m_engineItems; - - ObjectPropertiesView *m_propertiesView; -}; - -QT_END_NAMESPACE - -#endif // ENGINE_H - diff --git a/tools/qmldebugger/standalone/engine.png b/tools/qmldebugger/standalone/engine.png Binary files differdeleted file mode 100644 index a0a8a04..0000000 --- a/tools/qmldebugger/standalone/engine.png +++ /dev/null diff --git a/tools/qmldebugger/standalone/engines.qml b/tools/qmldebugger/standalone/engines.qml deleted file mode 100644 index 0b2b7ac..0000000 --- a/tools/qmldebugger/standalone/engines.qml +++ /dev/null @@ -1,46 +0,0 @@ -import Qt 4.6 - -Item { - height: 100 - id: root - signal engineClicked(int id) - signal refreshEngines() - - Row { - anchors.fill: parent - Repeater { - model: engines - Item { - width: 100; height: 100; - Image { - id: engineIcon; - source: "qrc:/engine.png" - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - anchors.top: engineIcon.bottom; - text: modelData.name + "(" + modelData.engineId + ")" - anchors.horizontalCenter: parent.horizontalCenter - } - MouseRegion { - anchors.fill: parent - onClicked: root.engineClicked(modelData.engineId); - } - } - } - } - - - Image { - y: 15 - source: "qrc:/refresh.png"; - width: 75; - height: 63; - smooth: true - anchors.right: parent.right - MouseRegion { - anchors.fill: parent - onClicked: root.refreshEngines() - } - } -} diff --git a/tools/qmldebugger/standalone/expressionquerywidget.cpp b/tools/qmldebugger/standalone/expressionquerywidget.cpp deleted file mode 100644 index a068982..0000000 --- a/tools/qmldebugger/standalone/expressionquerywidget.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QtCore/qdebug.h> - -#include <QtGui/qlabel.h> -#include <QtGui/qtextedit.h> -#include <QtGui/qlineedit.h> -#include <QtGui/qpushbutton.h> -#include <QtGui/qevent.h> -#include <QtGui/qgroupbox.h> -#include <QtGui/qtextobject.h> -#include <QtGui/qlayout.h> - -#include "expressionquerywidget.h" - -ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QmlEngineDebug *client, QWidget *parent) - : QWidget(parent), - m_mode(mode), - m_client(client), - m_query(0), - m_textEdit(new QTextEdit), - m_lineEdit(0) -{ - m_prompt = QLatin1String(">> "); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(m_textEdit); - - updateTitle(); - - if (m_mode == SeparateEntryMode) { - m_lineEdit = new QLineEdit; - connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression())); - QHBoxLayout *hbox = new QHBoxLayout; - hbox->setMargin(5); - hbox->setSpacing(5); - hbox->addWidget(new QLabel(tr("Expression:"))); - hbox->addWidget(m_lineEdit); - layout->addLayout(hbox); - - m_textEdit->setReadOnly(true); - m_lineEdit->installEventFilter(this); - } else { - m_textEdit->installEventFilter(this); - appendPrompt(); - } -} - -void ExpressionQueryWidget::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ExpressionQueryWidget::clear() -{ - m_textEdit->clear(); - if (m_lineEdit) - m_lineEdit->clear(); - if (m_mode == ShellMode) - appendPrompt(); -} - -void ExpressionQueryWidget::updateTitle() -{ - if (m_currObject.debugId() < 0) { - m_title = tr("Expression queries"); - } else { - QString desc = QLatin1String("<") - + m_currObject.className() + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("<unnamed>") : m_currObject.name()) - + QLatin1String(">"); - m_title = tr("Expression queries (using context for %1)" , "Selected object").arg(desc); - } -} - -void ExpressionQueryWidget::appendPrompt() -{ - m_textEdit->moveCursor(QTextCursor::End); - - if (m_mode == SeparateEntryMode) { - m_textEdit->insertPlainText("\n"); - } else { - m_textEdit->setTextColor(Qt::gray); - m_textEdit->append(m_prompt); - } -} - -void ExpressionQueryWidget::setCurrentObject(const QmlDebugObjectReference &obj) -{ - m_currObject = obj; - updateTitle(); -} - -void ExpressionQueryWidget::checkCurrentContext() -{ - m_textEdit->moveCursor(QTextCursor::End); - - if (m_currObject.debugId() != -1 && m_currObject.debugId() != m_objectAtLastFocus.debugId()) - showCurrentContext(); - m_objectAtLastFocus = m_currObject; -} - -void ExpressionQueryWidget::showCurrentContext() -{ - if (m_mode == ShellMode) { - // clear the initial prompt - if (m_textEdit->document()->lineCount() == 1) - m_textEdit->clear(); - } - - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->setTextColor(Qt::darkGreen); - m_textEdit->append(m_currObject.className() - + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("<unnamed object>") : m_currObject.name())); - appendPrompt(); -} - -void ExpressionQueryWidget::executeExpression() -{ - if (!m_client) - return; - - if (m_mode == SeparateEntryMode) - m_expr = m_lineEdit->text().trimmed(); - else - m_expr = m_expr.trimmed(); - - if (!m_expr.isEmpty() && m_currObject.debugId() != -1) { - if (m_query) - delete m_query; - m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr, this); - if (!m_query->isWaiting()) - showResult(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(showResult())); - - m_lastExpr = m_expr; - if (m_lineEdit) - m_lineEdit->clear(); - } -} - -void ExpressionQueryWidget::showResult() -{ - if (m_query) { - m_textEdit->moveCursor(QTextCursor::End); - QVariant value = m_query->result(); - QString result; - - if (value.type() == QVariant::List || value.type() == QVariant::StringList) { - result = tr("<%1 items>", "%1 = number of items").arg(value.toList().count()); - } else if (value.isNull()) { - result = QLatin1String("<no value>"); - } else { - result = value.toString(); - } - - if (m_mode == SeparateEntryMode) { - m_textEdit->setTextColor(Qt::black); - m_textEdit->setFontWeight(QFont::Bold); - m_textEdit->insertPlainText(m_expr + " : "); - m_textEdit->setFontWeight(QFont::Normal); - m_textEdit->insertPlainText(result); - } else { - m_textEdit->setTextColor(Qt::darkGreen); - m_textEdit->insertPlainText(" => "); - m_textEdit->setTextColor(Qt::black); - m_textEdit->insertPlainText(result); - } - appendPrompt(); - m_expr.clear(); - } -} - -bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == m_textEdit) { - switch (event->type()) { - case QEvent::KeyPress: - { - QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); - int key = keyEvent->key(); - if (key == Qt::Key_Return || key == Qt::Key_Enter) { - executeExpression(); - return true; - } else if (key == Qt::Key_Backspace) { - // ensure m_expr doesn't contain backspace characters - QTextCursor cursor = m_textEdit->textCursor(); - bool atLastLine = !(cursor.block().next().isValid()); - if (!atLastLine) - return true; - if (cursor.columnNumber() <= m_prompt.count()) - return true; - cursor.deletePreviousChar(); - m_expr = cursor.block().text().mid(m_prompt.count()); - return true; - } else { - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->setTextColor(Qt::black); - m_expr += keyEvent->text(); - } - break; - } - case QEvent::FocusIn: - checkCurrentContext(); - m_textEdit->moveCursor(QTextCursor::End); - break; - default: - break; - } - } else if (obj == m_lineEdit) { - switch (event->type()) { - case QEvent::KeyPress: - { - QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); - int key = keyEvent->key(); - if (key == Qt::Key_Up && m_lineEdit->text() != m_lastExpr) { - m_expr = m_lineEdit->text(); - if (!m_lastExpr.isEmpty()) - m_lineEdit->setText(m_lastExpr); - } else if (key == Qt::Key_Down) { - m_lineEdit->setText(m_expr); - } - break; - } - case QEvent::FocusIn: - checkCurrentContext(); - break; - default: - break; - } - } - return QWidget::eventFilter(obj, event); -} diff --git a/tools/qmldebugger/standalone/objectpropertiesview.cpp b/tools/qmldebugger/standalone/objectpropertiesview.cpp deleted file mode 100644 index b6089c3..0000000 --- a/tools/qmldebugger/standalone/objectpropertiesview.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QtCore/qdebug.h> - -#include <QtGui/qtreewidget.h> -#include <QtGui/qlayout.h> -#include <QtGui/qheaderview.h> - -#include <private/qmldebugservice_p.h> -#include <private/qmldebug_p.h> -#include <private/qmldebugclient_p.h> - -#include "objectpropertiesview.h" - -QT_BEGIN_NAMESPACE - -class PropertiesViewItem : public QObject, public QTreeWidgetItem -{ - Q_OBJECT -public: - enum Type { - BindingType, - OtherType - }; - - PropertiesViewItem(QTreeWidget *widget, Type type = OtherType); - PropertiesViewItem(QTreeWidgetItem *parent, Type type = OtherType); - - QmlDebugPropertyReference property; - Type type; -}; - -PropertiesViewItem::PropertiesViewItem(QTreeWidget *widget, Type type) - : QTreeWidgetItem(widget), type(type) -{ -} - -PropertiesViewItem::PropertiesViewItem(QTreeWidgetItem *parent, Type type) - : QTreeWidgetItem(parent), type(type) -{ -} - -ObjectPropertiesView::ObjectPropertiesView(QmlEngineDebug *client, QWidget *parent) - : QWidget(parent), - m_client(client), - m_query(0), - m_watch(0) -{ - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - setLayout(layout); - - m_tree = new QTreeWidget(this); - m_tree->setAlternatingRowColors(true); - m_tree->setExpandsOnDoubleClick(false); - m_tree->setHeaderLabels(QStringList() - << tr("Name") << tr("Value") << tr("Type")); - QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - this, SLOT(itemActivated(QTreeWidgetItem *))); - - m_tree->setColumnCount(3); - m_tree->header()->setDefaultSectionSize(150); - - layout->addWidget(m_tree); -} - -void ObjectPropertiesView::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ObjectPropertiesView::clear() -{ - setObject(QmlDebugObjectReference()); -} - -void ObjectPropertiesView::reload(const QmlDebugObjectReference &obj) -{ - if (!m_client) - return; - if (m_query) - delete m_query; - - m_query = m_client->queryObjectRecursive(obj, this); - if (!m_query->isWaiting()) - queryFinished(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(queryFinished())); -} - -void ObjectPropertiesView::queryFinished() -{ - if (!m_client || !m_query) - return; - - QmlDebugObjectReference obj = m_query->object(); - - QmlDebugWatch *watch = m_client->addWatch(obj, this); - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - if (m_watch) { - m_client->removeWatch(m_watch); - delete m_watch; - } - m_watch = watch; - QObject::connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), - this, SLOT(valueChanged(QByteArray,QVariant))); - } - - delete m_query; - m_query = 0; - - setObject(obj); -} - -void ObjectPropertiesView::setPropertyValue(PropertiesViewItem *item, const QVariant &value, bool makeGray) -{ - if (value.type() == QVariant::List || value.type() == QVariant::StringList) { - PropertiesViewItem *bindingItem = static_cast<PropertiesViewItem*>(item->takeChild(item->childCount() - 1)); - if (bindingItem && bindingItem->type != PropertiesViewItem::BindingType) { - delete bindingItem; - bindingItem = 0; - } - - qDeleteAll(item->takeChildren()); - - QVariantList variants = value.toList(); - item->setText(1, tr("<%1 items>", "%1 = number of items").arg(variants.count())); - item->setText(2, QString::fromUtf8(value.typeName())); - - PropertiesViewItem *child; - for (int i=0; i<variants.count(); i++) { - child = new PropertiesViewItem(item); - setPropertyValue(child, variants[i], makeGray); - } - - if (bindingItem) - item->addChild(bindingItem); - - item->setExpanded(false); - } else { - item->setText(1, (value.isNull() ? QLatin1String("<no value>") : value.toString())); - item->setExpanded(true); - } - - if (makeGray) { - for (int i=0; i<m_tree->columnCount(); i++) - item->setForeground(i, Qt::gray); - } -} - -void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object) -{ - m_object = object; - m_tree->clear(); - - QList<QmlDebugPropertyReference> properties = object.properties(); - for (int i=0; i<properties.count(); i++) { - const QmlDebugPropertyReference &p = properties[i]; - - PropertiesViewItem *item = new PropertiesViewItem(m_tree); - item->property = p; - - item->setText(0, p.name()); - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - setPropertyValue(item, p.value(), !p.hasNotifySignal()); - item->setText(2, p.valueTypeName()); - - // binding is set after property value to ensure it is added to the end of the - // list, if the value is a list - if (!p.binding().isEmpty()) { - PropertiesViewItem *binding = new PropertiesViewItem(item, PropertiesViewItem::BindingType); - binding->setText(1, p.binding()); - binding->setForeground(1, Qt::darkGreen); - } - } -} - -void ObjectPropertiesView::watchCreated(QmlDebugWatch *watch) -{ - if (watch->objectDebugId() == m_object.debugId() - && qobject_cast<QmlDebugPropertyWatch*>(watch)) { - connect(watch, SIGNAL(stateChanged(QmlDebugWatch::State)), SLOT(watchStateChanged())); - setWatched(qobject_cast<QmlDebugPropertyWatch*>(watch)->name(), true); - } -} - -void ObjectPropertiesView::watchStateChanged() -{ - QmlDebugWatch *watch = qobject_cast<QmlDebugWatch*>(sender()); - - if (watch->objectDebugId() == m_object.debugId() - && qobject_cast<QmlDebugPropertyWatch*>(watch) - && watch->state() == QmlDebugWatch::Inactive) { - setWatched(qobject_cast<QmlDebugPropertyWatch*>(watch)->name(), false); - } -} - -void ObjectPropertiesView::setWatched(const QString &property, bool watched) -{ - for (int i=0; i<m_tree->topLevelItemCount(); i++) { - PropertiesViewItem *item = static_cast<PropertiesViewItem *>(m_tree->topLevelItem(i)); - if (item->property.name() == property && item->property.hasNotifySignal()) { - QFont font = m_tree->font(); - font.setBold(watched); - item->setFont(0, font); - } - } -} - -void ObjectPropertiesView::valueChanged(const QByteArray &name, const QVariant &value) -{ - for (int i=0; i<m_tree->topLevelItemCount(); i++) { - PropertiesViewItem *item = static_cast<PropertiesViewItem *>(m_tree->topLevelItem(i)); - if (item->property.name() == name) { - setPropertyValue(item, value, !item->property.hasNotifySignal()); - return; - } - } -} - -void ObjectPropertiesView::itemActivated(QTreeWidgetItem *i) -{ - PropertiesViewItem *item = static_cast<PropertiesViewItem *>(i); - if (!item->property.name().isEmpty()) - emit activated(m_object, item->property); -} - -QT_END_NAMESPACE - -#include "objectpropertiesview.moc" diff --git a/tools/qmldebugger/standalone/objectpropertiesview.h b/tools/qmldebugger/standalone/objectpropertiesview.h deleted file mode 100644 index e524033..0000000 --- a/tools/qmldebugger/standalone/objectpropertiesview.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PROPERTIESTABLEMODEL_H -#define PROPERTIESTABLEMODEL_H - -#include <private/qmldebug_p.h> - -#include <QtGui/qwidget.h> - -QT_BEGIN_NAMESPACE - -class QTreeWidget; -class QTreeWidgetItem; -class QmlDebugConnection; -class PropertiesViewItem; - -class ObjectPropertiesView : public QWidget -{ - Q_OBJECT -public: - ObjectPropertiesView(QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - void clear(); - -signals: - void activated(const QmlDebugObjectReference &, const QmlDebugPropertyReference &); - -public slots: - void reload(const QmlDebugObjectReference &); - void watchCreated(QmlDebugWatch *); - -private slots: - void queryFinished(); - void watchStateChanged(); - void valueChanged(const QByteArray &name, const QVariant &value); - void itemActivated(QTreeWidgetItem *i); - -private: - void setObject(const QmlDebugObjectReference &object); - void setWatched(const QString &property, bool watched); - void setPropertyValue(PropertiesViewItem *item, const QVariant &value, bool makeGray); - - QmlEngineDebug *m_client; - QmlDebugObjectQuery *m_query; - QmlDebugWatch *m_watch; - - QTreeWidget *m_tree; - QmlDebugObjectReference m_object; -}; - - -QT_END_NAMESPACE - -#endif diff --git a/tools/qmldebugger/standalone/objecttree.cpp b/tools/qmldebugger/standalone/objecttree.cpp deleted file mode 100644 index 11857a6..0000000 --- a/tools/qmldebugger/standalone/objecttree.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QtGui/qevent.h> -#include <QtGui/qmenu.h> -#include <QtGui/qaction.h> - -#include <QInputDialog> - -#include <private/qmldebugservice_p.h> -#include <private/qmldebug_p.h> -#include <private/qmldebugclient_p.h> - -#include "objecttree.h" - -Q_DECLARE_METATYPE(QmlDebugObjectReference) - -ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent) - : QTreeWidget(parent), - m_client(client), - m_query(0) -{ - setHeaderHidden(true); - setMinimumWidth(250); - setExpandsOnDoubleClick(false); - - connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - SLOT(currentItemChanged(QTreeWidgetItem *))); - connect(this, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - SLOT(activated(QTreeWidgetItem *))); -} - -void ObjectTree::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ObjectTree::reload(int objectDebugId) -{ - if (!m_client) - return; - - if (m_query) { - delete m_query; - m_query = 0; - } - - m_query = m_client->queryObjectRecursive(QmlDebugObjectReference(objectDebugId), this); - if (!m_query->isWaiting()) - objectFetched(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(objectFetched())); -} - -void ObjectTree::setCurrentObject(int debugId) -{ - QTreeWidgetItem *item = findItemByObjectId(debugId); - if (item) { - setCurrentItem(item); - scrollToItem(item); - item->setExpanded(true); - } -} - -void ObjectTree::objectFetched() -{ - dump(m_query->object(), 0); - buildTree(m_query->object(), 0); - setCurrentItem(topLevelItem(0)); - - delete m_query; - m_query = 0; -} - -void ObjectTree::currentItemChanged(QTreeWidgetItem *item) -{ - if (!item) - return; - - QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (obj.debugId() >= 0) - emit currentObjectChanged(obj); -} - -void ObjectTree::activated(QTreeWidgetItem *item) -{ - if (!item) - return; - - QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (obj.debugId() >= 0) - emit activated(obj); -} - -void ObjectTree::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) -{ - if (!parent) - clear(); - - QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(this); - item->setText(0, obj.className()); - item->setData(0, Qt::UserRole, qVariantFromValue(obj)); - - if (parent && obj.contextDebugId() >= 0 - && obj.contextDebugId() != parent->data(0, Qt::UserRole - ).value<QmlDebugObjectReference>().contextDebugId()) { - QmlDebugFileReference source = obj.source(); - if (!source.url().isEmpty()) { - QString toolTipString = QLatin1String("URL: ") + source.url().toString(); - item->setToolTip(0, toolTipString); - } - item->setForeground(0, QColor("orange")); - } else { - item->setExpanded(true); - } - - if (obj.contextDebugId() < 0) - item->setForeground(0, Qt::lightGray); - - for (int ii = 0; ii < obj.children().count(); ++ii) - buildTree(obj.children().at(ii), item); -} - -void ObjectTree::dump(const QmlDebugContextReference &ctxt, int ind) -{ - QByteArray indent(ind * 4, ' '); - qWarning().nospace() << indent.constData() << ctxt.debugId() << " " - << qPrintable(ctxt.name()); - - for (int ii = 0; ii < ctxt.contexts().count(); ++ii) - dump(ctxt.contexts().at(ii), ind + 1); - - for (int ii = 0; ii < ctxt.objects().count(); ++ii) - dump(ctxt.objects().at(ii), ind); -} - -void ObjectTree::dump(const QmlDebugObjectReference &obj, int ind) -{ - QByteArray indent(ind * 4, ' '); - qWarning().nospace() << indent.constData() << qPrintable(obj.className()) - << " " << qPrintable(obj.name()) << " " - << obj.debugId(); - - for (int ii = 0; ii < obj.children().count(); ++ii) - dump(obj.children().at(ii), ind + 1); -} - -QTreeWidgetItem *ObjectTree::findItemByObjectId(int debugId) const -{ - for (int i=0; i<topLevelItemCount(); i++) { - QTreeWidgetItem *item = findItem(topLevelItem(i), debugId); - if (item) - return item; - } - - return 0; -} - -QTreeWidgetItem *ObjectTree::findItem(QTreeWidgetItem *item, int debugId) const -{ - if (item->data(0, Qt::UserRole).value<QmlDebugObjectReference>().debugId() == debugId) - return item; - - QTreeWidgetItem *child; - for (int i=0; i<item->childCount(); i++) { - child = findItem(item->child(i), debugId); - if (child) - return child; - } - - return 0; -} - -void ObjectTree::mousePressEvent(QMouseEvent *me) -{ - QTreeWidget::mousePressEvent(me); - if (!currentItem()) - return; - if(me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { - QAction action(tr("Add watch..."), 0); - QList<QAction *> actions; - actions << &action; - QmlDebugObjectReference obj = - currentItem()->data(0, Qt::UserRole).value<QmlDebugObjectReference>(); - if (QMenu::exec(actions, me->globalPos())) { - bool ok = false; - QString watch = QInputDialog::getText(this, tr("Watch expression"), - tr("Expression:"), QLineEdit::Normal, QString(), &ok); - if (ok && !watch.isEmpty()) - emit expressionWatchRequested(obj, watch); - } - } -} diff --git a/tools/qmldebugger/standalone/objecttree.h b/tools/qmldebugger/standalone/objecttree.h deleted file mode 100644 index 31c257f..0000000 --- a/tools/qmldebugger/standalone/objecttree.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef OBJECTTREE_H -#define OBJECTTREE_H - -#include <QtGui/qtreewidget.h> - -QT_BEGIN_NAMESPACE - -class QTreeWidgetItem; - -class QmlEngineDebug; -class QmlDebugObjectReference; -class QmlDebugObjectQuery; -class QmlDebugContextReference; -class QmlDebugConnection; - - -class ObjectTree : public QTreeWidget -{ - Q_OBJECT -public: - ObjectTree(QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - -signals: - void currentObjectChanged(const QmlDebugObjectReference &); - void activated(const QmlDebugObjectReference &); - void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); - -public slots: - void reload(int objectDebugId); // set the root object - void setCurrentObject(int debugId); // select an object in the tree - -protected: - virtual void mousePressEvent(QMouseEvent *); - -private slots: - void objectFetched(); - void currentItemChanged(QTreeWidgetItem *); - void activated(QTreeWidgetItem *); - -private: - QTreeWidgetItem *findItemByObjectId(int debugId) const; - QTreeWidgetItem *findItem(QTreeWidgetItem *item, int debugId) const; - void dump(const QmlDebugContextReference &, int); - void dump(const QmlDebugObjectReference &, int); - void buildTree(const QmlDebugObjectReference &, QTreeWidgetItem *parent); - - QmlEngineDebug *m_client; - QmlDebugObjectQuery *m_query; -}; - -QT_END_NAMESPACE - - -#endif diff --git a/tools/qmldebugger/standalone/qmldebugger.cpp b/tools/qmldebugger/standalone/qmldebugger.cpp deleted file mode 100644 index d713ce8..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QtCore/qtimer.h> -#include <QtCore/qdebug.h> -#include <QtCore/qsettings.h> - -#include <QtGui/qlayout.h> -#include <QtGui/qpushbutton.h> -#include <QtGui/qlineedit.h> -#include <QtGui/qtabwidget.h> -#include <QtGui/qspinbox.h> -#include <QtGui/qlabel.h> - -#include "canvasframerate.h" -#include "engine.h" -#include "qmldebugger.h" - -QmlDebugger::QmlDebugger(QWidget *parent) -: QWidget(parent) -{ - QVBoxLayout *layout = new QVBoxLayout; - setLayout(layout); - - QHBoxLayout *connectLayout = new QHBoxLayout; - layout->addLayout(connectLayout); - connectLayout->addStretch(2); - - m_connectionState = new QLabel(this); - connectLayout->addWidget(m_connectionState); - m_host = new QLineEdit(this); - connectLayout->addWidget(m_host); - m_port = new QSpinBox(this); - m_port->setMinimum(1024); - m_port->setMaximum(20000); - connectLayout->addWidget(m_port); - m_connectButton = new QPushButton(tr("Connect"), this); - QObject::connect(m_connectButton, SIGNAL(clicked()), - this, SLOT(connectToHost())); - connectLayout->addWidget(m_connectButton); - m_disconnectButton = new QPushButton(tr("Disconnect"), this); - QObject::connect(m_disconnectButton, SIGNAL(clicked()), - this, SLOT(disconnectFromHost())); - m_disconnectButton->setEnabled(false); - connectLayout->addWidget(m_disconnectButton); - - m_tabs = new QTabWidget(this); - layout->addWidget(m_tabs); - - CanvasFrameRate *cfr = new CanvasFrameRate(this); - cfr->reset(&client); - cfr->setSizeHint(QSize(800, 600)); - m_tabs->addTab(cfr, tr("Frame Rate")); - - m_enginePane = new EnginePane(&client, this); - m_tabs->addTab(m_enginePane, tr("QML Engine")); - - QObject::connect(&client, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - this, SLOT(connectionStateChanged())); - connectionStateChanged(); - - QObject::connect(&client, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(connectionError(QAbstractSocket::SocketError))); - - QSettings settings; - m_host->setText(settings.value("Host", "127.0.0.1").toString()); - m_port->setValue(settings.value("Port", 3768).toInt()); - - connectToHost(); -} - -void QmlDebugger::setHost(const QString &host) -{ - m_host->setText(host); -} - -void QmlDebugger::setPort(quint16 port) -{ - m_port->setValue(port); -} - -void QmlDebugger::showEngineTab() -{ - m_tabs->setCurrentWidget(m_enginePane); -} - -void QmlDebugger::closeEvent(QCloseEvent *event) -{ - QSettings settings; - settings.setValue("Host", m_host->text()); - settings.setValue("Port", m_port->value()); - - QWidget::closeEvent(event); -} - -void QmlDebugger::connectionStateChanged() -{ - switch (client.state()) { - default: - case QAbstractSocket::UnconnectedState: - m_connectionState->setText(tr("Disconnected")); - m_connectButton->setEnabled(true); - m_disconnectButton->setEnabled(false); - break; - case QAbstractSocket::HostLookupState: - m_connectionState->setText(tr("Resolving")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - break; - case QAbstractSocket::ConnectingState: - m_connectionState->setText(tr("Connecting")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - break; - case QAbstractSocket::ConnectedState: - m_connectionState->setText(tr("Connected")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - - QTimer::singleShot(0, m_enginePane, SLOT(refreshEngines())); - break; - case QAbstractSocket::ClosingState: - m_connectionState->setText(tr("Closing")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(false); - break; - } -} - -void QmlDebugger::connectionError(QAbstractSocket::SocketError socketError) -{ - qWarning() << "qmldebugger cannot connect:" << socketError - << client.errorString(); -} - -void QmlDebugger::connectToHost() -{ - client.connectToHost(m_host->text(), m_port->value()); -} - -void QmlDebugger::disconnectFromHost() -{ - client.disconnectFromHost(); -} diff --git a/tools/qmldebugger/standalone/qmldebugger.pri b/tools/qmldebugger/standalone/qmldebugger.pri deleted file mode 100644 index ede7d31..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.pri +++ /dev/null @@ -1,18 +0,0 @@ -QT += network declarative -contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl - -INCLUDEPATH += ../../../src/declarative/debugger - -# Input -HEADERS += $$PWD/canvasframerate.h \ - $$PWD/watchtable.h \ - $$PWD/objecttree.h \ - $$PWD/objectpropertiesview.h \ - $$PWD/expressionquerywidget.h - -SOURCES += $$PWD/canvasframerate.cpp \ - $$PWD/watchtable.cpp \ - $$PWD/objecttree.cpp \ - $$PWD/objectpropertiesview.cpp \ - $$PWD/expressionquerywidget.cpp - diff --git a/tools/qmldebugger/standalone/qmldebugger.qrc b/tools/qmldebugger/standalone/qmldebugger.qrc deleted file mode 100644 index cb53ad5..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>engines.qml</file> - <file>engine.png</file> - <file>refresh.png</file> - </qresource> -</RCC> diff --git a/tools/qmldebugger/standalone/refresh.png b/tools/qmldebugger/standalone/refresh.png Binary files differdeleted file mode 100644 index 8befc80..0000000 --- a/tools/qmldebugger/standalone/refresh.png +++ /dev/null diff --git a/tools/qmldebugger/standalone/standalone.pro b/tools/qmldebugger/standalone/standalone.pro deleted file mode 100644 index 72d051f..0000000 --- a/tools/qmldebugger/standalone/standalone.pro +++ /dev/null @@ -1,19 +0,0 @@ -DESTDIR = ../../../bin -TARGET = qmldebugger - -include(qmldebugger.pri) - -HEADERS += $$PWD/qmldebugger.h \ - $$PWD/engine.h - -SOURCES += $$PWD/qmldebugger.cpp \ - $$PWD/engine.cpp \ - $$PWD/main.cpp - -RESOURCES += $$PWD/qmldebugger.qrc -OTHER_FILES += $$PWD/engines.qml - -target.path=$$[QT_INSTALL_BINS] -INSTALLS += target - -CONFIG += console diff --git a/tools/qmldebugger/standalone/watchtable.cpp b/tools/qmldebugger/standalone/watchtable.cpp deleted file mode 100644 index 9d79a63..0000000 --- a/tools/qmldebugger/standalone/watchtable.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "watchtable.h" - -#include <QtCore/qdebug.h> -#include <QtGui/qevent.h> -#include <QtGui/qaction.h> -#include <QtGui/qmenu.h> - -#include <private/qmldebug_p.h> -#include <QtDeclarative/qmlmetatype.h> - -QT_BEGIN_NAMESPACE - - -WatchTableModel::WatchTableModel(QmlEngineDebug *client, QObject *parent) - : QAbstractTableModel(parent), - m_client(client) -{ -} - -WatchTableModel::~WatchTableModel() -{ - for (int i=0; i<m_columns.count(); i++) - delete m_columns[i].watch; -} - -void WatchTableModel::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void WatchTableModel::addWatch(QmlDebugWatch *watch, const QString &title) -{ - QString property; - if (qobject_cast<QmlDebugPropertyWatch *>(watch)) - property = qobject_cast<QmlDebugPropertyWatch *>(watch)->name(); - - connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), - SLOT(watchedValueChanged(QByteArray,QVariant))); - - connect(watch, SIGNAL(stateChanged(QmlDebugWatch::State)), SLOT(watchStateChanged())); - - int col = columnCount(QModelIndex()); - beginInsertColumns(QModelIndex(), col, col); - - WatchedEntity e; - e.title = title; - e.hasFirstValue = false; - e.property = property; - e.watch = watch; - m_columns.append(e); - - endInsertColumns(); -} - -void WatchTableModel::removeWatch(QmlDebugWatch *watch) -{ - int column = columnForWatch(watch); - if (column == -1) - return; - - WatchedEntity entity = m_columns.takeAt(column); - - for (QList<Value>::Iterator iter = m_values.begin(); iter != m_values.end();) { - if (iter->column == column) { - iter = m_values.erase(iter); - } else { - if(iter->column > column) - --iter->column; - ++iter; - } - } - - reset(); -} - -void WatchTableModel::updateWatch(QmlDebugWatch *watch, const QVariant &value) -{ - int column = columnForWatch(watch); - if (column == -1) - return; - - addValue(column, value); - - if (!m_columns[column].hasFirstValue) { - m_columns[column].hasFirstValue = true; - m_values[m_values.count() - 1].first = true; - } -} - -QmlDebugWatch *WatchTableModel::findWatch(int column) const -{ - if (column < m_columns.count()) - return m_columns.at(column).watch; - return 0; -} - -QmlDebugWatch *WatchTableModel::findWatch(int objectDebugId, const QString &property) const -{ - for (int i=0; i<m_columns.count(); i++) { - if (m_columns[i].watch->objectDebugId() == objectDebugId - && m_columns[i].property == property) { - return m_columns[i].watch; - } - } - return 0; -} - -int WatchTableModel::rowCount(const QModelIndex &) const -{ - return m_values.count(); -} - -int WatchTableModel::columnCount(const QModelIndex &) const -{ - return m_columns.count(); -} - -QVariant WatchTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal) { - if (section < m_columns.count() && role == Qt::DisplayRole) - return m_columns.at(section).title; - } else { - if (role == Qt::DisplayRole) - return section + 1; - } - return QVariant(); -} - -QVariant WatchTableModel::data(const QModelIndex &idx, int role) const -{ - if (m_values.at(idx.row()).column == idx.column()) { - if (role == Qt::DisplayRole) { - const QVariant &value = m_values.at(idx.row()).variant; - QString str = value.toString(); - - if (str.isEmpty() && QmlMetaType::isQObject(value.userType())) { - QObject *o = QmlMetaType::toQObject(value); - if(o) { - QString objectName = o->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String("<unnamed>"); - str = QLatin1String(o->metaObject()->className()) + - QLatin1String(": ") + objectName; - } - } - - if(str.isEmpty()) { - QDebug d(&str); - d << value; - } - return QVariant(str); - } else if(role == Qt::BackgroundRole) { - if(m_values.at(idx.row()).first) - return QColor(Qt::green); - else - return QVariant(); - } else { - return QVariant(); - } - } else { - return QVariant(); - } -} - -void WatchTableModel::watchStateChanged() -{ - QmlDebugWatch *watch = qobject_cast<QmlDebugWatch*>(sender()); - - if (watch && watch->state() == QmlDebugWatch::Inactive) { - removeWatch(watch); - watch->deleteLater(); - } -} - -int WatchTableModel::columnForWatch(QmlDebugWatch *watch) const -{ - for (int i=0; i<m_columns.count(); i++) { - if (m_columns.at(i).watch == watch) - return i; - } - return -1; -} - -void WatchTableModel::addValue(int column, const QVariant &value) -{ - int row = columnCount(QModelIndex()); - beginInsertRows(QModelIndex(), row, row); - - Value v; - v.column = column; - v.variant = value; - v.first = false; - m_values.append(v); - - endInsertRows(); -} - -void WatchTableModel::togglePropertyWatch(const QmlDebugObjectReference &object, const QmlDebugPropertyReference &property) -{ - if (!m_client || !property.hasNotifySignal()) - return; - - QmlDebugWatch *watch = findWatch(object.debugId(), property.name()); - if (watch) { - // watch will be deleted in watchStateChanged() - m_client->removeWatch(watch); - return; - } - - watch = m_client->addWatch(property, this); - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - QString desc = property.name() - + QLatin1String(" on\n") - + object.className() - + QLatin1String(":\n") - + (object.name().isEmpty() ? QLatin1String("<unnamed object>") : object.name()); - addWatch(watch, desc); - emit watchCreated(watch); - } -} - -void WatchTableModel::watchedValueChanged(const QByteArray &propertyName, const QVariant &value) -{ - Q_UNUSED(propertyName); - QmlDebugWatch *watch = qobject_cast<QmlDebugWatch*>(sender()); - if (watch) - updateWatch(watch, value); -} - -void WatchTableModel::expressionWatchRequested(const QmlDebugObjectReference &obj, const QString &expr) -{ - if (!m_client) - return; - - QmlDebugWatch *watch = m_client->addWatch(obj, expr, this); - - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - addWatch(watch, expr); - emit watchCreated(watch); - } -} - -void WatchTableModel::removeWatchAt(int column) -{ - if (!m_client) - return; - - QmlDebugWatch *watch = findWatch(column); - if (watch) { - m_client->removeWatch(watch); - delete watch; - watch = 0; - } -} - -void WatchTableModel::removeAllWatches() -{ - for (int i=0; i<m_columns.count(); i++) { - if (m_client) - m_client->removeWatch(m_columns[i].watch); - else - delete m_columns[i].watch; - } - m_columns.clear(); - m_values.clear(); - reset(); -} - -//---------------------------------------------- - -WatchTableHeaderView::WatchTableHeaderView(WatchTableModel *model, QWidget *parent) - : QHeaderView(Qt::Horizontal, parent), - m_model(model) -{ - setClickable(true); -} - -void WatchTableHeaderView::mousePressEvent(QMouseEvent *me) -{ - QHeaderView::mousePressEvent(me); - - if (me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { - int col = logicalIndexAt(me->pos()); - if (col >= 0) { - QAction action(tr("Stop watching"), 0); - QList<QAction *> actions; - actions << &action; - if (QMenu::exec(actions, me->globalPos())) - m_model->removeWatchAt(col); - } - } -} - - -//---------------------------------------------- - -WatchTableView::WatchTableView(WatchTableModel *model, QWidget *parent) - : QTableView(parent), - m_model(model) -{ - setAlternatingRowColors(true); - connect(model, SIGNAL(watchCreated(QmlDebugWatch*)), SLOT(watchCreated(QmlDebugWatch*))); - connect(this, SIGNAL(activated(QModelIndex)), SLOT(indexActivated(QModelIndex))); -} - -void WatchTableView::indexActivated(const QModelIndex &index) -{ - QmlDebugWatch *watch = m_model->findWatch(index.column()); - if (watch) - emit objectActivated(watch->objectDebugId()); -} - -void WatchTableView::watchCreated(QmlDebugWatch *watch) -{ - int column = m_model->columnForWatch(watch); - resizeColumnToContents(column); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/watchtable.h b/tools/qmldebugger/standalone/watchtable.h deleted file mode 100644 index 3dbba63..0000000 --- a/tools/qmldebugger/standalone/watchtable.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef WATCHTABLEMODEL_H -#define WATCHTABLEMODEL_H - -#include <QtCore/qpointer.h> -#include <QtCore/qlist.h> - -#include <QWidget> -#include <QHeaderView> -#include <QAbstractTableModel> -#include <QTableView> - -QT_BEGIN_NAMESPACE - -class QmlDebugWatch; -class QmlEngineDebug; -class QmlDebugConnection; -class QmlDebugPropertyReference; -class QmlDebugObjectReference; - -class WatchTableModel : public QAbstractTableModel -{ - Q_OBJECT -public: - WatchTableModel(QmlEngineDebug *client = 0, QObject *parent = 0); - ~WatchTableModel(); - - void setEngineDebug(QmlEngineDebug *client); - - QmlDebugWatch *findWatch(int column) const; - int columnForWatch(QmlDebugWatch *watch) const; - - void removeWatchAt(int column); - void removeAllWatches(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -signals: - void watchCreated(QmlDebugWatch *watch); - -public slots: - void togglePropertyWatch(const QmlDebugObjectReference &obj, const QmlDebugPropertyReference &prop); - void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); - -private slots: - void watchStateChanged(); - void watchedValueChanged(const QByteArray &propertyName, const QVariant &value); - -private: - void addWatch(QmlDebugWatch *watch, const QString &title); - void removeWatch(QmlDebugWatch *watch); - void updateWatch(QmlDebugWatch *watch, const QVariant &value); - - QmlDebugWatch *findWatch(int objectDebugId, const QString &property) const; - - void addValue(int column, const QVariant &value); - - struct WatchedEntity - { - QString title; - bool hasFirstValue; - QString property; - QPointer<QmlDebugWatch> watch; - }; - - struct Value { - int column; - QVariant variant; - bool first; - }; - - QmlEngineDebug *m_client; - QList<WatchedEntity> m_columns; - QList<Value> m_values; -}; - - -class WatchTableHeaderView : public QHeaderView -{ - Q_OBJECT -public: - WatchTableHeaderView(WatchTableModel *model, QWidget *parent = 0); - -protected: - void mousePressEvent(QMouseEvent *me); - -private: - WatchTableModel *m_model; -}; - - -class WatchTableView : public QTableView -{ - Q_OBJECT -public: - WatchTableView(WatchTableModel *model, QWidget *parent = 0); - -signals: - void objectActivated(int objectDebugId); - -private slots: - void indexActivated(const QModelIndex &index); - void watchCreated(QmlDebugWatch *watch); - -private: - WatchTableModel *m_model; -}; - - -QT_END_NAMESPACE - -#endif // WATCHTABLEMODEL_H diff --git a/tools/qmlviewer/content/Browser.qml b/tools/qmlviewer/content/Browser.qml index 446045b..35120bc 100644 --- a/tools/qmlviewer/content/Browser.qml +++ b/tools/qmlviewer/content/Browser.qml @@ -90,7 +90,7 @@ Rectangle { font.pixelSize: 32 color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText } - MouseRegion { + MouseArea { id: mouseRegion anchors.fill: parent onClicked: { launch() } @@ -211,7 +211,7 @@ Rectangle { color: "transparent" Image { anchors.centerIn: parent; source: "images/up.png" } - MouseRegion { id: upRegion; anchors.centerIn: parent + MouseArea { id: upRegion; anchors.centerIn: parent width: 56 height: 56 onClicked: if (folders.parentFolder != "") up() diff --git a/tools/qmlviewer/deviceorientation.cpp b/tools/qmlviewer/deviceorientation.cpp index 75ea48e..e7c70d5 100644 --- a/tools/qmlviewer/deviceorientation.cpp +++ b/tools/qmlviewer/deviceorientation.cpp @@ -41,6 +41,8 @@ #include "deviceorientation.h" +QT_USE_NAMESPACE + class DefaultDeviceOrientation : public DeviceOrientation { Q_OBJECT diff --git a/tools/qmlviewer/deviceorientation.h b/tools/qmlviewer/deviceorientation.h index a2ed6ec..c8125cd 100644 --- a/tools/qmlviewer/deviceorientation.h +++ b/tools/qmlviewer/deviceorientation.h @@ -44,6 +44,8 @@ #include <QObject> +QT_BEGIN_NAMESPACE + class DeviceOrientationPrivate; class DeviceOrientation : public QObject { @@ -66,4 +68,6 @@ private: friend class DeviceOrientationPrivate; }; +QT_END_NAMESPACE + #endif diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 18213ef..57c445f 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -47,6 +47,8 @@ #include <QTranslator> #include <QDebug> +QT_USE_NAMESPACE + #if defined (Q_OS_SYMBIAN) #include <unistd.h> #include <sys/types.h> @@ -93,6 +95,7 @@ void usage() qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); + qWarning(" -dragthreshold <size> .................... set mouse drag threshold size"); qWarning(" -netcache <size> ......................... set disk cache to size bytes"); qWarning(" -translation <translationfile> ........... set the language to run in"); qWarning(" -L <directory> ........................... prepend to the library search path"); @@ -215,6 +218,9 @@ int main(int argc, char ** argv) autorecord_to = range.mid(dash+1).toInt(); } else if (arg == "-devicekeys") { devkeys = true; + } else if (arg == "-dragthreshold") { + if (lastArg) usage(); + app.setStartDragDistance(QString(argv[++i]).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR); return 0; diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qmlviewer/proxysettings.cpp index b6caf6c..3255e42 100644 --- a/tools/qmlviewer/proxysettings.cpp +++ b/tools/qmlviewer/proxysettings.cpp @@ -45,6 +45,8 @@ #include "proxysettings.h" +QT_BEGIN_NAMESPACE + ProxySettings::ProxySettings (QWidget * parent) : QDialog (parent), Ui::ProxySettings() { @@ -104,3 +106,5 @@ bool ProxySettings::httpProxyInUse() QSettings settings; return settings.value ("http_proxy/use", 0).toBool (); } + +QT_END_NAMESPACE diff --git a/tools/qmlviewer/proxysettings.h b/tools/qmlviewer/proxysettings.h index 41bd7dc..325929a 100644 --- a/tools/qmlviewer/proxysettings.h +++ b/tools/qmlviewer/proxysettings.h @@ -46,6 +46,7 @@ #include <QNetworkProxy> #include "ui_proxysettings.h" +QT_BEGIN_NAMESPACE /** */ class ProxySettings : public QDialog, public Ui::ProxySettings @@ -65,4 +66,6 @@ public slots: virtual void accept (); }; +QT_END_NAMESPACE + #endif // PROXYSETTINGS_H diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index 1d5175d..c3c0124 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -147,7 +147,7 @@ void QmlGraphicsTester::imagefailure() void QmlGraphicsTester::complete() { if ((options & QmlViewer::TestErrorProperty) && !hasFailed) { - QString e = m_view->root()->property("error").toString(); + QString e = m_view->rootObject()->property("error").toString(); if (!e.isEmpty()) { qWarning() << "Test failed:" << e; hasFailed = true; diff --git a/tools/qmlviewer/qfxtester.h b/tools/qmlviewer/qfxtester.h index 0e7108e..4b8ff9f 100644 --- a/tools/qmlviewer/qfxtester.h +++ b/tools/qmlviewer/qfxtester.h @@ -65,8 +65,13 @@ public: private: QList<QObject *> m_events; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTest) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestFrame : public QObject { Q_OBJECT @@ -90,8 +95,13 @@ private: QString m_hash; QUrl m_image; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestFrame) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestMouse : public QObject { Q_OBJECT @@ -134,8 +144,13 @@ private: int m_modifiers; bool m_viewport; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestMouse) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestKey : public QObject { Q_OBJECT @@ -178,8 +193,13 @@ private: int m_count; bool m_viewport; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestKey) +QT_BEGIN_NAMESPACE + class QmlGraphicsTester : public QAbstractAnimation { public: diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp index 52caf13..698df54 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.cpp +++ b/tools/qmlviewer/qmlfolderlistmodel.cpp @@ -44,6 +44,8 @@ #include <QDebug> #include <qmlcontext.h> +QT_BEGIN_NAMESPACE + class QmlFolderListModelPrivate { public: diff --git a/tools/qmlviewer/qmlfolderlistmodel.h b/tools/qmlviewer/qmlfolderlistmodel.h index 2063896..c180e97 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.h +++ b/tools/qmlviewer/qmlfolderlistmodel.h @@ -45,6 +45,8 @@ #include <qml.h> #include "../../src/declarative/3rdparty/qlistmodelinterface_p.h" +QT_BEGIN_NAMESPACE + class QmlContext; class QModelIndex; @@ -114,6 +116,8 @@ private: QmlFolderListModelPrivate *d; }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlFolderListModel) #endif // QMLFOLDERLISTMODEL_H diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index f4f04be..626e4c4 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -56,8 +56,9 @@ #include <QAbstractAnimation> #include "deviceskin.h" -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3)) #include <private/qzipreader_p.h> +#define QMLVIEWER_ZIP_SUPPORT #endif #include <QSettings> @@ -83,6 +84,7 @@ #include <QAction> #include <QFileDialog> #include <QTimer> +#include <QGraphicsObject> #include <QNetworkProxyFactory> #include <QKeyEvent> #include <QMutex> @@ -111,7 +113,6 @@ QT_BEGIN_NAMESPACE - class Screen : public QObject { Q_OBJECT @@ -134,9 +135,14 @@ signals: void orientationChanged(); }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(Screen) + QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen) +QT_BEGIN_NAMESPACE + class SizedMenuBar : public QMenuBar { Q_OBJECT @@ -472,13 +478,12 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) canvas = new QmlView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); canvas->setFocus(); QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); - QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot())); - QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors())); - QObject::connect(canvas, SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); + QObject::connect(canvas, SIGNAL(statusChanged(QmlView::Status)), this, SLOT(statusChanged())); + QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); if (!(flags & Qt::FramelessWindowHint)) { createMenu(menuBar(),0); @@ -515,11 +520,6 @@ QmlViewer::~QmlViewer() delete namFactory; } -void QmlViewer::adjustSizeSlot() -{ - resize(sizeHint()); -} - QMenuBar *QmlViewer::menuBar() const { #if !defined(Q_OS_SYMBIAN) @@ -730,7 +730,7 @@ void QmlViewer::setScaleSkin() if (scaleSkin) return; scaleSkin = true; - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); if (skin) { canvas->setFixedSize(canvas->sizeHint()); skin->setScreenSize(canvas->sizeHint()); @@ -743,7 +743,7 @@ void QmlViewer::setScaleView() return; scaleSkin = false; if (skin) { - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); canvas->setMinimumSize(QSize(0,0)); canvas->setMaximumSize(QSize(16777215,16777215)); canvas->resize(skin->standardScreenSize()); @@ -870,7 +870,7 @@ void QmlViewer::reload() void QmlViewer::open(const QString& doc) { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT if (doc.endsWith(".wgt",Qt::CaseInsensitive) || doc.endsWith(".wgz",Qt::CaseInsensitive) || doc.endsWith(".zip",Qt::CaseInsensitive)) @@ -882,20 +882,21 @@ void QmlViewer::open(const QString& doc) void QmlViewer::openWgt(const QString& doc) { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT // XXX This functionality could be migrated to QmlView once refined QUrl url(doc); if (url.isRelative()) url = QUrl::fromLocalFile(doc); - canvas->reset(); + delete canvas->rootObject(); + canvas->engine()->clearComponentCache(); QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); wgtreply = nam->get(QNetworkRequest(url)); connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt())); #endif } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT static void removeRecursive(const QString& dirname) { QDir dir(dirname); @@ -911,7 +912,7 @@ static void removeRecursive(const QString& dirname) void QmlViewer::unpackWgt() { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT QByteArray all = wgtreply->readAll(); QBuffer buf(&all); buf.open(QIODevice::ReadOnly); @@ -970,7 +971,7 @@ void QmlViewer::unpackWgt() void QmlViewer::openFile() { - QString cur = canvas->url().toLocalFile(); + QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { openQml("qrc:/content/Browser.qml"); } else { @@ -982,9 +983,13 @@ void QmlViewer::openFile() } } -void QmlViewer::executeErrors() +void QmlViewer::statusChanged() { - if (tester) tester->executefailure(); + if (canvas->status() == QmlView::Error && tester) + tester->executefailure(); + + if (canvas->status() == QmlView::Ready) + resize(sizeHint()); } void QmlViewer::launch(const QString& file_or_url) @@ -1007,7 +1012,8 @@ void QmlViewer::openQml(const QString& file_or_url) if (!m_script.isEmpty()) tester = new QmlGraphicsTester(m_script, m_scriptOptions, canvas); - canvas->reset(); + delete canvas->rootObject(); + canvas->engine()->clearComponentCache(); QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("qmlViewer", this); #ifdef Q_OS_SYMBIAN @@ -1057,7 +1063,7 @@ void QmlViewer::openQml(const QString& file_or_url) } } - canvas->setUrl(url); + canvas->setSource(url); QTime t; t.start(); @@ -1124,7 +1130,7 @@ void QmlViewer::setSkin(const QString& skinDirOrName) skin->deleteLater(); } - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); DeviceSkinParameters parameters; if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 958210e..c7f87ed 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -116,7 +116,7 @@ public slots: void showProxySettings (); void proxySettingsChanged (); void setScaleView(); - void executeErrors(); + void statusChanged(); void setSlowMode(bool); void launch(const QString &); @@ -132,7 +132,6 @@ private slots: void chooseRecordingOptions(); void pickRecordingFile(); void setScaleSkin(); - void adjustSizeSlot(); void setPortrait(); void setLandscape(); void toggleOrientation(); diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 35e4ba8..aba3cf5 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -33,6 +33,7 @@ FORMS = recopts.ui \ proxysettings.ui INCLUDEPATH += ../../include/QtDeclarative INCLUDEPATH += ../../src/declarative/util +INCLUDEPATH += ../../src/declarative/graphicsitems include(../shared/deviceskin/deviceskin.pri) target.path = $$[QT_INSTALL_BINS] INSTALLS += target @@ -41,8 +42,11 @@ wince* { QT += scripttools \ xml \ xmlpatterns \ - webkit \ phonon + + contains(QT_CONFIG, webkit) { + QT += webkit + } } symbian { # TARGET.UID3 = diff --git a/tools/qtestlib/chart/database.cpp b/tools/qtestlib/chart/database.cpp index dfc0fc5..1f1f7da 100644 --- a/tools/qtestlib/chart/database.cpp +++ b/tools/qtestlib/chart/database.cpp @@ -42,6 +42,7 @@ #include <QtGui> #include <QtXml> +QT_BEGIN_NAMESPACE // Database schema definition and open/create functions QString resultsTable = QString("(TestName varchar, TestCaseName varchar, Series varchar, Idx varchar, ") + @@ -319,3 +320,5 @@ void DataBaseWriter::addResult(const QString &series, const QString &index, cons query.bindValue(":ChartType", "BarChart"); execQuery(query); } + +QT_END_NAMESPACE diff --git a/tools/qtestlib/chart/database.h b/tools/qtestlib/chart/database.h index d9861ad..9a67490 100644 --- a/tools/qtestlib/chart/database.h +++ b/tools/qtestlib/chart/database.h @@ -43,6 +43,9 @@ #include <QtCore> #include <QtSql> +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE extern QString resultsTable; QSqlDatabase openDataBase(const QString &databaseFile = "database"); @@ -57,6 +60,7 @@ void execQuery(const QString &spec, bool warnOnFail = true); void printDataBase(); void displayTable(const QString &table); + class TempTable { public: @@ -95,5 +99,7 @@ public: QSqlDatabase db; }; +QT_END_NAMESPACE #endif + diff --git a/tools/qtestlib/chart/reportgenerator.cpp b/tools/qtestlib/chart/reportgenerator.cpp index 1ce362c..c3b42a0 100644 --- a/tools/qtestlib/chart/reportgenerator.cpp +++ b/tools/qtestlib/chart/reportgenerator.cpp @@ -41,6 +41,7 @@ #include "reportgenerator.h" // Report generator file utility functions +QT_BEGIN_NAMESPACE QList<QByteArray> readLines(const QString &fileName) { @@ -559,3 +560,4 @@ QByteArray ReportGenerator::printColors(const QString &tableName, const QString return colors; } +QT_END_NAMESPACE diff --git a/tools/qtestlib/chart/reportgenerator.h b/tools/qtestlib/chart/reportgenerator.h index d44aea9..1f075bd 100644 --- a/tools/qtestlib/chart/reportgenerator.h +++ b/tools/qtestlib/chart/reportgenerator.h @@ -42,6 +42,9 @@ #define REPORTGENERATOR_H #include "database.h" +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE class ReportGenerator { @@ -59,5 +62,7 @@ private: void printTestCaseResults(const QString &testCaseName); +QT_END_NAMESPACE + #endif diff --git a/tools/qtestlib/wince/cetest/activesyncconnection.cpp b/tools/qtestlib/wince/cetest/activesyncconnection.cpp index 56fb173..98062ed 100644 --- a/tools/qtestlib/wince/cetest/activesyncconnection.cpp +++ b/tools/qtestlib/wince/cetest/activesyncconnection.cpp @@ -443,6 +443,145 @@ bool ActiveSyncConnection::execute(QString program, QString arguments, int timeo return result; } +bool ActiveSyncConnection::setDeviceAwake(bool activate, int *returnValue) +{ + if (!isConnected()) { + qWarning("Cannot execute, connect to device first!"); + return false; + } + bool result = false; + + // If we want to wait, we have to use CeRapiInvoke, as CeCreateProcess has no way to wait + // until the process ends. The lib must have been build and also deployed already. + if (!isConnected() && !connect()) + return false; + + HRESULT res = S_OK; + + //SYSTEM_POWER_STATUS_EX systemPowerState; + + //res = CeGetSystemPowerStatusEx(&systemPowerState, true); + + QString dllLocation = "\\Windows\\QtRemote.dll"; + QString functionName = "qRemoteToggleUnattendedPowerMode"; + + DWORD outputSize; + BYTE* output; + IRAPIStream *stream; + int returned = 0; + int toggle = int(activate); + + res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0); + if (S_OK != res) { + DWORD ce_error = CeGetLastError(); + if (S_OK != ce_error) { + qWarning("Error invoking %s on %s: %s", qPrintable(functionName), + qPrintable(dllLocation), strwinerror(ce_error).constData()); + } else { + qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName), + qPrintable(dllLocation), res); + } + } else { + DWORD written; + + if (S_OK != stream->Write(&toggle, sizeof(toggle), &written)) { + qWarning(" Could not write toggle option to process"); + return false; + } + + if (S_OK != stream->Read(&returned, sizeof(returned), &written)) { + qWarning(" Could not access return value of process"); + } + else + result = true; + } + + if (returnValue) + *returnValue = returned; + + return result; +} + +bool ActiveSyncConnection::resetDevice() +{ + if (!isConnected()) { + qWarning("Cannot execute, connect to device first!"); + return false; + } + + bool result = false; + if (!isConnected() && !connect()) + return false; + + QString dllLocation = "\\Windows\\QtRemote.dll"; + QString functionName = "qRemoteSoftReset"; + + DWORD outputSize; + BYTE* output; + IRAPIStream *stream; + + int returned = 0; + + HRESULT res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0); + if (S_OK != res) { + DWORD ce_error = CeGetLastError(); + if (S_OK != ce_error) { + qWarning("Error invoking %s on %s: %s", qPrintable(functionName), + qPrintable(dllLocation), strwinerror(ce_error).constData()); + } else { + qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName), + qPrintable(dllLocation), res); + } + } else { + result = true; + } + return result; +} + +bool ActiveSyncConnection::toggleDevicePower(int *returnValue) +{ + if (!isConnected()) { + qWarning("Cannot execute, connect to device first!"); + return false; + } + + bool result = false; + if (!isConnected() && !connect()) + return false; + + QString dllLocation = "\\Windows\\QtRemote.dll"; + QString functionName = "qRemotePowerButton"; + + DWORD outputSize; + BYTE* output; + IRAPIStream *stream; + int returned = 0; + + HRESULT res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0); + if (S_OK != res) { + DWORD ce_error = CeGetLastError(); + if (S_OK != ce_error) { + qWarning("Error invoking %s on %s: %s", qPrintable(functionName), + qPrintable(dllLocation), strwinerror(ce_error).constData()); + } else { + qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName), + qPrintable(dllLocation), res); + } + } else { + DWORD written; + if (S_OK != stream->Read(&returned, sizeof(returned), &written)) { + qWarning(" Could not access return value of process"); + } + else { + result = true; + } + } + + if (returnValue) + *returnValue = returned; + return result; +} + bool ActiveSyncConnection::createDirectory(const QString &path, bool deleteBefore) { if (deleteBefore) diff --git a/tools/qtestlib/wince/cetest/activesyncconnection.h b/tools/qtestlib/wince/cetest/activesyncconnection.h index 1891514..4502fc7 100644 --- a/tools/qtestlib/wince/cetest/activesyncconnection.h +++ b/tools/qtestlib/wince/cetest/activesyncconnection.h @@ -79,6 +79,9 @@ public: bool createDirectory(const QString&, bool deleteBefore=false); bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL); + bool resetDevice(); + bool toggleDevicePower(int *returnValue = NULL); + bool setDeviceAwake(bool activate, int *returnValue = NULL); private: bool connected; }; diff --git a/tools/qtestlib/wince/cetest/main.cpp b/tools/qtestlib/wince/cetest/main.cpp index 146cc5a..9fe5f02 100644 --- a/tools/qtestlib/wince/cetest/main.cpp +++ b/tools/qtestlib/wince/cetest/main.cpp @@ -45,6 +45,9 @@ # include "activesyncconnection.h" #endif +const int SLEEP_AFTER_RESET = 60000; // sleep for 1 minute +const int SLEEP_RECONNECT = 2000; // sleep for 2 seconds before trying another reconnect + #include "deployment.h" #include <option.h> #include <project.h> @@ -123,6 +126,8 @@ void usage() " -debug : Test debug version[default]\n" " -release : Test release version\n" " -libpath <path> : Remote path to deploy Qt libraries to\n" + " -reset : Reset device before starting a test\n" + " -awake : Device does not go sleep mode\n" " -qt-delete : Delete the Qt libraries after execution\n" " -project-delete : Delete the project file(s) after execution\n" " -delete : Delete everything deployed after execution\n" @@ -152,6 +157,8 @@ int main(int argc, char **argv) int timeout = -1; bool cleanupQt = false; bool cleanupProject = false; + bool deviceReset = false; + bool keepAwake = false; for (int i=1; i<arguments.size(); ++i) { if (arguments.at(i).toLower() == QLatin1String("-help") @@ -196,6 +203,10 @@ int main(int argc, char **argv) } else if (arguments.at(i).toLower() == QLatin1String("-delete")) { cleanupQt = true; cleanupProject = true; + } else if (arguments.at(i).toLower() == QLatin1String("-reset")) { + deviceReset = true; + } else if (arguments.at(i).toLower() == QLatin1String("-awake")) { + keepAwake = true; } else if (arguments.at(i).toLower() == QLatin1String("-conf")) { if (++i == arguments.size()) { cout << "Error: No qt.conf file specified!" << endl; @@ -353,6 +364,43 @@ int main(int argc, char **argv) cout << "Error: Could not copy file(s) to device" << endl; return -1; } + // device power mode + if (keepAwake) + { + int retVal = 0; + if (!connection.setDeviceAwake(true, &retVal)) { + cout << "Error: Could not set unattended mode on device" << endl; + return -1; + } + } + + // reset device + if (deviceReset) + { + if (!connection.resetDevice()) { + //if (!connection.toggleDevicePower( &retVal)) { + cout << "Error: Could not reset the device" << endl; + return -1; + } + cout << " Entering sleep after reset for " << SLEEP_AFTER_RESET / 1000 << " seconds ... " << endl; + Sleep(SLEEP_AFTER_RESET); + cout << " ... woke up. " << endl; + connection.disconnect(); + // reconnect after reset + int retryCount = 21; + while (--retryCount) + { + if (!connection.connect()) + Sleep(SLEEP_RECONNECT); + else + break; + } + if (!connection.isConnected()) + { + cout << "Error: Could not connect to device!" << endl; + return -1; + } + } // launch launchArguments.append("-o"); diff --git a/tools/qtestlib/wince/remotelib/commands.cpp b/tools/qtestlib/wince/remotelib/commands.cpp index 4244424..88bf9e6 100644 --- a/tools/qtestlib/wince/remotelib/commands.cpp +++ b/tools/qtestlib/wince/remotelib/commands.cpp @@ -39,6 +39,9 @@ ** ****************************************************************************/ #include "commands.h" +#include <Pm.h> +#include <Pmpolicy.h> + #define CLEAN_FAIL(a) {delete appName; \ delete arguments; \ @@ -124,3 +127,86 @@ bool qRemoteExecute(const wchar_t* program, const wchar_t* arguments, int *retur } return true; } +/** +\brief Reset the device. +*/ +int qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream) +{ + //POWER_STATE_ON On state + //POWER_STATE_OFF Off state + //POWER_STATE_CRITICAL Critical state + //POWER_STATE_BOOT Boot state + //POWER_STATE_IDLE Idle state + //POWER_STATE_SUSPEND Suspend state + //POWER_STATE_RESET Reset state + + DWORD returnValue = SetSystemPowerState(0, POWER_STATE_RESET, POWER_FORCE); + return returnValue; +} + +/** +\brief Toggle the unattended powermode of the device +*/ +int qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream) +{ + if (!stream) + return -1; + + DWORD bytesRead; + int toggleVal = 0; + int returnValue = S_OK; + + if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead)) + return -2; + + //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). + //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). + //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. + //PPN_SUSPENDKEYPRESSED or + //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). + //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). + //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). + //PPN_OEMBASE Greater than or equal to 0x10000 + //You can define higher values, such as 0x10001, 0x10002, and so on. + // Reserved. Set dwData to zero (0). + returnValue = PowerPolicyNotify(PPN_UNATTENDEDMODE, toggleVal); + + if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead)) + return -3; + else + return S_OK; +} + +/** +\brief Virtually press the power button of the device +*/ +int qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream) +{ + if (!stream) + return -1; + + DWORD bytesRead; + int toggleVal = 0; + int returnValue = S_OK; + + if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead)) + return -2; + + //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). + //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). + //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. + //PPN_SUSPENDKEYPRESSED or + //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). + //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). + //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). + //PPN_OEMBASE Greater than or equal to 0x10000 + //You can define higher values, such as 0x10001, 0x10002, and so on. + // Reserved. Set dwData to zero (0). + returnValue = PowerPolicyNotify(PPN_POWERBUTTONPRESSED, 0); + + if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead)) + return -3; + else + return S_OK; +} + diff --git a/tools/qtestlib/wince/remotelib/commands.h b/tools/qtestlib/wince/remotelib/commands.h index c5cc926..8f202c8 100644 --- a/tools/qtestlib/wince/remotelib/commands.h +++ b/tools/qtestlib/wince/remotelib/commands.h @@ -45,6 +45,9 @@ extern "C" { int __declspec(dllexport) qRemoteLaunch(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream*); + int __declspec(dllexport) qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream); + int __declspec(dllexport) qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream); + int __declspec(dllexport) qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream); bool __declspec(dllexport) qRemoteExecute(const wchar_t* program, const wchar_t* arguments = NULL, int *returnValue = NULL , DWORD* error = NULL, int timeout = -1); } diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp index a932d72..be7906b 100644 --- a/tools/qttracereplay/main.cpp +++ b/tools/qttracereplay/main.cpp @@ -49,7 +49,7 @@ class ReplayWidget : public QWidget { Q_OBJECT public: - ReplayWidget(const QString &filename); + ReplayWidget(const QString &filename, int from, int to, bool single); void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); @@ -68,6 +68,11 @@ public: QList<uint> visibleUpdates; QList<uint> iterationTimes; QString filename; + + int from; + int to; + + bool single; }; void ReplayWidget::updateRect() @@ -89,6 +94,11 @@ void ReplayWidget::paintEvent(QPaintEvent *) currentFrame = 0; ++currentIteration; + if (single) { + deleteLater(); + return; + } + if (currentIteration == 3) timer.start(); else if (currentIteration > 3) { @@ -137,20 +147,28 @@ void ReplayWidget::resizeEvent(QResizeEvent *event) visibleUpdates.clear(); QRect bounds = rect(); - for (int i = 0; i < updates.size(); ++i) { + + int first = qMax(0, from); + int last = qMin(unsigned(to), unsigned(updates.size())); + for (int i = first; i < last; ++i) { if (updates.at(i).intersects(bounds)) visibleUpdates << i; } - if (visibleUpdates.size() != updates.size()) - printf("Warning: skipped %d frames due to limited resolution\n", updates.size() - visibleUpdates.size()); + int range = last - first; + + if (visibleUpdates.size() != range) + printf("Warning: skipped %d frames due to limited resolution\n", range - visibleUpdates.size()); } -ReplayWidget::ReplayWidget(const QString &filename_) +ReplayWidget::ReplayWidget(const QString &filename_, int from_, int to_, bool single_) : currentFrame(0) , currentIteration(0) , filename(filename_) + , from(from_) + , to(to_) + , single(single_) { setWindowTitle(filename); QFile file(filename); @@ -165,15 +183,21 @@ ReplayWidget::ReplayWidget(const QString &filename_) char *data; uint size; in.readBytes(data, size); - bool isTraceFile = size == 7 && qstrncmp(data, "qttrace", 7) == 0; - delete [] data; + bool isTraceFile = size >= 7 && qstrncmp(data, "qttrace", 7) == 0; + + uint version = 0; + if (size == 9 && qstrncmp(data, "qttraceV2", 9) == 0) { + in.setFloatingPointPrecision(QDataStream::SinglePrecision); + in >> version; + } + if (!isTraceFile) { printf("File '%s' is not a trace file\n", qPrintable(filename_)); return; } in >> buffer >> updates; - printf("Read paint buffer with %d frames\n", buffer.numFrames()); + printf("Read paint buffer version %d with %d frames\n", version, buffer.numFrames()); resize(buffer.boundingRect().size().toSize()); @@ -189,17 +213,53 @@ int main(int argc, char **argv) if (argc <= 1 || qstrcmp(argv[1], "-h") == 0 || qstrcmp(argv[1], "--help") == 0) { printf("Replays a tracefile generated with '-graphicssystem trace'\n"); - printf("Usage:\n > %s [traceFile]\n", argv[0]); + printf("Usage:\n > %s [OPTIONS] [traceFile]\n", argv[0]); + printf("OPTIONS\n" + " --range=from-to to specify a frame range.\n" + " --singlerun to do only one run (without statistics)\n"); return 1; } - QFile file(argv[1]); + QFile file(app.arguments().last()); if (!file.exists()) { - printf("%s does not exist\n", argv[1]); + printf("%s does not exist\n", qPrintable(app.arguments().last())); return 1; } - ReplayWidget *widget = new ReplayWidget(argv[1]); + bool single = false; + + int from = 0; + int to = -1; + for (int i = 1; i < app.arguments().size() - 1; ++i) { + QString arg = app.arguments().at(i); + if (arg.startsWith(QLatin1String("--range="))) { + QString rest = arg.mid(8); + QStringList components = rest.split(QLatin1Char('-')); + + bool ok1 = false; + bool ok2 = false; + int fromCandidate = 0; + int toCandidate = 0; + if (components.size() == 2) { + fromCandidate = components.first().toInt(&ok1); + toCandidate = components.last().toInt(&ok2); + } + + if (ok1 && ok2) { + from = fromCandidate; + to = toCandidate; + } else { + printf("ERROR: malformed syntax in argument %s\n", qPrintable(arg)); + } + } else if (arg == QLatin1String("--singlerun")) { + single = true; + } else { + printf("Unrecognized argument: %s\n", qPrintable(arg)); + return 1; + } + } + + ReplayWidget *widget = new ReplayWidget(app.arguments().last(), from, to, single); if (!widget->updates.isEmpty()) { widget->show(); diff --git a/tools/shared/symbian/epocroot.cpp b/tools/shared/symbian/epocroot.cpp new file mode 100644 index 0000000..071477d --- /dev/null +++ b/tools/shared/symbian/epocroot.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake application of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <iostream> + +#include <QtCore/qdir.h> +#include <QtCore/qxmlstream.h> + +#include "epocroot.h" +#include "../windows/registry.h" + +// Registry key under which the location of the Symbian devices.xml file is +// stored. +// Note that, on 64-bit machines, this key is located under the 32-bit +// compatibility key: +// HKEY_LOCAL_MACHINE\Software\Wow6432Node +#define SYMBIAN_SDKS_REG_SUBKEY "Software\\Symbian\\EPOC SDKs\\CommonPath" + +#ifdef Q_OS_WIN32 +# define SYMBIAN_SDKS_REG_HANDLE HKEY_LOCAL_MACHINE +#else +# define SYMBIAN_SDKS_REG_HANDLE 0 +#endif + +// Value which is populated and returned by the epocRoot() function. +// Stored as a static value in order to avoid unnecessary re-evaluation. +static QString epocRootValue; + +#ifdef QT_BUILD_QMAKE +std::ostream &operator<<(std::ostream &s, const QString &val) { + s << val.toLocal8Bit().data(); + return s; +} +#else +// Operator implemented in configureapp.cpp +std::ostream &operator<<(std::ostream &s, const QString &val); +#endif + +QString getDevicesXmlPath() + { + // Note that the following call will return a null string on platforms other + // than Windows. If support is required on other platforms for devices.xml, + // an alternative mechanism for retrieving the location of this file will + // be required. + return readRegistryKey(SYMBIAN_SDKS_REG_HANDLE, SYMBIAN_SDKS_REG_SUBKEY); + } + +/** + * Checks whether epocRootValue points to an existent directory. + * If not, epocRootValue is set to an empty string and an error message is printed. + */ +void checkEpocRootExists(const QString &source) +{ + if (!epocRootValue.isEmpty()) { + QDir dir(epocRootValue); + if (!dir.exists()) { + std::cerr << "Warning: " << source << " is set to an invalid path: " << epocRootValue << std::endl; + epocRootValue = QString(); + } + } +} + +/** + * Translate path from Windows to Qt format. + */ +static void fixEpocRoot(QString &path) +{ + path.replace("\\", "/"); + + if (path.size() > 1 && path[1] == QChar(':')) { + path = path.mid(2); + } + + if (!path.size() || path[path.size()-1] != QChar('/')) { + path += QChar('/'); + } +} + +/** + * Determine the epoc root for the currently active SDK. + */ +QString epocRoot() +{ + if (epocRootValue.isEmpty()) { + // 1. If environment variable EPOCROOT is set and points to an existent + // directory, this is returned. + epocRootValue = qgetenv("EPOCROOT"); + checkEpocRootExists("EPOCROOT"); + + if (epocRootValue.isEmpty()) { + // 2. The location of devices.xml is specified by a registry key. If this + // file exists, it is parsed. + QString devicesXmlPath = getDevicesXmlPath(); + if (devicesXmlPath.isEmpty()) { + std::cerr << "Error: Symbian SDK registry key not found" << std::endl; + } else { + devicesXmlPath += "/devices.xml"; + QFile devicesFile(devicesXmlPath); + if (devicesFile.open(QIODevice::ReadOnly)) { + + // 3. If the EPOCDEVICE environment variable is set and a corresponding + // entry is found in devices.xml, and its epocroot value points to an + // existent directory, it is returned. + // 4. If a device element marked as default is found in devices.xml and its + // epocroot value points to an existent directory, this is returned. + + const QString epocDeviceValue = qgetenv("EPOCDEVICE"); + bool epocDeviceFound = false; + + QXmlStreamReader xml(&devicesFile); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "devices") { + if (xml.attributes().value("version") == "1.0") { + while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "device") { + const bool isDefault = xml.attributes().value("default") == "yes"; + const QString id = xml.attributes().value("id").toString(); + const QString name = xml.attributes().value("name").toString(); + const bool epocDeviceMatch = (id + ":" + name) == epocDeviceValue; + epocDeviceFound |= epocDeviceMatch; + + if((epocDeviceValue.isEmpty() && isDefault) || epocDeviceMatch) { + // Found a matching device + while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "epocroot") { + epocRootValue = xml.readElementText(); + const QString deviceSource = epocDeviceValue.isEmpty() + ? "default device" + : "EPOCDEVICE (" + epocDeviceValue + ")"; + checkEpocRootExists(deviceSource); + } + } + + if (epocRootValue.isEmpty()) + xml.raiseError("No epocroot element found"); + } + } + } + } else { + xml.raiseError("Invalid 'devices' element version"); + } + } + } + if (xml.hasError()) { + std::cerr << "Error: \"" << xml.errorString() << "\" when parsing devices.xml" << std::endl; + } else { + if (epocRootValue.isEmpty()) { + if (!epocDeviceValue.isEmpty()) { + if (epocDeviceFound) { + std::cerr << "Error: missing or invalid epocroot attribute " + << "in device '" << epocDeviceValue << "'"; + } else { + std::cerr << "Error: no device matching EPOCDEVICE (" + << epocDeviceValue << ")"; + } + } else { + if (epocDeviceFound) { + std::cerr << "Error: missing or invalid epocroot attribute " + << "in default device"; + } else { + std::cerr << "Error: no default device"; + } + } + std::cerr << " found in devices.xml file." << std::endl; + } + } + } else { + std::cerr << "Error: could not open file " << devicesXmlPath << std::endl; + } + } + } + + if (epocRootValue.isEmpty()) { + // 5. An empty string is returned. + std::cerr << "Error: failed to find epoc root" << std::endl + << "Either" << std::endl + << " 1. Set EPOCROOT environment variable to a valid value" << std::endl + << " or 2. Ensure that the HKEY_LOCAL_MACHINE\\" SYMBIAN_SDKS_REG_SUBKEY + " registry key is set, and then" << std::endl + << " a. Set EPOCDEVICE environment variable to a valid device" << std::endl + << " or b. Specify a default device in the devices.xml file." << std::endl; + } else { + fixEpocRoot(epocRootValue); + } + } + + return epocRootValue; +} + diff --git a/tools/qmldebugger/standalone/main.cpp b/tools/shared/symbian/epocroot.h index 9c075a1..9846485 100644 --- a/tools/qmldebugger/standalone/main.cpp +++ b/tools/shared/symbian/epocroot.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the qmake application of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,40 +38,30 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QtGui/qapplication.h> -#include "qmldebugger.h" +#ifndef SYMBIAN_EPOCROOT_H +#define SYMBIAN_EPOCROOT_H -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - app.setApplicationName("QtQmlDebugger"); - app.setOrganizationName("Nokia"); - app.setOrganizationDomain("nokia.com"); +#include <QtCore/qstring.h> - QStringList args = app.arguments(); +/** + * Determine the epoc root for the currently active SDK. + * + * The algorithm used is as follows: + * 1. If environment variable EPOCROOT is set and points to an existent + * directory, this is returned. + * 2. The location of devices.xml is specified by a registry key. If this + * file exists, it is parsed. + * 3. If the EPOCDEVICE environment variable is set and a corresponding + * entry is found in devices.xml, and its epocroot value points to an + * existent directory, it is returned. + * 4. If a device element marked as default is found in devices.xml and its + * epocroot value points to an existent directory, this is returned. + * 5. An empty string is returned. + * + * Any return value other than the empty string therefore is guaranteed to + * point to an existent directory. + */ +QString epocRoot(); - QmlDebugger win; - if (args.contains("--engine")) - win.showEngineTab(); - - for (int i=0; i<args.count(); i++) { - if (!args[i].contains(':')) - continue; - QStringList hostAndPort = args[i].split(':'); - bool ok = false; - quint16 port = hostAndPort.value(1).toInt(&ok); - if (ok) { - qWarning() << "qmldebugger connecting to" - << hostAndPort[0] << port << "..."; - win.setHost(hostAndPort[0]); - win.setPort(port); - win.connectToHost(); - break; - } - } - - win.show(); - - return app.exec(); -} +#endif // EPOCROOT_H diff --git a/tools/shared/windows/registry.cpp b/tools/shared/windows/registry.cpp new file mode 100644 index 0000000..d342d78 --- /dev/null +++ b/tools/shared/windows/registry.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake application of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qstringlist.h> +#include "registry.h" + +/*! + Returns the path part of a registry key. + e.g. + For a key + "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" + it returns + "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\" +*/ +static QString keyPath(const QString &rKey) +{ + int idx = rKey.lastIndexOf(QLatin1Char('\\')); + if (idx == -1) + return QString(); + return rKey.left(idx + 1); +} + +/*! + Returns the name part of a registry key. + e.g. + For a key + "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" + it returns + "ProductDir" +*/ +static QString keyName(const QString &rKey) +{ + int idx = rKey.lastIndexOf(QLatin1Char('\\')); + if (idx == -1) + return rKey; + + QString res(rKey.mid(idx + 1)); + if (res == "Default" || res == ".") + res = ""; + return res; +} + +QString readRegistryKey(HKEY parentHandle, const QString &rSubkey) +{ + QString result; + +#ifdef Q_OS_WIN32 + QString rSubkeyName = keyName(rSubkey); + QString rSubkeyPath = keyPath(rSubkey); + + HKEY handle = 0; + LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, KEY_READ, &handle); + + if (res != ERROR_SUCCESS) + return QString(); + + // get the size and type of the value + DWORD dataType; + DWORD dataSize; + res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize); + if (res != ERROR_SUCCESS) { + RegCloseKey(handle); + return QString(); + } + + // get the value + QByteArray data(dataSize, 0); + res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, 0, + reinterpret_cast<unsigned char*>(data.data()), &dataSize); + if (res != ERROR_SUCCESS) { + RegCloseKey(handle); + return QString(); + } + + switch (dataType) { + case REG_EXPAND_SZ: + case REG_SZ: { + result = QString::fromWCharArray(((const wchar_t *)data.constData())); + break; + } + + case REG_MULTI_SZ: { + QStringList l; + int i = 0; + for (;;) { + QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i); + i += s.length() + 1; + + if (s.isEmpty()) + break; + l.append(s); + } + result = l.join(", "); + break; + } + + case REG_NONE: + case REG_BINARY: { + result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); + break; + } + + case REG_DWORD_BIG_ENDIAN: + case REG_DWORD: { + Q_ASSERT(data.size() == sizeof(int)); + int i; + memcpy((char*)&i, data.constData(), sizeof(int)); + result = QString::number(i); + break; + } + + default: + qWarning("QSettings: unknown data %d type in windows registry", dataType); + break; + } + + RegCloseKey(handle); +#endif + + return result; +} + + diff --git a/tools/qmldebugger/standalone/qmldebugger.h b/tools/shared/windows/registry.h index 894cf0f..3896527 100644 --- a/tools/qmldebugger/standalone/qmldebugger.h +++ b/tools/shared/windows/registry.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt QML Debugger of the Qt Toolkit. +** This file is part of the qmake application of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,53 +38,27 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QMLDEBUGGER_H -#define QMLDEBUGGER_H -#include <private/qmldebugclient_p.h> -#include <QtNetwork/qtcpsocket.h> -#include <QtGui/qwidget.h> +#ifndef WINDOWS_REGISTRY_H +#define WINDOWS_REGISTRY_H -class QLabel; -class QLineEdit; -class QSpinBox; -class QPushButton; -class QTabWidget; +#include <QtCore/qglobal.h> -class EnginePane; - -class QmlDebugger : public QWidget -{ - Q_OBJECT -public: - QmlDebugger(QWidget * = 0); - - void setHost(const QString &host); - void setPort(quint16 port); - void showEngineTab(); - -public slots: - void connectToHost(); - void disconnectFromHost(); - -protected: - void closeEvent(QCloseEvent *); - -private slots: - void connectionStateChanged(); - void connectionError(QAbstractSocket::SocketError socketError); - -private: - QmlDebugConnection client; +#ifdef Q_OS_WIN32 + #include <QtCore/qt_windows.h> +#else + typedef void* HKEY; +#endif - QLabel *m_connectionState; - QLineEdit *m_host; - QSpinBox *m_port; - QPushButton *m_connectButton; - QPushButton *m_disconnectButton; +#include <QtCore/qstring.h> - EnginePane *m_enginePane; - QTabWidget *m_tabs; -}; +/** + * Read a value from the Windows registry. + * + * If the key is not found, or the registry cannot be accessed (for example + * if this code is compiled for a platform other than Windows), a null + * string is returned. + */ +QString readRegistryKey(HKEY parentHandle, const QString &rSubkey); -#endif +#endif // WINDOWS_REGISTRY_H diff --git a/tools/tools.pro b/tools/tools.pro index 4cff507..d5569b6 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -26,7 +26,7 @@ mac { embedded:SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmldebugger +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator embedded: SUBDIRS += makeqpf |