Load recent addresses list
This commit is contained in:
parent
258a6a3c59
commit
f01f057b68
@ -29,26 +29,25 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectToDevice(const QString& ipAddress);
|
void connectToDevice(const QString& ipAddress);
|
||||||
void connectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, std::string ipAddress);
|
void connectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, const std::string& ipAddress);
|
||||||
void connectionFailed(const QString& message);
|
void connectionFailed(const QString& message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onConnectButtonClicked();
|
void onConnectButtonClicked();
|
||||||
void onConnectionFailed(const QString& message);
|
void onConnectionFailed(const QString& message);
|
||||||
void onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, std::string ipAddress);
|
void onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, const std::string& ipAddress);
|
||||||
void setControlsEnabledStatus(bool status);
|
|
||||||
void connectHandler(const boost::system::error_code& ec, std::string ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void insertIpAddress(std::string ipAddress);
|
void insertIpAddress(const std::string& ipAddress);
|
||||||
void loadRecentList();
|
void loadRecentList();
|
||||||
|
void setControlsEnabledStatus(bool status);
|
||||||
|
void connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket);
|
||||||
|
|
||||||
boost::asio::io_service& ioService_;
|
boost::asio::io_service& ioService_;
|
||||||
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
||||||
openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList_;
|
openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList_;
|
||||||
Ui::ConnectDialog *ui_;
|
Ui::ConnectDialog *ui_;
|
||||||
QStringListModel recentAddressesModel_;
|
QStringListModel recentAddressesModel_;
|
||||||
QStringList recentAddressesModelList_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ ConnectDialog::ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITC
|
|||||||
, ui_(new Ui::ConnectDialog)
|
, ui_(new Ui::ConnectDialog)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<aasdk::tcp::ITCPEndpoint::SocketPointer>("aasdk::tcp::ITCPEndpoint::SocketPointer");
|
qRegisterMetaType<aasdk::tcp::ITCPEndpoint::SocketPointer>("aasdk::tcp::ITCPEndpoint::SocketPointer");
|
||||||
|
qRegisterMetaType<std::string>("std::string");
|
||||||
|
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &ConnectDialog::close);
|
connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &ConnectDialog::close);
|
||||||
@ -26,8 +27,8 @@ ConnectDialog::ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITC
|
|||||||
connect(this, &ConnectDialog::connectionSucceed, this, &ConnectDialog::onConnectionSucceed);
|
connect(this, &ConnectDialog::connectionSucceed, this, &ConnectDialog::onConnectionSucceed);
|
||||||
connect(this, &ConnectDialog::connectionFailed, this, &ConnectDialog::onConnectionFailed);
|
connect(this, &ConnectDialog::connectionFailed, this, &ConnectDialog::onConnectionFailed);
|
||||||
|
|
||||||
recentAddressesModel_.setStringList(recentAddressesModelList_);
|
|
||||||
ui_->listViewRecent->setModel(&recentAddressesModel_);
|
ui_->listViewRecent->setModel(&recentAddressesModel_);
|
||||||
|
this->loadRecentList();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectDialog::~ConnectDialog()
|
ConnectDialog::~ConnectDialog()
|
||||||
@ -52,7 +53,7 @@ void ConnectDialog::onConnectButtonClicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectDialog::connectHandler(const boost::system::error_code& ec, std::string ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
void ConnectDialog::connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||||
{
|
{
|
||||||
if(!ec)
|
if(!ec)
|
||||||
{
|
{
|
||||||
@ -65,7 +66,7 @@ void ConnectDialog::connectHandler(const boost::system::error_code& ec, std::str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectDialog::onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer, std::string ipAddress)
|
void ConnectDialog::onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer, const std::string& ipAddress)
|
||||||
{
|
{
|
||||||
this->insertIpAddress(ipAddress);
|
this->insertIpAddress(ipAddress);
|
||||||
this->setControlsEnabledStatus(true);
|
this->setControlsEnabledStatus(true);
|
||||||
@ -90,16 +91,18 @@ void ConnectDialog::setControlsEnabledStatus(bool status)
|
|||||||
|
|
||||||
void ConnectDialog::loadRecentList()
|
void ConnectDialog::loadRecentList()
|
||||||
{
|
{
|
||||||
recentAddressesModelList_.clear();
|
QStringList stringList;
|
||||||
const auto& configList = recentAddressesList_.getList();
|
const auto& configList = recentAddressesList_.getList();
|
||||||
|
|
||||||
for(const auto& element : configList)
|
for(const auto& element : configList)
|
||||||
{
|
{
|
||||||
recentAddressesModelList_.append(QString::fromStdString(element));
|
stringList.append(QString::fromStdString(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recentAddressesModel_.setStringList(stringList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectDialog::insertIpAddress(std::string ipAddress)
|
void ConnectDialog::insertIpAddress(const std::string& ipAddress)
|
||||||
{
|
{
|
||||||
recentAddressesList_.insertAddress(ipAddress);
|
recentAddressesList_.insertAddress(ipAddress);
|
||||||
this->loadRecentList();
|
this->loadRecentList();
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <f1x/aasdk/TCP/TCPWrapper.hpp>
|
#include <f1x/aasdk/TCP/TCPWrapper.hpp>
|
||||||
#include <f1x/openauto/autoapp/App.hpp>
|
#include <f1x/openauto/autoapp/App.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
||||||
@ -90,8 +91,11 @@ int main(int argc, char* argv[])
|
|||||||
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
||||||
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
|
autoapp::configuration::RecentAddressesList recentAddressesList(5);
|
||||||
|
recentAddressesList.read();
|
||||||
|
|
||||||
aasdk::tcp::TCPWrapper tcpWrapper;
|
aasdk::tcp::TCPWrapper tcpWrapper;
|
||||||
autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper);
|
autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper, recentAddressesList);
|
||||||
connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint);
|
connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { std::exit(0); });
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { std::exit(0); });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user