diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2018-11-15 01:01:52 +0100 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2018-11-15 07:29:07 +0100 |
commit | ca50d5ec952d56e5bfb28de9d882ecca029e1586 (patch) | |
tree | 3aaa18a2bb9886aaf32a388e5cab141fb25b3d93 /src | |
parent | 0ef98b70bf741e2f6018c923ef55a35d9b9b5921 (diff) |
Fix storing scroll position during search
Diffstat (limited to 'src')
-rw-r--r-- | src/library/library.cpp | 2 | ||||
-rw-r--r-- | src/library/library.h | 1 | ||||
-rw-r--r-- | src/skin/legacyskinparser.cpp | 2 | ||||
-rw-r--r-- | src/widget/wlibrarytableview.cpp | 20 | ||||
-rw-r--r-- | src/widget/wlibrarytableview.h | 8 | ||||
-rw-r--r-- | src/widget/wsearchlineedit.cpp | 6 | ||||
-rw-r--r-- | src/widget/wsearchlineedit.h | 1 | ||||
-rw-r--r-- | src/widget/wtracktableview.cpp | 20 | ||||
-rw-r--r-- | src/widget/wtracktableview.h | 1 |
9 files changed, 26 insertions, 35 deletions
diff --git a/src/library/library.cpp b/src/library/library.cpp index 22b00d7413..0bd6f6cfbe 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -251,8 +251,6 @@ void Library::bindWidget(WLibrary* pLibraryWidget, pTrackTableView, SLOT(setTrackTableRowHeight(int))); connect(this, SIGNAL(setSelectedClick(bool)), pTrackTableView, SLOT(setSelectedClick(bool))); - connect(this, SIGNAL(searchActive(bool)), - pTrackTableView, SLOT(onSearchActive(bool))); m_pLibraryControl->bindWidget(pLibraryWidget, pKeyboard); diff --git a/src/library/library.h b/src/library/library.h index e2724daf61..c699be4607 100644 --- a/src/library/library.h +++ b/src/library/library.h @@ -111,7 +111,6 @@ class Library: public QObject, void loadTrackToPlayer(TrackPointer pTrack, QString group, bool play = false); void restoreSearch(const QString&); void search(const QString& text); - void searchActive(bool active); void disableSearch(); // emit this signal to enable/disable the cover art widget void enableCoverArtDisplay(bool); diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 35850e4721..67998b1364 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -1185,8 +1185,6 @@ QWidget* LegacySkinParser::parseSearchBox(const QDomElement& node) { // Connect search box signals to the library connect(pLineEditSearch, SIGNAL(search(const QString&)), m_pLibrary, SIGNAL(search(const QString&))); - connect(pLineEditSearch, SIGNAL(searchActive(bool)), - m_pLibrary, SIGNAL(searchActive(bool))); connect(m_pLibrary, SIGNAL(disableSearch()), pLineEditSearch, SLOT(disableSearch())); connect(m_pLibrary, SIGNAL(restoreSearch(const QString&)), diff --git a/src/widget/wlibrarytableview.cpp b/src/widget/wlibrarytableview.cpp index 6e86e2a2e4..d8bff69a81 100644 --- a/src/widget/wlibrarytableview.cpp +++ b/src/widget/wlibrarytableview.cpp @@ -58,20 +58,22 @@ void WLibraryTableView::loadVScrollBarPosState() { // position across restarts of Mixxx. Now that we have different views for // each mode, the views should just maintain their scrollbar position when // you switch views. We should discuss this. - m_iSavedVScrollBarPos = m_pConfig->getValueString(m_vScrollBarPosKey).toInt(); + m_noSearchVScrollBarPos = m_pConfig->getValueString(m_vScrollBarPosKey).toInt(); } -void WLibraryTableView::restoreVScrollBarPos() { - //Restore the scrollbar's position (scroll to that spot) - //when the search has been cleared +void WLibraryTableView::restoreNoSearchVScrollBarPos() { + // Restore the scrollbar's position (scroll to that spot) + // when the search has been cleared + //qDebug() << "restoreNoSearchVScrollBarPos()" << m_noSearchVScrollBarPos; updateGeometries(); - verticalScrollBar()->setValue(m_iSavedVScrollBarPos); + verticalScrollBar()->setValue(m_noSearchVScrollBarPos); } -void WLibraryTableView::saveVScrollBarPos() { - //Save the scrollbar's position so we can return here after - //a search is cleared. - m_iSavedVScrollBarPos = verticalScrollBar()->value(); +void WLibraryTableView::saveNoSearchVScrollBarPos() { + // Save the scrollbar's position so we can return here after + // a search is cleared. + //qDebug() << "saveNoSearchVScrollBarPos()" << m_noSearchVScrollBarPos; + m_noSearchVScrollBarPos = verticalScrollBar()->value(); } diff --git a/src/widget/wlibrarytableview.h b/src/widget/wlibrarytableview.h index 14d3233dd5..41714eb55b 100644 --- a/src/widget/wlibrarytableview.h +++ b/src/widget/wlibrarytableview.h @@ -47,12 +47,14 @@ class WLibraryTableView : public QTableView, public virtual LibraryView { void scrollValueChanged(int); public slots: - void saveVScrollBarPos(); // these slosts remain for compatibility - void restoreVScrollBarPos(); void setTrackTableFont(const QFont& font); void setTrackTableRowHeight(int rowHeight); void setSelectedClick(bool enable); + protected: + void saveNoSearchVScrollBarPos(); + void restoreNoSearchVScrollBarPos(); + private: void loadVScrollBarPosState(); void saveVScrollBarPosState(); @@ -63,7 +65,7 @@ class WLibraryTableView : public QTableView, public virtual LibraryView { ConfigKey m_vScrollBarPosKey; // The position of the vertical scrollbar slider, eg. before a search is // executed - int m_iSavedVScrollBarPos; + int m_noSearchVScrollBarPos; }; diff --git a/src/widget/wsearchlineedit.cpp b/src/widget/wsearchlineedit.cpp index 25a2272820..7ad2664c75 100644 --- a/src/widget/wsearchlineedit.cpp +++ b/src/widget/wsearchlineedit.cpp @@ -157,8 +157,6 @@ void WSearchLineEdit::showPlaceholder() { QPalette pal = palette(); pal.setColor(foregroundRole(), Qt::lightGray); setPalette(pal); - - emit searchActive(false); } void WSearchLineEdit::showSearchText(const QString& text) { @@ -184,8 +182,6 @@ void WSearchLineEdit::showSearchText(const QString& text) { // This gets rid of the blue mac highlight. setAttribute(Qt::WA_MacShowFocusRect, false); - - emit searchActive(true); } void WSearchLineEdit::updateEditBox(const QString& text) { @@ -222,7 +218,7 @@ void WSearchLineEdit::updateText(const QString& text) { DEBUG_ASSERT(m_debouncingTimer.isSingleShot()); m_debouncingTimer.start(kDebouncingTimeoutMillis); } else { - updateClearButton(kEmptySearch); + updateClearButton(QString()); m_debouncingTimer.stop(); } } diff --git a/src/widget/wsearchlineedit.h b/src/widget/wsearchlineedit.h index 2e76ed1ba7..f36b9d051b 100644 --- a/src/widget/wsearchlineedit.h +++ b/src/widget/wsearchlineedit.h @@ -32,7 +32,6 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget { signals: void search(const QString& text); - void searchActive(bool active); public slots: void restoreSearch(const QString& text); diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index a7e39cfc52..8d33b35e72 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -1058,22 +1058,20 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { void WTrackTableView::onSearch(const QString& text) { TrackModel* trackModel = getTrackModel(); if (trackModel) { + bool searchWasEmpty = false; + if (trackModel->currentSearch().isEmpty()) { + saveNoSearchVScrollBarPos(); + searchWasEmpty = true; + } + trackModel->search(text); + if (!searchWasEmpty && text.isEmpty()) { + restoreNoSearchVScrollBarPos(); + } trackModel->search(text); - } - if (text.isEmpty()) { - restoreVScrollBarPos(); - } -} - -void WTrackTableView::onSearchActive(bool active) { - if (active) { - // Save the current position before a new search starts - saveVScrollBarPos(); } } void WTrackTableView::onShow() { - restoreVScrollBarPos(); } void WTrackTableView::mouseMoveEvent(QMouseEvent* pEvent) { diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 50cabc4940..034517b904 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -50,7 +50,6 @@ class WTrackTableView : public WLibraryTableView { void slotSendToAutoDJBottom() override; void slotSendToAutoDJTop() override; void slotSendToAutoDJReplace() override; - void onSearchActive(bool active); private slots: void slotRemove(); |