void MapEditorController::initMapSelectScene() { mapSelectDock->widget->show(); mapSelectDock->populaArvore(); Map *map; map = mapSelectDock->getMapaSelecionado(); if(map != NULL) { selectMap(map); } mapSelectSceneInitializated = true; }
static QString selectMap( const QVariantMap& m, const QStringList& l, int index) { if ( index >= l.count() ) return QString(); QString attributeName = l[index]; if ( index == l.count() - 1 ) return CalamaresUtils::getString( m, attributeName ); else { bool success = false; // bogus if ( m.contains( attributeName ) ) return selectMap( CalamaresUtils::getSubMap( m, attributeName, success ), l, index+1 ); return QString(); } }
GeoIP::RegionZonePair GeoIPJSON::processReply( const QByteArray& data ) { try { YAML::Node doc = YAML::Load( data ); QVariant var = CalamaresUtils::yamlToVariant( doc ); if ( !var.isNull() && var.isValid() && var.type() == QVariant::Map ) { return splitTZString( selectMap( var.toMap(), m_element.split('.'), 0 ) ); } else cWarning() << "Invalid YAML data for GeoIPJSON"; } catch ( YAML::Exception& e ) { CalamaresUtils::explainYamlException( e, data, "GeoIP data"); } return qMakePair( QString(), QString() ); }
static void eventHandler(objectKey key, windowEvent *event) { int status = 0; int selected = 0; char *fullName = NULL; char *dirName = NULL; // Check for window events. if (key == window) { // Check for window refresh if (event->type == EVENT_WINDOW_REFRESH) refreshWindow(); // Check for the window being closed else if (event->type == EVENT_WINDOW_CLOSE) windowGuiStop(); } else if ((key == mapList) && (event->type & EVENT_SELECTION) && (event->type & EVENT_MOUSE_DOWN)) { if (windowComponentGetSelected(mapList, &selected) < 0) return; if (loadMap(mapListParams[selected].text) < 0) return; makeKeyArray(selectedMap); updateKeyDiag(selectedMap); } else if ((key == saveButton) && (event->type == EVENT_MOUSE_LEFTUP)) { fullName = malloc(MAX_PATH_NAME_LENGTH); if (!fullName) return; findMapFile(selectedMap->name, fullName); status = windowNewFileDialog(window, _("Save as"), _("Choose the output file:"), cwd, fullName, MAX_PATH_NAME_LENGTH, 0); if (status != 1) { free(fullName); return; } status = saveMap(fullName); if (status < 0) { free(fullName); return; } // Are we working in a new directory? dirName = dirname(fullName); if (dirName) { strncpy(cwd, dirName, MAX_PATH_LENGTH); free(dirName); } free(fullName); if (getMapNameParams() < 0) return; windowComponentSetData(mapList, mapListParams, numMapNames, 1 /* redraw */); selectMap(selectedMap->name); windowNewInfoDialog(window, _("Saved"), _("Map saved")); } else if ((key == defaultButton) && (event->type == EVENT_MOUSE_LEFTUP)) { if (windowComponentGetSelected(mapList, &selected) < 0) return; if (setMap(mapListParams[selected].text) < 0) return; windowComponentSetData(currentNameLabel, mapListParams[selected].text, strlen(mapListParams[selected].text), 1 /* redraw */); } // Check for the window being closed by a GUI event. else if ((key == closeButton) && (event->type == EVENT_MOUSE_LEFTUP)) windowGuiStop(); }
static void constructWindow(void) { // If we are in graphics mode, make a window rather than operating on the // command line. objectKey rightContainer = NULL; objectKey bottomContainer = NULL; componentParameters params; // Create a new window window = windowNew(multitaskerGetCurrentProcessId(), WINDOW_TITLE); if (!window) return; memset(¶ms, 0, sizeof(componentParameters)); params.gridWidth = 1; params.gridHeight = 1; params.padTop = 5; params.padLeft = 5; params.orientationX = orient_left; params.orientationY = orient_top; // Create a list component for the keymap names mapList = windowNewList(window, windowlist_textonly, 5, 1, 0, mapListParams, numMapNames, ¶ms); windowRegisterEventHandler(mapList, &eventHandler); windowComponentFocus(mapList); // Select the map selectMap(selectedMap->name); // Make a container for the current keymap labels params.gridX += 1; params.padRight = 5; rightContainer = windowNewContainer(window, "rightContainer", ¶ms); // Create labels for the current keymap params.gridX = 0; params.gridY = 0; params.flags |= (WINDOW_COMPFLAG_FIXEDWIDTH | WINDOW_COMPFLAG_FIXEDHEIGHT); currentLabel = windowNewTextLabel(rightContainer, CURRENT, ¶ms); params.gridY += 1; currentNameLabel = windowNewTextLabel(rightContainer, currentName, ¶ms); // Create the diagram of the selected map params.gridX = 0; params.gridY += 1; params.gridWidth = 2; params.padTop = 5; params.orientationX = orient_center; params.flags &= ~(WINDOW_COMPFLAG_FIXEDWIDTH | WINDOW_COMPFLAG_FIXEDHEIGHT); diagContainer = constructKeyDiag(window, selectedMap, ¶ms); params.gridX = 0; params.gridY += 1; params.padBottom = 5; params.flags |= (WINDOW_COMPFLAG_FIXEDWIDTH | WINDOW_COMPFLAG_FIXEDHEIGHT); bottomContainer = windowNewContainer(window, "bottomContainer", ¶ms); // Create a 'Save' button params.gridY = 0; params.gridWidth = 1; params.padTop = 0; params.padBottom = 0; params.padLeft = 0; params.padRight = 5; params.orientationX = orient_right; saveButton = windowNewButton(bottomContainer, SAVE, NULL, ¶ms); windowRegisterEventHandler(saveButton, &eventHandler); // Create a 'Set as default' button params.gridX += 1; params.padLeft = 0; params.padRight = 0; params.orientationX = orient_center; defaultButton = windowNewButton(bottomContainer, SET_DEFAULT, NULL, ¶ms); windowRegisterEventHandler(defaultButton, &eventHandler); // Create a 'Close' button params.gridX += 1; params.padLeft = 5; params.orientationX = orient_left; closeButton = windowNewButton(bottomContainer, CLOSE, NULL, ¶ms); windowRegisterEventHandler(closeButton, &eventHandler); // Register an event handler to catch window close events windowRegisterEventHandler(window, &eventHandler); windowSetVisible(window, 1); return; }