EBN warnings-- QClass -> KClass fixes
[amarok.git] / src / servicebrowser / magnatunestore / magnatunepurchasedialog.cpp
blob4c8f7a461b75a7f99b788e992ee558aac8710758
1 /***************************************************************************
2 * Copyright (c) 2006, 2007 *
3 * Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "magnatunepurchasedialog.h"
23 #include "debug.h"
24 #include "magnatunedatabasehandler.h"
26 #include <KMessageBox>
28 #include <QComboBox>
29 #include <QLabel>
30 #include <QLineEdit>
31 #include <QPixmap>
32 #include <QPushButton>
33 #include <QRegExp>
36 MagnatunePurchaseDialog::MagnatunePurchaseDialog( QWidget* parent, const char* name, bool modal, Qt::WFlags fl )
37 : magnatunePurchaseDialogBase( parent, name, modal, fl )
40 MagnatunePurchaseDialog::~MagnatunePurchaseDialog()
44 void MagnatunePurchaseDialog::setAlbum( MagnatuneAlbum * album )
46 //albumEdit->setText("Hello!");
47 albumEdit->setText( album->name() );
49 artistEdit->setText( album->albumArtist()->name() );
50 //genresEdit->setText( album.getMp3Genre() ); FIXME: Broken because there can be more than one genre per album
51 launchDateEdit->setText( QString::number( album->launchYear() ) );
53 m_albumCode = album->albumCode();
55 album->subscribe( this );
57 coverPixmapLabel->setPixmap( album->image( 200, false ) );
61 void MagnatunePurchaseDialog::purchase( )
64 if ( verifyEntries( ) )
67 setEnabled( false ); //to prevent accidental double purchases
68 emit( makePurchase( ccEdit->text(), expYearEdit->text(), expMonthEdit->text(), nameEdit->text(), emailEdit->text(), m_albumCode, amountComboBox->currentText().toInt() ) );
73 void MagnatunePurchaseDialog::reject( )
75 cancel();
79 void MagnatunePurchaseDialog::cancel( )
81 hide();
82 emit ( cancelled() );
86 bool MagnatunePurchaseDialog::verifyEntries( )
89 // check all the entries for validity
91 //cc number:
92 QString ccString = ccEdit->text();
93 ccString.trimmed ();
94 QRegExp ccExp( "^[\\d]{10,20}$" );
96 if ( !ccExp.exactMatch( ccString ) )
98 KMessageBox::information( this, "Invalid credit card number",
99 "The credit card number entered does not appear to be valid\n" );
100 return false;
103 //email
104 QString emailString = emailEdit->text();
105 emailString.trimmed ();
106 QRegExp emailExp( "^\\S+@\\S+\\.\\S+$" );
108 if ( !emailExp.exactMatch( emailString ) )
110 KMessageBox::information( this, "Invalid email",
111 "The email address entered does not appear to be valid\n" );
112 return false;
115 //month
116 QString monthString = expMonthEdit->text();
117 monthString.trimmed ();
118 QRegExp monthExp( "^\\d{2}$" );
120 if ( !monthExp.exactMatch( monthString ) )
122 KMessageBox::information( this, "Invalid expiration month",
123 "The credit card expitation month does not appear to be valid\n" );
124 return false;
127 //month
128 QString yearString = expYearEdit->text();
129 yearString.trimmed ();
130 QRegExp yearExp( "^\\d{2}$" );
132 if ( !yearExp.exactMatch( yearString ) )
134 KMessageBox::information( this, "Invalid expiration month",
135 "The credit card expitation year does not appear to be valid\n" );
136 return false;
142 return true;
147 /*void MagnatunePurchaseDialog::setCover( const QString &coverFile )
149 coverPixmapLabel->setPixmap( QPixmap( coverFile ) );
153 void MagnatunePurchaseDialog::metadataChanged(Album * album)
155 coverPixmapLabel->setPixmap( album->image( 200, false ) );
159 /*$SPECIALIZATION$*/
164 #include "magnatunepurchasedialog.moc"