QWidget* TodoListDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { switch (index.column ()) { case StorageModel::Columns::Tags: { auto edit = new Util::TagsLineEdit (parent); new Util::TagsCompleter (edit); edit->AddSelector (); edit->setText (index.data (Qt::EditRole).toString ()); edit->setFrame (false); return edit; } case StorageModel::Columns::DueDate: case StorageModel::Columns::Created: { auto edit = new QDateTimeEdit (parent); edit->setFrame (false); edit->setCalendarPopup (true); edit->setDateTime (index.data (Qt::EditRole).toDateTime ()); return edit; } default: return QStyledItemDelegate::createEditor (parent, option, index); } }
/** * Add an edge with empty information associated * @param source is the source of the edge * @param target is the target of the edge * @param selector is the selector to be added * @return the created edge */ inline EdgeDescriptor AddEdge(const vertex source, const vertex target, const int selector) { if(ExistsEdge(source, target)) return AddSelector(source, target, selector); else return InternalAddEdge(source, target, selector, EdgeInfoRef(new OpEdgeInfo())); }
QWidget* EntriesDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { switch (index.column ()) { case EntriesModel::Columns::Account: case EntriesModel::Columns::EntryCurrency: return new QComboBox (parent); case EntriesModel::Columns::Categories: { auto result = new Util::TagsLineEdit (parent); auto completer = new Util::TagsCompleter (result, result); const auto& cats = Core::Instance ().GetOpsManager ()->GetKnownCategories ().toList (); completer->OverrideModel (new QStringListModel (cats, completer)); result->AddSelector (); return result; } default: return QStyledItemDelegate::createEditor (parent, option, index); } }