Commit 34163c10 authored by Scott Wheeler's avatar Scott Wheeler

Try even harder to not call redisplaySearch() again with the goal of making

switching lists faster.  It now won't be called more than one time per switch
but it still could be fixed to not call the above method on an empty search.

svn path=/trunk/kdemultimedia/juk/; revision=250470
parent 69387386
......@@ -229,6 +229,7 @@ Playlist::Playlist(QWidget *parent, const QString &name) :
m_selectedCount(0),
m_allowDuplicates(false),
m_polished(false),
m_applySharedSettings(true),
m_disableColumnWidthUpdates(true),
m_widthsDirty(true),
m_lastSelected(0),
......@@ -243,6 +244,7 @@ Playlist::Playlist(const QFileInfo &playlistFile, QWidget *parent, const QString
m_selectedCount(0),
m_allowDuplicates(false),
m_polished(false),
m_applySharedSettings(true),
m_disableColumnWidthUpdates(true),
m_widthsDirty(true),
m_lastSelected(0),
......@@ -708,10 +710,18 @@ void Playlist::contentsDropEvent(QDropEvent *e)
void Playlist::showEvent(QShowEvent *e)
{
SharedSettings::instance()->apply(this);
if(m_applySharedSettings) {
SharedSettings::instance()->apply(this);
m_applySharedSettings = false;
}
KListView::showEvent(e);
}
void Playlist::applySharedSettings()
{
m_applySharedSettings = true;
}
void Playlist::viewportPaintEvent(QPaintEvent *pe)
{
// If there are columns that need to be updated, well, update them.
......
......@@ -284,6 +284,13 @@ public:
void setColumnWidthUpdatesDisabled(bool disabled) { m_disableColumnWidthUpdates = disabled; }
/**
* Playlists have a common set of shared settings such as visible columns
* that should be applied just before the playlist is shown. Calling this
* method applies those.
*/
void applySharedSettings();
public slots:
/**
* Remove the currently selected items from the playlist and disk.
......@@ -574,6 +581,7 @@ private:
bool m_allowDuplicates;
bool m_polished;
bool m_applySharedSettings;
QValueList<int> m_weightDirty;
bool m_disableColumnWidthUpdates;
......
......@@ -215,6 +215,21 @@ bool PlaylistSearch::Component::matches(PlaylistItem *item) const
return false;
}
bool PlaylistSearch::Component::operator==(const Component &v) const
{
return m_query == v.m_query &&
m_queryRe == v.m_queryRe &&
m_columns == v.m_columns &&
m_mode == v.m_mode &&
m_searchAllVisible == v.m_searchAllVisible &&
m_caseSensitive == v.m_caseSensitive &&
m_re == v.m_re;
}
////////////////////////////////////////////////////////////////////////////////
// helper functions
////////////////////////////////////////////////////////////////////////////////
QDataStream &operator<<(QDataStream &s, const PlaylistSearch &search)
{
s << search.components()
......
......@@ -110,6 +110,8 @@ public:
bool isPatternSearch() const { return m_re; }
bool isCaseSensitive() const { return m_caseSensitive; }
MatchMode matchMode() const { return m_mode; }
bool operator==(const Component &v) const;
private:
QString m_query;
......
......@@ -662,6 +662,8 @@ QString PlaylistSplitter::play(PlaylistItem *item)
void PlaylistSplitter::redisplaySearch()
{
// kdDebug(65432) << k_funcinfo << endl;
if(!m_searchWidget->isVisible() || visiblePlaylist()->search().isEmpty())
visiblePlaylist()->setItemsVisible(visiblePlaylist()->items(), true);
else {
......@@ -834,16 +836,16 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
// First case: We're just showing one, currently existing list.
if(l.count() == 1) {
l.first()->applySharedSettings();
m_playlistStack->raiseWidget(l.first());
m_editor->slotSetItems(playlistSelection());
if(m_dynamicList != l.first())
m_dynamicList = 0;
if(m_searchWidget) {
if(m_searchWidget)
m_searchWidget->setSearch(l.first()->search());
redisplaySearch();
}
}
// Second case: There are multiple playlists in our list, so we need to create
......@@ -857,6 +859,7 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
// take the "first case" above.
setupPlaylist(m_dynamicList, true, 0);
m_dynamicList->applySharedSettings();
}
if(current) {
......
......@@ -78,6 +78,9 @@ PlaylistSearch::Component SearchLine::searchComponent() const
void SearchLine::setSearchComponent(const PlaylistSearch::Component &component)
{
if(component == searchComponent())
return;
if(!component.isPatternSearch()) {
m_lineEdit->setText(component.query());
m_caseSensitive->setCurrentItem(component.isCaseSensitive() ? CaseSensitive : Default);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment