playlist editor: add data fetch delay after position changes
This commit is contained in:
@@ -2798,6 +2798,8 @@ void listsChangeFinisher()
|
|||||||
else if (myScreen->isActiveWindow(myPlaylistEditor->Playlists))
|
else if (myScreen->isActiveWindow(myPlaylistEditor->Playlists))
|
||||||
{
|
{
|
||||||
myPlaylistEditor->Content.clear();
|
myPlaylistEditor->Content.clear();
|
||||||
|
myPlaylistEditor->Content.refresh();
|
||||||
|
myPlaylistEditor->updateTimer();
|
||||||
}
|
}
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
else if (myScreen->activeWindow() == myTagEditor->Dirs)
|
else if (myScreen->activeWindow() == myTagEditor->Dirs)
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ using Global::MainStartY;
|
|||||||
|
|
||||||
PlaylistEditor *myPlaylistEditor;
|
PlaylistEditor *myPlaylistEditor;
|
||||||
|
|
||||||
namespace {//
|
namespace {
|
||||||
|
|
||||||
|
const auto fetch_delay = boost::posix_time::milliseconds(500);
|
||||||
|
|
||||||
size_t LeftColumnStartX;
|
size_t LeftColumnStartX;
|
||||||
size_t LeftColumnWidth;
|
size_t LeftColumnWidth;
|
||||||
@@ -56,6 +58,7 @@ bool SongEntryMatcher(const boost::regex &rx, const MPD::Song &s);
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlaylistEditor::PlaylistEditor()
|
PlaylistEditor::PlaylistEditor()
|
||||||
|
: m_timer(boost::posix_time::from_time_t(0))
|
||||||
{
|
{
|
||||||
LeftColumnWidth = COLS/3-1;
|
LeftColumnWidth = COLS/3-1;
|
||||||
RightColumnStartX = LeftColumnWidth+1;
|
RightColumnStartX = LeftColumnWidth+1;
|
||||||
@@ -152,7 +155,9 @@ void PlaylistEditor::update()
|
|||||||
Playlists.refresh();
|
Playlists.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Playlists.empty() && (Content.reallyEmpty() || m_content_update_requested))
|
if (!Playlists.empty()
|
||||||
|
&& ((Content.reallyEmpty() && Global::Timer - m_timer > fetch_delay) || m_content_update_requested)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
m_content_update_requested = false;
|
m_content_update_requested = false;
|
||||||
Content.clearSearchResults();
|
Content.clearSearchResults();
|
||||||
@@ -535,6 +540,11 @@ void PlaylistEditor::nextColumn()
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
void PlaylistEditor::updateTimer()
|
||||||
|
{
|
||||||
|
m_timer = Global::Timer;
|
||||||
|
}
|
||||||
|
|
||||||
void PlaylistEditor::Locate(const std::string &name)
|
void PlaylistEditor::Locate(const std::string &name)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ struct PlaylistEditor: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, S
|
|||||||
virtual void nextColumn() OVERRIDE;
|
virtual void nextColumn() OVERRIDE;
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
|
void updateTimer();
|
||||||
|
|
||||||
void requestPlaylistsUpdate() { m_playlists_update_requested = true; }
|
void requestPlaylistsUpdate() { m_playlists_update_requested = true; }
|
||||||
void requestContentsUpdate() { m_content_update_requested = true; }
|
void requestContentsUpdate() { m_content_update_requested = true; }
|
||||||
|
|
||||||
@@ -87,6 +89,8 @@ private:
|
|||||||
|
|
||||||
bool m_playlists_update_requested;
|
bool m_playlists_update_requested;
|
||||||
bool m_content_update_requested;
|
bool m_content_update_requested;
|
||||||
|
|
||||||
|
boost::posix_time::ptime m_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PlaylistEditor *myPlaylistEditor;
|
extern PlaylistEditor *myPlaylistEditor;
|
||||||
|
|||||||
Reference in New Issue
Block a user