File indexing completed on 2024-05-05 04:48:22

0001 /****************************************************************************************
0002  * Copyright (c) 2010 Ralf Engels <ralf-engels@gmx.de>                                  *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "SqlBatchImporterConfig.h"
0018 
0019 #include "core/support/Amarok.h"
0020 
0021 #include <KLocalizedString>
0022 
0023 #include <QComboBox>
0024 #include <QCompleter>
0025 #include <QDirModel>
0026 #include <QGridLayout>
0027 #include <QLabel>
0028 #include <QLineEdit>
0029 #include <QVBoxLayout>
0030 #include <QFileSystemModel>
0031 
0032 SqlBatchImporterConfig::SqlBatchImporterConfig( QWidget *parent )
0033     : BoxWidget( true, parent )
0034 {
0035     QWidget *gridHolder = new QWidget( this );
0036 
0037     QGridLayout *databaseLayout = new QGridLayout( gridHolder );
0038 
0039     QLabel *explanationLabel = new QLabel( i18n( "Input file produced by amarokcollectionscanner.<br>"
0040                                                  "See <a href=\"http://community.kde.org/Amarok/Development/BatchMode\">Batch Mode</a>." ), gridHolder );
0041     explanationLabel->setTextFormat( Qt::RichText );
0042     explanationLabel->setAlignment( Qt::AlignHCenter );
0043     explanationLabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); // Don't stretch vertically
0044     explanationLabel->setMargin( 10 );
0045 
0046     QLabel *label = new QLabel( i18n( "Input file" ), gridHolder );
0047     m_inputFilePathInput = new QLineEdit( gridHolder );
0048     QCompleter *completer = new QCompleter( this );
0049     completer->setModel( new QFileSystemModel( completer ) );
0050     m_inputFilePathInput->setCompleter( completer );
0051     m_inputFilePathInput->setText( QDir::homePath() + "/result.xml" );
0052     label->setBuddy( m_inputFilePathInput );
0053 
0054     databaseLayout->addWidget( explanationLabel, 0, 0, 1, 2 );
0055     databaseLayout->addWidget( label, 1, 0 );
0056     databaseLayout->addWidget( m_inputFilePathInput, 1, 1 );
0057 
0058     gridHolder->setLayout( databaseLayout );
0059 
0060     QWidget *spacer = new QWidget( this );
0061     spacer->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
0062 }
0063 
0064 QString
0065 SqlBatchImporterConfig::inputFilePath() const
0066 {
0067     return m_inputFilePathInput->text();
0068 }