.
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
|||||||
|
#include "calbum.h"
|
||||||
|
|
||||||
|
|
||||||
|
cAlbum::cAlbum(const QString& szAlbum, const QString &szLeadArtist) :
|
||||||
|
m_szAlbum(szAlbum),
|
||||||
|
m_szLeadArtist(szLeadArtist)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void cAlbum::setAlbum(const QString& szAlbum)
|
||||||
|
{
|
||||||
|
m_szAlbum = szAlbum;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cAlbum::album()
|
||||||
|
{
|
||||||
|
return(m_szAlbum);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cAlbum::setLeadArtist(const QString& szLeadArtist)
|
||||||
|
{
|
||||||
|
m_szLeadArtist = szLeadArtist;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cAlbum::leadArtist()
|
||||||
|
{
|
||||||
|
return(m_szLeadArtist);
|
||||||
|
}
|
||||||
|
|
||||||
|
cAlbum* cAlbumList::add(const QString& szAlbum, const QString& szLeadArtist)
|
||||||
|
{
|
||||||
|
for(int x = 0;x < count();x++)
|
||||||
|
{
|
||||||
|
if(at(x)->album() == szAlbum && at(x)->leadArtist() == szLeadArtist)
|
||||||
|
return(at(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
cAlbum* lpAlbumNew = new cAlbum(szAlbum, szLeadArtist);
|
||||||
|
append(lpAlbumNew);
|
||||||
|
return(lpAlbumNew);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef CALBUM_H
|
||||||
|
#define CALBUM_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QString>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
|
class cAlbum
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cAlbum(const QString& szAlbum, const QString& szLeadArtist);
|
||||||
|
|
||||||
|
void setAlbum(const QString& szAlbum);
|
||||||
|
QString album();
|
||||||
|
|
||||||
|
void setLeadArtist(const QString& szLeadArtist);
|
||||||
|
QString leadArtist();
|
||||||
|
private:
|
||||||
|
QString m_szAlbum;
|
||||||
|
QString m_szLeadArtist;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(cAlbum*)
|
||||||
|
|
||||||
|
class cAlbumList : public QList<cAlbum*>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cAlbum* add(const QString& szAlbum, const QString &szLeadArtist);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CALBUM_H
|
||||||
+336
-11
@@ -1,10 +1,17 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include "cmainwindow.h"
|
#include "cmainwindow.h"
|
||||||
#include "ui_cmainwindow.h"
|
#include "ui_cmainwindow.h"
|
||||||
|
|
||||||
#include "cmediainfo.h"
|
#include "cmediainfo.h"
|
||||||
|
|
||||||
|
#include "cmusicviewitemdelegate.h"
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
|
|
||||||
@@ -49,8 +56,13 @@ void cMainWindow::addPath(const QString& szPath)
|
|||||||
|
|
||||||
cMainWindow::cMainWindow(QWidget *parent) :
|
cMainWindow::cMainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::cMainWindow)
|
ui(new Ui::cMainWindow),
|
||||||
|
m_lpDB(0),
|
||||||
|
m_lpMusicListModel(0),
|
||||||
|
m_bProcessing(false)
|
||||||
{
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
if(settings.value("application/version", QVariant(0.0)).toDouble() == 0.0)
|
if(settings.value("application/version", QVariant(0.0)).toDouble() == 0.0)
|
||||||
@@ -58,20 +70,39 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
m_lpDB = new cDatabase(this);
|
m_lpDB = new cDatabase(this);
|
||||||
|
|
||||||
QTime t;
|
m_lpMusicListModel = new QStandardItemModel(0, 3);
|
||||||
|
ui->m_lpMusicListOriginal->setModel(m_lpMusicListModel);
|
||||||
|
ui->m_lpMusicListOriginal->setItemDelegate(new cMusicViewItemDelegate(ui->m_lpMusicListOriginal));
|
||||||
|
ui->m_lpMusicListNew->setModel(m_lpMusicListModel);
|
||||||
|
ui->m_lpMusicListNew->setItemDelegate(new cMusicViewItemDelegate(ui->m_lpMusicListNew));
|
||||||
|
|
||||||
|
connect(ui->m_lpMusicListOriginal, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenuRequestedOriginal(QPoint)));
|
||||||
|
connect(ui->m_lpMusicListNew, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenuRequestedNew(QPoint)));
|
||||||
|
|
||||||
// bool bRet;
|
connect(ui->m_lpMusicListOriginal, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClickedOriginal(QModelIndex)));
|
||||||
// bRet = lpDatabase->getDB().transaction();
|
connect(ui->m_lpMusicListNew, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClickedNew(QModelIndex)));
|
||||||
t.start();
|
|
||||||
addPath("C:/Users/vet0572/Music");
|
connect(ui->m_lpMusicListOriginal, SIGNAL(pressed(QModelIndex)), this, SLOT(onPressedOriginal(QModelIndex)));
|
||||||
qDebug() << t.elapsed();
|
connect(ui->m_lpMusicListNew, SIGNAL(pressed(QModelIndex)), this, SLOT(onPressedNew(QModelIndex)));
|
||||||
|
|
||||||
|
connect(ui->m_lpMusicListOriginal, SIGNAL(expanded(QModelIndex)), this, SLOT(onExpandedOriginal(QModelIndex)));
|
||||||
|
connect(ui->m_lpMusicListNew, SIGNAL(expanded(QModelIndex)), this, SLOT(onExpandedNew(QModelIndex)));
|
||||||
|
|
||||||
|
connect(ui->m_lpMusicListOriginal, SIGNAL(collapsed(QModelIndex)), this, SLOT(onCollapsedOriginal(QModelIndex)));
|
||||||
|
connect(ui->m_lpMusicListNew, SIGNAL(collapsed(QModelIndex)), this, SLOT(onCollapsedNew(QModelIndex)));
|
||||||
|
|
||||||
|
connect(ui->m_lpMusicListOriginal->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cMainWindow::onSelectionChangedOriginal);
|
||||||
|
connect(ui->m_lpMusicListNew->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cMainWindow::onSelectionChangedNew);
|
||||||
|
|
||||||
|
connect(ui->m_lpMusicListOriginal->verticalScrollBar(), &QScrollBar::valueChanged, this, &cMainWindow::onScrollbarValueChangedOriginal);
|
||||||
|
connect(ui->m_lpMusicListNew->verticalScrollBar(), &QScrollBar::valueChanged, this, &cMainWindow::onScrollbarValueChangedNew);
|
||||||
|
|
||||||
|
loadDB();
|
||||||
|
displayDB();
|
||||||
|
|
||||||
|
// addPath("C:/Users/vet0572/Music");
|
||||||
// addPath("C:/Users/birkeh/Music");
|
// addPath("C:/Users/birkeh/Music");
|
||||||
// bRet = lpDatabase->getDB().commit();
|
|
||||||
|
|
||||||
// addFile("C:/Users/vet0572/Music/Amy MacDonald/Under Stars (Deluxe)/01 - Dream On.mp3");
|
// addFile("C:/Users/vet0572/Music/Amy MacDonald/Under Stars (Deluxe)/01 - Dream On.mp3");
|
||||||
|
|
||||||
ui->setupUi(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cMainWindow::~cMainWindow()
|
cMainWindow::~cMainWindow()
|
||||||
@@ -92,3 +123,297 @@ void cMainWindow::initSettings()
|
|||||||
|
|
||||||
dir.mkdir(settings.value("application/data").toString());
|
dir.mkdir(settings.value("application/data").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cMainWindow::loadDB()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
QString szOldLeadArtist = "";
|
||||||
|
QString szOldAlbum = "";
|
||||||
|
QString szAlbum;
|
||||||
|
QString szTitle;
|
||||||
|
qint16 iTrackNumber;
|
||||||
|
qint16 iPartOfSet;
|
||||||
|
QString szLeadArtist;
|
||||||
|
QString szBand;
|
||||||
|
QString szComposer;
|
||||||
|
QDate recordingTime;
|
||||||
|
|
||||||
|
cAlbum* lpAlbum = 0;
|
||||||
|
|
||||||
|
query.prepare("SELECT leadArtist, album, title, trackNumber, partOfSet, band, composer, recordingTime FROM file ORDER BY leadArtist, album, trackNumber;");
|
||||||
|
if(!query.exec())
|
||||||
|
{
|
||||||
|
myDebug << query.lastError().text();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(query.next())
|
||||||
|
{
|
||||||
|
szAlbum = query.value("album").toString();
|
||||||
|
szTitle = query.value("title").toString();
|
||||||
|
iTrackNumber = query.value("trackNumber").toInt();
|
||||||
|
iPartOfSet = query.value("partOfSet").toInt();
|
||||||
|
szLeadArtist = query.value("leadArtist").toString();
|
||||||
|
szBand = query.value("band").toString();
|
||||||
|
szComposer = query.value("composer").toString();
|
||||||
|
recordingTime = query.value("recordingTime").toDate();
|
||||||
|
|
||||||
|
if(szOldLeadArtist != szLeadArtist || szOldAlbum != szAlbum)
|
||||||
|
{
|
||||||
|
szOldLeadArtist = szLeadArtist;
|
||||||
|
szOldAlbum = szAlbum;
|
||||||
|
|
||||||
|
cAlbum* lpAlbum = m_albumList.add(szAlbum, szLeadArtist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::displayDB()
|
||||||
|
{
|
||||||
|
m_lpMusicListModel->clear();
|
||||||
|
|
||||||
|
QStringList header;
|
||||||
|
header << "Original" << "New";
|
||||||
|
|
||||||
|
m_lpMusicListModel->setHorizontalHeaderLabels(header);
|
||||||
|
|
||||||
|
ui->m_lpMusicListOriginal->setColumnHidden(1, true);
|
||||||
|
ui->m_lpMusicListNew->setColumnHidden(0, true);
|
||||||
|
|
||||||
|
QString szOldLeadArtist = "";
|
||||||
|
QString szOldAlbum = "";
|
||||||
|
QList<QStandardItem*> lpLeadArtistItem;
|
||||||
|
QList<QStandardItem*> lpAlbumItem;
|
||||||
|
|
||||||
|
for(int x = 0;x < m_albumList.count();x++)
|
||||||
|
{
|
||||||
|
cAlbum* lpAlbum = m_albumList.at(x);
|
||||||
|
|
||||||
|
if(szOldLeadArtist != lpAlbum->leadArtist())
|
||||||
|
{
|
||||||
|
|
||||||
|
szOldLeadArtist = lpAlbum->leadArtist();
|
||||||
|
szOldAlbum = "";
|
||||||
|
|
||||||
|
lpLeadArtistItem.clear();
|
||||||
|
lpLeadArtistItem.append(new QStandardItem(szOldLeadArtist));
|
||||||
|
lpLeadArtistItem.append(new QStandardItem(szOldLeadArtist));
|
||||||
|
|
||||||
|
m_lpMusicListModel->appendRow(lpLeadArtistItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(szOldAlbum != lpAlbum->album())
|
||||||
|
{
|
||||||
|
szOldAlbum = lpAlbum->album();
|
||||||
|
|
||||||
|
lpAlbumItem.clear();
|
||||||
|
lpAlbumItem.append(new QStandardItem(szOldAlbum));
|
||||||
|
lpAlbumItem.at(0)->setData(QVariant::fromValue(lpAlbum), Qt::UserRole+MUSICLIST_ORI_ALBUM);
|
||||||
|
lpAlbumItem.append(new QStandardItem(szOldAlbum));
|
||||||
|
|
||||||
|
lpLeadArtistItem.at(0)->appendRow(lpAlbumItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QStandardItem*> lpTrackItem;
|
||||||
|
lpTrackItem.append(new QStandardItem("track 1"));
|
||||||
|
lpTrackItem.append(new QStandardItem("track 1"));
|
||||||
|
lpAlbumItem.at(0)->appendRow(lpTrackItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onCustomContextMenuRequestedOriginal(const QPoint &pos)
|
||||||
|
{
|
||||||
|
onCustomContextMenuRequested(ui->m_lpMusicListOriginal, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onDoubleClickedOriginal(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
onDoubleClicked(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onPressedOriginal(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
onPressed(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onExpandedOriginal(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
ui->m_lpMusicListNew->expand(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onCollapsedOriginal(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
ui->m_lpMusicListNew->collapse(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onSelectionChangedOriginal(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
|
{
|
||||||
|
if(m_bProcessing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bProcessing = true;
|
||||||
|
|
||||||
|
QItemSelectionModel* lpOriginal = ui->m_lpMusicListOriginal->selectionModel();
|
||||||
|
QItemSelectionModel* lpNew = ui->m_lpMusicListNew->selectionModel();
|
||||||
|
QModelIndexList selected1 = lpOriginal->selectedIndexes();
|
||||||
|
|
||||||
|
lpNew->clearSelection();
|
||||||
|
|
||||||
|
for(int z = 0;z < selected1.count();z++)
|
||||||
|
{
|
||||||
|
|
||||||
|
QStandardItem* lpItem = m_lpMusicListModel->itemFromIndex(selected1.at(z));
|
||||||
|
QModelIndex index = lpItem->index();
|
||||||
|
lpNew->select(index, QItemSelectionModel::Select);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bProcessing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onScrollbarValueChangedOriginal(int value)
|
||||||
|
{
|
||||||
|
if(m_bProcessing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bProcessing = true;
|
||||||
|
|
||||||
|
ui->m_lpMusicListNew->verticalScrollBar()->setValue(value);
|
||||||
|
|
||||||
|
m_bProcessing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onCustomContextMenuRequestedNew(const QPoint &pos)
|
||||||
|
{
|
||||||
|
onCustomContextMenuRequested(ui->m_lpMusicListNew, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onDoubleClickedNew(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
onDoubleClicked(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onPressedNew(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
onPressed(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onExpandedNew(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
ui->m_lpMusicListOriginal->expand(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onCollapsedNew(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
ui->m_lpMusicListOriginal->collapse(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onSelectionChangedNew(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
|
{
|
||||||
|
if(m_bProcessing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bProcessing = true;
|
||||||
|
|
||||||
|
QItemSelectionModel* lpOriginal = ui->m_lpMusicListOriginal->selectionModel();
|
||||||
|
QItemSelectionModel* lpNew = ui->m_lpMusicListNew->selectionModel();
|
||||||
|
QModelIndexList selected2 = lpNew->selectedIndexes();
|
||||||
|
|
||||||
|
lpOriginal->clearSelection();
|
||||||
|
|
||||||
|
for(int z = 0;z < selected2.count();z++)
|
||||||
|
{
|
||||||
|
QStandardItem* lpItem = m_lpMusicListModel->itemFromIndex(selected2.at(z));
|
||||||
|
QModelIndex index = lpItem->index();
|
||||||
|
lpOriginal->select(index, QItemSelectionModel::Select);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bProcessing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onScrollbarValueChangedNew(int value)
|
||||||
|
{
|
||||||
|
if(m_bProcessing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bProcessing = true;
|
||||||
|
|
||||||
|
ui->m_lpMusicListOriginal->verticalScrollBar()->setValue(value);
|
||||||
|
|
||||||
|
m_bProcessing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onCustomContextMenuRequested(const QTreeView* lpTreeView, const QPoint &pos)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
QMenu* lpMenu = new QMenu(this);
|
||||||
|
|
||||||
|
lpMenu->addAction("add", this, SLOT(onActionAdd()));
|
||||||
|
|
||||||
|
lpMenu->addAction("update all", this, SLOT(onActionUpdateAll()));
|
||||||
|
lpMenu->addAction("update unfinished", this, SLOT(onActionUpdateUnfinished()));
|
||||||
|
lpMenu->addSeparator();
|
||||||
|
|
||||||
|
if(lpTreeView->selectionModel()->selectedRows().count() == 1)
|
||||||
|
{
|
||||||
|
cSerie* lpSerie = m_lpSeriesListModel->itemFromIndex(lpTreeView->selectionModel()->selectedRows().at(0))->data(Qt::UserRole).value<cSerie*>();
|
||||||
|
if(lpSerie)
|
||||||
|
{
|
||||||
|
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
|
||||||
|
lpMenu->addAction("delete", this, SLOT(onActionDelete()));
|
||||||
|
lpMenu->addAction("edit", this, SLOT(onActionEdit()));
|
||||||
|
lpMenu->addSeparator();
|
||||||
|
|
||||||
|
if(!lpSerie->IMDBID().isEmpty())
|
||||||
|
lpMenu->addAction("open IMDB", this, SLOT(onActionGotoIMDB()));
|
||||||
|
|
||||||
|
if(!lpSerie->download().isEmpty())
|
||||||
|
{
|
||||||
|
lpMenu->addAction("open download link", this, SLOT(onActionGotoDownload()));
|
||||||
|
lpMenu->addAction("copy download link", this, SLOT(onActionCopyDownload()));
|
||||||
|
}
|
||||||
|
lpMenu->addAction("open all download links", this, SLOT(onActionGotoAllDownload()));
|
||||||
|
lpMenu->addAction("open all download links (open)", this, SLOT(onActionGotoAllDownloadOpen()));
|
||||||
|
lpMenu->addSeparator();
|
||||||
|
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(lpTreeView->selectionModel()->selectedRows().count())
|
||||||
|
{
|
||||||
|
lpMenu->addAction("update selected", this, SLOT(onActionUpdate()));
|
||||||
|
lpMenu->addAction("delete selected", this, SLOT(onActionDelete()));
|
||||||
|
lpMenu->addSeparator();
|
||||||
|
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
|
||||||
|
}
|
||||||
|
|
||||||
|
lpMenu->addSeparator();
|
||||||
|
lpMenu->addAction("export...", this, SLOT(onActionExport()));
|
||||||
|
|
||||||
|
lpMenu->popup(lpTreeView->viewport()->mapToGlobal(pos));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onDoubleClicked(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void cMainWindow::onPressed(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
switch(QGuiApplication::mouseButtons())
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
case Qt::MiddleButton:
|
||||||
|
if(ui->m_lpSeriesList1->selectionModel()->selectedRows().count() == 1)
|
||||||
|
{
|
||||||
|
cSerie* lpSerie = m_lpSeriesListModel->itemFromIndex(ui->m_lpSeriesList1->selectionModel()->selectedRows().at(0))->data(Qt::UserRole).value<cSerie*>();
|
||||||
|
if(lpSerie)
|
||||||
|
{
|
||||||
|
if(!lpSerie->download().isEmpty())
|
||||||
|
onActionGotoDownload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+37
-2
@@ -1,10 +1,18 @@
|
|||||||
#ifndef CMAINWINDOW_H
|
#ifndef CMAINWINDOW_H
|
||||||
#define CMAINWINDOW_H
|
#define CMAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
|
|
||||||
#include "cdatabase.h"
|
#include "cdatabase.h"
|
||||||
|
|
||||||
|
#include "calbum.h"
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QItemSelection>
|
||||||
|
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@@ -22,11 +30,38 @@ public:
|
|||||||
private:
|
private:
|
||||||
Ui::cMainWindow* ui;
|
Ui::cMainWindow* ui;
|
||||||
cDatabase* m_lpDB;
|
cDatabase* m_lpDB;
|
||||||
|
QStandardItemModel* m_lpMusicListModel;
|
||||||
|
bool m_bProcessing;
|
||||||
|
|
||||||
|
cAlbumList m_albumList;
|
||||||
|
|
||||||
void addFile(const QString& szFile);
|
void addFile(const QString& szFile);
|
||||||
void addPath(const QString& szPath);
|
void addPath(const QString& szPath);
|
||||||
|
|
||||||
|
void loadDB();
|
||||||
|
void displayDB();
|
||||||
|
|
||||||
|
void onCustomContextMenuRequested(const QTreeView *lpTreeView, const QPoint &pos);
|
||||||
|
void onDoubleClicked(const QModelIndex &index);
|
||||||
|
void onPressed(const QModelIndex &index);
|
||||||
protected:
|
protected:
|
||||||
void initSettings();
|
void initSettings();
|
||||||
|
private slots:
|
||||||
|
void onCustomContextMenuRequestedOriginal(const QPoint &pos);
|
||||||
|
void onDoubleClickedOriginal(const QModelIndex &index);
|
||||||
|
void onPressedOriginal(const QModelIndex &index);
|
||||||
|
void onExpandedOriginal(const QModelIndex &index);
|
||||||
|
void onCollapsedOriginal(const QModelIndex &index);
|
||||||
|
void onSelectionChangedOriginal(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
void onScrollbarValueChangedOriginal(int value);
|
||||||
|
|
||||||
|
void onCustomContextMenuRequestedNew(const QPoint &pos);
|
||||||
|
void onDoubleClickedNew(const QModelIndex &index);
|
||||||
|
void onPressedNew(const QModelIndex &index);
|
||||||
|
void onExpandedNew(const QModelIndex &index);
|
||||||
|
void onCollapsedNew(const QModelIndex &index);
|
||||||
|
void onSelectionChangedNew(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
void onScrollbarValueChangedNew(int value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CMAINWINDOW_H
|
#endif // CMAINWINDOW_H
|
||||||
|
|||||||
+39
-11
@@ -1,24 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>cMainWindow</class>
|
<class>cMainWindow</class>
|
||||||
<widget class="QMainWindow" name="cMainWindow" >
|
<widget class="QMainWindow" name="cMainWindow">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>1124</width>
|
||||||
<height>300</height>
|
<height>682</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>cMainWindow</string>
|
<string>cMainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenuBar" name="menuBar" />
|
<widget class="QWidget" name="centralWidget">
|
||||||
<widget class="QToolBar" name="mainToolBar" />
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<widget class="QWidget" name="centralWidget" />
|
<item row="0" column="0">
|
||||||
<widget class="QStatusBar" name="statusBar" />
|
<widget class="QSplitter" name="m_lpSplitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QTreeView" name="m_lpMusicListOriginal"/>
|
||||||
|
<widget class="QTreeView" name="m_lpMusicListNew"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menuBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1124</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutDefault spacing="6" margin="11" />
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#include "cmusicviewitemdelegate.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTextDocument>
|
||||||
|
#include <QAbstractTextDocumentLayout>
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
|
||||||
|
void cMusicViewItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QStyleOptionViewItem options = option;
|
||||||
|
initStyleOption(&options, index);
|
||||||
|
|
||||||
|
int iLevel = 0;
|
||||||
|
QModelIndex index1 = index;
|
||||||
|
|
||||||
|
while(index1.parent().isValid())
|
||||||
|
{
|
||||||
|
iLevel++;
|
||||||
|
index1 = index1.parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeView* lpTreeView = (QTreeView*)parent();
|
||||||
|
int indentation = 20;
|
||||||
|
if(lpTreeView)
|
||||||
|
indentation = lpTreeView->indentation();
|
||||||
|
|
||||||
|
indentation *= iLevel;
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
QTextDocument doc;
|
||||||
|
|
||||||
|
doc.setHtml(QString("%1").arg(options.text));
|
||||||
|
|
||||||
|
options.text = "";
|
||||||
|
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
|
||||||
|
|
||||||
|
QRect clip;
|
||||||
|
|
||||||
|
// shift text right to make icon visible
|
||||||
|
if(index.column() == 1)
|
||||||
|
{
|
||||||
|
painter->translate(options.rect.left()+indentation, options.rect.top());
|
||||||
|
clip = QRect(0, 0, options.rect.width()+indentation, options.rect.height());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter->translate(options.rect.left(), options.rect.top());
|
||||||
|
clip = QRect(0, 0, options.rect.width(), options.rect.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->setClipRect(clip);
|
||||||
|
|
||||||
|
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||||
|
|
||||||
|
ctx.clip = clip;
|
||||||
|
doc.documentLayout()->draw(painter, ctx);
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize cMusicViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
|
||||||
|
{
|
||||||
|
QStyleOptionViewItem options = option;
|
||||||
|
initStyleOption(&options, index);
|
||||||
|
|
||||||
|
QTextDocument doc;
|
||||||
|
doc.setHtml(options.text);
|
||||||
|
doc.setTextWidth(options.rect.width());
|
||||||
|
return QSize(doc.idealWidth(), doc.size().height());
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef CMUSICVIEWITEMDELEGATE_H
|
||||||
|
#define CMUSICVIEWITEMDELEGATE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
|
|
||||||
|
class cMusicViewItemDelegate : public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cMusicViewItemDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
|
||||||
|
protected:
|
||||||
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CMUSICVIEWITEMDELEGATE_H
|
||||||
@@ -2,6 +2,13 @@
|
|||||||
#define COMMON_H
|
#define COMMON_H
|
||||||
|
|
||||||
|
|
||||||
|
#define MUSICLIST_ORI_ALBUM 0
|
||||||
|
#define MUSICLIST_ORI_TRACK 1
|
||||||
|
|
||||||
|
#define MUSICLIST_NEW_ALBUM 2
|
||||||
|
#define MUSICLIST_NEW_TRACK 3
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -23,7 +23,9 @@ SOURCES += main.cpp\
|
|||||||
cdatabase.cpp \
|
cdatabase.cpp \
|
||||||
cstring.cpp \
|
cstring.cpp \
|
||||||
common.cpp \
|
common.cpp \
|
||||||
cpixmap.cpp
|
cpixmap.cpp \
|
||||||
|
cmusicviewitemdelegate.cpp \
|
||||||
|
calbum.cpp
|
||||||
|
|
||||||
HEADERS += cmainwindow.h \
|
HEADERS += cmainwindow.h \
|
||||||
cmediainfo.h \
|
cmediainfo.h \
|
||||||
@@ -31,7 +33,9 @@ HEADERS += cmainwindow.h \
|
|||||||
cdatabase.h \
|
cdatabase.h \
|
||||||
cstring.h \
|
cstring.h \
|
||||||
common.h \
|
common.h \
|
||||||
cpixmap.h
|
cpixmap.h \
|
||||||
|
cmusicviewitemdelegate.h \
|
||||||
|
calbum.h
|
||||||
|
|
||||||
FORMS += cmainwindow.ui
|
FORMS += cmainwindow.ui
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user