• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TreeItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TreeItem的典型用法代码示例。如果您正苦于以下问题:C++ TreeItem类的具体用法?C++ TreeItem怎么用?C++ TreeItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TreeItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TreeCtrlEntry

/*************************************************************************
    Sample specific initialisation goes here.
*************************************************************************/
bool TreeDemoSample::initialiseSample()
   {
   using namespace CEGUI;
   Tree *      theTree;
   TreeItem *  newTreeCtrlEntryLvl1;  // Level 1 TreeCtrlEntry (branch)
   TreeItem *  newTreeCtrlEntryLvl2;  // Level 2 TreeCtrlEntry (branch)
   TreeItem *  newTreeCtrlEntryLvl3;  // Level 3 TreeCtrlEntry (branch)
   TreeItem *  newTreeCtrlEntryParent;
   Image *     iconArray[9];

#if defined( __WIN32__ ) || defined( _WIN32 )
   // Windows specific code.
   srand(time(NULL));
#endif

   // Get window manager which we will use for a few jobs here.
   WindowManager& winMgr = WindowManager::getSingleton();

//   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Standard);
//   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Insane);

   // Load the scheme to initialise the skin which we use in this sample
   SchemeManager::getSingleton().create(SCHEME_FILE_NAME);

   // set default mouse image
   System::getSingleton().setDefaultMouseCursor(IMAGES_FILE_NAME, "MouseArrow");

   // load an image to use as a background
   ImagesetManager::getSingleton().createFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

   // Load some icon images for our test tree
  // Imageset *iconImages = ImagesetManager::getSingleton().create("TreeIcons.imageset");
   Imageset& drives = ImagesetManager::getSingleton().create("DriveIcons.imageset");

   // here we will use a StaticImage as the root, then we can use it to place a background image
   Window* background = winMgr.createWindow(STATICIMAGE_NAME);

   // set area rectangle
   background->setArea(URect(cegui_reldim(0), cegui_reldim(0), cegui_reldim(1), cegui_reldim(1)));
   // disable frame and standard background
   background->setProperty("FrameEnabled", "false");
   background->setProperty("BackgroundEnabled", "false");
   // set the background image
   background->setProperty("Image", "set:BackgroundImage image:full_image");
   // install this as the root GUI sheet
   System::getSingleton().setGUISheet(background);

//   CEGUI::System::getSingleton().setTooltip(TOOLTIP_NAME);

    FontManager::getSingleton().create("DejaVuSans-10.font");
//	if(!FontManager::getSingleton().isFontPresent("Commonwealth-10"))
//		FontManager::getSingleton().createFont("Commonwealth-10.font");


   TreeDemoWindow = winMgr.loadWindowLayout(LAYOUT_FILE_NAME);

   background->addChildWindow(TreeDemoWindow);

   // listen for key presses on the root window.
   background->subscribeEvent(Window::EventKeyDown, Event::Subscriber(&TreeDemoSample::handleRootKeyDown, this));

   theTree = (Tree *)TreeDemoWindow->getChild(TreeID);
   theTree->initialise();
   theTree->subscribeEvent(Tree::EventSelectionChanged, Event::Subscriber(&TreeDemoSample::handleEventSelectionChanged, this));
   theTree->subscribeEvent(Tree::EventBranchOpened, Event::Subscriber(&TreeDemoSample::handleEventBranchOpened, this));
   theTree->subscribeEvent(Tree::EventBranchClosed, Event::Subscriber(&TreeDemoSample::handleEventBranchClosed, this));

   // activate the background window
   background->activate();

   Imageset& iconImages = drives;
   iconArray[0] = (Image *)&iconImages.getImage("Artic");
   iconArray[1] = (Image *)&iconImages.getImage("Black");
   iconArray[2] = (Image *)&iconImages.getImage("Sunset");
   iconArray[3] = (Image *)&iconImages.getImage("DriveStack");
   iconArray[4] = (Image *)&iconImages.getImage("GlobalDrive");
   iconArray[5] = (Image *)&iconImages.getImage("Blue");
   iconArray[6] = (Image *)&iconImages.getImage("Lime");
   iconArray[7] = (Image *)&iconImages.getImage("Silver");
   iconArray[8] = (Image *)&iconImages.getImage("GreenCandy");

   // Create a top-most TreeCtrlEntry
   newTreeCtrlEntryLvl1 = new TreeItem("Tree Item Level 1a");
   newTreeCtrlEntryLvl1->setIcon(drives.getImage("Black"));
   newTreeCtrlEntryLvl1->setSelectionBrushImage(IMAGES_FILE_NAME, BRUSH_NAME);
//   newTreeCtrlEntryLvl1->setUserData((void *)someData);
   theTree->addItem(newTreeCtrlEntryLvl1);
   // Create a second-level TreeCtrlEntry and attach it to the top-most TreeCtrlEntry
   newTreeCtrlEntryLvl2 = new TreeItem("Tree Item Level 2a (1a)");
   newTreeCtrlEntryLvl2->setIcon(drives.getImage("Artic"));
   newTreeCtrlEntryLvl2->setSelectionBrushImage(IMAGES_FILE_NAME, BRUSH_NAME);
   newTreeCtrlEntryLvl1->addItem(newTreeCtrlEntryLvl2);
   // Create a third-level TreeCtrlEntry and attach it to the above TreeCtrlEntry
   newTreeCtrlEntryLvl3 = new TreeItem("Tree Item Level 3a (2a)");
   newTreeCtrlEntryLvl3->setIcon(drives.getImage("Blue"));
   newTreeCtrlEntryLvl3->setSelectionBrushImage(IMAGES_FILE_NAME, BRUSH_NAME);
//.........这里部分代码省略.........
开发者ID:CharlesSadler,项目名称:CharlesSadlerRTSGame,代码行数:101,代码来源:Sample_TreeDemo.cpp


示例2: update_autoload

void EditorAutoloadSettings::update_autoload() {

	if (updating_autoload)
		return;

	updating_autoload = true;

	autoload_cache.clear();

	tree->clear();
	TreeItem *root = tree->create_item();

	List<PropertyInfo> props;
	ProjectSettings::get_singleton()->get_property_list(&props);

	for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {

		const PropertyInfo &pi = E->get();

		if (!pi.name.begins_with("autoload/"))
			continue;

		String name = pi.name.get_slice("/", 1);
		String path = ProjectSettings::get_singleton()->get(pi.name);

		if (name.empty())
			continue;

		AutoLoadInfo info;
		info.name = pi.name;
		info.order = ProjectSettings::get_singleton()->get_order(pi.name);

		autoload_cache.push_back(info);

		bool global = false;

		if (path.begins_with("*")) {
			global = true;
			path = path.substr(1, path.length());
		}

		TreeItem *item = tree->create_item(root);
		item->set_text(0, name);
		item->set_editable(0, true);

		item->set_text(1, path);
		item->set_selectable(1, false);

		item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
		item->set_editable(2, true);
		item->set_text(2, TTR("Enable"));
		item->set_checked(2, global);

		item->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP);
		item->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN);
		item->add_button(3, get_icon("Del", "EditorIcons"), BUTTON_DELETE);
		item->set_selectable(3, false);
	}

	updating_autoload = false;
}
开发者ID:GalanCM,项目名称:godot,代码行数:61,代码来源:editor_autoload_settings.cpp


示例3: beginUpdateAll

void ModulesHandler::beginUpdateAll()
{
    TreeItem *root = m_model->rootItem();
    for (int i = root->rowCount(); --i >= 0; )
        static_cast<ModuleItem *>(root->child(i))->updated = false;
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:6,代码来源:moduleshandler.cpp


示例4: if

bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) {


	TreeItem *item = tree->create_item(p_parent);
	String dname=p_dir->get_name();
	if (dname=="")
		dname="res://";

	item->set_text(0,dname);
	item->set_icon(0,get_icon("Folder","EditorIcons"));
	item->set_selectable(0,true);
	String lpath = p_dir->get_path();
	if (lpath!="res://" && lpath.ends_with("/")) {
		lpath=lpath.substr(0,lpath.length()-1);
	}
	item->set_metadata(0,lpath);
	if (lpath==path) {
		item->select(0);
	}


	//item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));

	bool has_items=false;

	for(int i=0;i<p_dir->get_subdir_count();i++) {

		if (_create_tree(item,p_dir->get_subdir(i)))
			has_items=true;
	}
#if 0
	for (int i=0;i<p_dir->get_file_count();i++) {

		String file_name = p_dir->get_file(i);
		String file_path = p_dir->get_file_path(i);

		// ScenesDockFilter::FILTER_PATH
		String search_from = file_path.right(6); // trim "res://"
		if (file_filter == ScenesDockFilter::FILTER_NAME)
			 search_from = file_name;
		else if (file_filter == ScenesDockFilter::FILTER_FOLDER)
			search_from = file_path.right(6).get_base_dir();

		if (search_term!="" && search_from.findn(search_term)==-1)
			continue;

		bool isfave = favorites.has(file_path);
		if (button_favorite->is_pressed() && !isfave)
			continue;

		TreeItem *fitem = tree->create_item(item);
		fitem->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
		fitem->set_editable(0,true);
		fitem->set_checked(0,isfave);
		fitem->set_text(0,file_name);

		Ref<Texture> icon = get_icon( (has_icon(p_dir->get_file_type(i),"EditorIcons")?p_dir->get_file_type(i):String("Object")),"EditorIcons");
		fitem->set_icon(0, icon );


		fitem->set_metadata(0,file_path);
		//if (p_dir->files[i]->icon.is_valid()) {
//			fitem->set_icon(0,p_dir->files[i]->icon);
//		}
		has_items=true;

	}
#endif
	/*if (!has_items) {

		memdelete(item);
		return false;

	}*/

	return true;
}
开发者ID:Darriall,项目名称:godot,代码行数:77,代码来源:scenes_dock.cpp


示例5: _autoload_edited

void EditorAutoloadSettings::_autoload_edited() {

	if (updating_autoload)
		return;

	TreeItem *ti = tree->get_edited();
	int column = tree->get_edited_column();

	UndoRedo *undo_redo = EditorNode::get_undo_redo();

	if (column == 0) {
		String name = ti->get_text(0);
		String old_name = selected_autoload.get_slice("/", 1);

		if (name == old_name)
			return;

		String error;
		if (!_autoload_name_is_valid(name, &error)) {
			ti->set_text(0, old_name);
			EditorNode::get_singleton()->show_warning(error);
			return;
		}

		if (ProjectSettings::get_singleton()->has("autoload/" + name)) {
			ti->set_text(0, old_name);
			EditorNode::get_singleton()->show_warning(vformat(TTR("Autoload '%s' already exists!"), name));
			return;
		}

		updating_autoload = true;

		name = "autoload/" + name;

		int order = ProjectSettings::get_singleton()->get_order(selected_autoload);
		String path = ProjectSettings::get_singleton()->get(selected_autoload);

		undo_redo->create_action(TTR("Rename Autoload"));

		undo_redo->add_do_property(ProjectSettings::get_singleton(), name, path);
		undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, order);
		undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", selected_autoload);

		undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, path);
		undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_autoload, order);
		undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);

		undo_redo->add_do_method(this, "update_autoload");
		undo_redo->add_undo_method(this, "update_autoload");

		undo_redo->add_do_method(this, "emit_signal", autoload_changed);
		undo_redo->add_undo_method(this, "emit_signal", autoload_changed);

		undo_redo->commit_action();

		selected_autoload = name;
	} else if (column == 2) {
		updating_autoload = true;

		bool checked = ti->is_checked(2);
		String base = "autoload/" + ti->get_text(0);

		int order = ProjectSettings::get_singleton()->get_order(base);
		String path = ProjectSettings::get_singleton()->get(base);

		if (path.begins_with("*"))
			path = path.substr(1, path.length());

		if (checked)
			path = "*" + path;

		undo_redo->create_action(TTR("Toggle AutoLoad Globals"));

		undo_redo->add_do_property(ProjectSettings::get_singleton(), base, path);
		undo_redo->add_undo_property(ProjectSettings::get_singleton(), base, ProjectSettings::get_singleton()->get(base));

		undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", base, order);
		undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", base, order);

		undo_redo->add_do_method(this, "update_autoload");
		undo_redo->add_undo_method(this, "update_autoload");

		undo_redo->add_do_method(this, "emit_signal", autoload_changed);
		undo_redo->add_undo_method(this, "emit_signal", autoload_changed);

		undo_redo->commit_action();
	}

	updating_autoload = false;
}
开发者ID:GalanCM,项目名称:godot,代码行数:90,代码来源:editor_autoload_settings.cpp


示例6: rowCount

int QmitkDataStorageTreeModel::rowCount(const QModelIndex &parent) const
{
  TreeItem *parentTreeItem = this->TreeItemFromIndex(parent);
  return parentTreeItem->GetChildCount();
}
开发者ID:m4271n,项目名称:MITK,代码行数:5,代码来源:QmitkDataStorageTreeModel.cpp


示例7: return

bool ScenesDock::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{

	Dictionary drag_data = p_data;

	if (drag_data.has("type") && String(drag_data["type"])=="favorite") {

		//moving favorite around
		TreeItem *ti = tree->get_item_at_pos(p_point);
		if (!ti)
			return false;

		int what = tree->get_drop_section_at_pos(p_point);

		if (ti==tree->get_root()->get_children()) {
			return (what==1); //the parent, first fav
		}
		if (ti->get_parent() && tree->get_root()->get_children()==ti->get_parent()) {
			return true; // a favorite
		}

		if (ti==tree->get_root()->get_children()->get_next()) {
			return (what==-1); //the tree, last fav
		}

		return false;

	}


	if (drag_data.has("type") && String(drag_data["type"])=="resource") {
		return true;
	}

	if (drag_data.has("type") && ( String(drag_data["type"])=="files" || String(drag_data["type"])=="files_and_dirs")) {

		Vector<String> fnames = drag_data["files"];

		if (p_from==files) {

			int at_pos = files->get_item_at_pos(p_point);
			if (at_pos!=-1) {

				String dir = files->get_item_metadata(at_pos);
				if (dir.ends_with("/"))
					return true;
			}
		}

		if (p_from==tree) {

			TreeItem *ti = tree->get_item_at_pos(p_point);
			if (!ti)
				return false;
			String path = ti->get_metadata(0);

			if (path==String())
				return false;

			return true;
		}

	}

	return false;
}
开发者ID:Darriall,项目名称:godot,代码行数:65,代码来源:scenes_dock.cpp


示例8: while

void ConnectionsDock::update_tree() {

	tree->clear();

	if (!selectedNode)
		return;

	TreeItem *root = tree->create_item();

	List<MethodInfo> node_signals;

	selectedNode->get_signal_list(&node_signals);

	//node_signals.sort_custom<_ConnectionsDockMethodInfoSort>();
	bool did_script = false;
	StringName base = selectedNode->get_class();

	while (base) {

		List<MethodInfo> node_signals;
		Ref<Texture> icon;
		String name;

		if (!did_script) {

			Ref<Script> scr = selectedNode->get_script();
			if (scr.is_valid()) {
				scr->get_script_signal_list(&node_signals);
				if (scr->get_path().is_resource_file())
					name = scr->get_path().get_file();
				else
					name = scr->get_class();

				if (has_icon(scr->get_class(), "EditorIcons")) {
					icon = get_icon(scr->get_class(), "EditorIcons");
				}
			}

		} else {

			ClassDB::get_signal_list(base, &node_signals, true);
			if (has_icon(base, "EditorIcons")) {
				icon = get_icon(base, "EditorIcons");
			}
			name = base;
		}

		TreeItem *pitem = NULL;

		if (node_signals.size()) {
			pitem = tree->create_item(root);
			pitem->set_text(0, name);
			pitem->set_icon(0, icon);
			pitem->set_selectable(0, false);
			pitem->set_editable(0, false);
			pitem->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
			node_signals.sort();
		}

		for (List<MethodInfo>::Element *E = node_signals.front(); E; E = E->next()) {

			MethodInfo &mi = E->get();

			String signaldesc;
			signaldesc = mi.name + "(";
			PoolStringArray argnames;
			if (mi.arguments.size()) {
				signaldesc += " ";
				for (int i = 0; i < mi.arguments.size(); i++) {

					PropertyInfo &pi = mi.arguments[i];

					if (i > 0)
						signaldesc += ", ";
					String tname = "var";
					if (pi.type == Variant::OBJECT && pi.class_name != StringName()) {
						tname = pi.class_name.operator String();
					} else if (pi.type != Variant::NIL) {
						tname = Variant::get_type_name(pi.type);
					}
					signaldesc += tname + " " + (pi.name == "" ? String("arg " + itos(i)) : pi.name);
					argnames.push_back(pi.name + ":" + tname);
				}
				signaldesc += " ";
			}

			signaldesc += ")";

			TreeItem *item = tree->create_item(pitem);
			item->set_text(0, signaldesc);
			Dictionary sinfo;
			sinfo["name"] = mi.name;
			sinfo["args"] = argnames;
			item->set_metadata(0, sinfo);
			item->set_icon(0, get_icon("Signal", "EditorIcons"));

			List<Object::Connection> connections;
			selectedNode->get_signal_connection_list(mi.name, &connections);

			for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) {
//.........这里部分代码省略.........
开发者ID:93i,项目名称:godot,代码行数:101,代码来源:connections_dialog.cpp


示例9: ERR_FAIL_COND

void ProjectExportDialog::_edit_preset(int p_index) {

	if (p_index < 0 || p_index >= presets->get_item_count()) {
		name->set_text("");
		name->set_editable(false);
		runnable->set_disabled(true);
		parameters->edit(NULL);
		delete_preset->set_disabled(true);
		sections->hide();
		patches->clear();
		export_error->hide();
		export_templates_error->hide();
		return;
	}

	Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(p_index);
	ERR_FAIL_COND(current.is_null());

	updating = true;

	presets->select(p_index);
	sections->show();

	name->set_editable(true);
	delete_preset->set_disabled(false);
	name->set_text(current->get_name());
	runnable->set_disabled(false);
	runnable->set_pressed(current->is_runnable());
	parameters->edit(current.ptr());

	export_filter->select(current->get_export_filter());
	include_filters->set_text(current->get_include_filter());
	exclude_filters->set_text(current->get_exclude_filter());

	patches->clear();
	TreeItem *patch_root = patches->create_item();
	Vector<String> patchlist = current->get_patches();
	for (int i = 0; i < patchlist.size(); i++) {
		TreeItem *patch = patches->create_item(patch_root);
		patch->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
		String file = patchlist[i].get_file();
		patch->set_editable(0, true);
		patch->set_text(0, file.get_file().replace("*", ""));
		if (file.ends_with("*"))
			patch->set_checked(0, true);
		patch->set_tooltip(0, patchlist[i]);
		patch->set_metadata(0, i);
		patch->add_button(0, get_icon("Del", "EditorIcons"), 0);
		patch->add_button(0, get_icon("folder", "FileDialog"), 1);
	}

	TreeItem *patch_add = patches->create_item(patch_root);
	patch_add->set_metadata(0, patchlist.size());
	if (patchlist.size() == 0)
		patch_add->set_text(0, "Add initial export..");
	else
		patch_add->set_text(0, "Add previous patches..");

	patch_add->add_button(0, get_icon("folder", "FileDialog"), 1);

	_fill_resource_tree();

	bool needs_templates;
	String error;
	if (!current->get_platform()->can_export(current, error, needs_templates)) {

		if (error != String()) {

			Vector<String> items = error.split("\n");
			error = "";
			for (int i = 0; i < items.size(); i++) {
				if (i > 0)
					error += "\n";
				error += " - " + items[i];
			}

			export_error->set_text(error);
			export_error->show();
		} else {
			export_error->hide();
		}
		if (needs_templates)
			export_templates_error->show();
		else
			export_templates_error->hide();

		export_button->set_disabled(true);

	} else {
		export_error->hide();
		export_templates_error->hide();
		export_button->set_disabled(false);
	}

	custom_features->set_text(current->get_custom_features());
	_update_feature_list();

	updating = false;
}
开发者ID:GalanCM,项目名称:godot,代码行数:99,代码来源:project_export.cpp


示例10: while

void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) {

	type_list.clear();
	ClassDB::get_class_list(&type_list);
	ScriptServer::get_global_class_list(&type_list);
	type_list.sort_custom<StringName::AlphCompare>();

	recent->clear();

	FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::READ);

	if (f) {

		TreeItem *root = recent->create_item();

		while (!f->eof_reached()) {
			String l = f->get_line().strip_edges();

			if (l != String()) {

				TreeItem *ti = recent->create_item(root);
				ti->set_text(0, l);
				ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(l, base_type));
			}
		}

		memdelete(f);
	}

	favorites->clear();

	f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::READ);

	favorite_list.clear();

	if (f) {

		while (!f->eof_reached()) {
			String l = f->get_line().strip_edges();

			if (l != String()) {
				favorite_list.push_back(l);
			}
		}

		memdelete(f);
	}

	_save_and_update_favorite_list();

	// Restore valid window bounds or pop up at default size.
	if (EditorSettings::get_singleton()->has_setting("interface/dialogs/create_new_node_bounds")) {
		popup(EditorSettings::get_singleton()->get("interface/dialogs/create_new_node_bounds"));
	} else {

		Size2 popup_size = Size2(900, 700) * editor_get_scale();
		Size2 window_size = get_viewport_rect().size;

		popup_size.x = MIN(window_size.x * 0.8, popup_size.x);
		popup_size.y = MIN(window_size.y * 0.8, popup_size.y);

		popup_centered(popup_size);
	}

	if (p_dont_clear) {
		search_box->select_all();
	} else {
		search_box->clear();
	}

	search_box->grab_focus();

	_update_search();

	bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines");
	Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color");

	if (enable_rl) {
		search_options->add_constant_override("draw_relationship_lines", 1);
		search_options->add_color_override("relationship_line_color", rl_color);
	} else {
		search_options->add_constant_override("draw_relationship_lines", 0);
	}

	is_replace_mode = p_replace_mode;

	if (p_replace_mode) {
		set_title(vformat(TTR("Change %s Type"), base_type));
		get_ok()->set_text(TTR("Change"));
	} else {
		set_title(vformat(TTR("Create New %s"), base_type));
		get_ok()->set_text(TTR("Create"));
	}
}
开发者ID:johnyc90,项目名称:godot,代码行数:94,代码来源:create_dialog.cpp


示例11: _is_item_signal

bool ConnectionsDock::_is_item_signal(TreeItem &item) {

	return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root());
}
开发者ID:93i,项目名称:godot,代码行数:4,代码来源:connections_dialog.cpp


示例12: _parse_fs

void CreateDialog::_update_search() {

	search_options->clear();
	favorite->set_disabled(true);

	help_bit->set_text("");
	/*
	TreeItem *root = search_options->create_item();
	_parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
*/

	HashMap<String, TreeItem *> types;

	TreeItem *root = search_options->create_item();
	EditorData &ed = EditorNode::get_editor_data();

	root->set_text(0, base_type);
	if (has_icon(base_type, "EditorIcons")) {
		root->set_icon(0, get_icon(base_type, "EditorIcons"));
	}

	TreeItem *to_select = search_box->get_text() == base_type ? root : NULL;

	for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) {

		String type = I->get();
		bool cpp_type = ClassDB::class_exists(type);

		if (base_type == "Node" && type.begins_with("Editor"))
			continue; // do not show editor nodes

		if (cpp_type && !ClassDB::can_instance(type))
			continue; // can't create what can't be instanced

		bool skip = false;
		if (cpp_type) {
			for (Set<StringName>::Element *E = type_blacklist.front(); E && !skip; E = E->next()) {
				if (ClassDB::is_parent_class(type, E->get()))
					skip = true;
			}
			if (skip)
				continue;
		}

		if (search_box->get_text() == "") {
			add_type(type, types, root, &to_select);
		} else {

			bool found = false;
			String type = I->get();
			while (type != "" && (cpp_type ? ClassDB::is_parent_class(type, base_type) : ed.script_class_is_parent(type, base_type)) && type != base_type) {
				if (search_box->get_text().is_subsequence_ofi(type)) {

					found = true;
					break;
				}

				type = cpp_type ? ClassDB::get_parent_class(type) : ed.script_class_get_base(type);
			}

			if (found)
				add_type(I->get(), types, root, &to_select);
		}

		if (EditorNode::get_editor_data().get_custom_types().has(type) && ClassDB::is_parent_class(type, base_type)) {
			//there are custom types based on this... cool.

			const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
			for (int i = 0; i < ct.size(); i++) {

				bool show = search_box->get_text().is_subsequence_ofi(ct[i].name);

				if (!show)
					continue;

				if (!types.has(type))
					add_type(type, types, root, &to_select);

				TreeItem *ti;
				if (types.has(type))
					ti = types[type];
				else
					ti = search_options->get_root();

				TreeItem *item = search_options->create_item(ti);
				item->set_metadata(0, type);
				item->set_text(0, ct[i].name);
				if (ct[i].icon.is_valid()) {
					item->set_icon(0, ct[i].icon);
				}

				if (!to_select || ct[i].name == search_box->get_text()) {
					to_select = item;
				}
			}
		}
	}

	if (search_box->get_text() == "") {
		to_select = root;
//.........这里部分代码省略.........
开发者ID:johnyc90,项目名称:godot,代码行数:101,代码来源:create_dialog.cpp


示例13: add_type

void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) {

	if (p_types.has(p_type))
		return;

	bool cpp_type = ClassDB::class_exists(p_type);
	EditorData &ed = EditorNode::get_editor_data();

	if (p_type == base_type)
		return;

	if (cpp_type) {
		if (!ClassDB::is_parent_class(p_type, base_type))
			return;
	} else {
		if (!ScriptServer::is_global_class(p_type) || !ed.script_class_is_parent(p_type, base_type))
			return;

		String script_path = ScriptServer::get_global_class_path(p_type);
		if (script_path.find("res://addons/", 0) != -1) {
			if (!EditorNode::get_singleton()->is_addon_plugin_enabled(script_path.get_slicec('/', 3)))
				return;
		}
	}

	String inherits = cpp_type ? ClassDB::get_parent_class(p_type) : ed.script_class_get_base(p_type);

	TreeItem *parent = p_root;

	if (inherits.length()) {

		if (!p_types.has(inherits)) {

			add_type(inherits, p_types, p_root, to_select);
		}

		if (p_types.has(inherits))
			parent = p_types[inherits];
		else if (ScriptServer::is_global_class(inherits))
			return;
	}

	bool can_instance = (cpp_type && ClassDB::can_instance(p_type)) || ScriptServer::is_global_class(p_type);

	TreeItem *item = search_options->create_item(parent);
	if (cpp_type) {
		item->set_text(0, p_type);
	} else {
		item->set_metadata(0, p_type);
		item->set_text(0, p_type + " (" + ScriptServer::get_global_class_path(p_type).get_file() + ")");
	}
	if (!can_instance) {
		item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
		item->set_selectable(0, false);
	} else {
		bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type);
		String to_select_type = *to_select ? (*to_select)->get_text(0) : "";
		to_select_type = to_select_type.split(" ")[0];
		bool current_item_is_preferred;
		if (cpp_type) {
			String cpp_to_select_type = to_select_type;
			if (ScriptServer::is_global_class(to_select_type))
				cpp_to_select_type = ScriptServer::get_global_class_base(to_select_type);
			current_item_is_preferred = ClassDB::is_parent_class(p_type, preferred_search_result_type) && !ClassDB::is_parent_class(cpp_to_select_type, preferred_search_result_type);
		} else {
			current_item_is_preferred = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type) && search_box->get_text() != to_select_type;
		}
		if (*to_select && p_type.length() < (*to_select)->get_text(0).length()) {
			current_item_is_preferred = true;
		}

		if (((!*to_select || current_item_is_preferred) && is_search_subsequence) || search_box->get_text() == p_type) {
			*to_select = item;
		}
	}

	if (bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) {
		item->set_collapsed(false);
	} else {
		// don't collapse search results
		bool collapse = (search_box->get_text() == "");
		// don't collapse the root node
		collapse &= (item != p_root);
		// don't collapse abstract nodes on the first tree level
		collapse &= ((parent != p_root) || (can_instance));
		item->set_collapsed(collapse);
	}

	const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
	item->set_tooltip(0, description);

	item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, base_type));

	p_types[p_type] = item;
}
开发者ID:johnyc90,项目名称:godot,代码行数:95,代码来源:create_dialog.cpp


示例14: init

	virtual void init() {
	
		SceneMainLoop::init();


#if 0


		Viewport *vp = memnew( Viewport );
		vp->set_world( Ref<World>( memnew( World )));
		get_root()->add_child(vp);

		vp->set_rect(Rect2(0,0,256,256));
		vp->set_as_render_target(true);
		vp->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);


		Camera *camera = memnew( Camera );
		vp->add_child(camera);
		camera->make_current();

		TestCube *testcube = memnew( TestCube );
		vp->add_child(testcube);
		testcube->set_transform(Transform( Matrix3().rotated(Vector3(0,1,0),Math_PI*0.25), Vector3(0,0,-8)));

		Sprite *sp = memnew( Sprite );
		sp->set_texture( vp->get_render_target_texture() );
//		sp->set_texture( ResourceLoader::load("res://ball.png") );
		sp->set_pos(Point2(300,300));
		get_root()->add_child(sp);


		return;
#endif

		Panel * frame = memnew( Panel );
		frame->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
		frame->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
		frame->set_end( Point2(0,0) );
		
		get_root()->add_child( frame );

		Label *label = memnew( Label );

		label->set_pos( Point2( 80,90 ) );
		label->set_size( Point2( 170,80 ) );
		label->set_align( Label::ALIGN_FILL );
		//label->set_text("There");
		label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls...");

		frame->add_child(label);

		Button *button = memnew( Button );

		button->set_pos( Point2( 20,20 ) );
		button->set_size( Point2( 1,1 ) );
		button->set_text("This is a biggie button");


		frame->add_child( button );


#if 0
		Sprite *tf = memnew( Sprite );
		frame->add_child(tf);
		Image img;
		ImageLoader::load_image("LarvoClub.png",&img);

		img.resize(512,512);
		img.generate_mipmaps();
		img.compress();
		Ref<Texture> text = memnew( Texture );
		text->create_from_image(img);
		tf->set_texture(text);
		tf->set_pos(Point2(50,50));
		//tf->set_scale(Point2(0.3,0.3));


		return;
#endif

		Tree * tree = memnew( Tree );
		tree->set_columns(2);

		tree->set_pos( Point2( 230,210 ) );
		tree->set_size( Point2( 150,250 ) );


		TreeItem *item = tree->create_item();
		item->set_editable(0,true);
		item->set_text(0,"root");
		item = tree->create_item( tree->get_root() );
		item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
		item->set_editable(0,true);
		item->set_text(0,"check");
		item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
		item->set_editable(1,true);
		item->set_text(1,"check2");
		item = tree->create_item( tree->get_root() );
		item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
//.........这里部分代码省略.........
开发者ID:Detox1957,项目名称:godot,代码行数:101,代码来源:test_gui.cpp


示例15: db

TreeItem* RhythmboxFeature::importPlaylists() {
    QFile db(QDir::homePath() + "/.gnome2/rhythmbox/playlists.xml");
    if (!db.exists()) {
        db.setFileName(QDir::homePath() + "/.local/share/rhythmbox/playlists.xml");
        if (!db.exists()) {
            return NULL;
        }
    }
    //Open file
     if (!db.open(QIODevice::ReadOnly | QIODevice::Text))
        return NULL;

    QSqlQuery query_insert_to_playlists(m_database);
    query_insert_to_playlists.prepare("INSERT INTO rhythmbox_playlists (id, name) "
                                      "VALUES (:id, :name)");

    QSqlQuery query_insert_to_playlist_tracks(m_database);
    query_insert_to_playlist_tracks.prepare(
            "INSERT INTO rhythmbox_playlist_tracks (playlist_id, track_id, position) "
            "VALUES (:playlist_id, :track_id, :position)");
    //The tree structure holding the playlists
    TreeItem* rootItem = new TreeItem();

    QXmlStreamReader xml(&db);
    while (!xml.atEnd() && !m_cancelImport) {
        xml.readNext();
        if (xml.isStartElement() && xml.name() == "playlist") {
            QXmlStreamAttributes attr = xml.attributes();

            //Only parse non build-in playlists
            if (attr.value("type").toString() == "static") {
                QString playlist_name = attr.value("name").toString();

                //Construct the childmodel
                TreeItem * item = new TreeItem(playlist_name, playlist_name, this, rootItem);
                rootItem->appendChild(item);

                //Execute SQL statement
                query_insert_to_playlists.bindValue(":name", playlist_name);

                if (!query_insert_to_playlists.exec()) {
                    LOG_FAILED_QUERY(query_insert_to_playlists)
                            << "Couldn't insert playlist:" << playlist_name;
                    continue;
                }

                // get playlist_id
                int playlist_id = query_insert_to_playlists.lastInsertId().toInt();

                //Process playlist entries
                importPlaylist(xml, query_insert_to_playlist_tracks, playlist_id);
            }
        }
    }

    if (xml.hasError()) {
        // do error handling
        qDebug() << "Cannot process Rhythmbox music collection";
        qDebug() << "XML ERROR: " << xml.errorString();
        delete rootItem;
        return NULL;
    }
    db.close();

    return rootItem;

}
开发者ID:Alppasa,项目名称:mixxx,代码行数:67,代码来源:rhythmboxfeature.cpp


示例16: sender

void RenderSettingsDialog::update() {
	int index = ui->integratorBox->currentIndex();
	Properties integratorProps, samplerProps;
	bool needsUpdate = false;

	if (sender() == ui->samplerBox) {
		m_samplerNode->putProperties(samplerProps);
		needsUpdate = true;
	}

	if (sender() == ui->integratorBox) {
		m_integratorNode->putProperties(integratorProps);
		needsUpdate = true;
	}

	if (sender() == ui->rFilterBox ||
		sender() == ui->icBox ||
		sender() == ui->aiBox) {
		needsUpdate = true;
	}

	m_integratorNode = m_model->updateClass(m_integratorNode,
		ui->integratorBox->itemData(index).toList().at(0).toString(),
		ui->integratorBox->itemText(index));
	index = ui->samplerBox->currentIndex();
	m_samplerNode = m_model->updateClass(m_samplerNode,
		ui->samplerBox->itemData(index).toList().at(0).toString(),
		ui->samplerBox->itemText(index));
	index = ui->rFilterBox->currentIndex();
	m_rFilterNode = m_model->updateClass(m_rFilterNode,
		ui->rFilterBox->itemData(index).toList().at(0).toString(),
		ui->rFilterBox->itemText(index));

	if (ui->icBox->isChecked()) {
		m_icNode = m_model->updateClass(m_icNode,
			"IrradianceCacheIntegrator", tr("Irradiance Cache"));
	} else {
		m_icNode = m_model->updateClass(m_icNode, "", "");
	}

	if (ui->aiBox->isChecked()) {
		m_aiNode = m_model->updateClass(m_aiNode,
			"AdaptiveIntegrator", tr("Adaptive Integration"));
	} else {
		m_aiNode = m_model->updateClass(m_aiNode, "", "");
	}

	if (sender() == ui->integratorBox) {
		for (int i=0; i<m_integratorNode->childCount(); ++i) {
			TreeItem *treeItem = m_integratorNode->child(i);
			if (integratorProps.hasProperty(treeItem->getName().toStdString()))
				m_integratorNode->setProperty(treeItem->getName().toStdString(), integratorProps);
		}
	}

	if (sender() == ui->samplerBox) {
		for (int i=0; i<m_samplerNode->childCount(); ++i) {
			TreeItem *treeItem = m_samplerNode->child(i);
			if (samplerProps.hasProperty(treeItem->getName().toStdString()))
				m_samplerNode->setProperty(treeItem->getName().toStdString(), samplerProps);
		}
	}

	if (needsUpdate) {
		int row = 0;
		/* Make comboboxes etc editable by default */
		for (int i = 0; i < m_model->rowCount(); ++i) {
			QModelIndex index = m_model->index(i, 0);

			for (int j = 0; j < m_model->rowCount(index); ++j) {
				QModelIndex idx = m_model->index(j, 1, index);
				ui->treeView->openPersistentEditor(idx);
				QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(ui->treeView->indexWidget(idx));
				if (spinBox) {
					QLineEdit *edit = spinBox->findChild<QLineEdit*>();
					if (row % 2 == 0)
						edit->setStyleSheet("background-color: palette(alternate-base);");
					edit->deselect();
				}
				row++;
			}
		}
	}
	ui->treeView->expandAll();

	dataChanged();
}
开发者ID:ArtisticCoding,项目名称:gradientdomain-mitsuba,代码行数:87,代码来源:rendersettingsdlg.cpp


示例17: ToTreeItemPtrList

bool QmitkDataStorageTreeModel::dropMimeData(
  const QMimeData *data, Qt::DropAction action, int row, int /*column*/, const QModelIndex &parent)
{
  // Early exit, returning true, but not actually doing anything (ignoring data).
  if (action == Qt::IgnoreAction)
  {
    return true;
  }

  // Note, we are returning true if we handled it, and false otherwise
  bool returnValue = false;

  if (data->hasFormat("application/x-qabstractitemmodeldatalist"))
  {
    returnValue = true;

    // First we extract a Qlist of TreeItem* pointers.
    QList<TreeItem *> listOfItemsToDrop = ToTreeItemPtrList(data);
    if (listOfItemsToDrop.empty())
    {
      return false;
    }

    // Retrieve the TreeItem* where we are dropping stuff, and its parent.
    TreeItem *dropItem = this->TreeItemFromIndex(parent);
    TreeItem *parentItem = dropItem->GetParent();

    // If item was dropped onto empty space, we select the root node
    if (dropItem == m_Root)
    {
      parentItem = m_Root;
    }

    // Dragging and Dropping is only allowed within the same parent, so use the first item in list to validate.
    // (otherwise, you could have a derived image such as a segmentation, and assign it to another image).
    // NOTE: We are assuming the input list is valid... i.e. when it was dragged, all the items had the same parent.

    // Determine whether or not the drag and drop operation is a valid one.
    // Examples of invalid operations include:
    //  - dragging nodes with different parents
    //  - dragging nodes from one parent to another parent, if m_AllowHierarchyChange is false
    //  - dragging a node on one of its child nodes (only relevant if m_AllowHierarchyChange is true)

    bool isValidDragAndDropOperation(true);

    // different parents
    {
      TreeItem *firstParent = listOfItemsToDrop[0]->GetParent();
      QList<TreeItem *>::iterator diIter;
      for (diIter = listOfItemsToDrop.begin() + 1; diIter != listOfItemsToDrop.end(); diIter++)
      {
        if (firstParent != (*diIter)->GetParent())
        {
          isValidDragAndDropOperation = false;
          break;
        }
      }
    }

    // dragging from one parent to another
    if ((!m_AllowHierarchyChange) && isValidDragAndDropOperation)
    {
      if (row == -1) // drag onto a node
      { 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TreeIterator类代码示例发布时间:2022-05-31
下一篇:
C++ Tree类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap