summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp')
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index f40d8c3..646efab 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,10 +25,13 @@
#include <QProgressDialog>
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
-const QString PROTO_FTP( QObject::tr("Remote") ); //Remote path
+const QString PROTO_FTP( QObject::tr("Remote FTP") ); //Remote path
+const QString PROTO_SFTP( QObject::tr("Remote SFTP") );
+const QString PROTO_HTTP( QObject::tr("Remote HTTP") );
+const QString PROTO_HTTPS( QObject::tr("Remote HTTPS") );
CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *parent*/)
: QDialog(),
@@ -39,7 +42,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->setMargin( 10 );
mainLayout->setSpacing( 5 );
- QHBoxLayout *captionLayout = new QHBoxLayout( this );
+ QHBoxLayout *captionLayout = new QHBoxLayout;
mainLayout->addLayout(captionLayout);
QLabel *label = new QLabel( tr("Caption"), this );
captionLayout->addWidget( label );
@@ -50,7 +53,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QGridLayout* layout = new QGridLayout( this );
+ QGridLayout* layout = new QGridLayout;
layout->setSpacing(3);
layout->setMargin(3);
mainLayout->addLayout(layout);
@@ -68,6 +71,9 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
m_protocolCombo = new QComboBox( this );
layout->addWidget(m_protocolCombo, 1, 0);
m_protocolCombo->addItem( PROTO_FTP );
+ m_protocolCombo->addItem( PROTO_SFTP );
+ m_protocolCombo->addItem( PROTO_HTTP );
+ m_protocolCombo->addItem( PROTO_HTTPS);
m_protocolCombo->addItem( PROTO_FILE );
m_serverEdit = new QLineEdit( this );
@@ -81,7 +87,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal, this);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
QPushButton* getListButton = new QPushButton(tr("Get list..."), this);
getListButton->setToolTip(tr("Download a list of sources from CrossWire server and add sources"));
buttonBox->addButton(getListButton, QDialogButtonBox::ActionRole);
@@ -95,7 +101,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
void CSwordSetupInstallSourcesDialog::slotOk() {
//run a few tests to validate the input first
if ( m_captionEdit->text().trimmed().isEmpty() ) { //no caption
- util::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
return;
}
@@ -103,25 +109,25 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, m_captionEdit->text() );
sword::InstallSource is = BtInstallBackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
- util::showInformation( this, tr( "Error" ),
+ message::showInformation( this, tr( "Error" ),
tr("A source with this caption already exists. Please provide a different caption."));
return;
}
- if ( m_protocolCombo->currentText() == PROTO_FTP &&
+ if ( this->isRemote(m_protocolCombo->currentText()) &&
m_serverEdit->text().trimmed().isEmpty() ) { //no server name
- util::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
return;
}
if ( m_protocolCombo->currentText() == PROTO_FILE) {
const QFileInfo fi( m_pathEdit->text() );
if (!fi.exists() || !fi.isReadable()) { //no valid and readable path
- util::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
return;
}
else if ( m_pathEdit->text().isEmpty() ) {
- util::showInformation( this, tr( "Error" ), tr("Please provide a path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a path."));
}
}
@@ -130,7 +136,7 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
}
void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
- if (m_protocolCombo->currentText() == PROTO_FTP) { //REMOTE
+ if (this->isRemote(m_protocolCombo->currentText())) { //REMOTE
m_serverLabel->setEnabled(true);
m_serverEdit->setEnabled(true);
}
@@ -152,7 +158,7 @@ void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
QString message(tr("List of sources will be downloaded from a remote server. Sources will be added to the current list. New source will replace an old one if it has the same label. You can later remove the sources you don't want to keep.\n\nDo you want to continue?"));
- QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ QMessageBox::StandardButton answer = message::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No) {
return;
}
@@ -206,9 +212,20 @@ void CSwordSetupInstallSourcesDialog::slotRefreshCanceled() {
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
sword::InstallSource newSource(""); //empty, invalid Source
- if (m_protocolCombo->currentText() == PROTO_FTP) {
- newSource.type = "FTP";
- newSource.source = m_serverEdit->text().toUtf8();
+ if (this->isRemote(m_protocolCombo->currentText())) {
+ if (m_protocolCombo->currentText() == PROTO_FTP) {
+ newSource.type = "FTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_SFTP) {
+ newSource.type = "SFTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTP) {
+ newSource.type = "HTTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTPS) {
+ newSource.type = "HTTPS";
+ }
+ newSource.source = m_serverEdit->text().toUtf8();
//a message to the user would be nice, but we're in message freeze right now (1.5.1)
if (m_serverEdit->text().right(1) == "/") { //remove a trailing slash
newSource.source = m_serverEdit->text().mid(0, m_serverEdit->text().length() - 1).toUtf8();
@@ -225,4 +242,7 @@ sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
return newSource;
}
-
+bool CSwordSetupInstallSourcesDialog::isRemote(const QString& sourceType) {
+ return sourceType == PROTO_FTP || sourceType == PROTO_SFTP ||
+ sourceType == PROTO_HTTP || sourceType == PROTO_HTTPS;
+}