/****************************************************************************
**
** Copyright (C) 2012 - 2014 Jolla Ltd.
** Contact: http://jolla.com/
**
** This file is part of Qt Creator.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Digia.
**
****************************************************************************/

#ifndef NXTOPTIONSWIDGET_H
#define NXTOPTIONSWIDGET_H

#include <qtc/nxtsdk.h>

#include <QTimer>
#include <QWidget>

QT_BEGIN_NAMESPACE
class QStandardItemModel;
QT_END_NAMESPACE

namespace Nxt {
namespace Internal {

namespace Ui {
class NxtOptionsWidget;
}

class NxtOptionsWidget : public QWidget
{
    Q_OBJECT
public:
    explicit NxtOptionsWidget(QWidget *parent = 0);
    ~NxtOptionsWidget() override;

    QString searchKeyWordMatchString() const;
    void setSdk(const QString &vmName);
    void store();

signals:
    void updateSearchKeys();

private:
    bool lockDownConnectionsOrCancelChangesThatNeedIt(QList<NxtSdk *> *lockedDownSdks);

private slots:
    // Ui
    void onSdksUpdated();
    void onSdkChanged(const QString &text);
    void onAddButtonClicked();
    void onRemoveButtonClicked();
    void onTestConnectionButtonClicked();
    void onStartVirtualMachineButtonClicked();
    void onStopVirtualMachineButtonClicked();
    //void onLaunchSDKControlCenterClicked();
    void onGenerateSshKey(const QString &path);
    void onAuthorizeSshKey(const QString &file);
    void onSshKeyChanged(const QString &file);
    void onSshTimeoutChanged(int timeout);
    void onSshPortChanged(quint16 port);
    void onHeadlessCheckBoxToggled(bool checked);
    void onSrcFolderApplyButtonClicked(const QString &path);
    void onWwwPortChanged(quint16 port);
    void onVmOffChanged(bool vmOff);
    void update();

private:
    Ui::NxtOptionsWidget *m_ui;
    QString m_virtualMachine;
    QMetaObject::Connection m_vmOffConnection;
    QString m_status;
    QMap<QString, NxtSdk*> m_sdks;
    QMap<NxtSdk*, QString> m_sshPrivKeys;
    QMap<NxtSdk*, int> m_sshTimeout;
    QMap<NxtSdk*, quint16> m_sshPort;
    QMap<NxtSdk*, bool> m_headless;
    QMap<NxtSdk*, quint16> m_wwwPort;
};

} // namespace Internal
} // namespace Nxt

#endif // NXTOPTIONSWIDGET_H
