/***************************** LICENSE START ***********************************

 Copyright 2017 ECMWF and INPE. This software is distributed under the terms
 of the Apache License version 2.0. In applying this license, ECMWF does not
 waive the privileges and immunities granted to it by virtue of its status as
 an Intergovernmental Organization or submit itself to any jurisdiction.

 ***************************** LICENSE END *************************************/

#ifndef LOCATIONWIDGET_H
#define LOCATIONWIDGET_H

#include "ui_LocationWidget.h"

#include <QWidget>

class BufrLocationCollector;
class MvKeyProfile;
class MvQKeyProfileModel;
class MvQKeyProfileSortFilterModel;

class LocationWidget : public QWidget, protected Ui::LocationWidget
{
    Q_OBJECT

public:
    explicit LocationWidget(QWidget* parent = 0);
    virtual ~LocationWidget() {}

    BufrLocationCollector* makeCollector();
    void update(BufrLocationCollector*);
    void update(MvKeyProfile*);
    void updateMessage(int);
    void clear();
    int maxNum() const { return maxNum_; }

    enum Mode
    {
        LocationMode,
        DataMode
    };
    void setMode(Mode mode) { mode_ = mode; }

protected Q_SLOTS:
    void slotCurrentChangedInMap(int index);
    void slotCurrentChangedInTree(const QModelIndex&);

Q_SIGNALS:
    void messageSelected(int);

protected:
    void updateNumLabel(int, int);

    Mode mode_;
    MvQKeyProfileModel* model_;
    MvQKeyProfileSortFilterModel* sortModel_;
    MvKeyProfile* prof_;
    int maxNum_;
    bool inChangeFromMap_;
    bool inChangeFromTree_;
    bool inUpdateMessage_;
};

#endif  // LOCATIONWIDGET_H
