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