bool RemoteSelectionFrame::populateNameComboAndSelect(QString sel) // ---------------------------------------------------------------------------- // Re-fill remotes combo box and select a name, or <None> if sel == "" // ---------------------------------------------------------------------------- { // The contents of the combo box depends on the newly selected item. // The combo is split in two sections: // (1) the list of remotes, including "<None>", and // (2) a list of actions (add/rename/delete). // If "<None>" is selected, only the "Add" action is present ; if a name is // chosen, the delete and rename actions are added, too. if (!populateNameCombo()) return false; if (sel.isEmpty()) { urlEdit->clear(); urlEdit->setEnabled(false); emit noneSelected(); return true; } int index = nameCombo->findText(sel); if (index == -1) return false; int kind = nameCombo->itemData(index).toInt(); if (kind != CIK_None && kind != CIK_Name) return false; if (kind == CIK_Name) { prevSelected = sel; nameCombo->addItem(tr("Rename %1...").arg(sel), CIK_Rename); nameCombo->addItem(tr("Delete %1...").arg(sel), CIK_Delete); index = nameCombo->findText(sel); if (index == -1) return false; nameCombo->setCurrentIndex(index); // Also update URL field QString url; if (whatFor == RSF_Fetch) url = repo->remoteFetchUrl(sel); else url = repo->remotePushUrl(sel); urlEdit->setText(url); urlEdit->setEnabled(true); emit nameSelected(); } else if (kind == CIK_None) { emit noneSelected(); } return true; }
void CollectionSelectorModel::indexChanged(int index) { int id = 0; if (index >= 0) // QComboBox will send -1 if the current item is removed. id = _root->child(index, 0)->data(Qt::UserRole).toInt(); if (id > 0) { _collection = QPointer<Collection>(new Collection(_db, id)); emit collectionSelected(id); return; } if (_all) { emit allSelected(); return; } emit noneSelected(); }