void MongoConnectionPool::removeHost(const std::string& host) { std::string errMsg; ConnectionString cs = ConnectionString::parse(host, errMsg); if(cs.isValid()) removeHost(cs); }
ConnectDialog::ConnectDialog(QWidget *parent) : QDialog(parent) { setAttribute(Qt::WA_DeleteOnClose, true); setWindowTitle("Kodimote - " + tr("Connect to Kodi")); m_stackedLayout = new QStackedLayout(); KodiDiscovery *discovery = new KodiDiscovery(this); discovery->setContinuousDiscovery(true); m_hostView = new QListView(); m_hostView->setModel(Kodi::instance()->hostModel()); m_stackedLayout->addWidget(m_hostView); QLabel *infoLabel = new QLabel(tr("Searching for Kodi hosts.") + "\n" + tr("Please enable the following options in the Services settings of Kodi:") + "\n- " + tr("Allow control of Kodi via HTTP") + "\n- " + tr("Allow programs on other systems to control Kodi") + "\n- " + tr("Announce these services to other systems via Zeroconf") + "\n" + tr("If you don't use Zeroconf, add a host manually.")); infoLabel->setWordWrap(true); infoLabel->setAlignment(Qt::AlignCenter); m_stackedLayout->addWidget(infoLabel); m_manualLayout = new QGridLayout(); QWidget *manualWidget = new QWidget(); manualWidget->setLayout(m_manualLayout); m_stackedLayout->addWidget(manualWidget); #ifdef Q_WS_MAEMO_5 QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->addLayout(m_stackedLayout); setLayout(hLayout); #else QVBoxLayout *vLayout = new QVBoxLayout(); vLayout->addLayout(m_stackedLayout); setLayout(vLayout); #endif m_manualLayout->addWidget(new QLabel(tr("Host:")), 0, 0); m_hostName = new QLineEdit(); m_manualLayout->addWidget(m_hostName, 0, 1); m_manualLayout->addWidget(new QLabel(tr("HTTP Port:")), 1, 0); m_port = new QLineEdit(); m_port->setValidator(new QIntValidator()); m_port->setText("8080"); m_manualLayout->addWidget(m_port, 1, 1); m_manualLayout->addWidget(new QLabel(tr("MAC Address (optional):")), 2, 0); m_mac = new QLineEdit(); m_mac->setInputMask("HH:HH:HH:HH:HH:HH;_"); m_manualLayout->addWidget(m_mac, 2, 1); // gridLayout->addWidget(new QLabel("Username:"******"Password:"******"Connect")); m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_manualButton = m_buttonBox->addButton(tr("Add Host"), QDialogButtonBox::ActionRole); connect(m_manualButton, SIGNAL(clicked()), SLOT(showManualLayout())); m_removeButton = m_buttonBox->addButton(tr("Remove Host"), QDialogButtonBox::ResetRole); connect(m_removeButton, SIGNAL(clicked()), SLOT(removeHost())); m_removeButton->setEnabled(false); connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); if(Kodi::instance()->hostModel()->rowCount(QModelIndex()) > 0) { showHostList(); } else { m_stackedLayout->setCurrentIndex(1); } connect(Kodi::instance()->hostModel(), SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(showHostList())); connect(m_hostView, SIGNAL(clicked(QModelIndex)), SLOT(enableOkButton())); #ifdef Q_WS_MAEMO_5 setMinimumHeight(400); #endif }