Пример #1
0
void DirectoryWindow::ScrollToCurrent()
{
   int32_t currentSongId   = clientState_.GetCurrentSongPos();
   Mpc::Song * currentSong = NULL;

   if ((currentSongId >= 0) && (currentSongId < static_cast<int32_t>(Main::Playlist().Size())))
   {
      currentSong = Main::Playlist().Get(currentSongId);
   }

   if ((currentSong != NULL) && (currentSong->Entry() != NULL) && (currentSong->URI() != ""))
   {
      std::string Directory = currentSong->URI();

      if (Directory.find("/") != std::string::npos)
      {
         Directory = Directory.substr(0, Directory.find_last_of("/"));
      }
      else
      {
         Directory = "";
      }

      directory_.ChangeDirectory(Directory);
   }
}
Пример #2
0
uint32_t LibraryWindow::Current() const
{
   int32_t current         = CurrentLine();
   int32_t currentSongId   = clientState_.GetCurrentSongPos();
   Mpc::Song * currentSong = NULL;

   if ((currentSongId >= 0) && (currentSongId < static_cast<int32_t>(Main::Playlist().Size())))
   {
      currentSong = Main::Playlist().Get(currentSongId);
   }

   if ((currentSong != NULL) && (currentSong->Entry() != NULL))
   {
      Mpc::LibraryEntry * entry = currentSong->Entry();
      current = library_.Index(entry);

      if ((current == -1) && (entry->parent_ != NULL))
      {
         current = library_.Index(entry->parent_);
      }

      if ((current == -1) && (entry->parent_ != NULL) && (entry->parent_->parent_ != NULL))
      {
         current = library_.Index(entry->parent_->parent_);
      }
   }

   return current;
}
Пример #3
0
int32_t SongWindow::DetermineColour(uint32_t line) const
{
   uint32_t printLine = line + FirstLine();
   Mpc::Song * song   = (printLine < BufferSize()) ? Buffer().Get(printLine) : NULL;

   int32_t colour = Colour::Song;

   if (song != NULL)
   {
      if ((song->URI() == client_.GetCurrentSongURI()))
      {
         colour = Colour::CurrentSong;
      }
      else if (client_.SongIsInQueue(*song))
      {
         colour = Colour::FullAdd;
      }
      else if ((search_.LastSearchString() != "") && (settings_.Get(Setting::HighlightSearch) == true) &&
               (search_.HighlightSearch() == true))
      {
         pcrecpp::RE const expression(".*" + search_.LastSearchString() + ".*", search_.LastSearchOptions());

         if (expression.FullMatch(song->FormatString(settings_.Get(Setting::SongFormat))))
         {
            colour = Colour::SongMatch;
         }
      }
   }

   return colour;
}
Пример #4
0
void SongWindow::ScrollToFirstMatch(std::string const & input)
{
   for (uint32_t i = 0; i < BufferSize(); ++i)
   {
      Mpc::Song * song = Buffer().Get(i);
      std::string line = song->FormatString(settings_.Get(Setting::SongFormat));

      if (Algorithm::imatch(line, input, settings_.Get(Setting::IgnoreTheSort), settings_.Get(Setting::IgnoreCaseSort)) == true)
      {
         ScrollTo(i);
         break;
      }
   }
}
Пример #5
0
uint32_t Client::Add(Mpc::Song & song)
{
   ClearCommand();

   if (Connected() == true)
   {
      mpd_send_add(connection_, song.URI().c_str());
      UpdateStatus(true);
   }
   else
   {
      ErrorString(ErrorNumber::ClientNoConnection);
   }

   return TotalNumberOfSongs() - 1;
}
Пример #6
0
uint32_t Client::Add(Mpc::Song & song, uint32_t position)
{
   ClearCommand();

   if (Connected() == true)
   {
      mpd_send_add_id_to(connection_, song.URI().c_str(), position);

      if ((currentSongId_ > -1) && (position <= static_cast<uint32_t>(currentSongId_)))
      {
         ++currentSongId_;
      }

      UpdateStatus(true);
   }
   else
   {
      ErrorString(ErrorNumber::ClientNoConnection);
   }

   return TotalNumberOfSongs() - 1;
}
Пример #7
0
bool Client::SongIsInQueue(Mpc::Song const & song) const
{
   return (song.Reference() != 0);
}