22 changed files with 845 additions and 24 deletions
@ -0,0 +1,148 @@ |
|||
#include "exchangedevicesmodel.h" |
|||
#include "exchangedevicesmodel_p.h" |
|||
using namespace QtMvvm; |
|||
using namespace QtDataSync; |
|||
|
|||
ExchangeDevicesModel::ExchangeDevicesModel(QObject *parent) : |
|||
QAbstractListModel(parent), |
|||
d(new ExchangeDevicesModelPrivate()) |
|||
{} |
|||
|
|||
ExchangeDevicesModel::~ExchangeDevicesModel() {} |
|||
|
|||
void ExchangeDevicesModel::setup(QtDataSync::UserExchangeManager *exchangeManager) |
|||
{ |
|||
if(d->exchangeManager) |
|||
d->exchangeManager->disconnect(this); |
|||
|
|||
beginResetModel(); |
|||
d->exchangeManager = exchangeManager; |
|||
d->devices = d->exchangeManager->devices(); |
|||
endResetModel(); |
|||
|
|||
connect(d->exchangeManager, &UserExchangeManager::devicesChanged, |
|||
this, &ExchangeDevicesModel::updateDevices); |
|||
} |
|||
|
|||
UserInfo ExchangeDevicesModel::infoAt(int index) const |
|||
{ |
|||
return d->devices.value(index); |
|||
} |
|||
|
|||
QVariant ExchangeDevicesModel::headerData(int section, Qt::Orientation orientation, int role) const |
|||
{ |
|||
if(orientation != Qt::Horizontal) |
|||
return {}; |
|||
|
|||
switch (section) { |
|||
case 0: |
|||
switch(role) { |
|||
case NameRole: |
|||
return tr("Name"); |
|||
case HostRole: |
|||
return tr("Host"); |
|||
case PortRole: |
|||
return tr("Port"); |
|||
case AddressRole: |
|||
return tr("Address"); |
|||
default: |
|||
break; |
|||
} |
|||
break; |
|||
case 1: |
|||
if(role == Qt::DisplayRole) |
|||
return tr("Address"); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
|
|||
return {}; |
|||
} |
|||
|
|||
int ExchangeDevicesModel::rowCount(const QModelIndex &parent) const |
|||
{ |
|||
if (parent.isValid()) |
|||
return 0; |
|||
else |
|||
return d->devices.size(); |
|||
} |
|||
|
|||
int ExchangeDevicesModel::columnCount(const QModelIndex &parent) const |
|||
{ |
|||
if (parent.isValid()) |
|||
return 0; |
|||
else |
|||
return 2; |
|||
} |
|||
|
|||
QVariant ExchangeDevicesModel::data(const QModelIndex &index, int role) const |
|||
{ |
|||
if (!index.isValid()) |
|||
return QVariant(); |
|||
|
|||
switch (index.column()) { |
|||
case 0: |
|||
switch(role) { |
|||
case NameRole: |
|||
return d->devices.value(index.row()).name(); |
|||
case HostRole: |
|||
return d->devices.value(index.row()).address().toString(); |
|||
case PortRole: |
|||
return d->devices.value(index.row()).port(); |
|||
case AddressRole: |
|||
return fullAddress(d->devices.value(index.row())); |
|||
default: |
|||
break; |
|||
} |
|||
break; |
|||
case 1: |
|||
if(role == Qt::DisplayRole) |
|||
return fullAddress(d->devices.value(index.row())); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
|
|||
return {}; |
|||
} |
|||
|
|||
QHash<int, QByteArray> ExchangeDevicesModel::roleNames() const |
|||
{ |
|||
return { |
|||
{NameRole, "name"}, |
|||
{HostRole, "host"}, |
|||
{PortRole, "port"}, |
|||
{AddressRole, "address"} |
|||
}; |
|||
} |
|||
|
|||
QString ExchangeDevicesModel::fullAddress(const UserInfo &userInfo) |
|||
{ |
|||
return tr("%1:%2") |
|||
.arg(userInfo.address().toString()) |
|||
.arg(userInfo.port()); |
|||
} |
|||
|
|||
void ExchangeDevicesModel::updateDevices(const QList<UserInfo> &devices) |
|||
{ |
|||
QList<UserInfo> addList; |
|||
for(auto device : devices) { |
|||
auto dIndex = d->devices.indexOf(device); |
|||
if(dIndex != -1) { |
|||
if(device.name() != d->devices[dIndex].name()) { |
|||
d->devices[dIndex] = device; |
|||
emit dataChanged(index(dIndex), index(dIndex, 1)); |
|||
} |
|||
} else |
|||
addList.append(device); |
|||
} |
|||
|
|||
if(addList.isEmpty()) |
|||
return; |
|||
beginInsertRows(QModelIndex(), |
|||
d->devices.size(), |
|||
d->devices.size() + addList.size() - 1); |
|||
d->devices.append(addList); |
|||
endInsertRows(); |
|||
} |
@ -0,0 +1,51 @@ |
|||
#ifndef QTMVVM_EXCHANGEDEVICESMODEL_H |
|||
#define QTMVVM_EXCHANGEDEVICESMODEL_H |
|||
|
|||
#include <QtCore/qabstractitemmodel.h> |
|||
#include <QtCore/qscopedpointer.h> |
|||
|
|||
#include <QtDataSync/userexchangemanager.h> |
|||
|
|||
#include "QtMvvmDataSyncCore/qtmvvmdatasynccore_global.h" |
|||
|
|||
namespace QtMvvm { |
|||
|
|||
class ExchangeDevicesModelPrivate; |
|||
class Q_MVVMDATASYNCCORE_EXPORT ExchangeDevicesModel : public QAbstractListModel |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
enum Roles { |
|||
NameRole = Qt::DisplayRole, |
|||
HostRole = Qt::UserRole + 1, |
|||
PortRole, |
|||
AddressRole |
|||
}; |
|||
Q_ENUM(Roles) |
|||
|
|||
explicit ExchangeDevicesModel(QObject *parent = nullptr); |
|||
~ExchangeDevicesModel(); |
|||
|
|||
Q_INVOKABLE void setup(QtDataSync::UserExchangeManager *exchangeManager); |
|||
|
|||
Q_INVOKABLE QtDataSync::UserInfo infoAt(int index) const; |
|||
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
|||
int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
|||
int columnCount(const QModelIndex &parent) const override; |
|||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
|||
QHash<int, QByteArray> roleNames() const override; |
|||
|
|||
static QString fullAddress(const QtDataSync::UserInfo &userInfo); |
|||
|
|||
private Q_SLOTS: |
|||
void updateDevices(const QList<QtDataSync::UserInfo> &devices); |
|||
|
|||
private: |
|||
QScopedPointer<ExchangeDevicesModelPrivate> d; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_EXCHANGEDEVICESMODEL_H
|
@ -0,0 +1,20 @@ |
|||
#ifndef QTMVVM_EXCHANGEDEVICESMODEL_P_H |
|||
#define QTMVVM_EXCHANGEDEVICESMODEL_P_H |
|||
|
|||
#include <QtCore/QHash> |
|||
|
|||
#include "qtmvvmdatasynccore_global.h" |
|||
#include "exchangedevicesmodel.h" |
|||
|
|||
namespace QtMvvm { |
|||
|
|||
class ExchangeDevicesModelPrivate |
|||
{ |
|||
public: |
|||
QtDataSync::UserExchangeManager *exchangeManager = nullptr; |
|||
QList<QtDataSync::UserInfo> devices; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_EXCHANGEDEVICESMODEL_P_H
|
@ -0,0 +1,225 @@ |
|||
#include "networkexchangeviewmodel.h" |
|||
#include "networkexchangeviewmodel_p.h" |
|||
#include "datasyncviewmodel.h" |
|||
#include "exportsetupviewmodel_p.h" |
|||
|
|||
#include <QtMvvmCore/Messages> |
|||
#include <QtDataSync/AccountManager> |
|||
|
|||
#undef logDebug |
|||
#undef logInfo |
|||
#undef logWarning |
|||
#undef logCritical |
|||
#include <QtMvvmCore/private/qtmvvm_logging_p.h> |
|||
|
|||
using namespace QtMvvm; |
|||
using namespace QtDataSync; |
|||
|
|||
const QString NetworkExchangeViewModel::paramSetup(QStringLiteral("setup")); |
|||
const QString NetworkExchangeViewModel::paramAccountManager(QStringLiteral("accountManager")); |
|||
|
|||
QVariantHash NetworkExchangeViewModel::showParams(const QString &setup) |
|||
{ |
|||
return { |
|||
{paramSetup, setup} |
|||
}; |
|||
} |
|||
|
|||
QVariantHash NetworkExchangeViewModel::showParams(AccountManager *accountManager) |
|||
{ |
|||
return { |
|||
{paramAccountManager, QVariant::fromValue(accountManager)} |
|||
}; |
|||
} |
|||
|
|||
NetworkExchangeViewModel::NetworkExchangeViewModel(QObject *parent) : |
|||
ViewModel(parent), |
|||
d(new NetworkExchangeViewModelPrivate(this)) |
|||
{} |
|||
|
|||
NetworkExchangeViewModel::~NetworkExchangeViewModel() {} |
|||
|
|||
quint16 NetworkExchangeViewModel::port() const |
|||
{ |
|||
return d->port; |
|||
} |
|||
|
|||
QString NetworkExchangeViewModel::deviceName() const |
|||
{ |
|||
return d->exchangeManager ? |
|||
d->exchangeManager->accountManager()->deviceName() : |
|||
QString(); |
|||
} |
|||
|
|||
bool NetworkExchangeViewModel::active() const |
|||
{ |
|||
return d->exchangeManager && d->exchangeManager->isActive(); |
|||
} |
|||
|
|||
ExchangeDevicesModel *NetworkExchangeViewModel::deviceModel() const |
|||
{ |
|||
return d->deviceModel; |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::exportTo(int index) |
|||
{ |
|||
auto exCode = NetworkExchangeViewModelPrivate::ExportRequestCode; |
|||
while(d->activeExports.contains(exCode)) |
|||
exCode++; |
|||
auto info = d->deviceModel->infoAt(index); |
|||
d->activeExports.insert(exCode, info); |
|||
showForResult<ExportSetupViewModel>(exCode, |
|||
ExportSetupViewModel::showParams(tr("Export accont data to device \"%1\" with address \"%1\":") |
|||
.arg(info.name()) |
|||
.arg(ExchangeDevicesModel::fullAddress(info)))); |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::setPort(quint16 port) |
|||
{ |
|||
if (d->port == port) |
|||
return; |
|||
|
|||
d->port = port; |
|||
emit portChanged(d->port); |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::setDeviceName(QString deviceName) |
|||
{ |
|||
if (!d->exchangeManager || |
|||
this->deviceName() == deviceName) |
|||
return; |
|||
|
|||
d->exchangeManager->accountManager()->setDeviceName(deviceName); |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::setActive(bool active) |
|||
{ |
|||
if(active != this->active()) { |
|||
if(active) |
|||
d->exchangeManager->startExchange(d->port); |
|||
else |
|||
d->exchangeManager->stopExchange(); |
|||
} |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::onInit(const QVariantHash ¶ms) |
|||
{ |
|||
try { |
|||
if(params.contains(paramAccountManager)) { |
|||
auto accountManager = params.value(paramAccountManager).value<AccountManager*>(); |
|||
d->exchangeManager = new UserExchangeManager(accountManager, this); |
|||
} else { |
|||
auto setup = params.value(paramSetup, QtDataSync::DefaultSetup).toString(); |
|||
d->exchangeManager = new UserExchangeManager(setup, this); |
|||
} |
|||
|
|||
connect(d->exchangeManager->accountManager(), &AccountManager::deviceNameChanged, |
|||
this, &NetworkExchangeViewModel::deviceNameChanged); |
|||
connect(d->exchangeManager, &UserExchangeManager::userDataReceived, |
|||
this, &NetworkExchangeViewModel::newUserData); |
|||
connect(d->exchangeManager, &UserExchangeManager::exchangeError, |
|||
this, &NetworkExchangeViewModel::exchangeError); |
|||
connect(d->exchangeManager, &UserExchangeManager::activeChanged, |
|||
this, &NetworkExchangeViewModel::activeChanged); |
|||
|
|||
emit deviceNameChanged(deviceName()); |
|||
|
|||
d->deviceModel->setup(d->exchangeManager); |
|||
emit ready(); |
|||
} catch(SetupDoesNotExistException &e) { |
|||
logCritical() << "Failed to init DataSyncViewModel with error:" |
|||
<< e.what(); |
|||
} |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::onResult(quint32 requestCode, const QVariant &result) |
|||
{ |
|||
if(d->activeExports.contains(requestCode)) { |
|||
auto info = d->activeExports.take(requestCode); |
|||
if(result.isValid()) { |
|||
auto res = ExportSetupViewModel::result(result); |
|||
if(std::get<0>(res)) |
|||
d->exchangeManager->exportTrustedTo(info, std::get<1>(res), std::get<2>(res)); |
|||
else |
|||
d->exchangeManager->exportTo(info, std::get<1>(res)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::exchangeError(const QString &errorString) |
|||
{ |
|||
critical(tr("Network exchange error"), errorString); |
|||
} |
|||
|
|||
void NetworkExchangeViewModel::newUserData(const UserInfo &userInfo, bool trusted) |
|||
{ |
|||
QPointer<NetworkExchangeViewModel> qPtr(this); |
|||
auto importDoneHandler = [this, qPtr](bool ok, QString error) { |
|||
if(!qPtr) |
|||
return; |
|||
if(ok) { |
|||
information(DataSyncViewModel::tr("Import completed"), |
|||
DataSyncViewModel::tr("Data was successfully imported.")); |
|||
} else |
|||
critical(DataSyncViewModel::tr("Import failed"), error); |
|||
}; |
|||
|
|||
if(trusted) { |
|||
MessageConfig config{MessageConfig::TypeInputDialog, QMetaType::typeName(QMetaType::QString)}; |
|||
config.setTitle(tr("Import account data")) |
|||
.setText(tr("Enter the password to decrypt the account data received from \"%1\" with address \"%2\". " |
|||
"Then choose whether you want to keep you local data or not:") |
|||
.arg(userInfo.name()) |
|||
.arg(ExchangeDevicesModel::fullAddress(userInfo))) |
|||
.setButtons(MessageConfig::YesToAll | MessageConfig::Yes | MessageConfig::Cancel) //TODO adjust to get ideal placement
|
|||
.setButtonText(MessageConfig::YesToAll, tr("Reset data")) |
|||
.setButtonText(MessageConfig::Yes, tr("Keep data")) |
|||
.setViewProperties({ |
|||
{QStringLiteral("echoMode"), 2} //QLineEdit::Password
|
|||
}); |
|||
auto res = CoreApp::showDialog(config); |
|||
connect(res, &MessageResult::dialogDone, this, [this, res, userInfo, importDoneHandler](MessageConfig::StandardButton btn) { |
|||
switch (btn) { |
|||
case MessageConfig::YesToAll: |
|||
d->exchangeManager->importTrustedFrom(userInfo, res->result().toString(), importDoneHandler, false); |
|||
break; |
|||
case MessageConfig::Yes: |
|||
d->exchangeManager->importTrustedFrom(userInfo, res->result().toString(), importDoneHandler, true); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
}); |
|||
} else { |
|||
MessageConfig config{MessageConfig::TypeMessageBox, MessageConfig::SubTypeQuestion}; |
|||
config.setTitle(tr("Import account data")) |
|||
.setText(tr("Do you want to import data received from \"%1\" with address \"%2\"? " |
|||
"Keep the local data after changing the account?") |
|||
.arg(userInfo.name()) |
|||
.arg(ExchangeDevicesModel::fullAddress(userInfo))) |
|||
.setButtons(MessageConfig::YesToAll | MessageConfig::Yes | MessageConfig::Cancel) //TODO adjust to get ideal placement
|
|||
.setButtonText(MessageConfig::YesToAll, tr("Reset data")) |
|||
.setButtonText(MessageConfig::Yes, tr("Keep data")); |
|||
auto res = CoreApp::showDialog(config); |
|||
connect(res, &MessageResult::dialogDone, this, [this, userInfo, importDoneHandler](MessageConfig::StandardButton btn) { |
|||
switch (btn) { |
|||
case MessageConfig::YesToAll: |
|||
d->exchangeManager->importFrom(userInfo, importDoneHandler, false); |
|||
break; |
|||
case MessageConfig::Yes: |
|||
d->exchangeManager->importFrom(userInfo, importDoneHandler, true); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
// ------------- Private Implementation -------------
|
|||
|
|||
NetworkExchangeViewModelPrivate::NetworkExchangeViewModelPrivate(NetworkExchangeViewModel *q_ptr) : |
|||
exchangeManager(nullptr), |
|||
deviceModel(new ExchangeDevicesModel(q_ptr)), |
|||
port(UserExchangeManager::DataExchangePort) |
|||
{} |
@ -0,0 +1,69 @@ |
|||
#ifndef QTMVVM_NETWORKEXCHANGEVIEWMODEL_H |
|||
#define QTMVVM_NETWORKEXCHANGEVIEWMODEL_H |
|||
|
|||
#include <QtCore/qscopedpointer.h> |
|||
|
|||
#include <QtMvvmCore/viewmodel.h> |
|||
|
|||
#include <QtDataSync/userexchangemanager.h> |
|||
|
|||
#include "QtMvvmDataSyncCore/qtmvvmdatasynccore_global.h" |
|||
#include "QtMvvmDataSyncCore/exchangedevicesmodel.h" |
|||
|
|||
namespace QtMvvm { |
|||
|
|||
class NetworkExchangeViewModelPrivate; |
|||
class Q_MVVMDATASYNCCORE_EXPORT NetworkExchangeViewModel : public ViewModel |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged) |
|||
Q_PROPERTY(QString deviceName READ deviceName WRITE setDeviceName NOTIFY deviceNameChanged) |
|||
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) |
|||
|
|||
Q_PROPERTY(ExchangeDevicesModel* deviceModel READ deviceModel CONSTANT) |
|||
|
|||
public: |
|||
static const QString paramSetup; |
|||
static const QString paramAccountManager; |
|||
|
|||
static QVariantHash showParams(const QString &setup); |
|||
static QVariantHash showParams(QtDataSync::AccountManager *accountManager); |
|||
|
|||
Q_INVOKABLE explicit NetworkExchangeViewModel(QObject *parent = nullptr); |
|||
~NetworkExchangeViewModel(); |
|||
|
|||
quint16 port() const; |
|||
QString deviceName() const; |
|||
bool active() const; |
|||
ExchangeDevicesModel* deviceModel() const; |
|||
|
|||
public Q_SLOTS: |
|||
void exportTo(int index); |
|||
|
|||
void setPort(quint16 port); |
|||
void setDeviceName(QString deviceName); |
|||
void setActive(bool active); |
|||
|
|||
Q_SIGNALS: |
|||
void ready(); |
|||
|
|||
void portChanged(quint16 port); |
|||
void deviceNameChanged(QString deviceName); |
|||
void activeChanged(bool active); |
|||
|
|||
protected: |
|||
void onInit(const QVariantHash ¶ms) override; |
|||
void onResult(quint32 requestCode, const QVariant &result) override; |
|||
|
|||
private Q_SLOTS: |
|||
void exchangeError(const QString &errorString); |
|||
void newUserData(const QtDataSync::UserInfo &userInfo, bool trusted); |
|||
|
|||
private: |
|||
QScopedPointer<NetworkExchangeViewModelPrivate> d; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_NETWORKEXCHANGEVIEWMODEL_H
|
@ -0,0 +1,24 @@ |
|||
#ifndef QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H |
|||
#define QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H |
|||
|
|||
#include "qtmvvmdatasynccore_global.h" |
|||
#include "networkexchangeviewmodel.h" |
|||
|
|||
namespace QtMvvm { |
|||
|
|||
class NetworkExchangeViewModelPrivate |
|||
{ |
|||
public: |
|||
static const quint32 ExportRequestCode = 0xb300; |
|||
|
|||
NetworkExchangeViewModelPrivate(NetworkExchangeViewModel *q_ptr); |
|||
|
|||
QtDataSync::UserExchangeManager *exchangeManager; |
|||
ExchangeDevicesModel *deviceModel; |
|||
quint16 port; |
|||
QHash<quint32, QtDataSync::UserInfo> activeExports; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H
|
@ -0,0 +1,42 @@ |
|||
#include "networkexchangewindow.h" |
|||
#include "networkexchangewindow_p.h" |
|||
#include "ui_networkexchangewindow.h" |
|||
#include <QtMvvmCore/Binding> |
|||
using namespace QtMvvm; |
|||
|
|||
NetworkExchangeWindow::NetworkExchangeWindow(ViewModel *viewModel, QWidget *parent) : |
|||
QWidget(parent, Qt::Window), |
|||
d(new NetworkExchangeWindowPrivate(viewModel)) |
|||
{ |
|||
d->ui->setupUi(this); |
|||
|
|||
connect(d->ui->treeView, &QTreeView::activated, |
|||
this, &NetworkExchangeWindow::activated); |
|||
|
|||
bind(d->viewModel, "port", |
|||
d->ui->exchangePortSpinBox, "value"); |
|||
bind(d->viewModel, "deviceName", |
|||
d->ui->deviceNameLineEdit, "text", |
|||
Binding::TwoWay, |
|||
nullptr, "editingFinished()"); |
|||
bind(d->viewModel, "active", |
|||
d->ui->exchangeCheckBox, "checked", |
|||
Binding::OneWayToViewModel);//NOTE workaround because of buggy active property in datasync
|
|||
|
|||
d->ui->treeView->setModel(d->viewModel->deviceModel()); |
|||
} |
|||
|
|||
NetworkExchangeWindow::~NetworkExchangeWindow() {} |
|||
|
|||
void NetworkExchangeWindow::activated(const QModelIndex &index) |
|||
{ |
|||
if(index.isValid()) |
|||
d->viewModel->exportTo(index.row()); |
|||
} |
|||
|
|||
// ------------- Private Implementation -------------
|
|||
|
|||
NetworkExchangeWindowPrivate::NetworkExchangeWindowPrivate(ViewModel *viewModel) : |
|||
viewModel(static_cast<NetworkExchangeViewModel*>(viewModel)), |
|||
ui(new Ui::NetworkExchangeWindow()) |
|||
{} |
@ -0,0 +1,32 @@ |
|||
#ifndef QTMVVM_NETWORKEXCHANGEWINDOW_H |
|||
#define QTMVVM_NETWORKEXCHANGEWINDOW_H |
|||
|
|||
#include <QtCore/qscopedpointer.h> |
|||
|
|||
#include <QtMvvmDataSyncCore/networkexchangeviewmodel.h> |
|||
|
|||
#include <QtWidgets/qwidget.h> |
|||
|
|||
#include "QtMvvmDataSyncWidgets/qtmvvmdatasyncwidgets_global.h" |
|||
|
|||
namespace QtMvvm { |
|||
|
|||
class NetworkExchangeWindowPrivate; |
|||
class Q_MVVMDATASYNCWIDGETS_EXPORT NetworkExchangeWindow : public QWidget |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
Q_INVOKABLE explicit NetworkExchangeWindow(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); |
|||
~NetworkExchangeWindow(); |
|||
|
|||
private Q_SLOTS: |
|||
void activated(const QModelIndex &index); |
|||
|
|||
private: |
|||
QScopedPointer<NetworkExchangeWindowPrivate> d; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_NETWORKEXCHANGEWINDOW_H
|
@ -0,0 +1,129 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>NetworkExchangeWindow</class> |
|||
<widget class="QWidget" name="NetworkExchangeWindow"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>433</width> |
|||
<height>303</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Form</string> |
|||
</property> |
|||
<layout class="QFormLayout" name="formLayout"> |
|||
<item row="0" column="0"> |
|||
<widget class="QLabel" name="exchangePortLabel"> |
|||
<property name="text"> |
|||
<string>Exchange &Port:</string> |
|||
</property> |
|||
<property name="buddy"> |
|||
<cstring>exchangePortSpinBox</cstring> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="0" column="1"> |
|||
<widget class="QSpinBox" name="exchangePortSpinBox"> |
|||
<property name="specialValueText"> |
|||
<string>Random</string> |
|||
</property> |
|||
<property name="accelerated"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="correctionMode"> |
|||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum> |
|||
</property> |
|||
<property name="showGroupSeparator" stdset="0"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="maximum"> |
|||
<number>65535</number> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="1" column="0"> |
|||
<widget class="QLabel" name="deviceNameLabel"> |
|||
<property name="text"> |
|||
<string>Device &Name:</string> |
|||
</property> |
|||
<property name="buddy"> |
|||
<cstring>deviceNameLineEdit</cstring> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="1" column="1"> |
|||
<widget class="QLineEdit" name="deviceNameLineEdit"> |
|||
<property name="placeholderText"> |
|||
<string>Name shown to other devices</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="2" column="0" colspan="2"> |
|||
<widget class="Line" name="line"> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="3" column="0" colspan="2"> |
|||
<widget class="QCheckBox" name="exchangeCheckBox"> |
|||
<property name="text"> |
|||
<string>&Exchange active:</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="4" column="0" colspan="2"> |
|||
<widget class="QTreeView" name="treeView"> |
|||
<property name="enabled"> |
|||
<bool>false</bool> |
|||
</property> |
|||
<property name="editTriggers"> |
|||
<set>QAbstractItemView::NoEditTriggers</set> |
|||
</property> |
|||
<property name="showDropIndicator" stdset="0"> |
|||
<bool>false</bool> |
|||
</property> |
|||
<property name="alternatingRowColors"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="rootIsDecorated"> |
|||
<bool>false</bool> |
|||
</property> |
|||
<property name="itemsExpandable"> |
|||
<bool>false</bool> |
|||
</property> |
|||
<property name="sortingEnabled"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="animated"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="expandsOnDoubleClick"> |
|||
<bool>false</bool> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections> |
|||
<connection> |
|||
<sender>exchangeCheckBox</sender> |
|||
<signal>toggled(bool)</signal> |
|||
<receiver>treeView</receiver> |
|||
<slot>setEnabled(bool)</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>93</x> |
|||
<y>151</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>118</x> |
|||
<y>229</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
</connections> |
|||
</ui> |
@ -0,0 +1,24 @@ |
|||
#ifndef QTMVVM_NETWORKEXCHANGEWINDOW_P_H |
|||
#define QTMVVM_NETWORKEXCHANGEWINDOW_P_H |
|||
|
|||
#include "qtmvvmdatasyncwidgets_global.h" |
|||
#include "networkexchangewindow.h" |
|||
|
|||
namespace Ui { |
|||
class NetworkExchangeWindow; |
|||
} |
|||
|
|||
namespace QtMvvm { |
|||
|
|||
class NetworkExchangeWindowPrivate |
|||
{ |
|||
public: |
|||
NetworkExchangeWindowPrivate(ViewModel *viewModel); |
|||
|
|||
NetworkExchangeViewModel *viewModel; |
|||
QScopedPointer<Ui::NetworkExchangeWindow> ui; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_NETWORKEXCHANGEWINDOW_P_H
|
Loading…
Reference in new issue