abstract shared parts of switchTo methods away

This commit is contained in:
Andrzej Rybczak
2012-09-15 22:27:50 +02:00
parent f7dba0a578
commit 14587cb4ec
46 changed files with 301 additions and 463 deletions

View File

@@ -23,6 +23,7 @@
#include "song_info.h"
#include "tag_editor.h"
#include "title.h"
#include "screen_switcher.h"
#ifdef HAVE_TAGLIB_H
# include "fileref.h"
@@ -71,34 +72,23 @@ std::wstring SongInfo::title()
void SongInfo::switchTo()
{
using Global::myScreen;
using Global::myOldScreen;
using Global::myLockedScreen;
if (myScreen == this)
return myOldScreen->switchTo();
if (myLockedScreen)
updateInactiveScreen(this);
auto s = currentSong(myScreen);
if (!s)
return;
if (hasToBeResized || myLockedScreen)
resize();
myOldScreen = myScreen;
myScreen = this;
w.clear();
w.reset();
PrepareSong(*s);
w.flush();
// redraw header after we're done with the file, since reading it from disk
// takes a bit of time and having header updated before content of a window
// is displayed doesn't look nice.
drawHeader();
if (myScreen != this)
{
auto s = currentSong(myScreen);
if (!s)
return;
SwitchTo::execute(this);
w.clear();
w.reset();
PrepareSong(*s);
w.flush();
// redraw header after we're done with the file, since reading it from disk
// takes a bit of time and having header updated before content of a window
// is displayed doesn't look nice.
drawHeader();
}
else
switchToPreviousScreen();
}
void SongInfo::PrepareSong(MPD::Song &s)