diff --git a/uploadjob.cpp b/uploadjob.cpp
--- a/uploadjob.cpp
+++ b/uploadjob.cpp
@@ -103,14 +103,21 @@
->data(m_uploadIndex, Qt::CheckStateRole).toInt());
KDevelop::Path url;
+ QUrl localUrl = m_uploadProjectModel->currentProfileLocalUrl().adjusted(QUrl::StripTrailingSlash);
+ KDevelop::Path localPath = KDevelop::Path(localUrl.path());
+
if (item->folder()) {
url = item->folder()->path();
} else if (item->file()) {
url = item->file()->path();
}
-
- QString relativeUrl(m_project->path().relativePath(url));
+
+ if(localPath.path().isEmpty()) {
+ localPath = m_project->path();
+ }
+
+ QString relativeUrl(localPath.relativePath(url));
if (isQuickUpload() && checked == Qt::Unchecked) {
appendLog(i18n("File was not modified for %1: %2",
diff --git a/uploadpreferences.cpp b/uploadpreferences.cpp
--- a/uploadpreferences.cpp
+++ b/uploadpreferences.cpp
@@ -68,6 +68,7 @@
void UploadPreferences::apply()
{
m_model->submit();
+ m_model->revert();
ProjectConfigPage::apply();
}
@@ -79,6 +80,7 @@
void UploadPreferences::addProfile()
{
UploadProfileItem* i = new UploadProfileItem();
+ i->setLocalUrl(QUrl(m_model->project()->path().path()));
if (m_model->rowCount() == 0) {
i->setDefault(true);
}
diff --git a/uploadprofiledlg.h b/uploadprofiledlg.h
--- a/uploadprofiledlg.h
+++ b/uploadprofiledlg.h
@@ -42,6 +42,10 @@
* Opens a directory browser to select the path
*/
void browse();
+ /**
+ * Opens a directory browser to select the local path
+ */
+ void browseLocal();
protected Q_SLOTS:
/**
@@ -61,6 +65,7 @@
void updateUrl( const QUrl& url );
Ui::UploadProfileDlg* m_ui;
+
};
diff --git a/uploadprofiledlg.cpp b/uploadprofiledlg.cpp
--- a/uploadprofiledlg.cpp
+++ b/uploadprofiledlg.cpp
@@ -38,6 +38,8 @@
m_ui = new Ui::UploadProfileDlg();
m_ui->setupUi(widget);
+ m_ui->browseButtonLocal->setIcon(QIcon::fromTheme("document-open"));
+ connect(m_ui->browseButtonLocal, SIGNAL(clicked()), this, SLOT(browseLocal()));
m_ui->browseButton->setIcon(QIcon::fromTheme("document-open"));
connect(m_ui->browseButton, SIGNAL(clicked()), this, SLOT(browse()));
@@ -73,12 +75,15 @@
{
m_ui->lineProfileName->setText(item->text());
m_ui->defaultProfile->setChecked(item->isDefault());
+ m_ui->lineLocalPath->setText(item->localUrl().toString());
updateUrl(item->url());
int result = exec();
if (result == QDialog::Accepted) {
item->setText(m_ui->lineProfileName->text());
item->setUrl(currentUrl());
+ QUrl localUrl = QUrl(m_ui->lineLocalPath->text());
+ item->setLocalUrl(localUrl);
item->setDefault(m_ui->defaultProfile->checkState() == Qt::Checked);
}
return result;
@@ -111,19 +116,22 @@
void UploadProfileDlg::browse()
{
-#if QT_VERSION >= 0x050400
QUrl chosenDir = QFileDialog::getExistingDirectoryUrl(this, QString(), currentUrl());
-#else
- QFileDialog dialog(this);
- dialog.setDirectoryUrl(currentUrl());
- dialog.setOptions(QFileDialog::ShowDirsOnly);
- dialog.exec();
- QUrl chosenDir = dialog.selectedUrls().first();
-#endif
+
if(chosenDir.isValid()) {
updateUrl(chosenDir);
}
}
+
+void UploadProfileDlg::browseLocal()
+{
+ QUrl chosenDir = QFileDialog::getExistingDirectoryUrl(this, QString(), m_ui->lineLocalPath->text());
+
+ if(chosenDir.isValid()) {
+ m_ui->lineLocalPath->setText(chosenDir.path());
+ }
+}
+
void UploadProfileDlg::slotAcceptButtonClicked()
{
KIO::StatJob* statJob = KIO::stat(currentUrl());
@@ -134,6 +142,14 @@
KMessageBox::sorry(this, i18n("The specified URL does not exist."));
return;
}
+
+ //TODO: check if local dir is subpath of project dir
+ QString selectedLocalPath = m_ui->lineLocalPath->text();
+ if(!QDir(selectedLocalPath).exists()) {
+ KMessageBox::sorry(this, i18n("The specified local directory does not exist."));
+ return;
+ }
+
QDialog::accept();
}
diff --git a/uploadprofiledlg.ui b/uploadprofiledlg.ui
--- a/uploadprofiledlg.ui
+++ b/uploadprofiledlg.ui
@@ -131,6 +131,36 @@
-
+
+
+ &Local Path:
+
+
+ false
+
+
+ linePath
+
+
+
+ -
+
+
-
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ -
Pa&th:
@@ -143,7 +173,7 @@
- -
+
-
-
@@ -160,7 +190,7 @@
- -
+
-
Use as &default profile
diff --git a/uploadprofileitem.h b/uploadprofileitem.h
--- a/uploadprofileitem.h
+++ b/uploadprofileitem.h
@@ -20,14 +20,16 @@
{
enum {
UrlRole = Qt::UserRole+1,
- IsDefaultRole = Qt::UserRole+2,
- ProfileNrRole = Qt::UserRole+3
+ IsDefaultRole,
+ ProfileNrRole,
+ LocalUrlRole
};
public:
UploadProfileItem();
~UploadProfileItem() override {}
void setUrl(const QUrl& url);
+ void setLocalUrl(const QUrl& url);
/**
* Set if this item is the default upload-profile.
@@ -41,6 +43,7 @@
void setProfileNr(const QString& nr);
QUrl url() const;
+ QUrl localUrl() const;
bool isDefault() const;
/**
diff --git a/uploadprofileitem.cpp b/uploadprofileitem.cpp
--- a/uploadprofileitem.cpp
+++ b/uploadprofileitem.cpp
@@ -26,6 +26,10 @@
{
setData(url, UrlRole);
}
+void UploadProfileItem::setLocalUrl(const QUrl& url)
+{
+ setData(url, LocalUrlRole);
+}
void UploadProfileItem::setDefault(bool isDefault)
{
@@ -55,6 +59,10 @@
{
return data(UrlRole).value();
}
+QUrl UploadProfileItem::localUrl() const
+{
+ return data(LocalUrlRole).value();
+}
bool UploadProfileItem::isDefault() const
{
diff --git a/uploadprofilemodel.cpp b/uploadprofilemodel.cpp
--- a/uploadprofilemodel.cpp
+++ b/uploadprofilemodel.cpp
@@ -67,6 +67,7 @@
Q_FOREACH (QString g, group.groupList()) {
if (g.startsWith("Profile")) {
QUrl url = group.group(g).readEntry("url", QUrl());
+ QUrl localUrl = group.group(g).readEntry("localUrl", QUrl());
QString name = group.group(g).readEntry("name", QString());
UploadProfileItem* i = uploadItem(row);
if (!i) {
@@ -75,6 +76,7 @@
}
i->setText(name);
i->setUrl(url);
+ i->setLocalUrl(localUrl);
i->setProfileNr(g.mid(7)); //group-name
i->setDefault(i->profileNr() == defProfile);
++row;
@@ -108,6 +110,7 @@
}
KConfigGroup profileGroup = group.group("Profile" + item->profileNr());
profileGroup.writeEntry("url", item->url().toString());
+ profileGroup.writeEntry("localUrl", item->localUrl().toString());
profileGroup.writeEntry("name", item->text());
if (item->isDefault()) {
defaultProfileNr = item->profileNr();
diff --git a/uploadprojectmodel.h b/uploadprojectmodel.h
--- a/uploadprojectmodel.h
+++ b/uploadprojectmodel.h
@@ -82,6 +82,11 @@
* Returns the url of the current Upload Profile (which is set through setProfileConfigGroup)
*/
QUrl currentProfileUrl();
+
+ /**
+ * Returns the local url of the current Upload Profile (which is set through setProfileConfigGroup)
+ */
+ QUrl currentProfileLocalUrl();
public Q_SLOTS:
/**
diff --git a/uploadprojectmodel.cpp b/uploadprojectmodel.cpp
--- a/uploadprojectmodel.cpp
+++ b/uploadprojectmodel.cpp
@@ -222,6 +222,11 @@
return m_profileConfigGroup.readEntry("url", QUrl());
}
+QUrl UploadProjectModel::currentProfileLocalUrl()
+{
+ return m_profileConfigGroup.readEntry("localUrl", QUrl());
+}
+
void UploadProjectModel::checkAll()
{
setData(index(0, 0), Qt::Checked, Qt::CheckStateRole);