コード例 #1
0
ファイル: directorywindow.cpp プロジェクト: Derecho/vimpc
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
ファイル: librarywindow.cpp プロジェクト: 0xtobit/vimpc
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
ファイル: songwindow.cpp プロジェクト: phanimahesh/vimpc
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
ファイル: songwindow.cpp プロジェクト: phanimahesh/vimpc
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
ファイル: mpdclient.cpp プロジェクト: phanimahesh/vimpc
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
ファイル: mpdclient.cpp プロジェクト: phanimahesh/vimpc
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
ファイル: mpdclient.cpp プロジェクト: phanimahesh/vimpc
bool Client::SongIsInQueue(Mpc::Song const & song) const
{
   return (song.Reference() != 0);
}