Commit 6592034c authored by Kacper Kasper's avatar Kacper Kasper

Fix sorting and build.

parent 381082b0
...@@ -172,9 +172,8 @@ void Cache::loadPlaylists(PlaylistCollection *collection) // static ...@@ -172,9 +172,8 @@ void Cache::loadPlaylists(PlaylistCollection *collection) // static
if(version >= 2) { if(version >= 2) {
qint32 sortColumn; qint32 sortColumn;
s >> sortColumn; s >> sortColumn;
// FIXME
if(playlist) if(playlist)
playlist->model()->sort(sortColumn); playlist->sortByColumn(sortColumn);
} }
} // while !s.atEnd() } // while !s.atEnd()
...@@ -271,8 +270,7 @@ void Cache::savePlaylists(const PlaylistList &playlists) ...@@ -271,8 +270,7 @@ void Cache::savePlaylists(const PlaylistList &playlists)
s << qint32(Normal) s << qint32(Normal)
<< *(*it); << *(*it);
} }
// FIXME s << qint32((*it)->sortColumn());
//s << qint32((*it)->sortColumn());
s << 0; s << 0;
} }
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <QTime> #include <QTime>
#include <QClipboard> #include <QClipboard>
#include <QFileInfo> #include <QFileInfo>
#include <QHeaderView>
#include "playlistcollection.h" #include "playlistcollection.h"
#include "splashscreen.h" #include "splashscreen.h"
...@@ -121,11 +122,7 @@ void CollectionList::completedLoadingCachedItems() ...@@ -121,11 +122,7 @@ void CollectionList::completedLoadingCachedItems()
if(config.readEntry("CollectionListSortAscending", true)) if(config.readEntry("CollectionListSortAscending", true))
order = Qt::AscendingOrder; order = Qt::AscendingOrder;
// FIXME m_list->sortByColumn(config.readEntry("CollectionListSortColumn", 1), order);
//m_list->setSortOrder(order);
//m_list->setSortColumn(config.readEntry("CollectionListSortColumn", 1));
//m_list->sort();
SplashScreen::finishedLoading(); SplashScreen::finishedLoading();
...@@ -346,8 +343,7 @@ CollectionList::CollectionList(PlaylistCollection *collection) : ...@@ -346,8 +343,7 @@ CollectionList::CollectionList(PlaylistCollection *collection) :
this, SLOT(slotPopulateBackMenu())); this, SLOT(slotPopulateBackMenu()));
connect(action<KToolBarPopupAction>("back")->menu(), SIGNAL(triggered(QAction*)), connect(action<KToolBarPopupAction>("back")->menu(), SIGNAL(triggered(QAction*)),
this, SLOT(slotPlayFromBackMenu(QAction*))); this, SLOT(slotPlayFromBackMenu(QAction*)));
//FIXME setSortingEnabled(false); // Temporarily disable sorting to add items faster.
//setSorting(-1); // Temporarily disable sorting to add items faster.
m_columnTags[PlaylistItem::ArtistColumn] = new TagCountDict; m_columnTags[PlaylistItem::ArtistColumn] = new TagCountDict;
m_columnTags[PlaylistItem::AlbumColumn] = new TagCountDict; m_columnTags[PlaylistItem::AlbumColumn] = new TagCountDict;
...@@ -360,9 +356,8 @@ CollectionList::CollectionList(PlaylistCollection *collection) : ...@@ -360,9 +356,8 @@ CollectionList::CollectionList(PlaylistCollection *collection) :
CollectionList::~CollectionList() CollectionList::~CollectionList()
{ {
KConfigGroup config(KGlobal::config(), "Playlists"); KConfigGroup config(KGlobal::config(), "Playlists");
//FIXME config.writeEntry("CollectionListSortColumn", header()->sortIndicatorSection());
//config.writeEntry("CollectionListSortColumn", sortColumn()); config.writeEntry("CollectionListSortAscending", header()->sortIndicatorOrder() == Qt::AscendingOrder);
//config.writeEntry("CollectionListSortAscending", sortOrder() == Qt::AscendingOrder);
// In some situations the dataChanged signal from clearItems will cause observers to // In some situations the dataChanged signal from clearItems will cause observers to
// subsequently try to access a deleted item. Since we're going away just remove all // subsequently try to access a deleted item. Since we're going away just remove all
......
...@@ -57,7 +57,7 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists, ...@@ -57,7 +57,7 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists,
setName(name); setName(name);
setAllowDuplicates(false); setAllowDuplicates(false);
sortItems(columnCount() + 1, Qt::AscendingOrder); setSortingEnabled(false);
for(PlaylistList::ConstIterator it = playlists.constBegin(); it != playlists.constEnd(); ++it) for(PlaylistList::ConstIterator it = playlists.constBegin(); it != playlists.constEnd(); ++it)
m_observers.append(new PlaylistDirtyObserver(this, *it)); m_observers.append(new PlaylistDirtyObserver(this, *it));
......
...@@ -38,7 +38,7 @@ HistoryPlaylist::HistoryPlaylist(PlaylistCollection *collection) : ...@@ -38,7 +38,7 @@ HistoryPlaylist::HistoryPlaylist(PlaylistCollection *collection) :
m_timer->setSingleShot(true); m_timer->setSingleShot(true);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotCreateNewItem())); connect(m_timer, SIGNAL(timeout()), this, SLOT(slotCreateNewItem()));
sortItems(-1, Qt::AscendingOrder); setSortingEnabled(false);
headerItem()->setText(0, i18n("Time")); headerItem()->setText(0, i18n("Time"));
} }
......
...@@ -244,9 +244,9 @@ void Playlist::SharedSettings::apply(Playlist *l) const ...@@ -244,9 +244,9 @@ void Playlist::SharedSettings::apply(Playlist *l) const
l->header()->moveSection(i++ + offset, column + offset); l->header()->moveSection(i++ + offset, column + offset);
for(int i = 0; i < m_columnsVisible.size(); i++) { for(int i = 0; i < m_columnsVisible.size(); i++) {
if(m_columnsVisible[i] && !l->isColumnVisible(i + offset)) if(m_columnsVisible[i] && l->isColumnHidden(i + offset))
l->showColumn(i + offset, false); l->showColumn(i + offset, false);
else if(!m_columnsVisible[i] && l->isColumnVisible(i + offset)) else if(!m_columnsVisible[i] && !l->isColumnHidden(i + offset))
l->hideColumn(i + offset, false); l->hideColumn(i + offset, false);
} }
...@@ -916,7 +916,7 @@ void Playlist::slotWeightDirty(int column) ...@@ -916,7 +916,7 @@ void Playlist::slotWeightDirty(int column)
if(column < 0) { if(column < 0) {
m_weightDirty.clear(); m_weightDirty.clear();
for(int i = 0; i < columnCount(); i++) { for(int i = 0; i < columnCount(); i++) {
if(isColumnVisible(i)) if(!isColumnHidden(i))
m_weightDirty.append(i); m_weightDirty.append(i);
} }
return; return;
...@@ -943,7 +943,7 @@ void Playlist::slotShowPlaying() ...@@ -943,7 +943,7 @@ void Playlist::slotShowPlaying()
m_collection->raise(l); m_collection->raise(l);
l->setCurrentItem(playingItem()); l->setCurrentItem(playingItem());
l->scrollTo(currentIndex()); l->scrollToItem(playingItem());
} }
void Playlist::slotColumnResizeModeChanged() void Playlist::slotColumnResizeModeChanged()
...@@ -1260,7 +1260,7 @@ void Playlist::read(QDataStream &s) ...@@ -1260,7 +1260,7 @@ void Playlist::read(QDataStream &s)
throw BICStreamException(); throw BICStreamException();
// Do not sort. Add the files in the order they were saved. // Do not sort. Add the files in the order they were saved.
sortItems(columnCount() + 1, Qt::AscendingOrder); setSortingEnabled(false);
QStringList files; QStringList files;
s >> files; s >> files;
...@@ -1491,6 +1491,12 @@ void Playlist::showColumn(int c, bool updateSearch) ...@@ -1491,6 +1491,12 @@ void Playlist::showColumn(int c, bool updateSearch)
redisplaySearch(); redisplaySearch();
} }
void Playlist::sortByColumn(int column, Qt::SortOrder order)
{
setSortingEnabled(true);
QTreeWidget::sortByColumn(column, order);
}
void Playlist::slotInitialize() void Playlist::slotInitialize()
{ {
addColumn(i18n("Track Name")); addColumn(i18n("Track Name"));
...@@ -1515,9 +1521,9 @@ void Playlist::slotInitialize() ...@@ -1515,9 +1521,9 @@ void Playlist::slotInitialize()
setRenameable(PlaylistItem::YearColumn, true);*/ setRenameable(PlaylistItem::YearColumn, true);*/
setAllColumnsShowFocus(true); setAllColumnsShowFocus(true);
/*setSelectionMode(QTreeWidget::Extended); setSelectionMode(QTreeWidget::ExtendedSelection);
setShowSortIndicator(true); header()->setSortIndicatorShown(true);
setDropVisualizer(true);*/ //setDropVisualizer(true);
m_columnFixedWidths.resize(columnCount()); m_columnFixedWidths.resize(columnCount());
...@@ -1678,7 +1684,7 @@ void Playlist::setup() ...@@ -1678,7 +1684,7 @@ void Playlist::setup()
// progress. // progress.
connect(this, SIGNAL(itemSelectionChanged()), m_fetcher, SLOT(abortSearch())); connect(this, SIGNAL(itemSelectionChanged()), m_fetcher, SLOT(abortSearch()));
sortItems(1, Qt::AscendingOrder); sortByColumn(1, Qt::AscendingOrder);
// This apparently must be created very early in initialization for other // This apparently must be created very early in initialization for other
// Playlist code requiring m_headerMenu. // Playlist code requiring m_headerMenu.
...@@ -1704,7 +1710,7 @@ void Playlist::loadFile(const QString &fileName, const QFileInfo &fileInfo) ...@@ -1704,7 +1710,7 @@ void Playlist::loadFile(const QString &fileName, const QFileInfo &fileInfo)
// Turn off non-explicit sorting. // Turn off non-explicit sorting.
sortItems(PlaylistItem::lastColumn() + columnOffset() + 1, Qt::AscendingOrder); setSortingEnabled(false);
PlaylistItem *after = 0; PlaylistItem *after = 0;
...@@ -1778,7 +1784,7 @@ bool Playlist::playing() const ...@@ -1778,7 +1784,7 @@ bool Playlist::playing() const
int Playlist::leftMostVisibleColumn() const int Playlist::leftMostVisibleColumn() const
{ {
int i = 0; int i = 0;
while(!isColumnVisible(header()->sectionPosition(i)) && i < PlaylistItem::lastColumn()) while(isColumnHidden(header()->sectionPosition(i)) && i < PlaylistItem::lastColumn())
i++; i++;
return header()->sectionPosition(i); return header()->sectionPosition(i);
...@@ -1944,7 +1950,7 @@ void Playlist::slotUpdateColumnWidths() ...@@ -1944,7 +1950,7 @@ void Playlist::slotUpdateColumnWidths()
QList<int> visibleColumns; QList<int> visibleColumns;
for(int i = 0; i < columnCount(); i++) { for(int i = 0; i < columnCount(); i++) {
if(isColumnVisible(i)) if(!isColumnHidden(i))
visibleColumns.append(i); visibleColumns.append(i);
} }
...@@ -2300,21 +2306,21 @@ void Playlist::slotToggleColumnVisible(QAction *action) ...@@ -2300,21 +2306,21 @@ void Playlist::slotToggleColumnVisible(QAction *action)
{ {
int column = action->data().toInt(); int column = action->data().toInt();
if(!isColumnVisible(column)) { if(isColumnHidden(column)) {
int fileNameColumn = PlaylistItem::FileNameColumn + columnOffset(); int fileNameColumn = PlaylistItem::FileNameColumn + columnOffset();
int fullPathColumn = PlaylistItem::FullPathColumn + columnOffset(); int fullPathColumn = PlaylistItem::FullPathColumn + columnOffset();
if(column == fileNameColumn && isColumnVisible(fullPathColumn)) { if(column == fileNameColumn && !isColumnHidden(fullPathColumn)) {
hideColumn(fullPathColumn, false); hideColumn(fullPathColumn, false);
SharedSettings::instance()->toggleColumnVisible(fullPathColumn); SharedSettings::instance()->toggleColumnVisible(fullPathColumn);
} }
if(column == fullPathColumn && isColumnVisible(fileNameColumn)) { if(column == fullPathColumn && !isColumnHidden(fileNameColumn)) {
hideColumn(fileNameColumn, false); hideColumn(fileNameColumn, false);
SharedSettings::instance()->toggleColumnVisible(fileNameColumn); SharedSettings::instance()->toggleColumnVisible(fileNameColumn);
} }
} }
if(isColumnVisible(column)) if(!isColumnHidden(column))
hideColumn(column); hideColumn(column);
else else
showColumn(column); showColumn(column);
......
...@@ -220,6 +220,8 @@ public: ...@@ -220,6 +220,8 @@ public:
* will be udated. * will be udated.
*/ */
void showColumn(int c, bool updateSearch = true); void showColumn(int c, bool updateSearch = true);
void sortByColumn(int column, Qt::SortOrder order = Qt::AscendingOrder);
/** /**
* This sets a name for the playlist that is \e different from the file name. * This sets a name for the playlist that is \e different from the file name.
......
...@@ -850,10 +850,10 @@ void PlaylistBox::Item::slotSetName(const QString &name) ...@@ -850,10 +850,10 @@ void PlaylistBox::Item::slotSetName(const QString &name)
setText(0, name); setText(0, name);
setSelected(true); setSelected(true);
// FIXME treeWidget()->sortItems(0, Qt::AscendingOrder);
/*listView()->sort(); treeWidget()->scrollToItem(treeWidget()->currentItem());
listView()->ensureItemVisible(listView()->currentItem());*/ //FIXME
listView()->viewMode()->queueRefresh(); //listView()->viewMode()->queueRefresh();
} }
} }
......
...@@ -329,10 +329,10 @@ int PlaylistItem::compare(QTreeWidgetItem *item, int column, bool ascending) con ...@@ -329,10 +329,10 @@ int PlaylistItem::compare(QTreeWidgetItem *item, int column, bool ascending) con
// Loop through the columns doing comparisons until something is differnt. // Loop through the columns doing comparisons until something is differnt.
// If all else is the same, compare the track name. // If all else is the same, compare the track name.
int last = playlist()->isColumnVisible(AlbumColumn + offset) ? TrackNumberColumn : ArtistColumn; int last = !playlist()->isColumnHidden(AlbumColumn + offset) ? TrackNumberColumn : ArtistColumn;
for(int i = ArtistColumn; i <= last; i++) { for(int i = ArtistColumn; i <= last; i++) {
if(playlist()->isColumnVisible(i + offset)) { if(!playlist()->isColumnHidden(i + offset)) {
c = compare(this, playlistItem, i, ascending); c = compare(this, playlistItem, i, ascending);
if(c != 0) if(c != 0)
return c; return c;
......
...@@ -188,7 +188,7 @@ bool PlaylistSearch::Component::matches(PlaylistItem *item) const ...@@ -188,7 +188,7 @@ bool PlaylistSearch::Component::matches(PlaylistItem *item) const
if(m_columns.isEmpty()) { if(m_columns.isEmpty()) {
Playlist *p = static_cast<Playlist *>(item->treeWidget()); Playlist *p = static_cast<Playlist *>(item->treeWidget());
for(int i = 0; i < p->columnCount(); i++) { for(int i = 0; i < p->columnCount(); i++) {
if(p->isColumnVisible(i)) if(!p->isColumnHidden(i))
m_columns.append(i); m_columns.append(i);
} }
} }
......
...@@ -92,7 +92,7 @@ PlaylistSearch::Component SearchLine::searchComponent() const ...@@ -92,7 +92,7 @@ PlaylistSearch::Component SearchLine::searchComponent() const
if(!m_searchFieldsBox || m_searchFieldsBox->currentIndex() == 0) { if(!m_searchFieldsBox || m_searchFieldsBox->currentIndex() == 0) {
foreach(int column, m_columnList) { foreach(int column, m_columnList) {
if(playlist->isColumnVisible(column)) if(!playlist->isColumnHidden(column))
searchedColumns.append(column); searchedColumns.append(column);
} }
} }
......
...@@ -36,7 +36,7 @@ UpcomingPlaylist::UpcomingPlaylist(PlaylistCollection *collection) : ...@@ -36,7 +36,7 @@ UpcomingPlaylist::UpcomingPlaylist(PlaylistCollection *collection) :
{ {
setName(i18n("Play Queue")); setName(i18n("Play Queue"));
setAllowDuplicates(true); setAllowDuplicates(true);
sortItems(-1, Qt::AscendingOrder); setSortingEnabled(false);
} }
UpcomingPlaylist::~UpcomingPlaylist() UpcomingPlaylist::~UpcomingPlaylist()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment