2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-08-01 16:44:59 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-08-01 16:44:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-08-01 16:44:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-08-01 16:44:59 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-08-01 16:44:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2016-01-15 14:57:40 +01:00
|
|
|
|
2014-03-27 18:00:55 +01:00
|
|
|
#include "deploymentdataview.h"
|
2011-08-01 16:44:59 +02:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
#include "deploymentdata.h"
|
2014-03-27 18:00:55 +01:00
|
|
|
#include "target.h"
|
2011-08-01 16:44:59 +02:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
#include <utils/treemodel.h>
|
|
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2014-03-27 18:00:55 +01:00
|
|
|
namespace ProjectExplorer {
|
2011-08-01 16:44:59 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
class DeploymentDataItem : public TreeItem
|
2011-08-01 16:44:59 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2019-08-20 16:53:28 +02:00
|
|
|
DeploymentDataItem() = default;
|
|
|
|
|
DeploymentDataItem(const DeployableFile &file) : file(file) {}
|
2011-08-01 16:44:59 +02:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
QVariant data(int column, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
|
return column == 0 ? file.localFilePath().toUserOutput() : file.remoteDirectory();
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
DeployableFile file;
|
|
|
|
|
};
|
2011-08-01 16:44:59 +02:00
|
|
|
|
|
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
DeploymentDataView::DeploymentDataView(Target *target)
|
2011-08-01 16:44:59 +02:00
|
|
|
{
|
2019-08-20 16:53:28 +02:00
|
|
|
auto model = new TreeModel<DeploymentDataItem>(this);
|
|
|
|
|
model->setHeader({tr("Local File Path"), tr("Remote Directory")});
|
2012-11-08 15:21:34 +01:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
auto view = new QTreeView(this);
|
|
|
|
|
view->setMinimumSize(QSize(100, 100));
|
|
|
|
|
view->setTextElideMode(Qt::ElideMiddle);
|
|
|
|
|
view->setWordWrap(false);
|
|
|
|
|
view->setUniformRowHeights(true);
|
|
|
|
|
view->setModel(model);
|
2012-11-08 15:21:34 +01:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
auto label = new QLabel(tr("Files to deploy:"), this);
|
2011-08-01 16:44:59 +02:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
auto layout = new QVBoxLayout(this);
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
layout->addWidget(view);
|
2011-08-01 16:44:59 +02:00
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
auto updatModel = [this, target, model, view] {
|
|
|
|
|
model->clear();
|
|
|
|
|
for (const DeployableFile &file : target->deploymentData().allFiles())
|
|
|
|
|
model->rootItem()->appendChild(new DeploymentDataItem(file));
|
|
|
|
|
|
|
|
|
|
QHeaderView *header = view->header();
|
|
|
|
|
header->setSectionResizeMode(0, QHeaderView::Interactive);
|
|
|
|
|
header->setSectionResizeMode(1, QHeaderView::Interactive);
|
|
|
|
|
view->resizeColumnToContents(0);
|
|
|
|
|
view->resizeColumnToContents(1);
|
|
|
|
|
if (header->sectionSize(0) + header->sectionSize(1) < header->width())
|
|
|
|
|
header->setSectionResizeMode(1, QHeaderView::Stretch);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
connect(target, &Target::deploymentDataChanged, this, updatModel);
|
|
|
|
|
updatModel();
|
2011-08-01 16:44:59 +02:00
|
|
|
}
|
|
|
|
|
|
2019-08-20 16:53:28 +02:00
|
|
|
} // Internal
|
|
|
|
|
} // ProjectExplorer
|