menu: remove Menu::Swap

master
Andrzej Rybczak 14 years ago
parent 419965924f
commit 3aa21f8ef7
  1. 10
      src/menu.h
  2. 19
      src/sort_playlist.cpp
  3. 1
      src/sort_playlist.h

@ -229,11 +229,6 @@ public:
/// @param pos given position of item to be deleted
void deleteItem(size_t pos);
/// Swaps the content of two items
/// @param one position of first item
/// @param two position of second item
void Swap(size_t one, size_t two);
/// Moves the highlighted position to the given line of window
/// @param y Y position of menu window to be highlighted
/// @return true if the position is reachable, false otherwise
@ -588,11 +583,6 @@ template <typename T> void Menu<T>::deleteItem(size_t pos)
m_options.erase(m_options.begin()+pos);
}
template <typename T> void Menu<T>::Swap(size_t one, size_t two)
{
std::swap(m_options.at(one), m_options.at(two));
}
template <typename T> bool Menu<T>::Goto(size_t y)
{
if (!isHighlightable(m_beginning+y))

@ -76,7 +76,6 @@ SortPlaylistDialog::SortPlaylistDialog()
w.addItem(Entry(std::make_pair("Filename", &MPD::Song::getURI),
std::bind(&Self::moveSortOrderHint, this)
));
m_sort_options = w.size();
w.addSeparator();
w.addItem(Entry(std::make_pair("Sort", static_cast<MPD::Song::GetFunction>(0)),
std::bind(&Self::sort, this)
@ -129,20 +128,20 @@ void SortPlaylistDialog::mouseButtonPressed(MEVENT me)
void SortPlaylistDialog::moveSortOrderDown()
{
size_t pos = w.choice();
if (pos < m_sort_options-1)
auto cur = w.currentVI();
if ((cur+1)->item().second)
{
w.Swap(pos, pos+1);
std::iter_swap(cur, cur+1);
w.scroll(NC::wDown);
}
}
void SortPlaylistDialog::moveSortOrderUp()
{
size_t pos = w.choice();
if (pos > 0 && pos < m_sort_options)
auto cur = w.currentVI();
if (cur > w.beginV() && cur->item().second)
{
w.Swap(pos, pos-1);
std::iter_swap(cur, cur-1);
w.scroll(NC::wUp);
}
}
@ -175,10 +174,10 @@ void SortPlaylistDialog::sort() const
LocaleStringComparison cmp(std::locale(), Config.ignore_leading_the);
std::function<void(Iterator, Iterator)> iter_swap, quick_sort;
auto song_cmp = [this, &cmp](const MPD::Song &a, const MPD::Song &b) -> bool {
for (size_t i = 0; i < m_sort_options; ++i)
for (auto it = w.beginV(); it->item().second; ++it)
{
int res = cmp(a.getTags(w[i].value().item().second, Config.tags_separator),
b.getTags(w[i].value().item().second, Config.tags_separator));
int res = cmp(a.getTags(it->item().second, Config.tags_separator),
b.getTags(it->item().second, Config.tags_separator));
if (res != 0)
return res < 0;
}

@ -59,7 +59,6 @@ private:
void setDimensions();
size_t m_sort_options;
size_t m_height;
size_t m_width;
};

Loading…
Cancel
Save