QVariant VirtualSystemModel::data(const QModelIndex &idx, int role /* = Qt::DisplayRole */) const
{
    if (!idx.isValid())
        return QVariant();

    ModelItem *item = static_cast<ModelItem*>(idx.internalPointer());

    return item->data(idx.column(), role);
}
Пример #2
0
void AutoMateUi::tweakContextMenu(const QPoint &p) {
	QModelIndex index = tweaks_view->indexAt(p);
	if (!index.isValid())
		return;

	index = tweaksProxyModel->mapToSource(index);
	QMenu *menu = new QMenu(this);
	ModelItem *item = static_cast<ModelItem*>(index.internalPointer());
	selectedTweakFileName = item->data(1).toString();
	if (selectedTweakFileName.size() ==0)
		return;
	QAction *action = menu->addAction(QString("Edit %1").arg(selectedTweakFileName));
	connect(action, SIGNAL(triggered()), SLOT(editSelectedTweak()));

	menu->exec(tweaks_view->viewport()->mapToGlobal(p));
}