Warning, file /sdk/cervisia/cvsinitdialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Copyright (c) 2004 Christian Loose <christian.loose@kdemail.net>
0003  *
0004  * This program is free software; you can redistribute it and/or modify
0005  * it under the terms of the GNU General Public License as published by
0006  * the Free Software Foundation; either version 2 of the License, or
0007  * (at your option) any later version.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  * GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License
0015  * along with this program; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0017  */
0018 
0019 #include "cvsinitdialog.h"
0020 
0021 #include <QDialogButtonBox>
0022 #include <QFileDialog>
0023 #include <QHBoxLayout>
0024 #include <QPushButton>
0025 #include <QVBoxLayout>
0026 #include <qlabel.h>
0027 #include <qlayout.h>
0028 #include <qpushbutton.h>
0029 
0030 #include <KLineEdit>
0031 #include <KLocalizedString>
0032 #include <kurlcompletion.h>
0033 
0034 using Cervisia::CvsInitDialog;
0035 
0036 CvsInitDialog::CvsInitDialog(QWidget *parent)
0037     : QDialog(parent)
0038 {
0039     setWindowTitle(i18n("Create New Repository (cvs init)"));
0040     setModal(true);
0041 
0042     auto mainLayout = new QVBoxLayout;
0043     setLayout(mainLayout);
0044 
0045     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0046     okButton = buttonBox->button(QDialogButtonBox::Ok);
0047     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0048     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
0049     connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
0050 
0051     auto dirLabel = new QLabel(i18n("Repository folder:"));
0052     mainLayout->addWidget(dirLabel);
0053 
0054     auto dirLayout = new QHBoxLayout;
0055     mainLayout->addLayout(dirLayout);
0056 
0057     m_directoryEdit = new KLineEdit;
0058     m_directoryEdit->setFocus();
0059 
0060     auto comp = new KUrlCompletion();
0061     m_directoryEdit->setCompletionObject(comp);
0062     m_directoryEdit->setAutoDeleteCompletionObject(true);
0063 
0064     dirLabel->setBuddy(m_directoryEdit);
0065     dirLayout->addWidget(m_directoryEdit);
0066 
0067     auto dirButton = new QPushButton("...");
0068     dirButton->setFixedWidth(30);
0069     dirLayout->addWidget(dirButton);
0070 
0071     connect(dirButton, SIGNAL(clicked()), this, SLOT(dirButtonClicked()));
0072     connect(m_directoryEdit, SIGNAL(textChanged(QString)), this, SLOT(lineEditTextChanged(QString)));
0073 
0074     mainLayout->addWidget(buttonBox);
0075 
0076     okButton->setEnabled(false);
0077 
0078     setMinimumWidth(350);
0079 }
0080 
0081 QString CvsInitDialog::directory() const
0082 {
0083     return m_directoryEdit->text();
0084 }
0085 
0086 void CvsInitDialog::dirButtonClicked()
0087 {
0088     QString dir = QFileDialog::getExistingDirectory(0, QString(), m_directoryEdit->text());
0089     if (!dir.isEmpty())
0090         m_directoryEdit->setText(dir);
0091 }
0092 
0093 void CvsInitDialog::lineEditTextChanged(const QString &text)
0094 {
0095     okButton->setEnabled(!text.trimmed().isEmpty());
0096 }