QGCUASFileView.h 1.86 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * 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 12 13 14
#ifndef QGCUASFILEVIEW_H
#define QGCUASFILEVIEW_H

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

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

class QGCUASFileView : public QWidget
{
    Q_OBJECT

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

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

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

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

Don Gagne's avatar
Don Gagne committed
49 50 51 52 53 54 55
    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;
56
    
Don Gagne's avatar
Don Gagne committed
57 58 59 60 61 62
    enum CommandState {
        commandNone,        ///< No command active
        commandList,        ///< List command active
        commandDownload,    ///< Download command active
        commandUpload       ///< Upload command active
    };
63
    
Don Gagne's avatar
Don Gagne committed
64
    CommandState _currentCommand;   ///< Current active command
65 66 67
};

#endif // QGCUASFILEVIEW_H