int MainWindow::loadUsercols() { if (!dbAvailable()) return -1; QSqlQuery q(m_db); int loaded = 0; m_userColMap.clear(); m_userColCollation.clear(); if (q.exec("SELECT name, user_name, collation FROM zbr_usercols ORDER BY name")) { QStringList lstH(columnHeaderList()); qDebug() << "Asserting table headers (loadUsercols)"; int n; const char *_tblFields[] = { PROPERTY_TABLE_FIELDS }; for (n = 0; n < lstH.length(); n++) { if (!strncmp(_tblFields[n], "_nd", 3)) continue; if (!strncmp(_tblFields[n], "user", 4)) continue; // add these later emit addColumn( _tblFields[n], lstH[n] ); //m_dlgWeight->addColumn( _tblFields[n], lstH[n] ); } while (q.next()) { QString nameLabel(q.value("name").toString()); QString name(q.value("user_name").toString()); int nameCollation = q.value("collation").toInt(); if (nameLabel.isEmpty() || name.isEmpty()) continue; m_userColMap[nameLabel] = name; m_userColCollation[nameLabel] = nameCollation; emit addColumn(nameLabel, name); lstH << name; loaded++; } if (ui->tblData->columnCount() < COL_START_USER + loaded) { qDebug() << "Adding additional columns:" << loaded; ui->tblData->setColumnCount(COL_START_USER + loaded); } else if (loaded > 0) qDebug() << "Additional user cols:" << loaded; ui->tblData->setHorizontalHeaderLabels(lstH); } else qDebug() << "Column query failed:" << q.lastError(); return loaded; }
void nameStmnt(t_tree node) { if (node == NULL) return; switch(node->Kind) { case kAssign: nameAssign(node); break; case kIf: nameIf(node); break; case kWhile: nameWhile(node); break; case kFuncCallStmnt: nameFuncCallStmnt(node); break; case kReturn: nameReturn(node); break; case kLoop: nameLoop(node); break; case kExit: nameExit(node); break; case kAsm: nameAsm(node); break; case kLabel: nameLabel(node); break; case kGoto: nameGoto(node); break; default: printf("Error in name.c!\n"); break; } }
int ResultScreen::Run(sf::RenderWindow &App, Game &game) { windowWidth = App.getSize().x; windowHeight = App.getSize().y; sf::Event event; bool running = true; sf::Font font; if (!font.loadFromFile("fonts/arial.ttf")) std::cerr << "Problem with loading fonts" << std::endl; const float MENU_LABEL_SCREEN_POS_X = 0.50; const float MENU_LABEL_SCREEN_POS_Y = 0.10; sf::Text menuLabel("Wyniki", font); menuLabel.setCharacterSize(60); menuLabel.setColor(sf::Color::White); float menuLabelPosX = windowWidth * MENU_LABEL_SCREEN_POS_X - menuLabel.getGlobalBounds().width * 0.5; float menuLabelPosY = windowHeight * MENU_LABEL_SCREEN_POS_Y - menuLabel.getGlobalBounds().height * 0.5; menuLabel.setPosition(sf::Vector2f(menuLabelPosX, menuLabelPosY)); const float CONTINUE_LABEL_SCREEN_POS_X = 0.5; const float CONTINUE_LABEL_SCREEN_POS_Y = 0.8; sf::Text continueLabel("Czy chcesz kontynulowac?", font); continueLabel.setCharacterSize(35); continueLabel.setColor(sf::Color::White); float continueLabelPosX = windowWidth * CONTINUE_LABEL_SCREEN_POS_X - continueLabel.getGlobalBounds().width * 0.5; float continueLabelPosY = windowHeight * CONTINUE_LABEL_SCREEN_POS_Y - continueLabel.getGlobalBounds().height * 0.5; continueLabel.setPosition(sf::Vector2f(continueLabelPosX, continueLabelPosY)); const float NEXT_ROUND_BUTTON_SCREEN_POS_X = 0.6; const float NEXT_ROUND_BUTTON_SCREEN_POS_Y = 0.90; sf::String nextRoundButtonPath("image/Accept.png"); sf::String nextRoundButtonHoverPath("image/AcceptShadow.png"); ButtonView nextRoundButton(nextRoundButtonPath, nextRoundButtonHoverPath, false); float nextRoundButtonWidth = nextRoundButton.getGlobalBounds().width; float nextRoundButtonHeight = nextRoundButton.getGlobalBounds().height; float nextRoundButtonPosX = windowWidth * NEXT_ROUND_BUTTON_SCREEN_POS_X - nextRoundButtonWidth * 0.5; float nextRoundButtonPosY = windowHeight * NEXT_ROUND_BUTTON_SCREEN_POS_Y - nextRoundButtonHeight * 0.5; nextRoundButton.setPosition(sf::Vector2f(nextRoundButtonPosX, nextRoundButtonPosY)); const float BACK_MENU_BUTTON_POS_X = 0.08; const float BACK_MENU_BUTTON_POS_Y = 0.10; sf::String backToMenuButtonPath("image/MenuButton.png"); sf::String backToMenuHoverButtonPath("image/MenuButtonShadow.png"); ButtonView backToMenuButton(backToMenuButtonPath, backToMenuHoverButtonPath, false); float backToMenuButtonWidth = backToMenuButton.getGlobalBounds().width; float backToMenuButtonHeight = backToMenuButton.getGlobalBounds().height; float backToMenuButtonPosX = windowWidth * BACK_MENU_BUTTON_POS_X - backToMenuButtonWidth * 0.5; float backToMenuButtonPosY = windowHeight * BACK_MENU_BUTTON_POS_Y - backToMenuButtonHeight * 0.5; backToMenuButton.setPosition(sf::Vector2f(backToMenuButtonPosX, backToMenuButtonPosY)); const float NO_BUTTON_POS_X = 0.4; const float NO_BUTTON_POS_Y = 0.9; sf::String noButtonPath("image/ExitButton.png"); ButtonView noButton(noButtonPath, noButtonPath, false); float noButtonWidth = noButton.getGlobalBounds().width; float noButtonHeight = noButton.getGlobalBounds().height; float noButtonPosX = windowWidth * NO_BUTTON_POS_X - noButtonWidth * 0.5; float noButtonPosY = windowHeight * NO_BUTTON_POS_Y - noButtonHeight * 0.5; noButton.setPosition(sf::Vector2f(noButtonPosX, noButtonPosY)); vector<Player> allPlayers = game.getPlayers(); vector<int> currentRoundPoints = game.getPointsOfAllPlayers(); float NAMES_POS_X = 0.2; float CURRENT_POINTS_POS_X = 0.5; float ALL_POINTS_POS_X = 0.7; float LABELS_POS_Y = 0.2; sf::Text nameLabel("", font); nameLabel.setCharacterSize(35); nameLabel.setColor(sf::Color::White); sf::Text currentPointsLabel("", font); currentPointsLabel.setCharacterSize(35); currentPointsLabel.setColor(sf::Color::White); sf::Text allPointsLabel("", font); allPointsLabel.setCharacterSize(35); allPointsLabel.setColor(sf::Color::White); bool isDisplayed = false; while (running) { while (App.pollEvent(event)) { sf::Mouse mouse; sf::Vector2i mousePos = mouse.getPosition(App); switch (event.type) { case sf::Event::Closed: App.close(); break; case sf::Event::MouseMoved: if (nextRoundButton.isButtonHoverd(mousePos) && mouse.isButtonPressed(sf::Mouse::Left)) { return (2); } if (backToMenuButton.isButtonHoverd(mousePos) && mouse.isButtonPressed(sf::Mouse::Left)) { return (0); } if (noButton.isButtonHoverd(mousePos) && mouse.isButtonPressed(sf::Mouse::Left)) { return (0); } default: break; } } App.clear(sf::Color(56, 134, 185, 255)); if (!isDisplayed) { isDisplayed = true; for (int i = 0; i < allPlayers.size(); i++) { nameLabel.setString(allPlayers[i].getPlayerName()); float nameLabelPosX = windowWidth * NAMES_POS_X - nameLabel.getGlobalBounds().width * 0.5; float nameLabelPosY = windowHeight * LABELS_POS_Y - nameLabel.getGlobalBounds().height * 0.5; nameLabel.setPosition(sf::Vector2f(nameLabelPosX, nameLabelPosY)); App.draw(nameLabel); allPointsLabel.setString(std::to_string(allPlayers[i].getPoints())); float allPointsLabelPosX = windowWidth * ALL_POINTS_POS_X - allPointsLabel.getGlobalBounds().width * 0.5; float allPointsLabelPosY = windowHeight * LABELS_POS_Y - allPointsLabel.getGlobalBounds().height * 0.5; allPointsLabel.setPosition(sf::Vector2f(allPointsLabelPosX, allPointsLabelPosY)); App.draw(allPointsLabel); currentPointsLabel.setString(std::to_string(currentRoundPoints[i])); float currentPointsLabelPosX = windowWidth * CURRENT_POINTS_POS_X - currentPointsLabel.getGlobalBounds().width * 0.5; float currentPointsLabelPosY = windowHeight * LABELS_POS_Y - currentPointsLabel.getGlobalBounds().height * 0.5; currentPointsLabel.setPosition(sf::Vector2f(currentPointsLabelPosX, currentPointsLabelPosY)); App.draw(currentPointsLabel); LABELS_POS_Y += 0.1; } } else { LABELS_POS_Y = 0.2; isDisplayed = false; } App.draw(nextRoundButton); App.draw(continueLabel); App.draw(backToMenuButton); App.draw(noButton); App.draw(menuLabel); App.display(); } return (-1); }
//If this works, we can maybe get rid of customLabel() and nameLabel()?? QString StarObject::labelString() const { return nameLabel( Options::showStarNames(), Options::showStarMagnitudes() ); }
void Monitor::MonitorDataStorage::manageTopicLink( TreeNode* node, const OpenDDS::DCPS::GUID_t& dp_id, const OpenDDS::DCPS::GUID_t& topic_id, bool& create ) { // This gets a bit tedious. Here are the cases: // 1) We currently have no reference, and found a Topic node to // reference: // - attach a reference to the topic node; // 2) We currently have no reference, and found a Name node to // reference: // - attach a reference to the name node; // 3) We currently have a Topic node referenced, and found the same // topic node to reference: // - nothing to do; // 4) We currently have a Topic node referenced, and found a different // Topic node to reference: // - detach previous reference and reattach to new topic node; // 5) We currently have a Topic node referenced, but were able to find // a name node to reference: // - detach previous reference and reattach to new name node; // 6) We currently have a Name node referenced, and found the same name // node to reference: // - nothing to do; // 7) We currently have a Name node referenced, and found a different // name node to reference: // - detach previous reference and reattach to new name node; // 8) We currently have a Name node referenced, and found a different // Topic node to reference: // - detach previous reference and reattach to new topic node. // // Note that cases (4), (7), and (8) indicate inconsistent data reports // and are error conditions. We chose to not handle these cases. // Cases (3) and (6) require no action, so the only code paths we need // to consider are for cases (1), (2), and (5). // Find the actual topic. TreeNode* topicNode = this->getNode( std::string( "Topic"), dp_id, topic_id, create ); if( !topicNode) { return; } // Find the topic name to reference instead of the GUID value. TreeNode* nameNode = 0; QString nameLabel( QObject::tr( "Topic Name")); int row = topicNode->indexOf( 0, nameLabel); if( row != -1) { nameNode = (*topicNode)[ row]; } // Check for an existing Topic entry. QString topicLabel( QObject::tr( "Topic")); int topicRow = node->indexOf( 0, topicLabel); if( nameNode && topicRow != -1) { // Case 5: We have a topic reference and found a name reference, // remove the existing topic reference TreeNode* topicRef = (*node)[ topicRow]; if( topicRef && topicRef->valueSource()) { topicRef->valueSource()->removeValueRef( topicRef); } // node->removeChildren( topicRow, 1); // DEVELOPMENT: don't delete to show stale data. } // The node to install. TreeNode* refNode = nameNode; if( !refNode) { refNode = topicNode; } // Check to see if we need to create a name entry. int nameRow = node->indexOf( 0, nameLabel); if( nameRow == -1) { // New entry, add a reference to the topic or its name. QList<QVariant> list; list << topicLabel << QString( QObject::tr("<error>")); TreeNode* idNode = new TreeNode( list, node); idNode->setColor( 1, QColor("#bfbfff")); node->append( idNode); refNode->addValueRef( idNode); refNode->setColor( 1, QColor("#bfffbf")); create = true; } }
void SetupPluginsDialog::updatePlugins() { FModel.clear(); int errorsCount = 0; int disableCount = 0; QDomElement pluginElem = FPluginsSetup.documentElement().firstChildElement(); while (!pluginElem.isNull()) { QUuid uuid = pluginElem.attribute("uuid"); QString file = pluginElem.tagName(); QString name = pluginElem.firstChildElement("name").text(); QString version = pluginElem.firstChildElement("version").text(); QString error = pluginElem.firstChildElement("error").text(); QString descr = pluginElem.firstChildElement("desc").text(); bool isEnabled = pluginElem.attribute("enabled","true") == "true"; const IPluginInfo *info = FPluginManager->pluginInfo(uuid); bool isLoaded = info!=NULL; QString homePage = info!=NULL ? info->homePage.toString() : QString::null; QStringList dependsOn, dependsFor; if (info != NULL) { foreach(const QUuid &dependUid, FPluginManager->pluginDependencesOn(uuid)) dependsOn.append(dependUid.toString()); foreach(const QUuid &dependUid, FPluginManager->pluginDependencesFor(uuid)) dependsFor.append(dependUid.toString()); } QStandardItem *pluginItem = new QStandardItem(name); pluginItem->setData(uuid.toString(), PDR_UUID); pluginItem->setData(file, PDR_FILE); pluginItem->setData(name.isEmpty() ? file : name, PDR_NAME); pluginItem->setData(error.isEmpty() ? descr : error, PDR_DESCR); pluginItem->setData(version, PDR_VERSION); pluginItem->setData(homePage, PDR_HOMEPAGE); pluginItem->setData(isLoaded, PDR_ISLOADED); pluginItem->setData(isEnabled, PDR_ISENABLED); pluginItem->setData(dependsOn, PDR_DEPENDS_ON); pluginItem->setData(dependsFor, PDR_DEPENDS_FOR); pluginItem->setData(file+" "+name+" "+descr+" "+error, PDR_FILTER); pluginItem->setData(pluginItem->data(PDR_DESCR), Qt::ToolTipRole); AdvancedDelegateItem nameLabel(AdvancedDelegateItem::DisplayId); nameLabel.d->kind = AdvancedDelegateItem::Display; nameLabel.d->data = pluginItem->data(PDR_NAME); nameLabel.d->hints.insert(AdvancedDelegateItem::FontWeight,QFont::Bold); AdvancedDelegateItem versionLabel(AdvancedDelegateItem::DisplayId+1); versionLabel.d->kind = AdvancedDelegateItem::CustomData; versionLabel.d->data = pluginItem->data(PDR_VERSION); AdvancedDelegateItem descrLabel(AdvancedDelegateItem::makeId(AdvancedDelegateItem::Bottom,129,10)); descrLabel.d->kind = AdvancedDelegateItem::CustomData; descrLabel.d->data = pluginItem->data(PDR_DESCR); AdvancedDelegateItems labels; labels.insert(nameLabel.d->id, nameLabel); labels.insert(versionLabel.d->id, versionLabel); labels.insert(descrLabel.d->id, descrLabel); pluginItem->setData(QVariant::fromValue<AdvancedDelegateItems>(labels), PDR_LABELS); if (!isEnabled) { disableCount++; nameLabel.d->hints.insert(AdvancedDelegateItem::Foreground, ui.tbvPlugins->palette().color(QPalette::Disabled, QPalette::Text)); } else if (!isLoaded) { errorsCount++; // descrLabel.d->hints.insert(AdvancedDelegateItem::Foreground, Qt::red); descrLabel.d->hints.insert(AdvancedDelegateItem::Foreground, QColor(Qt::red)); nameLabel.d->hints.insert(AdvancedDelegateItem::Foreground, ui.tbvPlugins->palette().color(QPalette::Disabled, QPalette::Text)); } pluginItem->setCheckable(true); pluginItem->setCheckState(isEnabled ? Qt::Checked : Qt::Unchecked); FModel.appendRow(pluginItem); FPluginItem.insert(uuid, pluginItem); FItemElement.insert(pluginItem, pluginElem); pluginElem = pluginElem.nextSiblingElement(); }