Optimize selected functions;
This commit is contained in:
parent
69db4572d2
commit
e5033adff6
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -39,6 +39,7 @@ public Q_SLOTS:
|
|||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent * event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void initConnections();
|
||||
|
|
|
@ -237,7 +237,9 @@ void ResultView::onRowSelectedSlot(const QModelIndex &index)
|
|||
{
|
||||
//NEW_TODO
|
||||
m_is_selected = true;
|
||||
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();
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue