summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorkh <qtc-committer@nokia.com>2009-05-18 15:26:34 (GMT)
committerkh <qtc-committer@nokia.com>2009-05-18 15:26:34 (GMT)
commita13ef81dbd66472e7fb0c18ea528502295aa24ab (patch)
tree67b3975dd1deb0a7de6e1bfa938a23035bc4b9ea /tools/assistant
parent0266129d26695987e93c3c3f856e8353a5d7cd89 (diff)
downloadQt-a13ef81dbd66472e7fb0c18ea528502295aa24ab.zip
Qt-a13ef81dbd66472e7fb0c18ea528502295aa24ab.tar.gz
Qt-a13ef81dbd66472e7fb0c18ea528502295aa24ab.tar.bz2
Make ctrl+lmb and mmb work in a same way everywhere (like in browsers).
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp77
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp9
-rw-r--r--tools/assistant/tools/assistant/indexwindow.cpp9
3 files changed, 51 insertions, 44 deletions
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 6f5732f..66475a4 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -536,58 +536,57 @@ void BookmarkWidget::focusInEvent(QFocusEvent *e)
bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
{
- if (object == this && e->type() == QEvent::KeyPress) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
+ if ((object == this) || (object == treeView->viewport())) {
QModelIndex index = treeView->currentIndex();
- switch (ke->key()) {
+ if (e->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(e);
if (index.isValid() && searchField->text().isEmpty()) {
- case Qt::Key_F2: {
- const QModelIndex& source = filterBookmarkModel->mapToSource(index);
- QStandardItem *item =
- bookmarkManager->treeBookmarkModel()->itemFromIndex(source);
+ if (ke->key() == Qt::Key_F2) {
+ QStandardItem *item = bookmarkManager->treeBookmarkModel()
+ ->itemFromIndex(filterBookmarkModel->mapToSource(index));
if (item) {
item->setEditable(true);
treeView->edit(index);
item->setEditable(false);
}
- } break;
-
- case Qt::Key_Delete: {
+ } else if (ke->key() == Qt::Key_Delete) {
bookmarkManager->removeBookmarkItem(treeView,
filterBookmarkModel->mapToSource(index));
- } break;
+ }
}
- case Qt::Key_Up:
- case Qt::Key_Down:
- treeView->subclassKeyPressEvent(ke);
- break;
-
- case Qt::Key_Enter: {
- case Qt::Key_Return:
- index = treeView->selectionModel()->currentIndex();
- if (index.isValid()) {
- QString data = index.data(Qt::UserRole + 10).toString();
- if (!data.isEmpty() && data != QLatin1String("Folder"))
- emit requestShowLink(data);
- }
- } break;
+ switch (ke->key()) {
+ default: break;
+ case Qt::Key_Up: {
+ case Qt::Key_Down:
+ treeView->subclassKeyPressEvent(ke);
+ } break;
- case Qt::Key_Escape:
- emit escapePressed();
- break;
+ case Qt::Key_Enter: {
+ case Qt::Key_Return:
+ index = treeView->selectionModel()->currentIndex();
+ if (index.isValid()) {
+ QString data = index.data(Qt::UserRole + 10).toString();
+ if (!data.isEmpty() && data != QLatin1String("Folder"))
+ emit requestShowLink(data);
+ }
+ } break;
- default:
- break;
- }
- }
- else if (object == treeView->viewport() && e->type() == QEvent::MouseButtonRelease) {
- const QModelIndex& index = treeView->currentIndex();
- QMouseEvent *me = static_cast<QMouseEvent*>(e);
- if (index.isValid() && (me->button() == Qt::MidButton)) {
- QString data = index.data(Qt::UserRole + 10).toString();
- if (!data.isEmpty() && data != QLatin1String("Folder"))
- CentralWidget::instance()->setSourceInNewTab(data);
+ case Qt::Key_Escape: {
+ emit escapePressed();
+ } break;
+ }
+ } else if (e->type() == QEvent::MouseButtonRelease) {
+ if (index.isValid()) {
+ QMouseEvent *me = static_cast<QMouseEvent*>(e);
+ bool controlPressed = me->modifiers() & Qt::ControlModifier;
+ if(((me->button() == Qt::LeftButton) && controlPressed)
+ || (me->button() == Qt::MidButton)) {
+ QString data = index.data(Qt::UserRole + 10).toString();
+ if (!data.isEmpty() && data != QLatin1String("Folder"))
+ CentralWidget::instance()->setSourceInNewTab(data);
+ }
+ }
}
}
return QWidget::eventFilter(object, e);
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp
index 89060bd..9f39de5 100644
--- a/tools/assistant/tools/assistant/contentwindow.cpp
+++ b/tools/assistant/tools/assistant/contentwindow.cpp
@@ -124,10 +124,10 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
QModelIndex index = m_contentWidget->indexAt(me->pos());
QItemSelectionModel *sm = m_contentWidget->selectionModel();
+ Qt::MouseButtons button = me->button();
if (index.isValid() && (sm && sm->isSelected(index))) {
- if (me->button() == Qt::LeftButton) {
- itemClicked(index);
- } else if (me->button() == Qt::MidButton) {
+ if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier))
+ || (button == Qt::MidButton)) {
QHelpContentModel *contentModel =
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
@@ -135,12 +135,15 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
if (itm && !isPdfFile(itm))
CentralWidget::instance()->setSourceInNewTab(itm->url());
}
+ } else if (button == Qt::LeftButton) {
+ itemClicked(index);
}
}
}
return QWidget::eventFilter(o, e);
}
+
void ContentWindow::showContextMenu(const QPoint &pos)
{
if (!m_contentWidget->indexAt(pos).isValid())
diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp
index a2c0950..1117ae0 100644
--- a/tools/assistant/tools/assistant/indexwindow.cpp
+++ b/tools/assistant/tools/assistant/indexwindow.cpp
@@ -146,8 +146,13 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
&& e->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
QModelIndex idx = m_indexWidget->indexAt(mouseEvent->pos());
- if (idx.isValid() && mouseEvent->button()==Qt::MidButton)
- open(m_indexWidget, idx);
+ if (idx.isValid()) {
+ Qt::MouseButtons button = mouseEvent->button();
+ if (((button == Qt::LeftButton) && (mouseEvent->modifiers() & Qt::ControlModifier))
+ || (button == Qt::MidButton)) {
+ open(m_indexWidget, idx);
+ }
+ }
}
#ifdef Q_OS_MAC
else if (obj == m_indexWidget && e->type() == QEvent::KeyPress) {