From 50b48aec6ddd451a6d1709c0942477b503457663 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 3 Feb 2010 02:15:56 +0000 Subject: 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 --- src/rip/k3bcddbpatternwidget.cpp | 175 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 src/rip/k3bcddbpatternwidget.cpp (limited to 'src/rip/k3bcddbpatternwidget.cpp') diff --git a/src/rip/k3bcddbpatternwidget.cpp b/src/rip/k3bcddbpatternwidget.cpp new file mode 100644 index 0000000..9cea4d5 --- /dev/null +++ b/src/rip/k3bcddbpatternwidget.cpp @@ -0,0 +1,175 @@ +/* + * + * $Id: k3bcddbpatternwidget.cpp 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003-2007 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * 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 "k3bcddbpatternwidget.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +K3bCddbPatternWidget::K3bCddbPatternWidget( QWidget* parent, const char* name ) + : base_K3bCddbPatternWidget( parent, name ) +{ + // fix the layout + ((QGridLayout*)layout())->setRowStretch( 4, 1 ); + + // setup validators + // there can never be one of the following characters in both dir and filename: + // * ? " + // additional the filename can never contain a slash / + // and the dir should never start with a slash since it should always be a relative path + + QRegExpValidator* dirValidator = new QRegExpValidator( QRegExp( "[^/][^?\\*\\\"]*" ), this ); + m_comboFilenamePattern->setValidator( dirValidator ); + m_comboPlaylistPattern->setValidator( dirValidator ); + m_editBlankReplace->setValidator( dirValidator ); + + // default pattern + m_comboFilenamePattern->insertItem( i18n("%A - %T/%n - !a='%A'{%a - }%t") ); + m_comboFilenamePattern->insertItem( i18n( "%{albumartist} - %{albumtitle}/%{number} - %{artist} - %{title}" ) ); + m_comboFilenamePattern->insertItem( i18n( "%{genre}/%{albumartist} - %{albumtitle}/Track%{number}" ) ); + m_comboFilenamePattern->insertItem( i18n( "music/ripped-tracks/%a - %t" ) ); + + m_comboPlaylistPattern->insertItem( i18n( "%{albumartist} - %{albumtitle}" ) ); + m_comboPlaylistPattern->insertItem( i18n( "Playlist" ) ); + m_comboPlaylistPattern->insertItem( i18n( "playlists/%{albumartist}/%{albumtitle }" ) ); + + connect( m_comboFilenamePattern, SIGNAL(textChanged(const QString&)), + this, SIGNAL(changed()) ); + connect( m_comboPlaylistPattern, SIGNAL(textChanged(const QString&)), + this, SIGNAL(changed()) ); + connect( m_editBlankReplace, SIGNAL(textChanged(const QString&)), + this, SIGNAL(changed()) ); + connect( m_checkBlankReplace, SIGNAL(toggled(bool)), + this, SIGNAL(changed()) ); + connect( m_specialStringsLabel, SIGNAL(leftClickedURL()), + this, SLOT(slotSeeSpecialStrings()) ); + connect( m_conditionalInclusionLabel, SIGNAL(leftClickedURL()), + this, SLOT(slotSeeConditionalInclusion()) ); +} + + +K3bCddbPatternWidget::~K3bCddbPatternWidget() +{ +} + + +QString K3bCddbPatternWidget::filenamePattern() const +{ + return m_comboFilenamePattern->currentText(); +} + + +QString K3bCddbPatternWidget::playlistPattern() const +{ + return m_comboPlaylistPattern->currentText(); +} + + +QString K3bCddbPatternWidget::blankReplaceString() const +{ + return m_editBlankReplace->text(); +} + + +bool K3bCddbPatternWidget::replaceBlanks() const +{ + return m_checkBlankReplace->isChecked(); +} + + +void K3bCddbPatternWidget::loadConfig( KConfigBase* c ) +{ + m_comboPlaylistPattern->setEditText( c->readEntry( "playlist pattern", m_comboPlaylistPattern->text(0) ) ); + m_comboFilenamePattern->setEditText( c->readEntry( "filename pattern", m_comboFilenamePattern->text(0) ) ); + m_checkBlankReplace->setChecked( c->readBoolEntry( "replace blanks", false ) ); + m_editBlankReplace->setText( c->readEntry( "blank replace string", "_" ) ); +} + + +void K3bCddbPatternWidget::saveConfig( KConfigBase* c ) +{ + c->writeEntry( "playlist pattern", m_comboPlaylistPattern->currentText() ); + c->writeEntry( "filename pattern", m_comboFilenamePattern->currentText() ); + c->writeEntry( "replace blanks", m_checkBlankReplace->isChecked() ); + c->writeEntry( "blank replace string", m_editBlankReplace->text() ); +} + + +void K3bCddbPatternWidget::loadDefaults() +{ + m_comboPlaylistPattern->setEditText( m_comboPlaylistPattern->text(0) ); + m_comboFilenamePattern->setEditText( m_comboFilenamePattern->text(0) ); + m_checkBlankReplace->setChecked( false ); + m_editBlankReplace->setText( "_" ); +} + + +void K3bCddbPatternWidget::slotSeeSpecialStrings() +{ + QWhatsThis::display( i18n( "

Pattern special strings:" + "

The following strings will be replaced with their respective meaning in every " + "track name.
" + "Hint: %A differs from %a only on soundtracks or compilations." + "

" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
MeaningAlternatives
%aartist of the track%{a} or %{artist}
%ttitle of the track%{t} or %{title}
%ntrack number%{n} or %{number}
%yyear of the CD%{y} or %{year}
%cextended track information%{c} or %{comment}
%ggenre of the CD%{g} or %{genre}
%Aalbum artist%{A} or %{albumartist}
%Talbum title%{T} or %{albumtitle}
%Cextended CD information%{C} or %{albumcomment}
%dcurrent date%{d} or %{date}
") ); +} + +void K3bCddbPatternWidget::slotSeeConditionalInclusion() +{ + QWhatsThis::display( i18n( "

Conditional inclusion:" + "

These patterns make it possible to selectively include texts, " + "depending on the value of CDDB entries. You can choose only to " + "include or exclude texts if one of the entries is empty, " + "or if it has a specific value. Examples:" + "

    " + "
  • @T{TEXT} includes TEXT if the album title is specified" + "
  • !T{TEXT} includes TEXT if the album title is not specified" + "
  • @C=\'Soundtrack\'{TEXT} includes TEXT if the CD's extended " + "information is named Soundtrack" + "
  • !C=\'Soundtrack\'{TEXT} includes TEXT if the CD's extended " + "information is anything else but Soundtrack" + "
  • It is also possible to include special strings in texts and conditions, " + "e.g. !a='%A'{%a} only includes the title's artist information " + "if it does not differ from the album artist." + "
" + "

Conditional includes make use of the same characters as the special " + "strings, which means that the X in @X{...} can be one character out of " + "[atnycgATCd]." ) ); +} + +#include "k3bcddbpatternwidget.moc" + -- cgit v1.2.3