void FavoriteHubs::slotDblClicked(){ FavoriteHubItem *item = getItem(); if (!item) return; QString address = item->data(COLUMN_HUB_ADDRESS).toString(); FavoriteHubEntry *entry = FavoriteManager::getInstance()->getFavoriteHubEntry(address.toStdString()); QString encoding = WulforUtil::getInstance()->dcEnc2QtEnc(_q(entry->getEncoding())); MainWindow::getInstance()->newHubFrame(address, encoding); }
void QuickConnect::slotAccept() { QString hub = comboBox_HUB->currentText(); QString encoding = ""; hub.replace(" ", ""); if (hub.isEmpty()){ accept(); return; } if (hub.startsWith("adc://") || hub.startsWith("adcs://")) encoding = "UTF-8"; if (!hub.isEmpty()) { if (encoding.isEmpty()){//Has favorite entry for hub? FavoriteHubEntry* entry = FavoriteManager::getInstance()->getFavoriteHubEntry(_tq(hub)); if (entry) encoding = WulforUtil::getInstance()->dcEnc2QtEnc(_q(entry->getEncoding())); } MainWindow::getInstance()->newHubFrame(hub, (encoding.isEmpty())? (WSGET(WS_DEFAULT_LOCALE)) : (encoding)); QStringList list = WulforSettings::getInstance()->getStr(WS_QCONNECT_HISTORY).split(" ", QString::SkipEmptyParts); if (!list.contains(hub)) list.push_back(hub); else{ accept(); return; } QString hist = ""; foreach (const QString &i, list) hist += (i + " "); WulforSettings::getInstance()->setStr(WS_QCONNECT_HISTORY, hist); } accept(); }
void FavoriteHubs::init(){ model = new FavoriteHubModel(); setUnload(false); treeView->setModel(model); fakeNMDCTags = QStringList(); fakeADCTags = QStringList(); fakeNMDCTags << QString("%1").arg(fullVersionString) << "++ V:0.782" << "++ V:0.791" << "StrgDC++ V:2.42" << "ApexDC++ V:1.3.6" << "ApexDC++ V:1.5.1" << "FlylinkDC++ V:r500" << "FlylinkDC++ V:r500-x64" << "FlylinkDC++ V:r501-beta60" << "HomeDC++ V:2.22" << "FakeDC++ V:1.3"; fakeADCTags << QString("%1").arg(fullADCVersionString) << "++ 0.782" << "++ 0.791" << "StrgDC++ 2.42" << "ApexDC++ 1.3.6" << "ApexDC++ 1.5.1" << "FlylinkDC++ r500" << "FlylinkDC++ r500-x64" << "FlylinkDC++ r501-beta60" << "HomeDC++ 2.22" << "FakeDC++ 1.3"; const FavoriteHubEntryList& fl = FavoriteManager::getInstance()->getFavoriteHubs(); for(FavoriteHubEntryList::const_iterator i = fl.begin(); i != fl.end(); ++i) { FavoriteHubEntry* entry = *i; QList<QVariant> data; data << entry->getConnect() << _q(entry->getName()) << _q(entry->getDescription()) << _q(entry->getServer()) << _q(entry->getNick()) << _q(entry->getPassword()) << _q(entry->getUserDescription()) << WulforUtil::getInstance()->dcEnc2QtEnc(_q(entry->getEncoding())); model->addResult(data); } treeView->setRootIsDecorated(false); treeView->setContextMenuPolicy(Qt::CustomContextMenu); treeView->header()->setContextMenuPolicy(Qt::CustomContextMenu); treeView->viewport()->setAcceptDrops(false); // temporary treeView->setDragEnabled(false); // temporary treeView->setAcceptDrops(false); // temporary WulforUtil *WU = WulforUtil::getInstance(); add_newButton->setIcon(WU->getPixmap(WulforUtil::eiBOOKMARK_ADD)); changeButton->setIcon(WU->getPixmap(WulforUtil::eiEDIT)); removeButton->setIcon(WU->getPixmap(WulforUtil::eiEDITDELETE)); connectButton->setIcon(WU->getPixmap(WulforUtil::eiCONNECT)); load(); int row_num = model->rowCount(); if (row_num == 0){ changeButton->setEnabled(false); removeButton->setEnabled(false); connectButton->setEnabled(false); } connect(treeView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContexMenu(const QPoint&))); connect(treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotClicked(QModelIndex))); connect(treeView->header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotHeaderMenu())); connect(treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotDblClicked())); connect(add_newButton, SIGNAL(clicked()), this, SLOT(slotAdd_newButtonClicked())); connect(changeButton, SIGNAL(clicked()), this, SLOT(slotChangeButtonClicked())); connect(removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveButtonClicked())); connect(connectButton, SIGNAL(clicked()), this, SLOT(slotConnectButtonClicked())); connect(WulforSettings::getInstance(), SIGNAL(strValueChanged(QString,QString)), this, SLOT(slotSettingsChanged(QString,QString))); ArenaWidget::setState( ArenaWidget::Flags(ArenaWidget::state() | ArenaWidget::Singleton | ArenaWidget::Hidden) ); }