QGCUDPLinkConfiguration.h 1.26 KB
Newer Older
1 2 3 4
#ifndef QGCUDPLINKCONFIGURATION_H
#define QGCUDPLINKCONFIGURATION_H

#include <QWidget>
5
#include <QListView>
6 7 8

#include "UDPLink.h"

9
namespace Ui {
10
class QGCUDPLinkConfiguration;
11 12
}

13 14
class UPDViewModel;

15 16 17 18 19
class QGCUDPLinkConfiguration : public QWidget
{
    Q_OBJECT

public:
20
    explicit QGCUDPLinkConfiguration(UDPConfiguration* config, QWidget *parent = 0);
21 22
    ~QGCUDPLinkConfiguration();

23 24 25 26 27 28
private slots:
    void on_addHost_clicked();
    void on_removeHost_clicked();
    void on_editHost_clicked();
    void on_listView_clicked(const QModelIndex &index);
    void on_listView_doubleClicked(const QModelIndex &index);
29

30
    void on_portNumber_valueChanged(int arg1);
31 32

private:
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

    void _reloadList();
    void _editHost(int row);

    bool _inConstructor;
    Ui::QGCUDPLinkConfiguration* _ui;
    UDPConfiguration*            _config;
    UPDViewModel*                _viewModel;
};

class UPDViewModel : public QAbstractListModel
{
public:
    UPDViewModel(QObject *parent = 0);
    int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
    QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
    void beginChange() { beginResetModel(); }
    void endChange() { endResetModel(); }
    QStringList hosts;
52 53 54
};

#endif // QGCUDPLINKCONFIGURATION_H