.
This commit is contained in:
+84
-12
@@ -1,21 +1,92 @@
|
||||
#include "common.h"
|
||||
|
||||
#include "calbum.h"
|
||||
#include "ctrack.h"
|
||||
|
||||
|
||||
static bool compare(cAlbum* lpFirst, cAlbum* lpSecond)
|
||||
class cAlbumCompare
|
||||
{
|
||||
if(lpFirst->band() < lpSecond->band())
|
||||
return(true);
|
||||
else if(lpFirst->band() > lpSecond->band())
|
||||
return(false);
|
||||
else
|
||||
public:
|
||||
cAlbumCompare(qint32 sort) : m_sort(sort) {}
|
||||
|
||||
bool operator()(cAlbum* lpFirst, cAlbum* lpSecond)
|
||||
{
|
||||
if(lpFirst->album() < lpSecond->album())
|
||||
return(true);
|
||||
if(m_sort & SORT_BAND_ASC)
|
||||
{
|
||||
if(lpFirst->band() < lpSecond->band())
|
||||
return(true);
|
||||
else if(lpFirst->band() > lpSecond->band())
|
||||
return(false);
|
||||
else
|
||||
{
|
||||
if(m_sort & SORT_ALBUM_ASC)
|
||||
{
|
||||
if(lpFirst->album() < lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else if(m_sort & SORT_ALBUM_DESC)
|
||||
{
|
||||
if(lpFirst->album() > lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else if(m_sort & SORT_BAND_DESC)
|
||||
{
|
||||
if(lpFirst->band() > lpSecond->band())
|
||||
return(true);
|
||||
else if(lpFirst->band() < lpSecond->band())
|
||||
return(false);
|
||||
else
|
||||
{
|
||||
if(m_sort & SORT_ALBUM_ASC)
|
||||
{
|
||||
if(lpFirst->album() < lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else if(m_sort & SORT_ALBUM_DESC)
|
||||
{
|
||||
if(lpFirst->album() > lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
{
|
||||
if(m_sort & SORT_ALBUM_ASC)
|
||||
{
|
||||
if(lpFirst->album() < lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else if(m_sort & SORT_ALBUM_DESC)
|
||||
{
|
||||
if(lpFirst->album() > lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
qint32 m_sort;
|
||||
};
|
||||
|
||||
cAlbum::cAlbum(const QString& szAlbum, const QString &szBand) :
|
||||
m_szAlbum(szAlbum),
|
||||
@@ -74,7 +145,8 @@ cAlbum* cAlbumList::add(const QString& szAlbum, const QString& szBand)
|
||||
return(lpAlbumNew);
|
||||
}
|
||||
|
||||
void cAlbumList::sort()
|
||||
void cAlbumList::sort(qint32 sort)
|
||||
{
|
||||
std::sort(begin(), end(), compare);
|
||||
// std::sort(begin(), end(), compare);
|
||||
std::sort(begin(), end(), cAlbumCompare(sort));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class cAlbumList : public QList<cAlbum*>
|
||||
{
|
||||
public:
|
||||
cAlbum* add(const QString& szAlbum, const QString &szBand);
|
||||
void sort();
|
||||
void sort(qint32 sort);
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ void cMainWindow::displayDB()
|
||||
{
|
||||
m_lpMusicListModel->clear();
|
||||
|
||||
m_albumList.sort();
|
||||
m_albumList.sort(SORT_ALBUM_ASC | SORT_BAND_ASC);
|
||||
|
||||
QStringList header;
|
||||
header << "Original";
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#define MUSICLIST_ORI_ALBUM 0
|
||||
#define MUSICLIST_ORI_TRACK 1
|
||||
|
||||
@@ -9,11 +12,12 @@
|
||||
#define MUSICLIST_NEW_TRACK 3
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#define SORT_ALBUM_ASC 0x0001
|
||||
#define SORT_ALBUM_DESC 0x0002
|
||||
#define SORT_BAND_ASC 0x0004
|
||||
#define SORT_BAND_DESC 0x0008
|
||||
|
||||
|
||||
//#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":"
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
+2
-1
@@ -58,6 +58,7 @@ HEADERS += cmainwindow.h \
|
||||
cpixmap.h \
|
||||
cmusicviewitemdelegate.h \
|
||||
calbum.h \
|
||||
ctrack.h
|
||||
ctrack.h \
|
||||
common.h
|
||||
|
||||
FORMS += cmainwindow.ui
|
||||
|
||||
Reference in New Issue
Block a user