bool BootstrapModelPrivate::save() { QString ret; for(const Lines* l : m_lines) { if (!l->hostname.trimmed().isEmpty()) { if (ret.size()) ret += ';'; ret += l->hostname + (l->port > -1? ':'+QString::number(l->port):QString()); } } //Clear empty lines bool val = true; for(int i=0;i<m_lines.size();i++) { Lines* l = m_lines[i]; if (l->hostname.isEmpty() && l->port == -1) { q_ptr->beginRemoveRows(QModelIndex(),i,i); const int idx = m_lines.indexOf(l); if (idx >= 0) m_lines.removeAt(idx); q_ptr->endRemoveRows(); val = false; } } m_pAccount->d_ptr->setAccountProperty(DRing::Account::ConfProperties::HOSTNAME,ret); return val; }
void BootstrapModelPrivate::clearLines() { if (m_lines.size() > 0) { q_ptr->beginRemoveRows(QModelIndex(), 0, m_lines.size()); for (int i = 0; i < m_lines.size(); i++) delete m_lines[i]; m_lines.clear(); q_ptr->endRemoveRows(); } }