int main()
{
	Tree *head = new Tree;
	head->value = -32999;
	head->left = NULL;
	head->right = NULL;
	head->prev = NULL;

	char c = 0;

	while (c != '0')
	{
		printf("\n	0 Exit\n	1 Add value to tree\n	2 Delete value from tree\n	3 Exist?\n	4 Print\n	");
		scanf("%c", &c);
		if (c == '\n')
			scanf("%c", &c);
		if (c == '1')
			addValue(head);
		if (c == '2')
			delValue(head);
		if (c == '3')
			existence(head);
		if (c == '4')
			printEl(head->left);
	}
	
	
	delTree(head->left);
	delete head;	
	return 0;
}
Example #2
0
void QDoubleListWidget::contextMenuEvent(QContextMenuEvent* evt)
{
    QMenu menu(this);
    QAction* addObjItem = menu.addAction(tr("Add Item"));
    QAction* delObjItem = menu.addAction(tr("Remove Item"));

    if (currentItem() == NULL)
        delObjItem->setEnabled(false);

    QAction* sel = menu.exec(evt->globalPos());
    if (sel == addObjItem) {
        bool ok;
        double val = QInputDialog::getDouble(this, tr("Add Item"),
                            tr("Enter a value"), 0.0, 0.0, 2147483647.0,
                            3, &ok);
        if (ok) addValue(val);
    } else if (sel == delObjItem) {
        delValue(currentRow());
    }
}
Example #3
0
bool Config::setAddValue(int action, std::string key, std::string value, int type){
	bool deleted=false;

	if(key == "homedir"){
		LOG(key << " " << value, LOG_DEBUG);
	}

	bool exists = configItems.count(key) != 0;

	if(exists && (
			(action == C_SET && configItems[key].type <= type) || 
			(action == C_ADD && configItems[key].type < type)))
	{
		delValue(key);
		deleted = true;
	}

	if(configItems.count(key) != 0){
		if(configItems[key].type <= type){
			configItems[key].value.push_back(value);
			return true;
		}
	}
	
	else{
		if(type == VAR_INTERNAL || deleted || key.substr(0, 5) == "user_"){
			ConfigItem tmp;
			tmp.value.push_back(value);
			tmp.key = key;
			tmp.type = type;
			configItems[key] = tmp;
			return true;
		}
		
		else{
			ThrowEx(ConfigException, "Unknown option in project file: '" << key << "'");
		}
	}

	return exists;
}