Commit 1fa53faa authored by Don Gagne's avatar Don Gagne

Added support for progress indication

Also restructured signals to be more command-centric as opposed to
ui-centric.
parent af6676b6
......@@ -107,7 +107,9 @@ void QGCUASFileManager::_openAckResponse(Request* openAck)
// File length comes back in data
Q_ASSERT(openAck->hdr.size == sizeof(uint32_t));
emit openFileLength(openAck->openFileLength);
emit downloadFileLength(openAck->openFileLength);
// Start the sequence of read commands
_readOffset = 0; // Start reading at beginning of file
_readFileAccumulator.clear(); // Start with an empty file
......@@ -142,7 +144,7 @@ void QGCUASFileManager::_closeReadSession(bool success)
}
file.close();
_emitStatusMessage(tr("Download complete '%1'").arg(downloadFilePath));
emit downloadFileComplete();
}
// Close the open session
......@@ -167,6 +169,7 @@ void QGCUASFileManager::_readAckResponse(Request* readAck)
}
_readFileAccumulator.append((const char*)readAck->data, readAck->hdr.size);
emit downloadFileProgress(_readFileAccumulator.length());
if (readAck->hdr.size == sizeof(readAck->data)) {
// Possibly still more data to read, send next read request
......@@ -221,7 +224,9 @@ void QGCUASFileManager::_listAckResponse(Request* listAck)
// Returned names are prepended with D for directory, F for file, U for unknown
if (*ptr == 'F' || *ptr == 'D') {
// put it in the view
_emitStatusMessage(ptr);
_emitListEntry(ptr);
} else {
qDebug() << "unknown entry" << ptr;
}
// account for the name + NUL
......@@ -357,9 +362,6 @@ void QGCUASFileManager::listDirectory(const QString& dirPath)
return;
}
// clear the text widget
emit resetStatusMessages();
// initialise the lister
_listPath = dirPath;
_listOffset = 0;
......@@ -411,8 +413,6 @@ void QGCUASFileManager::downloadPath(const QString& from, const QDir& downloadDi
i++; // move past slash
_readFileDownloadFilename = from.right(from.size() - i);
emit resetStatusMessages();
_currentOperation = kCOOpen;
Request request;
......@@ -532,10 +532,10 @@ void QGCUASFileManager::_emitErrorMessage(const QString& msg)
emit errorMessage(msg);
}
void QGCUASFileManager::_emitStatusMessage(const QString& msg)
void QGCUASFileManager::_emitListEntry(const QString& entry)
{
qDebug() << "QGCUASFileManager: Status" << msg;
emit statusMessage(msg);
qDebug() << "QGCUASFileManager: list entry" << entry;
emit listEntry(entry);
}
/// @brief Sends the specified Request out to the UAS.
......
......@@ -45,11 +45,28 @@ public:
static const int ackTimerTimeoutMsecs = 1000;
signals:
void statusMessage(const QString& msg);
void resetStatusMessages();
/// @brief Signalled whenever an error occurs during the listDirectory or downloadPath methods.
void errorMessage(const QString& msg);
// Signals associated with the listDirectory method
/// @brief Signalled to indicate a new directory entry was received.
void listEntry(const QString& entry);
/// @brief Signalled after listDirectory completes. If an error occurs during directory listing this signal will not be emitted.
void listComplete(void);
void openFileLength(unsigned int length);
// Signals associated with the downloadPath method
/// @brief Signalled after downloadPath is called to indicate length of file being downloaded
void downloadFileLength(unsigned int length);
/// @brief Signalled during file download to indicate download progress
/// @param bytesReceived Number of bytes currently received from file
void downloadFileProgress(unsigned int bytesReceived);
/// @brief Signaled to indicate completion of file download. If an error occurs during download this signal will not be emitted.
void downloadFileComplete(void);
public slots:
void receiveMessage(LinkInterface* link, mavlink_message_t message);
......@@ -140,7 +157,7 @@ protected:
void _setupAckTimeout(void);
void _clearAckTimeout(void);
void _emitErrorMessage(const QString& msg);
void _emitStatusMessage(const QString& msg);
void _emitListEntry(const QString& entry);
void _sendRequest(Request* request);
void _fillRequestWithString(Request* request, const QString& str);
void _openAckResponse(Request* openAck);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment