diff --git a/frontend/control/list-labels/list-labels.pri b/frontend/control/list-labels/list-labels.pri index 8a10490..4049a43 100644 --- a/frontend/control/list-labels/list-labels.pri +++ b/frontend/control/list-labels/list-labels.pri @@ -2,8 +2,8 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/show-more-label.h \ - $$PWD/title-label.h \ + $$PWD/title-label.h SOURCES += \ $$PWD/show-more-label.cpp \ - $$PWD/title-label.cpp \ + $$PWD/title-label.cpp diff --git a/frontend/view/best-list-view.cpp b/frontend/view/best-list-view.cpp index 3c66fbc..7a83edc 100644 --- a/frontend/view/best-list-view.cpp +++ b/frontend/view/best-list-view.cpp @@ -145,18 +145,34 @@ void BestListView::mousePressEvent(QMouseEvent *event) { m_tmpCurrentIndex = this->currentIndex(); m_tmpMousePressIndex = indexAt(event->pos()); + if (m_tmpMousePressIndex.isValid() and m_tmpCurrentIndex != m_tmpMousePressIndex) { + Q_EMIT this->clicked(m_tmpMousePressIndex); + } + return QTreeView::mousePressEvent(event); } void BestListView::mouseReleaseEvent(QMouseEvent *event) { QModelIndex index = indexAt(event->pos()); - if (!index.isValid() or index != m_tmpMousePressIndex) { - this->setCurrentIndex(m_tmpCurrentIndex); + if (index.isValid()) { + Q_EMIT this->clicked(index); + } else { + Q_EMIT this->clicked(this->currentIndex()); } return QTreeView::mouseReleaseEvent(event); } +void BestListView::mouseMoveEvent(QMouseEvent *event) +{ + m_tmpCurrentIndex = this->currentIndex(); + m_tmpMousePressIndex = indexAt(event->pos()); + if (m_tmpMousePressIndex.isValid() and m_tmpCurrentIndex != m_tmpMousePressIndex) { + Q_EMIT this->clicked(m_tmpMousePressIndex); + } + return QTreeView::mouseMoveEvent(event); +} + void BestListView::initConnections() { connect(this, &BestListView::startSearch, [ = ](const QString &keyword) { diff --git a/frontend/view/best-list-view.h b/frontend/view/best-list-view.h index 51f1151..1b5d22c 100644 --- a/frontend/view/best-list-view.h +++ b/frontend/view/best-list-view.h @@ -39,6 +39,7 @@ public Q_SLOTS: protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent * event); + void mouseMoveEvent(QMouseEvent *event); private: void initConnections(); diff --git a/frontend/view/result-view.cpp b/frontend/view/result-view.cpp index ea6b7ad..c44fc84 100644 --- a/frontend/view/result-view.cpp +++ b/frontend/view/result-view.cpp @@ -237,8 +237,10 @@ void ResultView::onRowSelectedSlot(const QModelIndex &index) { //NEW_TODO m_is_selected = true; - Q_EMIT this->currentRowChanged(m_plugin_id, m_model->getInfo(index)); -// if(!selected.isEmpty()) { + if(index.isValid()) { + Q_EMIT this->currentRowChanged(m_plugin_id, m_model->getInfo(index)); + } + // if(!selected.isEmpty()) { // QRegion region = visualRegionForSelection(selected); // QRect rect = region.boundingRect(); //// Q_EMIT this->currentSelectPos(mapToParent(rect.topLeft())); @@ -282,18 +284,34 @@ void ResultView::mousePressEvent(QMouseEvent *event) { m_tmpCurrentIndex = this->currentIndex(); m_tmpMousePressIndex = indexAt(event->pos()); + if (m_tmpMousePressIndex.isValid() and m_tmpCurrentIndex != m_tmpMousePressIndex) { + Q_EMIT this->clicked(m_tmpMousePressIndex); + } + return QTreeView::mousePressEvent(event); } void ResultView::mouseReleaseEvent(QMouseEvent *event) { QModelIndex index = indexAt(event->pos()); - if (!index.isValid() or index != m_tmpMousePressIndex) { - this->setCurrentIndex(m_tmpCurrentIndex); + if (index.isValid()) { + Q_EMIT this->clicked(index); + } else { + Q_EMIT this->clicked(this->currentIndex()); } return QTreeView::mouseReleaseEvent(event); } +void ResultView::mouseMoveEvent(QMouseEvent *event) +{ + m_tmpCurrentIndex = this->currentIndex(); + m_tmpMousePressIndex = indexAt(event->pos()); + if (m_tmpMousePressIndex.isValid() and m_tmpCurrentIndex != m_tmpMousePressIndex) { + Q_EMIT this->clicked(m_tmpMousePressIndex); + } + return QTreeView::mouseMoveEvent(event); +} + void ResultView::initConnections() { connect(this, &ResultView::startSearch, [ = ](const QString &keyword) { diff --git a/frontend/view/result-view.h b/frontend/view/result-view.h index 1ff0678..f2456e4 100644 --- a/frontend/view/result-view.h +++ b/frontend/view/result-view.h @@ -36,6 +36,7 @@ public Q_SLOTS: protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); private: void initConnections(); @@ -55,6 +56,7 @@ Q_SIGNALS: void listLengthChanged(const int &); void rowClicked(); void lableReset(); + void mouseSelect(QModelIndex &index); }; class ResultWidget : public QWidget