summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-12-26 19:49:55 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-12-26 19:49:55 (GMT)
commit24270550463fbc81c7725595719e6e21eade2819 (patch)
tree4e7c118ed3c4b42e43403960365a2672441ea05e /tools/assistant
parent4376f8871b4422830e9ffb7f3acbc29766d8d218 (diff)
parent444fb94e02308bedc7b37a702adb95b740168a94 (diff)
downloadQt-24270550463fbc81c7725595719e6e21eade2819.zip
Qt-24270550463fbc81c7725595719e6e21eade2819.tar.gz
Qt-24270550463fbc81c7725595719e6e21eade2819.tar.bz2
Merge branch '4.6'
Conflicts: examples/webkit/fancybrowser/main.cpp src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp tools/assistant/tools/assistant/bookmarkmanager.cpp
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/lib/qhelpindexwidget.cpp4
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp116
2 files changed, 69 insertions, 51 deletions
diff --git a/tools/assistant/lib/qhelpindexwidget.cpp b/tools/assistant/lib/qhelpindexwidget.cpp
index 475a1fe..6cf1a72 100644
--- a/tools/assistant/lib/qhelpindexwidget.cpp
+++ b/tools/assistant/lib/qhelpindexwidget.cpp
@@ -130,6 +130,7 @@ void QHelpIndexProvider::stopCollecting()
m_abort = true;
m_mutex.unlock();
wait();
+ m_abort = false;
}
QStringList QHelpIndexProvider::indices() const
@@ -164,7 +165,6 @@ void QHelpIndexProvider::run()
foreach (QString dbFileName, m_helpEngine->fileNameReaderMap.keys()) {
m_mutex.lock();
if (m_abort) {
- m_abort = false;
m_mutex.unlock();
return;
}
@@ -181,7 +181,6 @@ void QHelpIndexProvider::run()
foreach (QString s, lst)
indicesSet.insert(s);
if (m_abort) {
- m_abort = false;
m_mutex.unlock();
return;
}
@@ -194,7 +193,6 @@ void QHelpIndexProvider::run()
m_mutex.lock();
m_indices = indicesSet.values();
qSort(m_indices.begin(), m_indices.end(), caseInsensitiveLessThan);
- m_abort = false;
m_mutex.unlock();
}
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 592c643..6ef1ea0 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -71,9 +71,12 @@ BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
, bookmarkManager(manager)
{
TRACE_OBJ
+ ui.setupUi(this);
+
installEventFilter(this);
+ ui.treeView->installEventFilter(this);
+ ui.treeView->viewport()->installEventFilter(this);
- ui.setupUi(this);
ui.bookmarkEdit->setText(title);
ui.newFolderButton->setVisible(false);
ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
@@ -282,12 +285,14 @@ void BookmarkDialog::currentChanged(const QModelIndex &current)
bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
{
TRACE_OBJ
- if (object == this && e->type() == QEvent::KeyPress) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
+ if (object != ui.treeView && object != ui.treeView->viewport())
+ return QWidget::eventFilter(object, e);
- QModelIndex index = ui.treeView->currentIndex();
+ if (e->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(e);
switch (ke->key()) {
case Qt::Key_F2: {
+ const QModelIndex &index = ui.treeView->currentIndex();
const QModelIndex &source = proxyModel->mapToSource(index);
QStandardItem *item =
bookmarkManager->treeBookmarkModel()->itemFromIndex(source);
@@ -299,13 +304,13 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
} break;
case Qt::Key_Delete: {
+ const QModelIndex &index = ui.treeView->currentIndex();
bookmarkManager->removeBookmarkItem(ui.treeView,
proxyModel->mapToSource(index));
ui.bookmarkFolders->clear();
ui.bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
QString name = tr("Bookmarks");
- index = ui.treeView->currentIndex();
if (index.isValid())
name = index.data().toString();
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
@@ -315,6 +320,7 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
break;
}
}
+
return QObject::eventFilter(object, e);
}
@@ -331,7 +337,10 @@ BookmarkWidget::BookmarkWidget(BookmarkManager *manager, QWidget *parent,
{
TRACE_OBJ
setup(showButtons);
+
installEventFilter(this);
+ treeView->installEventFilter(this);
+ treeView->viewport()->installEventFilter(this);
}
BookmarkWidget::~BookmarkWidget()
@@ -510,7 +519,6 @@ void BookmarkWidget::setup(bool showButtons)
treeView->setAutoExpandDelay(1000);
treeView->setDropIndicatorShown(true);
treeView->header()->setVisible(false);
- treeView->viewport()->installEventFilter(this);
treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(treeView, SIGNAL(expanded(QModelIndex)), this,
@@ -559,59 +567,71 @@ void BookmarkWidget::focusInEvent(QFocusEvent *e)
bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
{
TRACE_OBJ
- if ((object == this) || (object == treeView->viewport())) {
- QModelIndex index = treeView->currentIndex();
- if (e->type() == QEvent::KeyPress) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
- if (index.isValid() && searchField->text().isEmpty()) {
+ if (object != this && object != treeView
+ && object != treeView->viewport()) {
+ return QWidget::eventFilter(object, e);
+ }
+
+ if (e->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(e);
+ const bool tree = object == treeView || object == treeView->viewport();
+ switch (ke->key()) {
+ case Qt::Key_F2: {
+ const QModelIndex &index = treeView->currentIndex();
const QModelIndex &src = filterBookmarkModel->mapToSource(index);
- if (ke->key() == Qt::Key_F2) {
- QStandardItem *item =
- bookmarkManager->treeBookmarkModel()->itemFromIndex(src);
- if (item) {
+ if (tree && searchField->text().isEmpty()) {
+ if (QStandardItem *item = bookmarkManager->treeBookmarkModel()
+ ->itemFromIndex(src)) {
item->setEditable(true);
treeView->edit(index);
item->setEditable(false);
}
- } else if (ke->key() == Qt::Key_Delete) {
- bookmarkManager->removeBookmarkItem(treeView, src);
}
- }
+ } break;
+
+ case Qt::Key_Enter: {
+ case Qt::Key_Return:
+ if (tree) {
+ const QString &data = treeView->selectionModel()->currentIndex()
+ .data(Qt::UserRole + 10).toString();
+ if (!data.isEmpty() && data != QLatin1String("Folder"))
+ emit requestShowLink(data);
+ }
+ } break;
- switch (ke->key()) {
- default: break;
- case Qt::Key_Up: {
- case Qt::Key_Down:
+ case Qt::Key_Delete: {
+ const QModelIndex &index = treeView->currentIndex();
+ const QModelIndex &src = filterBookmarkModel->mapToSource(index);
+ if (tree && searchField->text().isEmpty())
+ bookmarkManager->removeBookmarkItem(treeView, src);
+ } break;
+
+ case Qt::Key_Up: {
+ case Qt::Key_Down:
+ if (!tree)
treeView->subclassKeyPressEvent(ke);
- } break;
-
- case Qt::Key_Enter: {
- case Qt::Key_Return:
- index = treeView->selectionModel()->currentIndex();
- if (index.isValid()) {
- QString data = index.data(Qt::UserRole + 10).toString();
- if (!data.isEmpty() && data != QLatin1String("Folder"))
- emit requestShowLink(data);
- }
- } break;
+ } break;
- case Qt::Key_Escape: {
- emit escapePressed();
- } break;
- }
- } else if (e->type() == QEvent::MouseButtonRelease) {
- if (index.isValid()) {
- QMouseEvent *me = static_cast<QMouseEvent*>(e);
- bool controlPressed = me->modifiers() & Qt::ControlModifier;
- if(((me->button() == Qt::LeftButton) && controlPressed)
- || (me->button() == Qt::MidButton)) {
- QString data = index.data(Qt::UserRole + 10).toString();
- if (!data.isEmpty() && data != QLatin1String("Folder"))
- CentralWidget::instance()->setSourceInNewTab(data);
- }
- }
+ case Qt::Key_Escape: {
+ emit escapePressed();
+ } break;
+
+ default: break;
}
}
+
+ if (e->type() == QEvent::MouseButtonRelease) {
+ QMouseEvent *me = static_cast<QMouseEvent*>(e);
+ bool controlPressed = me->modifiers() & Qt::ControlModifier;
+ if(((me->button() == Qt::LeftButton) && controlPressed)
+ || (me->button() == Qt::MidButton)) {
+ const QModelIndex &index = treeView->currentIndex();
+ const QString &data = index.data(Qt::UserRole + 10).toString();
+ if (!data.isEmpty() && data != QLatin1String("Folder"))
+ CentralWidget::instance()->setSourceInNewTab(data);
+ }
+ }
+
return QWidget::eventFilter(object, e);
}