void HandlerDependencyTracker::writeGraph(QList<int> indexPermutation) { if(!mEnabled) { return; } QString filename = "handlers.gv"; QString graph = "digraph {\n node [shape = \"rectangle\", style = \"filled\", fillcolor = \"forestgreen\"];\n\n"; QMap<QString, QString> names; // Declare each node. int idx = 1; QString idxStr; foreach(QString label, mEvents) { names.insert(label, QString("event_%1").arg(idx)); idxStr = (idx-1) < indexPermutation.length() ? QString::number(indexPermutation.at(idx-1)) : ""; idxStr = idx == mEvents.length() ? "B" : idxStr; graph += QString(" %1 [label = \"%2\", xlabel = \"%3\"];\n").arg(names[label], label, idxStr); idx++; }
QHash<QString,QList<XDGDesktop> > LXDG::sortDesktopCats(QList<XDGDesktop> apps){ //Sort the list of applications into their different categories (main categories only) //Create the category lists QList<XDGDesktop> multimedia, dev, ed, game, graphics, network, office, science, settings, sys, utility, other, wine; //Sort the apps into the lists for(int i=0; i<apps.length(); i++){ if(apps[i].catList.contains("AudioVideo")){ multimedia << apps[i]; } else if(apps[i].catList.contains("Development")){ dev << apps[i]; } else if(apps[i].catList.contains("Education")){ ed << apps[i]; } else if(apps[i].catList.contains("Game")){ game << apps[i]; } else if(apps[i].catList.contains("Graphics")){ graphics << apps[i]; } else if(apps[i].catList.contains("Network")){ network << apps[i]; } else if(apps[i].catList.contains("Office")){ office << apps[i]; } else if(apps[i].catList.contains("Science")){ science << apps[i]; } else if(apps[i].catList.contains("Settings")){ settings << apps[i]; } else if(apps[i].catList.contains("System")){ sys << apps[i]; } else if(apps[i].catList.contains("Utility")){ utility << apps[i]; } else if(apps[i].catList.contains("Wine")){ wine << apps[i]; } else{ other << apps[i]; } } //Now create the output hash QHash<QString,QList<XDGDesktop> > out; if(!multimedia.isEmpty()){ out.insert("Multimedia", LXDG::sortDesktopNames(multimedia)); } if(!dev.isEmpty()){ out.insert("Development", LXDG::sortDesktopNames(dev)); } if(!ed.isEmpty()){ out.insert("Education", LXDG::sortDesktopNames(ed)); } if(!game.isEmpty()){ out.insert("Game", LXDG::sortDesktopNames(game)); } if(!graphics.isEmpty()){ out.insert("Graphics", LXDG::sortDesktopNames(graphics)); } if(!network.isEmpty()){ out.insert("Network", LXDG::sortDesktopNames(network)); } if(!office.isEmpty()){ out.insert("Office", LXDG::sortDesktopNames(office)); } if(!science.isEmpty()){ out.insert("Science", LXDG::sortDesktopNames(science)); } if(!settings.isEmpty()){ out.insert("Settings", LXDG::sortDesktopNames(settings)); } if(!sys.isEmpty()){ out.insert("System", LXDG::sortDesktopNames(sys)); } if(!utility.isEmpty()){ out.insert("Utility", LXDG::sortDesktopNames(utility)); } if(!wine.isEmpty()){ out.insert("Wine", LXDG::sortDesktopNames(wine)); } if(!other.isEmpty()){ out.insert("Unsorted", LXDG::sortDesktopNames(other)); } //return the resulting hash return out; }
FindChests::FindChests(const QList<World::Chest> &chests, QWidget *parent) : QDialog(parent), ui(new Ui::FindChests) { ui->setupUi(this); QHash<QString, QList<int>> roots; for (int i = 0; i < chests.length(); i++) { for (auto const &item : chests[i].items) { if (!roots[item.name].contains(i)) roots[item.name].append(i); } } QHashIterator<QString, QList<int>> i(roots); auto root = model.invisibleRootItem(); while (i.hasNext()) { i.next(); auto item = new QStandardItem(i.key()); item->setEditable(false); for (int num : i.value()) { auto child = new QStandardItem(chests[num].name.isEmpty() ? tr("Chest #%1").arg(num) : chests[num].name); child->setEditable(false); child->setData(QPointF(chests[num].x, chests[num].y), Qt::UserRole); item->appendRow(child); } root->appendRow(item); } model.sort(0, Qt::AscendingOrder); filter = new ItemsFilterProxyModel(this); filter->setSourceModel(&model); ui->treeView->setModel(filter); connect(ui->treeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(chestSelected(const QModelIndex&, const QModelIndex&))); }
void LDesktop::DesktopPluginRemoved(QString ID){ //Close down that plugin instance (NOTE: the container might have already closed by the user) if(DEBUG){ qDebug() << "Desktop Plugin Removed:" << ID; } //First look for the container (just in case) QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); for(int i=0; i<wins.length(); i++){ if(wins[i]->whatsThis() == ID){ if(DEBUG){ qDebug() << " - Removing Plugin Container"; } //wins[i]->setWhatsThis(""); //clear this so it knows it is being temporarily removed bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container bgDesktop->removeSubWindow(wins[i]); //remove container from screen delete wins[i]; //delete old container break; } } //qDebug() << "PLUGINS:" << PLUGINS.length() << ID; for(int i=0; i<PLUGINS.length(); i++){ if(PLUGINS[i]->ID() == ID){ //qDebug() << "- found ID"; if(DEBUG){ qDebug() << " - Deleting Desktop Plugin:" << ID; } delete PLUGINS.takeAt(i); break; } } //Now remove that plugin from the internal list (then let the plugin system remove the actual plugin) QStringList plugins = settings->value(DPREFIX+"pluginlist",QStringList()).toStringList(); if(DEBUG){ qDebug() << " - Also removing plugin from future list"; } plugins.removeAll(ID); issyncing = true; if(DEBUG){ qDebug() << " - Save modified plugins list"; } settings->setValue(DPREFIX+"pluginlist", plugins); if(DEBUG){ qDebug() << " - Unlock settings file in 200 ms"; } //settings->sync(); QTimer::singleShot(200, this, SLOT(UnlockSettings()) ); if(DEBUG){ qDebug() << " - Done removing plugin"; } }
QGeoTileSpec QGeoTileCache::filenameToTileSpec(const QString &filename) { QGeoTileSpec emptySpec; QStringList parts = filename.split('.'); if (parts.length() != 2) return emptySpec; QString name = parts.at(0); QStringList fields = name.split('-'); int length = fields.length(); if (length != 5 && length != 6) return emptySpec; QList<int> numbers; bool ok = false; for (int i = 1; i < length; ++i) { ok = false; int value = fields.at(i).toInt(&ok); if (!ok) return emptySpec; numbers.append(value); } //File name without version, append default if (numbers.length() < 5) numbers.append(-1); return QGeoTileSpec(fields.at(0), numbers.at(0), numbers.at(1), numbers.at(2), numbers.at(3), numbers.at(4)); }
bool Slash::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{ int slash_targets = 1; if(Self->hasWeapon("halberd") && Self->isLastHandCard(this)){ slash_targets = 3; } bool distance_limit = true; if(Self->hasFlag("tianyi_success")){ distance_limit = false; slash_targets ++; } if(Self->hasSkill("lihuo") && inherits("FireSlash")) slash_targets ++; if(Self->hasSkill("tieji_p") && Self->getWeapon() && Self->getWeapon()->getRange() >= 3){ slash_targets ++ ; } if(Self->hasSkill("shenji") && Self->getWeapon() == NULL) slash_targets = 3; if(targets.length() >= slash_targets) return false; if(inherits("WushenSlash")){ distance_limit = false; } if(getSkillName() == "wusheng" && Self->isSkillEnhance("wusheng", 1)){ int card_id = getSubcards().first() ; if(Sanguosha->getCard(card_id)->getSuit() == Card::Heart) distance_limit = false ; } return Self->canSlash(to_select, distance_limit); }
void QgsCompoundColorWidget::removePalette() { //get current scheme QList<QgsColorScheme *> schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog ); int prevIndex = mSchemeComboBox->currentIndex(); if ( prevIndex >= schemeList.length() ) { return; } //make user scheme is a user removable scheme QgsUserColorScheme *userScheme = dynamic_cast<QgsUserColorScheme *>( schemeList.at( prevIndex ) ); if ( !userScheme ) { return; } if ( QMessageBox::question( this, tr( "Remove Color Palette" ), QString( tr( "Are you sure you want to remove %1?" ) ).arg( userScheme->schemeName() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) { //user canceled return; } //remove palette and associated gpl file if ( !userScheme->erase() ) { //something went wrong return; } //remove scheme from registry QgsApplication::colorSchemeRegistry()->removeColorScheme( userScheme ); refreshSchemeComboBox(); prevIndex = std::max( std::min( prevIndex, mSchemeComboBox->count() - 1 ), 0 ); mSchemeComboBox->setCurrentIndex( prevIndex ); }
LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){ //Verify that a container does not already exist for this plugin QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); for(int i=0; i<wins.length(); i++){ if(wins[i]->whatsThis()==plug->ID()){ return 0; } } //Create a new plugin container LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked); win->loadInitialSize(); //Sizing should be done before adding the window to the area if(desktoplocked){ bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint); }else{ bgDesktop->addSubWindow(win, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); } if( !win->hasFixedPosition() ){ //NOTE: This section *only* runs for new plugins - it does not run for re-creations of old plugins //Need to determine the location of the plugin (leave size alone) if(DEBUG){ qDebug() << " --- Floating Plugin - find a spot for it"; } QPoint pt = findNewPluginLocation(availDPArea, win->size()); if(pt.x()>=0 && pt.y()>=0){ win->saveNewPosition(pt); win->move(pt); if(DEBUG){ qDebug() << " --- Moving to point:" << pt; } } //Make sure to remove this plugin from the availability region availDPArea = availDPArea.subtracted( QRegion(win->geometry()) ); } QApplication::processEvents(); QTimer::singleShot(300+(5*PLUGINS.length()), win, SLOT(loadInitialPosition()) ); //Now load the position (if one is saved) if(DEBUG){ qDebug() << "Initial DP Geom:" << plug->geometry(); qDebug() << " - Container Geom:" << win->geometry(); } QApplication::processEvents(); connect(win, SIGNAL(PluginRemoved(QString)), this, SLOT(DesktopPluginRemoved(QString)) ); return win; }
//从配置文件加载用户歌曲到播放器 void MusicList::loadMusicList() { /* DatabaseOperation db(musicListDatabaseName); QList<QMap<QString, QStringList> > tableNamesAndTableData; tableNamesAndTableData = db.getTableNamesAndTableData(); for (int i=0; i<tableNamesAndTableData.length(); ++i) { QString musicListName = tableNamesAndTableData.at(i).firstKey(); QStringList musicNames = tableNamesAndTableData.at(i).first(); if ( !DefaultList.contains(musicListName) ) { createMusiclistToplevel(musicListName); } addMusicToList(musicListName, musicNames); } */ QList<QMap<QString, QList<QMap<QString, QString> > > > musicListAndMusics; QStringList urlAndName; urlAndName << "url" << "name"; musicListAndMusics = xml.getElementAttributeValueAndChildrenText(xml.MusicListElement, urlAndName); for (int i=0; i<musicListAndMusics.length(); ++i) { QString musicListName = musicListAndMusics.at(i).firstKey(); QList<QMap<QString, QString> > musics = musicListAndMusics.at(i).first(); if ( !DefaultList.contains(musicListName) ) { createMusiclistToplevel(musicListName); } addMusicToList(musicListName, musics); } }
void ServerKernel::requestStopProcessByPID(KernelRequest *request){ //Die gewählte PID einlesen uint pidToFind = request->propertyValue(KernelRequest::ProcessToStop).toUInt(); QList<ProcessManager::Process *> processes = ProcessManager::instance()->processes(); //Alle Prozesse durchgehen for(int i = 0; i < processes.length();++i){ //Prozess gefunden? if(processes.at(i)->pid == pidToFind){ //Prozess enden lassen processes.at(i)->thread->endProcess(); //Prozess beenden processes.at(i)->thread->terminate(); //Prozess später löschen //this->_objectsToDelete.append(processes.at(i)->thread); break; } } }
void OptionsWindow::createTableModel( QString data ) { //vytvorenie polozky tabulky model = new QStandardItemModel( 0, 2 ); model->setHeaderData( 0, Qt::Horizontal, QObject::tr( "Attribute" ) ); model->setHeaderData( 1, Qt::Horizontal, QObject::tr( "Value" ) ); // rozdelenie dat QList<QString> rows = data.split( ";" ); //postupne sa vytvaraju riadky tabulky for ( int i=0; i< rows.length(); i++ ) { QList<QString> row = rows[i].split( "," ); model->insertRow( i ); model->setData( model->index( i, 0 ), row[0] ); model->setData( model->index( i, 1 ), row[1] ); model->item( i,0 )->setFlags( Qt::NoItemFlags ); } view->setVisible( true ); view->setModel( model ); }
void VanityGenPage::deleteRows() { QModelIndexList selection = ui->tableView->selectionModel()->selectedRows();//selectedIndexes();//; QList<int> sortIndex; for(int i=0; i< selection.count(); i++) { QModelIndex index = selection.at(i); sortIndex.append(index.row()); } qSort(sortIndex); for(int i=sortIndex.length()-1; i>=0 ; i--) { VanityGenWorkList.removeAt(sortIndex[i]); } rebuildTableView(); updateUi(); VanityGenRunning = false; saveFile(); }
void Slash::use(Room *room, ServerPlayer *source, const QList<ServerPlayer *> &targets) const{ if(source->getPhase() == Player::Play && source->hasUsed("Slash") && source->hasWeapon("crossbow")) room->setEmotion(source,"weapon/crossbow"); else if(this->isVirtualCard() && this->skill_name == "spear") room->setEmotion(source,"weapon/spear"); else if(targets.length()>1 && source->handCards().size() == 0 && source->hasWeapon("halberd")) room->setEmotion(source,"weapon/halberd"); else if(this->isVirtualCard() && this->skill_name == "fan") room->setEmotion(source,"weapon/fan"); BasicCard::use(room, source, targets); if(source->hasFlag("drank")){ LogMessage log; log.type = "#UnsetDrank"; log.from = source; room->sendLog(log); } }
void PFindSchemaElement::start() { /* 1) add actions 2) start actions 3) wait signals */ // Evalutate requires QList<PSchemaElement> childRequireSchemas = m_from.schema().requires(); if (!childRequireSchemas.isEmpty()) { // there is at least one require to evaluate PActionGroup *evalRequireGroup = new PActionGroup(this); evalRequireGroup->setSingleStatusToStop(PAction::StatusFailure, PAction::StatusFailure); for (int i=0; i<childRequireSchemas.length(); i++) { // add the require evaluator for the current require to the action group PWrapperRequire *require = m_from.childRequire(childRequireSchemas.at(i)); PEvalWrapperRequire *evalRequire = new PEvalWrapperRequire(require); evalRequireGroup->addAction(evalRequire); // fail if the group fails connect(evalRequireGroup, SIGNAL(failure(PAction::StatusType)), this, SLOT(finish(PAction::StatusType))); } } }
void QgsCompoundColorWidget::schemeIndexChanged( int index ) { //save changes to scheme if ( mSchemeList->isDirty() ) { mSchemeList->saveColorsToScheme(); } //get schemes with ShowInColorDialog set QList<QgsColorScheme *> schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorDialog ); if ( index >= schemeList.length() ) { return; } QgsColorScheme *scheme = schemeList.at( index ); mSchemeList->setScheme( scheme ); updateActionsForCurrentScheme(); //copy action defaults to disabled mActionCopyColors->setEnabled( false ); }
void MainWindow::updateNewsLabel() { auto newsChecker = MMC->newsChecker(); if (newsChecker->isLoadingNews()) { newsLabel->setText(tr("Loading news...")); newsLabel->setEnabled(false); } else { QList<NewsEntryPtr> entries = newsChecker->getNewsEntries(); if (entries.length() > 0) { newsLabel->setText(entries[0]->title); newsLabel->setEnabled(true); } else { newsLabel->setText(tr("No news available.")); newsLabel->setEnabled(false); } } }
bool SerialPortReader::checkSerialPortAvailable(){ QList<QSerialPortInfo> list = QSerialPortInfo::availablePorts(); for(int i = 0;i<list.length();i++){ if(list.at(i).portName().contains("usbmodem")){ if(list.at(i).isBusy()){ emit status(Status::usb_busy); return false; } this->serialPort.setPortName(list.at(i).portName()); return true; } } emit status(Status::usb_not_found); return false; }
QPoint MyMoveServer::getCentralPoint(const QList<QPoint>& list, int& width, int& height) { int minx = 0; int maxx = 0; int miny = 0; int maxy = 0; int x = 0; int y = 0; for (int i=0; i < list.length(); i++) { QPoint p = list.at(i); x = p.x(); y = p.y(); if (x < minx ) minx = x; else if (x > maxx) maxx = x; if (y < miny ) miny = y; else if (y > maxy) maxy = y; } width = maxx - minx; height = maxy - miny; return QPointF((minx+maxx)*0.5, (maxy+miny)*0.5).toPoint(); }
static QByteArray generate_html_list(const QByteArray &data) { QList<QByteArray> dives = data.split('\n'); QByteArray html; html.append("<html><body><table>"); for (int i = 0; i < dives.length(); i++ ) { html.append("<tr>"); QList<QByteArray> dive_details = dives[i].split(','); if (dive_details.length() < 3) continue; QByteArray dive_id = dive_details[0]; QByteArray dive_delete = dive_details[1]; html.append("<td>"); html.append("<a href=\"" DIVESHARE_BASE_URI "/dive/" + dive_id + "\">"); //Title gets separated too, this puts it back together const char *sep = ""; for (int t = 2; t < dive_details.length(); t++) { html.append(sep); html.append(dive_details[t]); sep = ","; } html.append("</a>"); html.append("</td>"); html.append("<td>"); html.append("<a href=\"" DIVESHARE_BASE_URI "/delete/dive/" + dive_delete + "\">Delete dive</a>"); html.append("</td>" ); html.append("</tr>"); } html.append("</table></body></html>"); return html; }
ChooseGeneralDialog::ChooseGeneralDialog(const QStringList &general_names, QWidget *parent) :QDialog(parent), free_chooser(NULL) { setWindowTitle(tr("Choose general")); QList<const General *> generals; foreach(QString general_name, general_names){ const General *general = Sanguosha->getGeneral(general_name); generals << general; } QSignalMapper *mapper = new QSignalMapper(this); QList<OptionButton *> buttons; QString category("card"); QSize icon_size(200*0.8, 290*0.8); if(generals.length() > 10){ category = "big"; icon_size = QSize(94, 96); } foreach(const General *general, generals){ QString icon_path = general->getPixmapPath(category); QString caption = Sanguosha->translate(general->objectName()); OptionButton *button = new OptionButton(icon_path, caption); button->setToolTip(general->getSkillDescription()); button->setIconSize(icon_size); buttons << button; mapper->setMapping(button, general->objectName()); connect(button, SIGNAL(double_clicked()), mapper, SLOT(map())); connect(button, SIGNAL(double_clicked()), this, SLOT(accept())); // special case if(Self->getRoleEnum() == Player::Lord && general->objectName() == "shencaocao"){ button->setEnabled(false); } }
void PropertyEditorView::editorValueChanged(QtProperty *prop, QVariant value) { if (mChangingPropertyValue) { return; } QtVariantProperty *property = dynamic_cast<QtVariantProperty*>(prop); int propertyType = property->propertyType(); int row = mPropertyEditor->properties().indexOf(property); const QModelIndex &index = mModel->index(row, 1); if (propertyType == QtVariantPropertyManager::enumTypeId()) { QList<QPair<QString, QString>> const values = mModel->enumValues(index); if (mModel->enumEditable(index)) { for (const auto &keyValue : values) { if (keyValue.second == value) { value = keyValue.first; } } } else { const int intValue = value.toInt(); if (intValue >= 0 && intValue < values.length()) { value = values.at(intValue).first; } } } value = QVariant(value.toString()); const Id id = mModel->idByIndex(index); const QString propertyName = mModel->propertyName(index); // TODO: edit included Qt Property Browser framework or inherit new browser // from it and create propertyCommited() and propertyCancelled() signal qReal::commands::ChangePropertyCommand *changeCommand = new qReal::commands::ChangePropertyCommand(mLogicalModelAssistApi, propertyName, id, value); mController->execute(changeCommand); }
// Read the qmldir file, extract a list of plugins by // parsing the "plugin" and "classname" lines. QVariantMap pluginsForModulePath(const QString &modulePath) { QFile qmldirFile(modulePath + QStringLiteral("/qmldir")); if (!qmldirFile.exists()) return QVariantMap(); qmldirFile.open(QIODevice::ReadOnly | QIODevice::Text); // a qml import may contain several plugins QString plugins; QString classnames; QStringList dependencies; QByteArray line; do { line = qmldirFile.readLine(); if (line.startsWith("plugin")) { plugins += QString::fromUtf8(line.split(' ').at(1)); plugins += QStringLiteral(" "); } else if (line.startsWith("classname")) { classnames += QString::fromUtf8(line.split(' ').at(1)); classnames += QStringLiteral(" "); } else if (line.startsWith("depends")) { QList<QByteArray> dep = line.split(' '); if (dep.length() != 3) std::cerr << "depends: expected 2 arguments: module identifier and version" << std::endl; else dependencies << QString::fromUtf8(dep[1]) + QStringLiteral(" ") + QString::fromUtf8(dep[2]).simplified(); } } while (line.length() > 0); QVariantMap pluginInfo; pluginInfo[QStringLiteral("plugins")] = plugins.simplified(); pluginInfo[QStringLiteral("classnames")] = classnames.simplified(); if (dependencies.length()) pluginInfo[QStringLiteral("dependencies")] = dependencies; return pluginInfo; }
// =========== // PRIVATE SLOTS // =========== void LScreenSaver::ShowScreenSaver(){ if(DEBUG){ qDebug() << "Showing Screen Saver:" << QDateTime::currentDateTime().toString(); } SSRunning = true; updating = true; //Now remove any current Base widgets (prevent any lingering painting between sessions) for(int i=0; i<BASES.length(); i++){ if(DEBUG){ qDebug() << " - Removing SS Base"; } delete BASES.takeAt(i); i--; } //Now go through and create/show all the various widgets QList<QScreen*> SCREENS = QApplication::screens(); QRect bounds; cBright = LOS::ScreenBrightness(); if(cBright>0){ LOS::setScreenBrightness(cBright/2); } //cut to half while the screensaver is active for(int i=0; i<SCREENS.length(); i++){ bounds = bounds.united(SCREENS[i]->geometry()); if(DEBUG){ qDebug() << " - New SS Base:" << i; } BASES << new SSBaseWidget(this, settings); connect(BASES[i], SIGNAL(InputDetected()), this, SLOT(newInputEvent()) ); //Setup the geometry of the base to match the screen BASES[i]->setGeometry(SCREENS[i]->geometry()); //match this screen geometry BASES[i]->setPlugin(settings->value("screenplugin"+QString::number(i+1), settings->value("defaultscreenplugin","random").toString() ).toString() ); } //Now set the overall parent widget geometry and show everything this->setGeometry(bounds); //overall background widget if(!this->isActiveWindow()){ this->raise(); this->show(); this->activateWindow(); } for(int i=0; i<BASES.length(); i++){ BASES[i]->show(); BASES[i]->startPainting(); } updating = false; UpdateTimers(); }
void BSInterpolation::CalculateParameters() { //int knotsNo; //calculate length between segments QList<float> segmentslength; //0...n+1 float totalLength = 0; for (int i = 0; i<markers.length()-1; i++) { segmentslength.append(sqrt(pow((markers[i+1]->point.x()-markers[i]->point.x()),2) +pow((markers[i+1]->point.y()-markers[i]->point.y()),2) +pow((markers[i+1]->point.z()-markers[i]->point.z()),2))); totalLength += segmentslength[i]; } //data set -> n+1 length //calculate parameters t -> length n+1 parameters.append(0); float sum = 0; for (int i = 0; i<segmentslength.length(); i++) { sum += segmentslength[i]; parameters.append(sum /totalLength); } //calculate knots -> n+1+p+1 = m+1 length //first and last p+1 point -> 0 and 1 respectively if clamped //knots - avarage of p parameters for (int i = 0; i<degree+1; i++) { knots.append(0); } sum = 0; for (int i = 1; i<parameters.length()-degree; i++) { //i = 1... n-p for (int j = i; j<degree+i; j++) sum += parameters[j]; knots.append(sum/(float)degree); sum = 0; } for (int i = 0; i<degree+1; i++) { knots.append(1); } }
void convertAllFrames() { mProgressBar->setMaximum(mFrames.length() - 1); int count = 0; foreach(QVideoFrame frame, mFrames) { mProgressBar->setValue(count++); QImage image; if (frame.pixelFormat() == QVideoFrame::Format_RGB32) { // Copy const QVideoFrame to mutable QVideoFrame. QVideoFrame nonConstFrame = frame; // Unlock for reading the stack frame (increment ref pointer) nonConstFrame.map(QAbstractVideoBuffer::ReadOnly); // Create new image from the frame bits image = QImage( nonConstFrame.bits(), nonConstFrame.width(), nonConstFrame.height(), nonConstFrame.bytesPerLine(), QVideoFrame::imageFormatFromPixelFormat(nonConstFrame.pixelFormat())); nonConstFrame.unmap(); } else { image = QImage(frame.size(), QImage::Format_RGB32); mFrameConverter->convertFrame(frame, &image); } QString imgFileName = QString("%1.%2.png").arg(mFileName).arg(++mCount, 2, 10, QChar('0')); //QFile file(imgFileName); //file.open(QFile::WriteOnly); bool saved = image.save(imgFileName, "png"); if (saved) { log->info("File: %1 saved", imgFileName); } else { log->info("File: %1 not saved", imgFileName); } }
void Dashboard::selectCard(const QString &pattern, bool forward){ if(selected) selected->select(); // adjust the position // find all cards that match the card type QList<CardItem*> matches; foreach(CardItem *card_item, card_items){ if(card_item->isEnabled()){ if(pattern == "." || card_item->getFilteredCard()->match(pattern)) matches << card_item; } } if(matches.isEmpty()){ unselectAll(); return; } int index = matches.indexOf(selected); int n = matches.length(); if(forward) index = (index + 1) % n; else index = (index - 1 + n) % n; CardItem *to_select = matches[index]; if(to_select != selected){ if(selected) selected->unselect(); to_select->select(); selected = to_select; emit card_selected(selected->getFilteredCard()); } }
void GameScene:: loadTexture() { BlockListNode *bn=world->getBlockIndex(0); int tw=bn->texWidth; int th=bn->texHeight; QStringList filter; QList<QFileInfo> files; QMap<QString,int>texMap; filter = QStringList("*.png"); //索引材质的数量 files = QDir(":/res/divinecraft/textures/blocks/").entryInfoList(filter, QDir::Files | QDir::Readable); int tc=files.length(); // qWarning()<<tc; world->setBlockListLength(tc); //更新方块列表的材质数量记录 blockTexture=new GLTexture3D(tw,th,tc+1); //为了使材质列表的最后一张材质能够使用,需要再增加一张多余的材质来垫底 QRgb *data=new QRgb[tw*th*(tc+1)]; // memset(data,0,tw*th*tc*sizeof(QRgb)); QRgb *p=data; for(int k=0;k<=tc;k++){ QImage img(files[k==tc?0:k].absoluteFilePath()); if(k<tc){ texMap.insert(files[k].baseName(),k); } for(int i=0;i<tw;i++){ for(int j=0;j<th;j++){ *p=img.pixel(j,i); p++; } } } blockTexture->load(tw,th,tc+1,data); delete [] data; world->calcBlockListNodeTexId(texMap); //进行名称->ID映射 }
/** * Initiate object retrieval, initialize queue with objects to be retrieved. */ void TelemetryMonitor::startRetrievingObjects() { // Clear object queue queue.clear(); // Get all objects, add metaobjects, settings and data objects with OnChange update mode to the queue QList< QList<UAVObject*> > objs = objMngr->getObjects(); for (int n = 0; n < objs.length(); ++n) { UAVObject* obj = objs[n][0]; UAVMetaObject* mobj = dynamic_cast<UAVMetaObject*>(obj); UAVDataObject* dobj = dynamic_cast<UAVDataObject*>(obj); UAVObject::Metadata mdata = obj->getMetadata(); if ( mobj != NULL ) { queue.enqueue(obj); } else if ( dobj != NULL ) { if ( dobj->isSettings() ) { queue.enqueue(obj); } else { if ( UAVObject::GetFlightTelemetryUpdateMode(mdata) == UAVObject::UPDATEMODE_ONCHANGE ) { queue.enqueue(obj); } } } } // Start retrieving qxtLog->debug(tr("Starting to retrieve meta and settings objects from the autopilot (%1 objects)") .arg( queue.length()) ); retrieveNextObject(); }
bool MainUI::fillVerticalAppArea( QScrollArea* area, QStringList applist, bool filter){ //clear the scroll area first clearScrollArea(area); bool ok = false; //returns whether any apps were shown after filtering //Re-create the layout QVBoxLayout *layout = new QVBoxLayout; QList<NGApp> apps = PBI->AppInfo(applist); for(int i=0; i<apps.length(); i++){ bool goodApp = false; if(apps[i].type.toLower()=="graphical"){goodApp = ui->actionGraphical_Apps->isChecked(); } else if(apps[i].type.toLower()=="text"){goodApp = ui->actionText_Apps->isChecked(); } else if(apps[i].type.toLower()=="server"){goodApp = ui->actionServer_Apps->isChecked(); } else{goodApp = ui->actionRaw_Packages->isChecked(); } if( !filter || goodApp){ LargeItemWidget *item = new LargeItemWidget(this,apps[i], checkIcon(apps[i].icon, apps[i].type) ); connect(item,SIGNAL(appClicked(QString)),this,SLOT(slotGoToApp(QString)) ); layout->addWidget(item); ok = true; } } layout->addStretch(); area->widget()->setLayout(layout); return ok; }
bool BDTools::update(QString table, QList<QString> fields, QList<QString> values, QString fieldCondition, QString valueCondition){ QString sql = "update " + table + " set "; for (int i = 0; i < fields.length(); i++){ if (values[i].isEmpty()) sql += fields[i] + " = null, "; else{ values[i].replace("'", "''"); sql += fields[i] + " = '" + values[i] + "', "; } } sql = sql.mid(0, sql.length() - 2); sql += " where " + fieldCondition + " = '" + valueCondition + "'"; bool b = exec(sql); if (! b) qDebug() << "[BDTools] [UPDATE] Erro na SQL: " << sql; return b; }