oolist.cpp
来自「磁盘管理工具,主要管理光盘信息和内容希望大家喜欢」· C++ 代码 · 共 566 行 · 第 1/2 页
CPP
566 行
/// \param iter: Iterator to position in the list/// \returns HCelebrity: Handle of the selected line//-----------------------------------------------------------------------------HCelebrity OwnerObjectList::getCelebrityAt (const Gtk::TreeIter iter) const { TRACE9 ("GetCelibrity: " << (*iter)[colOwnerObjects->name]); Check2 (!(*iter)->parent ()); Check2 (colOwnerObjects); HEntity hObj ((*iter)[colOwnerObjects->entry]); Check3 (hObj.isDefined ()); HCelebrity owner (HCelebrity::cast (hObj)); TRACE7 ("CDManager::getCelebrityAt (const Gtk::TreeIter&) - Selected: " << owner->getId () << '/' << owner->getName ()); return owner;}//-----------------------------------------------------------------------------/// Sets the name of the object/// \param object: Object to change/// \param value: Value to set/// \remarks To be implemented//-----------------------------------------------------------------------------void OwnerObjectList::setName (HEntity& object, const Glib::ustring& value) {}//-----------------------------------------------------------------------------/// Sets the year of the object/// \param object: Object to change/// \param value: Value to set/// \throw std::exception: In case of an error/// \remarks To be implemented//-----------------------------------------------------------------------------void OwnerObjectList::setYear (HEntity& object, const Glib::ustring& value) throw (std::exception) {}//-----------------------------------------------------------------------------/// Sets the genre of the object/// \param object: Object to change/// \param value: Value to set/// \remarks To be implemented//-----------------------------------------------------------------------------void OwnerObjectList::setGenre (HEntity& object, unsigned int value) {}//-----------------------------------------------------------------------------/// Sets the genre in the passed row/// \param row: Row to change/// \param value: Value to set//-----------------------------------------------------------------------------void OwnerObjectList::changeGenre (Gtk::TreeModel::Row& row, unsigned int value) { TRACE9 ("OwnerObjectList::changeGenre (Gtk::TreeModel::Row&, unsigned int) - " << value); Check2 (colOwnerObjects); if (value >= genres.size ()) value = 0; row[colOwnerObjects->genre] = genres[value];}//-----------------------------------------------------------------------------/// Sorts the entries in the listbox according to the name (ignoring first names,/// articles, ...)/// \param a: First entry to compare/// \param a: Second entry to compare/// \returns int: Value as strcmp//-----------------------------------------------------------------------------int OwnerObjectList::sortByName (const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b) const { Check2 (a->parent () == b->parent ()); if (a->parent ()) return sortEntity (a, b); else return sortOwner (a, b);}//-----------------------------------------------------------------------------/// Sorts the entries in the listbox according to the year/// \param a: First entry to compare/// \param a: Second entry to compare/// \returns int: Value as strcmp//-----------------------------------------------------------------------------int OwnerObjectList::sortByYear (const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b) const { Check2 (a->parent () == b->parent ()); if (a->parent ()) { Gtk::TreeRow ra (*a); Gtk::TreeRow rb (*b); Glib::ustring sa (ra[colOwnerObjects->year]); Glib::ustring sb (rb[colOwnerObjects->year]); YGP::AYear ya (sa); YGP::AYear yb (sb); return ya.compare (yb); } else return sortOwner (a, b);}//-----------------------------------------------------------------------------/// Sorts the entries in the listbox according to the genre/// \param a: First entry to compare/// \param a: Second entry to compare/// \returns int: Value as strcmp//-----------------------------------------------------------------------------int OwnerObjectList::sortByGenre (const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b) const { if ((*a)->parent ()) { Gtk::TreeRow ra (*a); Gtk::TreeRow rb (*b); Check2 (rb->parent ()); Glib::ustring sa (ra[colOwnerObjects->genre]); Glib::ustring sb (rb[colOwnerObjects->genre]); return sa.compare (sb); } else return sortOwner (a, b);}//-----------------------------------------------------------------------------/// Sorts the owner in the listbox according to the name/// \param a: First entry to compare/// \param a: Second entry to compare/// \returns int: Value as strcmp//-----------------------------------------------------------------------------int OwnerObjectList::sortOwner (const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b) const { Check2 (!a->parent ()); Check2 (!b->parent ()); HCelebrity ha (getCelebrityAt (a)); Check3 (ha.isDefined ()); HCelebrity hb (getCelebrityAt (b)); Check3 (hb.isDefined ()); TRACE9 ("OwnerObjectList::sortOwner (2x const Gtk::TreeModel::iterator&) - " << ha->getName () << "<->" << hb->getName ()); int rc (Celebrity::removeIgnored (ha->getName ()).compare (Celebrity::removeIgnored (hb->getName ()))); return rc ? rc : (ha->getName () < hb->getName ());}//-----------------------------------------------------------------------------/// Sorts the entries in the listbox according to the name/// \param a: First entry to compare/// \param a: Second entry to compare/// \returns int: Value as strcmp//-----------------------------------------------------------------------------int OwnerObjectList::sortEntity (const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b) const { Check2 (a->parent ()); Check2 (b->parent ()); Check2 (colOwnerObjects); Gtk::TreeRow ra (*a); Gtk::TreeRow rb (*b); Check2 (rb->parent ()); Glib::ustring sa (ra[colOwnerObjects->name]); Glib::ustring sb (rb[colOwnerObjects->name]); TRACE9 ("OwnerObjectList::sortEntity (2x const Gtk::TreeModel::iterator&) - " << sa << '/' << sb << '=' << sa.compare (sb)); return sa.compare (sb);}//-----------------------------------------------------------------------------/// Returns an iterator to the owner having the passed value as name/// \param name: Name of entry/// \returns Gtk::TreeModel::iterator: Iterator to found entry or end ().//-----------------------------------------------------------------------------Gtk::TreeModel::iterator OwnerObjectList::getOwner (const Glib::ustring& name) const { Check2 (colOwnerObjects); for (Gtk::TreeModel::const_iterator i (mOwnerObjects->children ().begin ()); i != mOwnerObjects->children ().end (); ++i) { Gtk::TreeModel::Row actRow (*i); if (actRow[colOwnerObjects->name] == name) return i; } return mOwnerObjects->children ().end ();}//-----------------------------------------------------------------------------/// Returns an iterator to the owner identified by the passed handle/// \param owner: Handle to owner/// \returns Gtk::TreeModel::iterator: Iterator to found entry or end ().//-----------------------------------------------------------------------------Gtk::TreeModel::iterator OwnerObjectList::getOwner (const HCelebrity& owner) const { Check2 (colOwnerObjects); Check2 (owner.isDefined ()); HEntity obj (HEntity::cast (owner)); for (Gtk::TreeModel::const_iterator i (mOwnerObjects->children ().begin ()); i != mOwnerObjects->children ().end (); ++i) { Gtk::TreeModel::Row actRow (*i); if (obj == actRow[colOwnerObjects->entry]) return i; } return mOwnerObjects->children ().end ();}//-----------------------------------------------------------------------------/// Returns an iterator to the children having the passed value as name/// \param parent: Parent row/// \param name: Name of entry/// \returns Gtk::TreeModel::iterator: Iterator to found entry or end ().//-----------------------------------------------------------------------------Gtk::TreeModel::iterator OwnerObjectList::getObject (const Gtk::TreeIter& parent, const Glib::ustring& name) const { Check2 (colOwnerObjects); for (Gtk::TreeModel::const_iterator i (parent->children ().begin ()); i != parent->children ().end (); ++i) { Gtk::TreeModel::Row actRow (*i); if (actRow[colOwnerObjects->name] == name) return i; } return parent->children ().end ();}//-----------------------------------------------------------------------------/// Returns an iterator to the children identified by the passed object/// \param parent: Parent row/// \param object: Entry to find/// \returns Gtk::TreeModel::iterator: Iterator to found entry or end ().//-----------------------------------------------------------------------------Gtk::TreeModel::iterator OwnerObjectList::getObject (const Gtk::TreeIter& parent, const HEntity& object) const { Check2 (colOwnerObjects); for (Gtk::TreeModel::const_iterator i (parent->children ().begin ()); i != parent->children ().end (); ++i) { Gtk::TreeModel::Row actRow (*i); if (object == actRow[colOwnerObjects->entry]) return i; } return parent->children ().end ();}//-----------------------------------------------------------------------------/// Returns an iterator to the children identified by the passed object/// \param object: Entry to find/// \returns Gtk::TreeModel::iterator: Iterator to found entry or end ().//-----------------------------------------------------------------------------Gtk::TreeModel::iterator OwnerObjectList::getObject (const HEntity& object) const { Check2 (colOwnerObjects); for (Gtk::TreeModel::const_iterator i (mOwnerObjects->children ().begin ()); i != mOwnerObjects->children ().end (); ++i) for (Gtk::TreeModel::const_iterator j (i->children ().begin ()); j != i->children ().end (); ++j) { Gtk::TreeModel::Row actRow (*j); if (object == actRow[colOwnerObjects->entry]) return j; } return mOwnerObjects->children ().end ();}//-----------------------------------------------------------------------------/// Selects the passed row (as only one) and centers it/// \param i: Iterator to row to select//-----------------------------------------------------------------------------void OwnerObjectList::selectRow (const Gtk::TreeModel::const_iterator& i) { Glib::RefPtr<Gtk::TreeSelection> sel (get_selection ()); Gtk::TreePath path (mOwnerObjects->get_path (i)); scroll_to_row (path, 0.5); set_cursor (path); sel->select (path);}//-----------------------------------------------------------------------------/// Updates the displayed movies, showing them in the passed language/// \param row: Row to update/// \param obj: Object, whose values to set//-----------------------------------------------------------------------------void OwnerObjectList::set (Gtk::TreeModel::Row& row, const HEntity& obj) { row[colOwnerObjects->entry] = obj; update (row);}//-----------------------------------------------------------------------------/// Updates the displayed movies, showing them in the passed language/// \param row: Row to update//-----------------------------------------------------------------------------void OwnerObjectList::update (Gtk::TreeModel::Row& row) { if (row->parent ()) row[colOwnerObjects->chgAll] = true; else { HCelebrity owner (getCelebrityAt (row)); row[colOwnerObjects->name] = owner->getName (); row[colOwnerObjects->year] = owner->getLifespan (); row[colOwnerObjects->chgAll] = false; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?