QString ProfilePlotView::profileLabel(Profile::Ptr profile) { if (profile->name()) return QString::fromStdString(profile->name().get()); if (profile->computer()) { if (profile->computer()->name()) return QString::fromStdString(profile->computer()->name().get()); if (profile->computer()->model()) { if (profile->computer()->manufacturer()) { return QString("%1 %2") .arg(QString::fromStdString(profile->computer()->manufacturer().get())) .arg(QString::fromStdString(profile->computer()->model().get())); } else { return QString::fromStdString(profile->computer()->model().get()); } } } return "Unknown Profile"; }
void ProfileMapper::bindUpdate(statement::ptr s, Persistent::Ptr p) const { Profile::Ptr o = downcast(p); if (o->dive()) s->bind(2, o->dive()->id()); else s->bind(2); if (o->computer()) s->bind(3, o->computer()->id()); else s->bind(3); if (o->profile().empty()) s->bind(5); else s->bind(5, profileToJSON(o->profile())); s->bind(4, o->name()); s->bind(6, o->vendor()); s->bind(7, o->imported()); s->bind(8, o->raw_profile()); }
std::list<Persistent::Ptr> ProfileMapper::cascade_add(Persistent::Ptr p) { std::list<Persistent::Ptr> result; Profile::Ptr o = downcast(p); if (! o) return result; if (o->computer()) result.push_back(o->computer()); if (o->dive()) result.push_back(o->dive()); std::set<Mix::Ptr> mixes; std::list<waypoint>::const_iterator it; for (it = o->profile().begin(); it != o->profile().end(); it++) mixes.insert(it->mix); std::set<Mix::Ptr>::iterator it2; for (it2 = mixes.begin(); it2 != mixes.end(); it2++) result.push_back(* it2); return result; }