move Global::Timer to Playlist class

This commit is contained in:
Andrzej Rybczak
2009-03-12 20:20:26 +01:00
parent d5a68a1a60
commit 0aa36f3fb2
5 changed files with 38 additions and 29 deletions

View File

@@ -70,8 +70,6 @@ Connection *Global::Mpd;
size_t Global::MainStartY;
size_t Global::MainHeight;
time_t Global::Timer;
bool Global::BlockItemListUpdate = 0;
bool Global::MessagesAllowed = 0;
@@ -161,7 +159,7 @@ int main(int argc, char *argv[])
myScreen = myPlaylist;
time(&Timer);
myPlaylist->UpdateTimer();
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
@@ -248,12 +246,9 @@ int main(int argc, char *argv[])
if (!title_allowed)
RedrawHeader = 1;
title_allowed = 1;
time(&Timer);
if (myScreen == myPlaylist)
{
myPlaylist->Main()->Highlighting(1);
}
myPlaylist->EnableHighlighting();
else if (
myScreen == myLibrary
|| myScreen == myPlaylistEditor
@@ -460,7 +455,7 @@ int main(int argc, char *argv[])
{
size_t id = myPlaylist->Main()->Choice();
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
if (myPlaylist->NowPlaying > myPlaylist->CurrentSong()->GetPosition()) // needed for keeping proper
myPlaylist->NowPlaying--; // position of now playing song.
Mpd->DeleteID(myPlaylist->CurrentSong()->GetID());
@@ -526,7 +521,7 @@ int main(int argc, char *argv[])
while (!myPlaylistEditor->Content->Empty() && Keypressed(input, Key.Delete))
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
Mpd->Delete(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice());
myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice());
myPlaylistEditor->Content->Refresh();
@@ -629,7 +624,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
{
(*it)--;
@@ -656,7 +651,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && to > 0)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
to--;
myPlaylist->Main()->at(from).SetPosition(to);
myPlaylist->Main()->at(to).SetPosition(from);
@@ -682,7 +677,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
{
(*it)--;
@@ -705,7 +700,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && to > 0)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
to--;
myPlaylistEditor->Content->Swap(to, to+1);
myPlaylistEditor->Content->Scroll(wUp);
@@ -744,7 +739,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylist->Main()->Size()-1)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
{
(*it)++;
@@ -771,7 +766,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongDown) && to < myPlaylist->Main()->Size()-1)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
to++;
myPlaylist->Main()->at(from).SetPosition(to);
myPlaylist->Main()->at(to).SetPosition(from);
@@ -798,7 +793,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylistEditor->Content->Size()-1)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
{
(*it)++;
@@ -821,7 +816,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongDown) && to < myPlaylistEditor->Content->Size()-1)
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
to++;
myPlaylistEditor->Content->Swap(to, to-1);
myPlaylistEditor->Content->Scroll(wDown);
@@ -934,10 +929,10 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
{
TraceMpdStatus();
time(&Timer);
myPlaylist->UpdateTimer();
myPlaylist->Main()->ReadKey(input);
int howmuch = Config.incremental_seeking ? (Timer-t)/2+Config.seek_time : Config.seek_time;
int howmuch = Config.incremental_seeking ? (myPlaylist->Timer()-t)/2+Config.seek_time : Config.seek_time;
if (songpos < s->GetTotalLength() && Keypressed(input, Key.SeekForward))
{
@@ -1450,7 +1445,7 @@ int main(int argc, char *argv[])
myBrowser->GetDirectory("/");
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
}
time(&Timer);
myPlaylist->UpdateTimer();
FreeSongList(result);
}
else if (Keypressed(input, Key.Crop))
@@ -1514,8 +1509,7 @@ int main(int argc, char *argv[])
else if (Keypressed(input, Key.SortPlaylist) && myScreen == myPlaylist)
{
myPlaylist->Sort();
myPlaylist->Main()->Highlighting(1);
time(&Timer);
myPlaylist->EnableHighlighting();
}
else if (Keypressed(input, Key.ApplyFilter))
{
@@ -1538,8 +1532,7 @@ int main(int argc, char *argv[])
if (myScreen == myPlaylist)
{
time(&Timer);
myPlaylist->Main()->Highlighting(1);
myPlaylist->EnableHighlighting();
Playlist::ReloadTotalLength = 1;
RedrawHeader = 1;
}
@@ -1555,7 +1548,7 @@ int main(int argc, char *argv[])
Statusbar() << "Find " << (Keypressed(input, Key.FindForward) ? "forward" : "backward") << ": ";
string findme = wFooter->GetString(mList->GetSearchConstraint());
UnlockStatusbar();
time(&Timer);
myPlaylist->UpdateTimer();
if (!findme.empty())
ShowMessage("Searching...");
@@ -1571,6 +1564,9 @@ int main(int argc, char *argv[])
mList->NextFound(Config.wrapped_search);
else
mList->PrevFound(Config.wrapped_search);
if (myScreen == myPlaylist)
myPlaylist->EnableHighlighting();
}
else if (Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition))
{