- Place CdAlbum within its own header

- Rename cddb.h/cpp to cddbinterface.h/cpp to avoid conflicts with installed cddb/cddb.h
BUG:254
This commit is contained in:
craig.p.drummond@gmail.com
2013-07-16 11:09:43 +00:00
committed by craig.p.drummond@gmail.com
parent 2266c959a0
commit 53a4d299ac
11 changed files with 71 additions and 38 deletions

View File

@@ -341,8 +341,8 @@ if (TAGLIB_FOUND)
endif (MTP_FOUND)
if (CDDB_FOUND OR MUSICBRAINZ5_FOUND)
if (CDDB_FOUND)
set(CANTATA_SRCS ${CANTATA_SRCS} devices/cddb.cpp)
set(CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/cddb.h)
set(CANTATA_SRCS ${CANTATA_SRCS} devices/cddbinterface.cpp)
set(CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/cddbinterface.h)
endif (CDDB_FOUND)
if (MUSICBRAINZ5_FOUND)
set(CANTATA_SRCS ${CANTATA_SRCS} devices/musicbrainz.cpp)

View File

@@ -29,7 +29,7 @@
#include "messagebox.h"
#include "inputdialog.h"
#include "devicesmodel.h"
#include "cddb.h"
#include "cdalbum.h"
#include "icons.h"
#include "coverdialog.h"
#include <QMenu>

View File

@@ -22,7 +22,9 @@
*/
#include "audiocddevice.h"
#include "cddb.h"
#ifdef CDDB_FOUND
#include "cddbinterface.h"
#endif
#ifdef MUSICBRAINZ5_FOUND
#include "musicbrainz.h"
#endif
@@ -171,7 +173,7 @@ void AudioCdDevice::connectService(bool useCddb)
&& useCddb
#endif
) {
cddb=new Cddb(block->device());
cddb=new CddbInterface(block->device());
connect(cddb, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
connect(cddb, SIGNAL(initialDetails(CdAlbum)), this, SLOT(setDetails(CdAlbum)));
connect(cddb, SIGNAL(matches(const QList<CdAlbum> &)), SLOT(cdMatches(const QList<CdAlbum> &)));

View File

@@ -35,7 +35,7 @@
#endif
#include <QImage>
class Cddb;
class CddbInterface;
class MusicBrainz;
struct CdAlbum;
@@ -109,7 +109,7 @@ private:
Solid::OpticalDrive *drive;
Solid::Block *block;
#ifdef CDDB_FOUND
Cddb *cddb;
CddbInterface *cddb;
#endif
#ifdef MUSICBRAINZ5_FOUND
MusicBrainz *mb;

43
devices/cdalbum.h Normal file
View File

@@ -0,0 +1,43 @@
/*
* Cantata
*
* Copyright (c) 2011-2013 Craig Drummond <craig.p.drummond@gmail.com>
*
* ----
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CDALBUM_H
#define CDALBUM_H
#include <QString>
#include <QList>
#include "song.h"
struct CdAlbum {
CdAlbum() : isDefault(false), year(0), disc(0) { }
bool isNull() const { return 0==year && 0==disc && tracks.isEmpty() && name.isEmpty() && artist.isEmpty() && genre.isEmpty(); }
bool isDefault;
QString name;
QString artist;
QString genre;
int year;
int disc;
QList<Song> tracks;
};
#endif

View File

@@ -21,7 +21,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "cddb.h"
#include "cddbinterface.h"
#include "settings.h"
#ifdef ENABLE_KDE_SUPPORT
#include <KDE/KProtocolManager>
@@ -43,17 +43,17 @@
#include <linux/cdrom.h>
#endif
static struct CddbCleanup
static struct CddbInterfaceCleanup
{
~CddbCleanup() { libcddb_shutdown(); }
~CddbInterfaceCleanup() { libcddb_shutdown(); }
} cleanup;
QString Cddb::dataTrack()
QString CddbInterface::dataTrack()
{
return i18n("Data Track");
}
Cddb::Cddb(const QString &device)
CddbInterface::CddbInterface(const QString &device)
: dev(device)
, disc(0)
{
@@ -62,7 +62,7 @@ Cddb::Cddb(const QString &device)
thread->start();
}
Cddb::~Cddb()
CddbInterface::~CddbInterface()
{
thread->stop();
if (disc) {
@@ -97,7 +97,7 @@ static CdAlbum toAlbum(cddb_disc_t *disc, const CdAlbum &initial=CdAlbum())
if (initial.isNull()) {
track.time=cddb_track_get_length(trk);
if (Cddb::dataTrack()==track.title) {
if (CddbInterface::dataTrack()==track.title) {
// Adjust last track length...
if (album.tracks.count()) {
Song last=album.tracks.takeLast();
@@ -126,7 +126,7 @@ static CdAlbum toAlbum(cddb_disc_t *disc, const CdAlbum &initial=CdAlbum())
}
// Copied from asunder v2.2 - GPL v2
void Cddb::readDisc()
void CddbInterface::readDisc()
{
if (disc) {
return;
@@ -269,7 +269,7 @@ private:
cddb_disc_t *disc;
};
void Cddb::lookup(bool full)
void CddbInterface::lookup(bool full)
{
bool isInitial=!disc;
if (!disc) {

View File

@@ -26,34 +26,21 @@
#include <QObject>
#include <QString>
#include "song.h"
#include "config.h"
#include "cdalbum.h"
struct CdAlbum {
CdAlbum() : isDefault(false), year(0), disc(0) { }
bool isNull() const { return 0==year && 0==disc && tracks.isEmpty() && name.isEmpty() && artist.isEmpty() && genre.isEmpty(); }
bool isDefault;
QString name;
QString artist;
QString genre;
int year;
int disc;
QList<Song> tracks;
};
#ifdef CDDB_FOUND
class Thread;
typedef struct cddb_disc_s cddb_disc_t;
class Cddb : public QObject
class CddbInterface : public QObject
{
Q_OBJECT
public:
static QString dataTrack();
Cddb(const QString &device);
~Cddb();
CddbInterface(const QString &device);
~CddbInterface();
public Q_SLOTS:
void lookup(bool full);
@@ -72,7 +59,6 @@ private:
cddb_disc_t *disc;
CdAlbum initial;
};
#endif
#endif

View File

@@ -25,7 +25,7 @@
#define CDDBSELECTIONDIALOG_H
#include "dialog.h"
#include "cddb.h"
#include "cdalbum.h"
#include <QList>
class QComboBox;

View File

@@ -30,7 +30,7 @@
#ifdef ENABLE_REMOTE_DEVICES
#include "remotefsdevice.h"
#endif
#include "cddb.h"
#include "cdalbum.h"
#include "musiclibraryproxymodel.h"
class Action;

View File

@@ -26,8 +26,9 @@
#ifndef MUSICBRAINZ_H
#define MUSICBRAINZ_H
#include "cddb.h"
#include "cdalbum.h"
#include <QString>
#include <QObject>
class Thread;
@@ -55,4 +56,5 @@ private:
QString discId;
CdAlbum initial;
};
#endif // MUSICBRAINZ_H

View File

@@ -28,7 +28,7 @@
#include "config.h"
#include "remotefsdevice.h"
#include "actionmodel.h"
#include "cddb.h"
#include "cdalbum.h"
#include "musiclibraryproxymodel.h"
class QMimeData;