1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[BookmarksSidebar] Activate bookmarks on mouseRelease

So it doesn't interfere with bookmarks reordering
This commit is contained in:
nowrep 2014-02-10 15:09:51 +01:00
parent 1d822d3a03
commit 338a6f991e
3 changed files with 28 additions and 3 deletions

View File

@ -31,6 +31,8 @@ BookmarksTreeView::BookmarksTreeView(QWidget* parent)
, m_model(m_bookmarks->model()) , m_model(m_bookmarks->model())
, m_filter(new BookmarksFilterModel(m_model)) , m_filter(new BookmarksFilterModel(m_model))
, m_type(BookmarksManagerViewType) , m_type(BookmarksManagerViewType)
, m_buttons(Qt::NoButton)
, m_modifiers(Qt::NoModifier)
{ {
setModel(m_filter); setModel(m_filter);
setDragEnabled(true); setDragEnabled(true);
@ -179,6 +181,8 @@ void BookmarksTreeView::rowsInserted(const QModelIndex &parent, int start, int e
void BookmarksTreeView::mouseMoveEvent(QMouseEvent* event) void BookmarksTreeView::mouseMoveEvent(QMouseEvent* event)
{ {
QTreeView::mouseMoveEvent(event);
if (m_type == BookmarksSidebarViewType) { if (m_type == BookmarksSidebarViewType) {
QCursor cursor = Qt::ArrowCursor; QCursor cursor = Qt::ArrowCursor;
if (event->buttons() == Qt::NoButton) { if (event->buttons() == Qt::NoButton) {
@ -190,11 +194,13 @@ void BookmarksTreeView::mouseMoveEvent(QMouseEvent* event)
setCursor(cursor); setCursor(cursor);
} }
QTreeView::mouseMoveEvent(event);
} }
void BookmarksTreeView::mousePressEvent(QMouseEvent* event) void BookmarksTreeView::mousePressEvent(QMouseEvent* event)
{ {
m_buttons = event->buttons();
m_modifiers = event->modifiers();
QTreeView::mousePressEvent(event); QTreeView::mousePressEvent(event);
if (selectionModel()->selectedRows().count() == 1) { if (selectionModel()->selectedRows().count() == 1) {
@ -211,13 +217,29 @@ void BookmarksTreeView::mousePressEvent(QMouseEvent* event)
else if (buttons == Qt::MiddleButton || modifiers == Qt::ControlModifier) { else if (buttons == Qt::MiddleButton || modifiers == Qt::ControlModifier) {
emit bookmarkCtrlActivated(item); emit bookmarkCtrlActivated(item);
} }
}
}
}
void BookmarksTreeView::mouseReleaseEvent(QMouseEvent* event)
{
QTreeView::mouseReleaseEvent(event);
if (selectionModel()->selectedRows().count() == 1) {
QModelIndex index = indexAt(event->pos());
if (index.isValid()) {
BookmarkItem* item = m_model->item(m_filter->mapToSource(index));
// Activate bookmarks with single mouse click in Sidebar // Activate bookmarks with single mouse click in Sidebar
if (m_type == BookmarksSidebarViewType && buttons == Qt::LeftButton && modifiers == Qt::NoModifier) { if (m_type == BookmarksSidebarViewType && m_buttons == Qt::LeftButton && m_modifiers == Qt::NoModifier) {
emit bookmarkActivated(item); emit bookmarkActivated(item);
} }
} }
} }
m_buttons = Qt::NoButton;
m_modifiers = Qt::NoModifier;
} }
void BookmarksTreeView::mouseDoubleClickEvent(QMouseEvent* event) void BookmarksTreeView::mouseDoubleClickEvent(QMouseEvent* event)

View File

@ -79,6 +79,7 @@ private:
void mouseMoveEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event); void mouseDoubleClickEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent* event);
@ -86,6 +87,9 @@ private:
BookmarksModel* m_model; BookmarksModel* m_model;
BookmarksFilterModel* m_filter; BookmarksFilterModel* m_filter;
ViewType m_type; ViewType m_type;
Qt::MouseButtons m_buttons;
Qt::KeyboardModifiers m_modifiers;
}; };
#endif // BOOKMARKSTREEVIEW_H #endif // BOOKMARKSTREEVIEW_H

View File

@ -108,7 +108,6 @@ void BrowsingLibrary::importBookmarks()
void BrowsingLibrary::exportBookmarks() void BrowsingLibrary::exportBookmarks()
{ {
} }
void BrowsingLibrary::showHistory(QupZilla* mainClass) void BrowsingLibrary::showHistory(QupZilla* mainClass)