File indexing completed on 2024-05-05 04:41:01

0001 /*
0002     SPDX-FileCopyrightText: 2007 Dukju Ahn <dukjuahn@gmail.com>
0003     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "svnimportmetadatawidget.h"
0009 #include "ui_importmetadatawidget.h"
0010 #include <vcs/vcslocation.h>
0011 
0012 SvnImportMetadataWidget::SvnImportMetadataWidget( QWidget *parent )
0013     : VcsImportMetadataWidget( parent ), m_ui(new Ui::SvnImportMetadataWidget)
0014     , useSourceDirForDestination( false )
0015 {
0016     m_ui->setupUi( this );
0017     m_ui->srcEdit->setUrl( QUrl() );
0018     connect( m_ui->srcEdit, &KUrlRequester::textChanged, this, &KDevelop::VcsImportMetadataWidget::changed );
0019     connect( m_ui->srcEdit, &KUrlRequester::urlSelected, this, &KDevelop::VcsImportMetadataWidget::changed );
0020     connect( m_ui->dest, &QLineEdit::textChanged, this, &KDevelop::VcsImportMetadataWidget::changed );
0021     connect( m_ui->message, &QTextEdit::textChanged, this, &KDevelop::VcsImportMetadataWidget::changed );
0022 }
0023 
0024 SvnImportMetadataWidget::~SvnImportMetadataWidget()
0025 {
0026     delete m_ui;
0027 }
0028 
0029 void SvnImportMetadataWidget::setSourceLocation( const KDevelop::VcsLocation& importdir )
0030 {
0031     m_ui->srcEdit->setUrl( importdir.localUrl() );
0032 }
0033 
0034 QUrl SvnImportMetadataWidget::source() const
0035 {
0036     return m_ui->srcEdit->url();
0037 }
0038 
0039 KDevelop::VcsLocation SvnImportMetadataWidget::destination() const
0040 {
0041     KDevelop::VcsLocation destloc;
0042     QString url = m_ui->dest->text();
0043     if( useSourceDirForDestination ) {
0044         url += QLatin1Char('/') + m_ui->srcEdit->url().fileName();
0045     }
0046     destloc.setRepositoryServer(url);
0047     return destloc;
0048 }
0049 
0050 void SvnImportMetadataWidget::setUseSourceDirForDestination( bool b )
0051 {
0052     useSourceDirForDestination = b;
0053 }
0054 
0055 
0056 void SvnImportMetadataWidget::setSourceLocationEditable( bool enable )
0057 {
0058     m_ui->srcEdit->setEnabled( enable );
0059 }
0060 
0061 void SvnImportMetadataWidget::setMessage(const QString& message)
0062 {
0063     m_ui->message->setText(message);
0064 }
0065 
0066 QString SvnImportMetadataWidget::message() const
0067 {
0068     return m_ui->message->toPlainText();
0069 }
0070 
0071 bool SvnImportMetadataWidget::hasValidData() const
0072 {
0073     return !m_ui->message->toPlainText().isEmpty() && !m_ui->srcEdit->text().isEmpty();
0074 }
0075 
0076 #include "moc_svnimportmetadatawidget.cpp"