changeset 214:ce6f65ab3327

* Add large chunks of context help in the optional status bar * Add an extra overlay mode in which even the centre frame is disabled * Fixes to FTP retrieval
author Chris Cannam
date Fri, 19 Jan 2007 13:13:14 +0000
parents e0e7f6c5fda9
children a051929fef3b
files base/CommandHistory.cpp data/fileio/RemoteFile.cpp data/fileio/RemoteFile.h
diffstat 3 files changed, 54 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/base/CommandHistory.cpp	Fri Jan 12 19:32:55 2007 +0000
+++ b/base/CommandHistory.cpp	Fri Jan 19 13:13:14 2007 +0000
@@ -49,6 +49,7 @@
 {
     m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this);
     m_undoAction->setShortcut(tr("Ctrl+Z"));
+    m_undoAction->setStatusTip(tr("Undo the last editing operation"));
     connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo()));
     
     m_undoMenuAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this);
@@ -61,6 +62,7 @@
 
     m_redoAction = new QAction(QIcon(":/icons/redo.png"), tr("Re&do"), this);
     m_redoAction->setShortcut(tr("Ctrl+Shift+Z"));
+    m_redoAction->setStatusTip(tr("Redo the last operation that was undone"));
     connect(m_redoAction, SIGNAL(triggered()), this, SLOT(redo()));
     
     m_redoMenuAction = new QAction(QIcon(":/icons/redo.png"), tr("Re&do"), this);
--- a/data/fileio/RemoteFile.cpp	Fri Jan 12 19:32:55 2007 +0000
+++ b/data/fileio/RemoteFile.cpp	Fri Jan 19 13:13:14 2007 +0000
@@ -63,7 +63,7 @@
         connect(m_http, SIGNAL(dataReadProgress(int, int)),
                 this, SLOT(dataReadProgress(int, int)));
         connect(m_http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
-                this, SLOT(responseHeaderReceived(const QHttpResponseHeader &)));
+                this, SLOT(httpResponseHeaderReceived(const QHttpResponseHeader &)));
         m_http->get(url.path(), m_localFile);
 
     } else if (scheme == "ftp") {
@@ -71,6 +71,8 @@
         m_ok = true;
         m_ftp = new QFtp;
         connect(m_ftp, SIGNAL(done(bool)), this, SLOT(done(bool)));
+        connect(m_ftp, SIGNAL(commandFinished(int, bool)),
+                this, SLOT(ftpCommandFinished(int, bool)));
         connect(m_ftp, SIGNAL(dataTransferProgress(qint64, qint64)),
                 this, SLOT(dataTransferProgress(qint64, qint64)));
         m_ftp->connectToHost(url.host(), url.port(21));
@@ -85,16 +87,14 @@
             password = QString("%1@%2").arg(getenv("USER")).arg(getenv("HOST"));
         }
 
-        QStringList path = url.path().split('/');
-        for (QStringList::iterator i = path.begin(); i != path.end(); ) {
-            QString bit = *i;
-            ++i;
-            if (i != path.end()) {
-                m_ftp->cd(*i);
-            } else {
-                m_ftp->get(*i, m_localFile);
-            }
-        }
+        m_ftp->login(username, password);
+
+        QString dirpath = url.path().section('/', 0, -2);
+        QString filename = url.path().section('/', -1);
+
+        if (dirpath == "") dirpath = "/";
+        m_ftp->cd(dirpath);
+        m_ftp->get(filename, m_localFile);
     }
 
     if (m_ok) {
@@ -118,10 +118,15 @@
 {
 //    std::cerr << "RemoteFile::cleanup" << std::endl;
     m_done = true;
-    delete m_http;
-    m_http = 0;
-    delete m_ftp;
-    m_ftp = 0;
+    if (m_http) {
+        delete m_http;
+        m_http = 0;
+    }
+    if (m_ftp) {
+        m_ftp->abort();
+        m_ftp->deleteLater();
+        m_ftp = 0;
+    }
     delete m_progressDialog;
     m_progressDialog = 0;
     delete m_localFile;
@@ -188,7 +193,7 @@
 }
 
 void
-RemoteFile::responseHeaderReceived(const QHttpResponseHeader &resp)
+RemoteFile::httpResponseHeaderReceived(const QHttpResponseHeader &resp)
 {
     m_lastStatus = resp.statusCode();
     if (m_lastStatus / 100 >= 4) {
@@ -203,6 +208,34 @@
 }
 
 void
+RemoteFile::ftpCommandFinished(int id, bool error)
+{
+    std::cerr << "RemoteFile::ftpCommandFinished(" << id << ", " << error << ")" << std::endl;
+
+    if (!m_ftp) return;
+
+    QFtp::Command command = m_ftp->currentCommand();
+
+    if (!error) {
+        std::cerr << "RemoteFile::ftpCommandFinished: success for command "
+                  << command << std::endl;
+        return;
+    }
+
+    if (command == QFtp::ConnectToHost) {
+        m_errorString = tr("Failed to connect to FTP server");
+    } else if (command == QFtp::Login) {
+        m_errorString = tr("Login failed");
+    } else if (command == QFtp::Cd) {
+        m_errorString = tr("Failed to change to correct directory");
+    } else if (command == QFtp::Get) {
+        m_errorString = tr("FTP download aborted");
+    }
+
+    m_lastStatus = 400; // for done()
+}
+
+void
 RemoteFile::dataTransferProgress(qint64 done, qint64 total)
 {
     if (!m_progressDialog) return;
@@ -228,7 +261,7 @@
 void
 RemoteFile::done(bool error)
 {
-//    std::cerr << "RemoteFile::done(" << error << ")" << std::endl;
+    std::cerr << "RemoteFile::done(" << error << ")" << std::endl;
 
     if (m_done) return;
 
--- a/data/fileio/RemoteFile.h	Fri Jan 12 19:32:55 2007 +0000
+++ b/data/fileio/RemoteFile.h	Fri Jan 19 13:13:14 2007 +0000
@@ -55,7 +55,8 @@
 
 protected slots:
     void dataReadProgress(int done, int total);
-    void responseHeaderReceived(const QHttpResponseHeader &resp);
+    void httpResponseHeaderReceived(const QHttpResponseHeader &resp);
+    void ftpCommandFinished(int, bool);
     void dataTransferProgress(qint64 done, qint64 total);
     void done(bool error);
     void showProgressDialog();