.
This commit is contained in:
+27
-7
@@ -2,6 +2,21 @@
|
||||
#include "ctrack.h"
|
||||
|
||||
|
||||
static bool compare(cAlbum* lpFirst, cAlbum* lpSecond)
|
||||
{
|
||||
if(lpFirst->band() < lpSecond->band())
|
||||
return(true);
|
||||
else if(lpFirst->band() > lpSecond->band())
|
||||
return(false);
|
||||
else
|
||||
{
|
||||
if(lpFirst->album() < lpSecond->album())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
cAlbum::cAlbum(const QString& szAlbum, const QString &szBand) :
|
||||
m_szAlbum(szAlbum),
|
||||
m_szBand(szBand)
|
||||
@@ -40,21 +55,26 @@ cTrackList cAlbum::trackList()
|
||||
|
||||
cAlbum* cAlbumList::add(const QString& szAlbum, const QString& szBand)
|
||||
{
|
||||
QString szAlbum1 = szAlbum;
|
||||
QString szLeadArtist1 = szLeadArtist;
|
||||
QString szAlbum1 = szAlbum;
|
||||
QString szBand1 = szBand;
|
||||
|
||||
if(szAlbum1.isEmpty())
|
||||
szAlbum1 = "*** NO ALBUM ***";
|
||||
if(szLeadArtist1.isEmpty())
|
||||
szLeadArtist1 = "*** NO LEAD ARTIST ***";
|
||||
szAlbum1 = "*** NO ALBUM ***";
|
||||
if(szBand1.isEmpty())
|
||||
szBand1 = "*** NO BAND ***";
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->album() == szAlbum1 && at(x)->leadArtist() == szLeadArtist1)
|
||||
if(at(x)->album() == szAlbum1 && at(x)->band() == szBand1)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
cAlbum* lpAlbumNew = new cAlbum(szAlbum1, szLeadArtist1);
|
||||
cAlbum* lpAlbumNew = new cAlbum(szAlbum1, szBand1);
|
||||
append(lpAlbumNew);
|
||||
return(lpAlbumNew);
|
||||
}
|
||||
|
||||
void cAlbumList::sort()
|
||||
{
|
||||
std::sort(begin(), end(), compare);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ class cAlbumList : public QList<cAlbum*>
|
||||
{
|
||||
public:
|
||||
cAlbum* add(const QString& szAlbum, const QString &szBand);
|
||||
void sort();
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
+11
-9
@@ -219,30 +219,32 @@ void cMainWindow::displayDB()
|
||||
{
|
||||
m_lpMusicListModel->clear();
|
||||
|
||||
m_albumList.sort();
|
||||
|
||||
QStringList header;
|
||||
header << "Original";
|
||||
|
||||
m_lpMusicListModel->setHorizontalHeaderLabels(header);
|
||||
|
||||
QString szOldLeadArtist = "OldLeadArtist";
|
||||
QString szOldAlbum = "OldAlbum";
|
||||
QList<QStandardItem*> lpLeadArtistItem;
|
||||
QString szOldBand = "OldBand";
|
||||
QString szOldAlbum = "OldAlbum";
|
||||
QList<QStandardItem*> lpBandItem;
|
||||
QList<QStandardItem*> lpAlbumItem;
|
||||
|
||||
for(int x = 0;x < m_albumList.count();x++)
|
||||
{
|
||||
cAlbum* lpAlbum = m_albumList.at(x);
|
||||
|
||||
if(szOldLeadArtist != lpAlbum->leadArtist())
|
||||
if(szOldBand != lpAlbum->band())
|
||||
{
|
||||
|
||||
szOldLeadArtist = lpAlbum->leadArtist();
|
||||
szOldBand = lpAlbum->band();
|
||||
szOldAlbum = "";
|
||||
|
||||
lpLeadArtistItem.clear();
|
||||
lpLeadArtistItem.append(new QStandardItem(szOldLeadArtist));
|
||||
lpBandItem.clear();
|
||||
lpBandItem.append(new QStandardItem(szOldBand));
|
||||
|
||||
m_lpMusicListModel->appendRow(lpLeadArtistItem);
|
||||
m_lpMusicListModel->appendRow(lpBandItem);
|
||||
}
|
||||
|
||||
if(szOldAlbum != lpAlbum->album())
|
||||
@@ -254,7 +256,7 @@ void cMainWindow::displayDB()
|
||||
lpAlbumItem.at(0)->setData(QVariant::fromValue(lpAlbum), Qt::UserRole+MUSICLIST_ORI_ALBUM);
|
||||
lpAlbumItem.append(new QStandardItem(szOldAlbum));
|
||||
|
||||
lpLeadArtistItem.at(0)->appendRow(lpAlbumItem);
|
||||
lpBandItem.at(0)->appendRow(lpAlbumItem);
|
||||
}
|
||||
|
||||
cTrackList trackList = lpAlbum->trackList();
|
||||
|
||||
Reference in New Issue
Block a user