summaryrefslogtreecommitdiffstats
path: root/plugins/project
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:15:56 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:15:56 +0000
commit50b48aec6ddd451a6d1709c0942477b503457663 (patch)
treea9ece53ec06fd0a2819de7a2a6de997193566626 /plugins/project
downloadk3b-50b48aec6ddd451a6d1709c0942477b503457663.tar.gz
k3b-50b48aec6ddd451a6d1709c0942477b503457663.zip
Added abandoned KDE3 version of K3B
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k3b@1084400 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugins/project')
-rw-r--r--plugins/project/Makefile.am1
-rw-r--r--plugins/project/audiometainforenamer/Makefile.am19
-rw-r--r--plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.cpp392
-rw-r--r--plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.h76
-rw-r--r--plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.plugin9
-rw-r--r--plugins/project/audioprojectcddb/Makefile.am22
-rw-r--r--plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.cpp151
-rw-r--r--plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.h53
-rw-r--r--plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.plugin9
9 files changed, 732 insertions, 0 deletions
diff --git a/plugins/project/Makefile.am b/plugins/project/Makefile.am
new file mode 100644
index 0000000..d762841
--- /dev/null
+++ b/plugins/project/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = audioprojectcddb audiometainforenamer
diff --git a/plugins/project/audiometainforenamer/Makefile.am b/plugins/project/audiometainforenamer/Makefile.am
new file mode 100644
index 0000000..6199e50
--- /dev/null
+++ b/plugins/project/audiometainforenamer/Makefile.am
@@ -0,0 +1,19 @@
+AM_CPPFLAGS = -I$(srcdir)/../../../libk3b/core \
+ -I$(srcdir)/../../../libk3b/core \
+ -I$(srcdir)/../../../libk3b/plugin \
+ -I$(srcdir)/../../../libk3b/tools \
+ -I$(srcdir)/../../../libk3b/projects \
+ -I$(srcdir)/../../../libk3b/projects/datacd \
+ -I$(srcdir)/../../../libk3bdevice \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = libk3baudiometainforenamerplugin.la
+
+libk3baudiometainforenamerplugin_la_SOURCES = k3baudiometainforenamerplugin.cpp
+libk3baudiometainforenamerplugin_la_LIBADD = ../../../libk3b/libk3b.la
+libk3baudiometainforenamerplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+pluginsdir = $(kde_datadir)/k3b/plugins
+plugins_DATA = k3baudiometainforenamerplugin.plugin
+
+METASOURCES = AUTO
diff --git a/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.cpp b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.cpp
new file mode 100644
index 0000000..1fb39a6
--- /dev/null
+++ b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.cpp
@@ -0,0 +1,392 @@
+/*
+ *
+ * $Id$
+ * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * 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.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include <config.h>
+
+#include "k3baudiometainforenamerplugin.h"
+
+// the k3b stuff we need
+#include <k3bcore.h>
+#include <k3bdatadoc.h>
+#include <k3bdiritem.h>
+#include <k3bfileitem.h>
+#include <k3blistview.h>
+#include <k3bpluginfactory.h>
+
+#include <kdebug.h>
+#include <kinstance.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kfilemetainfo.h>
+#include <kcombobox.h>
+#include <kconfig.h>
+#include <kmimetype.h>
+#include <kdialog.h>
+
+#include <qstring.h>
+#include <qfile.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qpushbutton.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qpair.h>
+#include <qvaluelist.h>
+#include <qlayout.h>
+#include <qptrdict.h>
+
+
+
+K_EXPORT_COMPONENT_FACTORY( libk3baudiometainforenamerplugin, K3bPluginFactory<K3bAudioMetainfoRenamerPlugin>("libk3baudiometainforenamerplugin") )
+
+
+class K3bAudioMetainfoRenamerPluginWidget::Private
+{
+public:
+ K3bDataDoc* doc;
+ QString pattern;
+
+ KComboBox* comboPattern;
+ K3bListView* viewFiles;
+ // KProgressDialog* progressDialog;
+ QPushButton* scanButton;
+
+ QValueList< QPair<K3bFileItem*, QCheckListItem*> > renamableItems;
+ QPtrDict<QListViewItem> dirItemDict;
+
+// long long scannedSize;
+// int progressCounter;
+};
+
+
+K3bAudioMetainfoRenamerPluginWidget::K3bAudioMetainfoRenamerPluginWidget( K3bDoc* doc,
+ QWidget* parent,
+ const char* name )
+ : QWidget( parent, name )
+{
+ d = new Private();
+ d->doc = dynamic_cast<K3bDataDoc*>(doc);
+ // d->progressDialog = 0;
+
+ // pattern group
+ QGroupBox* patternGroup = new QGroupBox( 2, Qt::Horizontal,
+ i18n("Rename Pattern"), this );
+ patternGroup->setInsideMargin( KDialog::marginHint() );
+ patternGroup->setInsideSpacing( KDialog::spacingHint() );
+
+ d->comboPattern = new KComboBox( patternGroup );
+ d->comboPattern->setEditable( true );
+
+ d->scanButton = new QPushButton( i18n("Scan"), patternGroup );
+
+ // the files view
+ QGroupBox* filesGroup = new QGroupBox( 1, Qt::Horizontal,
+ i18n("Found Files"), this );
+ filesGroup->setInsideMargin( KDialog::marginHint() );
+ filesGroup->setInsideSpacing( KDialog::spacingHint() );
+
+ d->viewFiles = new K3bListView( filesGroup );
+ d->viewFiles->addColumn( i18n("New Name") );
+ d->viewFiles->addColumn( i18n("Old Name") );
+ d->viewFiles->setNoItemText( i18n("Please click the Scan button to search for renameable files.") );
+
+ // layout
+ QVBoxLayout* box = new QVBoxLayout( this );
+ box->setMargin( 0 );
+ box->setSpacing( KDialog::spacingHint() );
+
+ box->addWidget( patternGroup );
+ box->addWidget( filesGroup );
+
+ connect( d->scanButton, SIGNAL(clicked()), this, SLOT(slotScanClicked()) );
+
+ QToolTip::add( d->scanButton, i18n("Scan for renamable files") );
+ QWhatsThis::add( d->comboPattern, i18n("<qt>This specifies how the files should be renamed. "
+ "Currently only the special strings <em>%a</em> (Artist), "
+ "<em>%n</em> (Track number), and <em>%t</em> (Title) ,"
+ "are supported.") );
+}
+
+
+K3bAudioMetainfoRenamerPluginWidget::~K3bAudioMetainfoRenamerPluginWidget()
+{
+ delete d;
+}
+
+
+QString K3bAudioMetainfoRenamerPluginWidget::title() const
+{
+ return i18n("Rename Audio Files");
+}
+
+
+QString K3bAudioMetainfoRenamerPluginWidget::subTitle() const
+{
+ return i18n("Based on meta info");
+}
+
+
+void K3bAudioMetainfoRenamerPluginWidget::loadDefaults()
+{
+ d->comboPattern->setEditText( "%a - %t" );
+}
+
+
+void K3bAudioMetainfoRenamerPluginWidget::readSettings( KConfigBase* c )
+{
+ d->comboPattern->setEditText( c->readEntry( "rename pattern", "%a - %t" ) );
+}
+
+
+void K3bAudioMetainfoRenamerPluginWidget::saveSettings( KConfigBase* c )
+{
+ c->writeEntry( "rename pattern", d->comboPattern->currentText() );
+}
+
+
+void K3bAudioMetainfoRenamerPluginWidget::slotScanClicked()
+{
+ d->pattern = d->comboPattern->currentText();
+ if( d->pattern.isEmpty() ) {
+ KMessageBox::error( this, i18n("Please specify a valid pattern.") );
+ }
+ else {
+// if( d->progressDialog == 0 ) {
+// d->progressDialog = new KProgressDialog( this, "scanning_progress",
+// i18n("Scanning..."),
+// i18n("Scanning for renameable files."),
+// true );
+// d->progressDialog->setAllowCancel(false);
+// }
+
+ K3bDirItem* dir = d->doc->root();
+
+ // clear old searches
+ d->viewFiles->clear();
+ d->renamableItems.clear();
+ d->dirItemDict.clear();
+// d->scannedSize = 0;
+// d->progressCounter = 0;
+
+ // create root item
+ KListViewItem* rootItem = new KListViewItem( d->viewFiles, "/" );
+
+ // d->progressDialog->show();
+ scanDir( dir, rootItem );
+ // d->progressDialog->close();
+
+ rootItem->setOpen(true);
+
+ if( d->renamableItems.isEmpty() )
+ KMessageBox::sorry( this, i18n("No renameable files found.") );
+ }
+}
+
+
+void K3bAudioMetainfoRenamerPluginWidget::scanDir( K3bDirItem* dir, QListViewItem* viewRoot )
+{
+ kdDebug() << "(K3bAudioMetainfoRenamerPluginWidget) scanning dir " << dir->k3bName() << endl;
+
+ d->dirItemDict.insert( dir, viewRoot );
+
+ for( QPtrListIterator<K3bDataItem> it( dir->children() ); it.current(); ++it ) {
+ K3bDataItem* item = it.current();
+
+ if( item->isFile() ) {
+ if( item->isRenameable() ) {
+ QString newName = createNewName( (K3bFileItem*)item );
+ if( !newName.isEmpty() ) {
+ QCheckListItem* fileViewItem = new QCheckListItem( viewRoot,
+ newName,
+ QCheckListItem::CheckBox );
+ fileViewItem->setText(1, item->k3bName() );
+ fileViewItem->setOn(true);
+ d->renamableItems.append( qMakePair( (K3bFileItem*)item, fileViewItem ) );
+ }
+ }
+
+// d->scannedSize += item->k3bSize();
+// d->progressCounter++;
+// if( d->progressCounter > 50 ) {
+// d->progressCounter = 0;
+// d->progressDialog->progressBar()->setProgress( 100*d->scannedSize/d->doc->root()->k3bSize() );
+// qApp->processEvents();
+// }
+ }
+ else if( item->isDir() ) {
+ // create dir item
+ KListViewItem* dirViewItem = new KListViewItem( viewRoot, item->k3bName() );
+ scanDir( (K3bDirItem*)item, dirViewItem );
+ dirViewItem->setOpen(true);
+ }
+ }
+}
+
+
+void K3bAudioMetainfoRenamerPluginWidget::activate()
+{
+ if( d->renamableItems.isEmpty() ) {
+ KMessageBox::sorry( this, i18n("Please click the Scan button to search for renameable files.") );
+ }
+ else {
+ for( QValueList< QPair<K3bFileItem*, QCheckListItem*> >::iterator it = d->renamableItems.begin();
+ it != d->renamableItems.end(); ++it ) {
+ QPair<K3bFileItem*, QCheckListItem*>& item = *it;
+
+ if( item.second->isOn() )
+ item.first->setK3bName( item.second->text(0) );
+ }
+
+ d->viewFiles->clear();
+ d->renamableItems.clear();
+
+ KMessageBox::information( this, i18n("Done.") );
+ }
+}
+
+
+QString K3bAudioMetainfoRenamerPluginWidget::createNewName( K3bFileItem* item )
+{
+ KMimeType::Ptr mimetype = KMimeType::findByPath( item->localPath() );
+ // sometimes ogg-vorbis files go as "application/x-ogg"
+ if( mimetype != 0 &&
+ ( mimetype->name().contains( "audio" ) || mimetype->name().contains("ogg") ) ) {
+
+ QString artist, title, track;
+
+ KFileMetaInfo metaInfo( item->localPath() );
+ if( metaInfo.isValid() ) {
+
+ KFileMetaInfoItem artistItem = metaInfo.item( "Artist" );
+ KFileMetaInfoItem titleItem = metaInfo.item( "Title" );
+ KFileMetaInfoItem trackItem = metaInfo.item( "Tracknumber" );
+
+ if( artistItem.isValid() )
+ artist = artistItem.string().stripWhiteSpace();
+
+ if( titleItem.isValid() )
+ title = titleItem.string().stripWhiteSpace();
+
+ if( trackItem.isValid() )
+ track = track.sprintf("%02d",trackItem.string().toInt());
+ }
+
+ QString newName;
+ for( unsigned int i = 0; i < d->pattern.length(); ++i ) {
+
+ if( d->pattern[i] == '%' ) {
+ ++i;
+
+ if( i < d->pattern.length() ) {
+ if( d->pattern[i] == 'a' ) {
+ if( artist.isEmpty() )
+ return QString::null;
+ newName.append(artist);
+ }
+ else if( d->pattern[i] == 'n' ) {
+ if( title.isEmpty() )
+ return QString::null;
+ newName.append(track);
+ }
+ else if( d->pattern[i] == 't' ) {
+ if( title.isEmpty() )
+ return QString::null;
+ newName.append(title);
+ }
+ else {
+ newName.append( "%" );
+ newName.append( d->pattern[i] );
+ }
+ }
+ else { // end of pattern
+ newName.append( "%" );
+ }
+ }
+ else {
+ newName.append( d->pattern[i] );
+ }
+ }
+
+ // remove white spaces from end and beginning
+ newName = newName.stripWhiteSpace();
+
+ QString extension = item->k3bName().mid( item->k3bName().findRev(".") );
+
+ if( !newName.isEmpty() ) {
+ //
+ // Check if files with that name exists and if so append number
+ //
+ if( existsOtherItemWithSameName( item, newName + extension ) ) {
+ kdDebug() << "(K3bAudioMetainfoRenamerPluginWidget) file with name "
+ << newName << extension << " already exists" << endl;
+ int i = 1;
+ while( existsOtherItemWithSameName( item, newName + QString( " (%1)").arg(i) + extension ) )
+ i++;
+ newName.append( QString( " (%1)").arg(i) );
+ }
+
+ // append extension
+ newName.append( extension );
+ }
+
+ return newName;
+ }
+ else
+ return QString::null;
+}
+
+
+bool K3bAudioMetainfoRenamerPluginWidget::existsOtherItemWithSameName( K3bFileItem* item, const QString& name )
+{
+ K3bDirItem* dir = item->parent();
+ K3bDataItem* otherItem = dir->find( name );
+ if( otherItem && otherItem != item )
+ return true;
+
+ QListViewItem* dirViewItem = d->dirItemDict[dir];
+ QListViewItem* current = dirViewItem->firstChild();
+ while( current && current->parent() == dirViewItem ) {
+ if( current->text(0) == name )
+ return true;
+ current = current->nextSibling();
+ }
+
+ return false;
+}
+
+
+
+K3bAudioMetainfoRenamerPlugin::K3bAudioMetainfoRenamerPlugin( QObject* parent,
+ const char* name )
+ : K3bProjectPlugin( DATA_PROJECTS, true, parent, name )
+{
+ setText( i18n("Rename Audio Files") );
+ setToolTip( i18n("Rename audio files based on their meta info.") );
+}
+
+
+K3bAudioMetainfoRenamerPlugin::~K3bAudioMetainfoRenamerPlugin()
+{
+}
+
+
+K3bProjectPluginGUIBase* K3bAudioMetainfoRenamerPlugin::createGUI( K3bDoc* doc, QWidget* parent, const char* name )
+{
+ return new K3bAudioMetainfoRenamerPluginWidget( doc, parent, name );
+}
+
+#include "k3baudiometainforenamerplugin.moc"
diff --git a/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.h b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.h
new file mode 100644
index 0000000..b387aa5
--- /dev/null
+++ b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.h
@@ -0,0 +1,76 @@
+/*
+ *
+ * $Id$
+ * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * 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.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_AUDIO_METAINFO_RENAMER_PLUGIN_H_
+#define _K3B_AUDIO_METAINFO_RENAMER_PLUGIN_H_
+
+
+#include <k3bprojectplugin.h>
+#include <qwidget.h>
+
+
+class K3bDataDoc;
+class K3bDirItem;
+class K3bFileItem;
+class QListViewItem;
+
+
+class K3bAudioMetainfoRenamerPluginWidget : public QWidget, public K3bProjectPluginGUIBase
+{
+ Q_OBJECT
+
+ public:
+ K3bAudioMetainfoRenamerPluginWidget( K3bDoc* doc, QWidget* parent = 0, const char* name = 0 );
+ ~K3bAudioMetainfoRenamerPluginWidget();
+
+ QWidget* qWidget() { return this; }
+
+ QString title() const;
+ QString subTitle() const;
+
+ void loadDefaults();
+ void readSettings( KConfigBase* );
+ void saveSettings( KConfigBase* );
+
+ void activate();
+
+ private slots:
+ void slotScanClicked();
+
+ private:
+ void scanDir( K3bDirItem*, QListViewItem* parent );
+ QString createNewName( K3bFileItem* );
+ bool existsOtherItemWithSameName( K3bFileItem*, const QString& );
+
+ class Private;
+ Private* d;
+};
+
+
+class K3bAudioMetainfoRenamerPlugin : public K3bProjectPlugin
+{
+ Q_OBJECT
+
+ public:
+ K3bAudioMetainfoRenamerPlugin( QObject* parent, const char* name );
+ ~K3bAudioMetainfoRenamerPlugin();
+
+ int pluginSystemVersion() const { return 3; }
+
+ K3bProjectPluginGUIBase* createGUI( K3bDoc*, QWidget* = 0, const char* = 0 );
+};
+
+
+#endif
diff --git a/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.plugin b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.plugin
new file mode 100644
index 0000000..42c24d8
--- /dev/null
+++ b/plugins/project/audiometainforenamer/k3baudiometainforenamerplugin.plugin
@@ -0,0 +1,9 @@
+[K3b Plugin]
+Lib=libk3baudiometainforenamerplugin
+Group=ProjectPlugin
+Name=K3b Audio Metainfo Renamer
+Author=Sebastian Trueg
+Email=trueg@k3b.org
+Version=1.0
+Comment=Plugin to rename audio files in a data project based on the meta info.
+License=GPL
diff --git a/plugins/project/audioprojectcddb/Makefile.am b/plugins/project/audioprojectcddb/Makefile.am
new file mode 100644
index 0000000..8af3e67
--- /dev/null
+++ b/plugins/project/audioprojectcddb/Makefile.am
@@ -0,0 +1,22 @@
+AM_CPPFLAGS = -I$(srcdir)/../../../libk3b/core \
+ -I$(srcdir)/../../../libk3b/tools \
+ -I$(srcdir)/../../../libk3b/core \
+ -I$(srcdir)/../../../libk3b/projects/audiocd \
+ -I$(srcdir)/../../../libk3b/projects \
+ -I$(srcdir)/../../../libk3bdevice \
+ -I$(srcdir)/../../../libk3b/cddb \
+ -I$(srcdir)/../../../libk3b/plugin \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = libk3baudioprojectcddbplugin.la
+
+libk3baudioprojectcddbplugin_la_SOURCES = k3baudioprojectcddbplugin.cpp
+
+libk3baudioprojectcddbplugin_la_LIBADD = ../../../libk3b/libk3b.la
+
+libk3baudioprojectcddbplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+pluginsdir = $(kde_datadir)/k3b/plugins
+plugins_DATA = k3baudioprojectcddbplugin.plugin
+
+METASOURCES = AUTO
diff --git a/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.cpp b/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.cpp
new file mode 100644
index 0000000..e523eb3
--- /dev/null
+++ b/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.cpp
@@ -0,0 +1,151 @@
+/*
+ *
+ * $Id$
+ * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * 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.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include <config.h>
+
+#include "k3baudioprojectcddbplugin.h"
+
+// the k3b stuff we need
+#include <k3bcore.h>
+#include <k3bglobals.h>
+#include <k3baudiodoc.h>
+#include <k3baudiotrack.h>
+#include <k3btoc.h>
+#include <k3btrack.h>
+#include <k3bmsf.h>
+#include <k3bcddb.h>
+#include <k3bcddbresult.h>
+#include <k3bcddbquery.h>
+#include <k3bprogressdialog.h>
+#include <k3bpluginfactory.h>
+
+#include <kdebug.h>
+#include <kaction.h>
+#include <kinstance.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kconfig.h>
+
+#include <qstring.h>
+
+
+K_EXPORT_COMPONENT_FACTORY( libk3baudioprojectcddbplugin, K3bPluginFactory<K3bAudioProjectCddbPlugin>( "libk3baudioprojectcddbplugin" ) )
+
+
+K3bAudioProjectCddbPlugin::K3bAudioProjectCddbPlugin( QObject* parent,
+ const char* name )
+ : K3bProjectPlugin( AUDIO_CD, false, parent, name ),
+ m_cddb(0),
+ m_progress(0)
+{
+ setText( i18n("Query Cddb") );
+ setToolTip( i18n("Query a cddb entry for the current audio project.") );
+}
+
+
+K3bAudioProjectCddbPlugin::~K3bAudioProjectCddbPlugin()
+{
+ delete m_progress;
+}
+
+
+void K3bAudioProjectCddbPlugin::activate( K3bDoc* doc, QWidget* parent )
+{
+ m_doc = dynamic_cast<K3bAudioDoc*>( doc );
+ m_parentWidget = parent;
+ m_canceled = false;
+
+ if( !m_doc || m_doc->numOfTracks() == 0 ) {
+ KMessageBox::sorry( parent, i18n("Please select a non-empty audio project for a cddb query.") );
+ }
+ else {
+ if( !m_cddb ) {
+ m_cddb = new K3bCddb( this );
+ connect( m_cddb, SIGNAL(queryFinished(int)),
+ this, SLOT(slotCddbQueryFinished(int)) );
+ }
+ if( !m_progress ) {
+ m_progress = new K3bProgressDialog( i18n("Query Cddb"), parent, i18n("Audio Project") );
+ connect( m_progress, SIGNAL(cancelClicked()),
+ this, SLOT(slotCancelClicked()) );
+ }
+
+ // read the k3b config :)
+ KConfig* c = k3bcore->config();
+ c->setGroup("Cddb");
+ m_cddb->readConfig( c );
+
+ // start the query
+ m_cddb->query( m_doc->toToc() );
+
+ m_progress->exec(false);
+ }
+}
+
+
+void K3bAudioProjectCddbPlugin::slotCancelClicked()
+{
+ m_canceled = true;
+ m_progress->close();
+}
+
+
+void K3bAudioProjectCddbPlugin::slotCddbQueryFinished( int error )
+{
+ if( !m_canceled ) {
+ m_progress->hide();
+
+ if( error == K3bCddbQuery::SUCCESS ) {
+ K3bCddbResultEntry cddbInfo = m_cddb->result();
+
+ // save the entry locally
+ KConfig* c = k3bcore->config();
+ c->setGroup( "Cddb" );
+ if( c->readBoolEntry( "save cddb entries locally", true ) )
+ m_cddb->saveEntry( cddbInfo );
+
+ // save the entry to the doc
+ m_doc->setTitle( cddbInfo.cdTitle );
+ m_doc->setPerformer( cddbInfo.cdArtist );
+ m_doc->setCdTextMessage( cddbInfo.cdExtInfo );
+
+ int i = 0;
+ for( K3bAudioTrack* track = m_doc->firstTrack(); track; track = track->next() ) {
+ track->setTitle( cddbInfo.titles[i] );
+ track->setPerformer( cddbInfo.artists[i] );
+ track->setCdTextMessage( cddbInfo.extInfos[i] );
+
+ ++i;
+ }
+
+ // and enable cd-text
+ m_doc->writeCdText( true );
+ }
+ else if( error == K3bCddbQuery::NO_ENTRY_FOUND ) {
+ KMessageBox::information( m_parentWidget, i18n("No CDDB entry found."), i18n("CDDB") );
+ }
+ else if( error != K3bCddbQuery::CANCELED ) {
+ KMessageBox::information( m_parentWidget, m_cddb->errorString(), i18n("Cddb error") );
+ }
+ }
+
+ // make sure the progress dialog does not get deleted by it's parent
+ delete m_progress;
+ m_doc = 0;
+ m_parentWidget = 0;
+ m_progress = 0;
+}
+
+#include "k3baudioprojectcddbplugin.moc"
diff --git a/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.h b/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.h
new file mode 100644
index 0000000..a0e7880
--- /dev/null
+++ b/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.h
@@ -0,0 +1,53 @@
+/*
+ *
+ * $Id$
+ * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * 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.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_AUDIO_PROJECT_CDDB_PLUGIN_H_
+#define _K3B_AUDIO_PROJECT_CDDB_PLUGIN_H_
+
+
+#include <k3bprojectplugin.h>
+
+class K3bCddb;
+class K3bAudioDoc;
+class K3bProgressDialog;
+class QWidget;
+
+class K3bAudioProjectCddbPlugin : public K3bProjectPlugin
+{
+ Q_OBJECT
+
+ public:
+ K3bAudioProjectCddbPlugin( QObject* parent, const char* name );
+ ~K3bAudioProjectCddbPlugin();
+
+ int pluginSystemVersion() const { return 3; }
+
+ void activate( K3bDoc* doc, QWidget* parent );
+
+ private slots:
+ void slotCddbQueryFinished( int result );
+ void slotCancelClicked();
+
+ private:
+ K3bCddb* m_cddb;
+ K3bAudioDoc* m_doc;
+ K3bProgressDialog* m_progress;
+ QWidget* m_parentWidget;
+
+ bool m_canceled;
+};
+
+
+#endif
diff --git a/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.plugin b/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.plugin
new file mode 100644
index 0000000..8fbea0f
--- /dev/null
+++ b/plugins/project/audioprojectcddb/k3baudioprojectcddbplugin.plugin
@@ -0,0 +1,9 @@
+[K3b Plugin]
+Lib=libk3baudioprojectcddbplugin
+Group=ProjectPlugin
+Name=K3b Cddb Audio Plugin
+Author=Sebastian Trueg
+Email=trueg@k3b.org
+Version=0.1
+Comment=Plugin to query a cddb server for information about an audio project.
+License=GPL