diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-12-12 15:47:00 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-12-12 15:47:00 -0800 |
| commit | 9ffda4f955283c50e559c23541567cca5fbf1607 (patch) | |
| tree | 12a9a5ac38eaaa2a676c1e6f3d3fbc6495ec4f0f /ZeroTierUI/network.cpp | |
| parent | 239c9e46ea7e0279f95197cc2dc62bb1dd69aa8f (diff) | |
| download | infinitytier-9ffda4f955283c50e559c23541567cca5fbf1607.tar.gz infinitytier-9ffda4f955283c50e559c23541567cca5fbf1607.zip | |
Update Qt build to enable building against local static libraries, rename Network to NetworkWidget to avoid filesystem or object naming collision with Network.o in node/.
Diffstat (limited to 'ZeroTierUI/network.cpp')
| -rw-r--r-- | ZeroTierUI/network.cpp | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/ZeroTierUI/network.cpp b/ZeroTierUI/network.cpp deleted file mode 100644 index e23bc6ba..00000000 --- a/ZeroTierUI/network.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "network.h" -#include "mainwindow.h" -#include "ui_network.h" - -#include <QClipboard> -#include <QString> -#include <QStringList> -#include <QCoreApplication> -#include <QProcess> -#include <QList> -#include <QMessageBox> - -Network::Network(QWidget *parent,const std::string &nwid) : - QWidget(parent), - ui(new Ui::Network), - networkIdStr(nwid) -{ - ui->setupUi(this); - ui->networkIdPushButton->setText(QString(nwid.c_str())); - QFontMetrics fm(ui->ipListWidget->font()); - int lineHeight = ui->ipListWidget->spacing() + fm.height(); - ui->ipListWidget->setMinimumHeight(lineHeight * 3); - ui->ipListWidget->setMaximumHeight(lineHeight * 3); -} - -Network::~Network() -{ - delete ui; -} - -void Network::setStatus(const std::string &status,const std::string &age) -{ - ui->statusLabel->setText(QString(status.c_str())); - if (status == "OK") - ui->ageLabel->setText(QString("(configuration is ") + age.c_str() + " seconds old)"); - else ui->ageLabel->setText(QString()); -} - -void Network::setNetworkName(const std::string &name) -{ - ui->nameLabel->setText(QString(name.c_str())); -} - -void Network::setNetworkType(const std::string &type) -{ - ui->networkTypeLabel->setText(QString(type.c_str())); - if (type == "?") - ui->networkTypeLabel->setToolTip("Waiting for configuration..."); - else if (type == "public") - ui->networkTypeLabel->setToolTip("This network can be joined by anyone."); - else if (type == "private") - ui->networkTypeLabel->setToolTip("This network is private, only authorized peers can join."); - else ui->networkTypeLabel->setToolTip(QString()); -} - -void Network::setNetworkDeviceName(const std::string &dev) -{ - ui->deviceLabel->setText(QString(dev.c_str())); -} - -void Network::setIps(const std::string &commaSeparatedList) -{ - QStringList ips(QString(commaSeparatedList.c_str()).split(QChar(','),QString::SkipEmptyParts)); - if (commaSeparatedList == "-") - ips.clear(); - - QStringList tmp; - ips.sort(); - for(QStringList::iterator i(ips.begin());i!=ips.end();++i) { - QString ipOnly(*i); - int slashIdx = ipOnly.indexOf('/'); - if (slashIdx > 0) - ipOnly.truncate(slashIdx); - tmp.append(ipOnly); - } - ips = tmp; - - for(QStringList::iterator i(ips.begin());i!=ips.end();++i) { - if (ui->ipListWidget->findItems(*i,Qt::MatchCaseSensitive).size() == 0) - ui->ipListWidget->addItem(*i); - } - - for(int i=0;i<ui->ipListWidget->count();++i) { - QListWidgetItem *item = ui->ipListWidget->item(i); - if (!ips.contains(item->text())) - ui->ipListWidget->removeItemWidget(item); - } -} - -const std::string &Network::networkId() -{ - return networkIdStr; -} - -void Network::on_leaveNetworkButton_clicked() -{ - if (QMessageBox::question(this,"Leave Network?",QString("Are you sure you want to leave network '") + networkIdStr.c_str() + "'?",QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) { - zeroTierClient->send((QString("leave ") + networkIdStr.c_str()).toStdString()); - this->setEnabled(false); - } -} - -void Network::on_networkIdPushButton_clicked() -{ - QApplication::clipboard()->setText(ui->networkIdPushButton->text()); -} |
