QGCUASFileView.h 1.8 KB
Newer Older
1 2
/****************************************************************************
 *
3
 *   (c) 2009-2018 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

Don Gagne's avatar
Don Gagne committed
10

11
#pragma once
12 13

#include <QWidget>
Don Gagne's avatar
Don Gagne committed
14
#include <QTreeWidgetItem>
15

Don Gagne's avatar
Don Gagne committed
16
#include "Vehicle.h"
17
#include "uas/FileManager.h"
Don Gagne's avatar
Don Gagne committed
18
#include "ui_QGCUASFileView.h"
19 20 21 22 23 24

class QGCUASFileView : public QWidget
{
    Q_OBJECT

public:
Don Gagne's avatar
Don Gagne committed
25
    explicit QGCUASFileView(QWidget *parent, Vehicle* vehicle);
Lorenz Meier's avatar
Lorenz Meier committed
26

27
protected:
28
    FileManager* _manager;
Don Gagne's avatar
Don Gagne committed
29 30
    
private slots:
31 32
    void _listEntryReceived(const QString& entry);
    
Don Gagne's avatar
Don Gagne committed
33
    void _refreshTree(void);
34
    void _downloadFile(void);
35
    void _uploadFile(void);
Don Gagne's avatar
Don Gagne committed
36 37 38 39
    
    void _commandProgress(int value);
    void _commandError(const QString& msg);
    void _commandComplete(void);
40

Don Gagne's avatar
Don Gagne committed
41
    void _currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
42 43

private:
Don Gagne's avatar
Don Gagne committed
44
    void _listComplete(void);
Don Gagne's avatar
Don Gagne committed
45
    void _requestDirectoryList(const QString& dir);
Don Gagne's avatar
Don Gagne committed
46
    void _setAllButtonsEnabled(bool enabled);
Don Gagne's avatar
Don Gagne committed
47

Don Gagne's avatar
Don Gagne committed
48 49 50 51 52 53 54
    static const int        _typeFile = QTreeWidgetItem::UserType + 1;
    static const int        _typeDir = QTreeWidgetItem::UserType + 2;
    static const int        _typeError = QTreeWidgetItem::UserType + 3;
    
    QList<int>              _walkIndexStack;
    QList<QTreeWidgetItem*> _walkItemStack;
    Ui::QGCUASFileView      _ui;
55
    
Don Gagne's avatar
Don Gagne committed
56 57 58 59 60 61
    enum CommandState {
        commandNone,        ///< No command active
        commandList,        ///< List command active
        commandDownload,    ///< Download command active
        commandUpload       ///< Upload command active
    };
62
    
Don Gagne's avatar
Don Gagne committed
63
    CommandState _currentCommand;   ///< Current active command
64 65
};