mirror of https://github.com/f1xpl/openauto.git
Load recent addresses list
parent
258a6a3c59
commit
f01f057b68
|
@ -29,26 +29,25 @@ public:
|
|||
|
||||
signals:
|
||||
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);
|
||||
|
||||
private slots:
|
||||
void onConnectButtonClicked();
|
||||
void onConnectionFailed(const QString& message);
|
||||
void onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, std::string ipAddress);
|
||||
void setControlsEnabledStatus(bool status);
|
||||
void connectHandler(const boost::system::error_code& ec, std::string ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket);
|
||||
void onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, const std::string& ipAddress);
|
||||
|
||||
private:
|
||||
void insertIpAddress(std::string ipAddress);
|
||||
void insertIpAddress(const std::string& ipAddress);
|
||||
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_;
|
||||
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
||||
openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList_;
|
||||
Ui::ConnectDialog *ui_;
|
||||
QStringListModel recentAddressesModel_;
|
||||
QStringList recentAddressesModelList_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ ConnectDialog::ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITC
|
|||
, ui_(new Ui::ConnectDialog)
|
||||
{
|
||||
qRegisterMetaType<aasdk::tcp::ITCPEndpoint::SocketPointer>("aasdk::tcp::ITCPEndpoint::SocketPointer");
|
||||
qRegisterMetaType<std::string>("std::string");
|
||||
|
||||
ui_->setupUi(this);
|
||||
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::connectionFailed, this, &ConnectDialog::onConnectionFailed);
|
||||
|
||||
recentAddressesModel_.setStringList(recentAddressesModelList_);
|
||||
ui_->listViewRecent->setModel(&recentAddressesModel_);
|
||||
this->loadRecentList();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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->setControlsEnabledStatus(true);
|
||||
|
@ -90,16 +91,18 @@ void ConnectDialog::setControlsEnabledStatus(bool status)
|
|||
|
||||
void ConnectDialog::loadRecentList()
|
||||
{
|
||||
recentAddressesModelList_.clear();
|
||||
QStringList stringList;
|
||||
const auto& configList = recentAddressesList_.getList();
|
||||
|
||||
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);
|
||||
this->loadRecentList();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <f1x/aasdk/TCP/TCPWrapper.hpp>
|
||||
#include <f1x/openauto/autoapp/App.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/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
||||
|
@ -90,8 +91,11 @@ int main(int argc, char* argv[])
|
|||
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
||||
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
|
||||
autoapp::configuration::RecentAddressesList recentAddressesList(5);
|
||||
recentAddressesList.read();
|
||||
|
||||
aasdk::tcp::TCPWrapper tcpWrapper;
|
||||
autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper);
|
||||
autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper, recentAddressesList);
|
||||
connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { std::exit(0); });
|
||||
|
|
Loading…
Reference in New Issue