void ScanDialog::onFetchTitlesFinished() { if (mgrt->errorOccurred()) { resetUI(); return; } if (fetchedTitles >= 0) { QString title; if (!Scan::title(mgrt->getData(), title)) title = videoLinks[fetchedTitles]; // Fallback to link. QTreeWidgetItem *item = new QTreeWidgetItem; item->setCheckState(0, Qt::Unchecked); item->setText(0, title); item->setText(1, videoLinks[fetchedTitles]); itemsTree->addTopLevelItem(item); updateCount(); progressBar->setValue(++fetchedTitles); if (fetchedTitles == expectedTitles) { resetUI(); videoLinks.clear(); mgrt->deleteLater(); Util::appendLog(logEdit, tr("Done.")); return; } } else fetchedTitles++; mgrt->fetch(videoLinks[fetchedTitles]); }
void ScanDialog::resetUI() { enableWidgets(true); scanButton->setText(tr("&Scan")); scanButton->setIcon(QIcon(":edit-find.png")); updateCount(); }
void ScanDialog::onScan() { if (!linkEdit->isEnabled()) { // Assumes it is disabled when we're scanning. if (mgr) mgr->abort(); if (mgrt) mgrt->abort(); return; } QString lnk = linkEdit->text().simplified(); if (lnk.isEmpty()) return; if (!lnk.startsWith("http://", Qt::CaseInsensitive)) lnk.insert(0,"http://"); itemsTree->clear(); updateCount(); logEdit->clear(); enableWidgets(false); progressBar->setTextVisible(false); scanButton->setText(tr("&Abort")); scanButton->setIcon(QIcon(":process-stop.png")); mgr->fetch(lnk); }
void PicsSelectWidget::pressedGlobalAll() { int g, p; for (g = 0; g < PicBucket::instance().grps.size() ; ++g) { const PicGroupDef &gp = PicBucket::instance().grps[g]; for (p = 0; p < gp.numPics(); ++p) { gp.getPic(p).setSelected(1); } } globalSignalBlock(true); setUpdatesEnabled(false); for (g = 0; g < PicBucket::instance().grps.size() ; ++g) // UpdateCount optimization { const PicGroupDef &gp = PicBucket::instance().grps[g]; for (p = 0; p < gp.numPics(); ++p) { updatePic(g, p, 1); } } updateCount(); setUpdatesEnabled(true); globalSignalBlock(false); }
void PicsSelectWidget::pressedGlobalNone() { int g, p; for (g = 0; g < PicBucket::instance().grps.size() ; ++g) { PicGroupDef &gp = PicBucket::mutableInstance().grps[g]; for (p = 0; p < gp.numPics(); ++p) { PicDef& def = gp.getPic(p); def.setSelected(0); def.lastnSelected = 1; } } globalSignalBlock(true); setUpdatesEnabled(false); for (g = 0; g < PicBucket::instance().grps.size() ; ++g) // UpdateCount optimization { const PicGroupDef &gp = PicBucket::instance().grps[g]; for (p = 0; p < gp.numPics(); ++p) { updatePic(g, p, 0); } } updateCount(); setUpdatesEnabled(true); globalSignalBlock(false); }
void PicsSelectWidget::changeToResetValues() // SLOT { int g, p, f; PicBucket& bucket = PicBucket::mutableInstance(); bucket.setToFamResetSel(); setUpdatesEnabled(false); // this is not superflous. if we're not connected to anyone else, we need it // although with the BuildDlg feedback this may seem unnecessary. for(f = 0; f < bucket.families.size(); ++f) { const PicFamily &fam = bucket.families[f]; int setTo = fam.onResetSetCount; for (g = fam.startIndex; g < fam.startIndex + fam.numGroups; ++g) { const PicGroupDef &grp = bucket.grps[g]; for (p = 0; p < grp.numPics(); ++p) { updatePic(g, p, setTo); // save all the UpdateCounts } } } updateCount(); setUpdatesEnabled(true); }
void shaftEncodingTurnLeft(int percent, int counts) { //Reset encoder counts clearCounts(); //Set both motors to desired percent turnLeft(percent); //While the average of the left and right encoder are less than counts, //keep running motors while(updateCount() < counts){ LCD.WriteLine(updateCount()); } //Turn off motors stop(); }
int getNextCount() { char card_name[3]; puts("\nEnter the card_name"); scanf("%ss", card_name); return updateCount(card_name); }
void shaftEncodingStraight(int percent, double distance) { int counts = 318*distance/(2.5*3.1415); //Reset encoder counts clearCounts(); //Set both motors to desiRED_LIGHT percent drive(percent); //While the average of the left and right encoder are less than counts, //keep running motors while(updateCount() < counts){ LCD.WriteLine(updateCount()); } //Turn off motors stop(); }
ItemButton::ItemButton(int frameRect,sf::Texture* tex,int id){ this->id = id; this->setImage(tex); setFrameSize(32,32); setFrameRect(frameRect); text = new sf::Text(); updateCount(0); setVisible(false); }
void PicsSelectWidget::changedNumBox(int num, int data) { int g = (data >> 16) & 0xFFFF, p = data & 0xFFFF; const PicDef *pd = &(PicBucket::instance().getPic(g, p)); pd->setSelected(num); // index and actual number are the same updatePic(g, p, num); updateCount(); }
void ggEditor::onEvent( sf::Window* window , sf::Event* e ) { if ( *currentController != CTRL_EDITOR ) { return; } // create cells on left click if ( e->type == sf::Event::MouseButtonPressed && e->mouseButton.button == sf::Mouse::Left ) { if ( e->mouseButton.y > GG_CONTROL_BAR_HEIGHT ) { sf::Vector2i gridLocation = i->windowToGrid( e->mouseButton.x , e->mouseButton.y ); // std::cout << "(" << gridLocation.x << ", " << gridLocation.y << ")\n"; // delete cell under ggCell* under = i->cellAt(gridLocation.x, gridLocation.y, CELL_ANY, &i->cellsInitial); if ( under ) { ggCell cellDeleted = i->delCellInitial(gridLocation.x, gridLocation.y); updateCount(); } if ( i->selectedType == CELL_WSPAWN && wspawn_count >= GG_WSPAWN_MAX ) { out("You can only place 1 water spawner!\n"); } else if ( i->selectedType == CELL_SEED && seed_count >= GG_SEED_MAX ) { out( "You can only place 20 seeds!\n"); } else { i->addCellInitial( ggCell(gridLocation.x, gridLocation.y, i->selectedType) ); } if ( i->selectedType == CELL_WSPAWN ) ++ wspawn_count; if ( i->selectedType == CELL_SEED ) ++ seed_count; } } // delete cells on right click if ( e->type == sf::Event::MouseButtonPressed && e->mouseButton.button == sf::Mouse::Right ) { if ( e->mouseButton.y > GG_CONTROL_BAR_HEIGHT ) { sf::Vector2i gridLocation = i->windowToGrid( e->mouseButton.x , e->mouseButton.y ); // std::cout << "(" << gridLocation.x << ", " << gridLocation.y << ")\n"; ggCell cellDeleted = i->delCellInitial(gridLocation.x, gridLocation.y); // doesn't matter if cell doesn't exist updateCount(); } } }
void ProcessorDlg::slotFinished(const QUrl& url) { qDebug() << "Completed item " << url.toLocalFile(); QProgressBar* const b = findProgressBar(url); if (b) { b->setMinimum(0); b->setMaximum(100); b->setValue(100); b->setFormat(QString::fromUtf8("Done")); d->count--; updateCount(); } }
void SyntheticDimChunkMerger::SyntheticDimAdjuster::updateMapCoordToCount(MemChunk const* chunk, ConstChunkIterator* chunkIter) { // Note that default values can't be ignored. Otherwise the coordinate in the synthetic dimension would mess up. std::shared_ptr<ConstChunkIterator> localIter; if (!chunkIter) { localIter = chunk->getConstIterator(ChunkIterator::IGNORE_EMPTY_CELLS| ChunkIterator::APPEND_CHUNK); chunkIter = localIter.get(); } while (!chunkIter->end()) { updateCount(chunkIter->getPosition()); ++(*chunkIter); } }
void ProcessorDlg::slotFailed(const QUrl& url, const QString& err) { qDebug() << "Failed to complete item " << url.toLocalFile(); QProgressBar* const b = findProgressBar(url); if (b) { b->setMinimum(0); b->setMaximum(100); b->setValue(100); b->setFormat(err); d->count--; updateCount(); } }
bool Packet::decompress(Controller &_rctrl){ if(!(flags() & CompressedFlag)){ return true; } const uint32 updatesz = updateCount() * sizeof(uint32); const uint32 headersize = headerSize() - updatesz; PacketContext bctx(headersize); uint32 datasz = dl + updatesz; char *pd = pb + headersize; uint32 tmpdatasz = datasz; char *tmppd(pd); vdbgx(Debug::ipc, "packet before decompress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize()); if(_rctrl.decompressPacket(bctx, tmppd, tmpdatasz)){ if(bctx.reqbufid != (uint)-1){ if(tmppd == pd){ THROW_EXCEPTION("Requested buffer not returned"); } tmppd -= bctx.offset; memcpy(tmppd, pb, headersize); Specific::pushBuffer(this->pb, Specific::capacityToIndex(this->bc)); this->bc = Specific::indexToCapacity(bctx.reqbufid); this->pb = tmppd; }else{ //on-place decompression if(tmppd != pd){ THROW_EXCEPTION("Invalid buffer pointer returned"); } } this->flags(this->flags() & (~CompressedFlag)); this->dl += (tmpdatasz - datasz); vdbgx(Debug::ipc, "packet success decompress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize()); }else{ //decompression failed if(bctx.reqbufid != (uint)-1){ if(pd == tmppd){ THROW_EXCEPTION("Allocated buffer must be returned even on failed compression"); } tmppd -= bctx.offset; Specific::pushBuffer(tmppd, bctx.reqbufid); } vdbgx(Debug::ipc, "packet failed decompress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize()); return false; } return true; }
void ggEditor::tick( sf::Window* window ) { if ( *currentController != CTRL_EDITOR ) { return; } i->wspawn_count = wspawn_count; // If play pressed, hand control over to game. if ( i->btnPlay.doAction ) { i->btnPlay.doAction = false; i->loadInitialCellPattern(); *currentController = CTRL_GAME; } if ( i->btnStop.doAction ) i->btnStop.doAction = false; if ( i->btnPause.doAction ) i->btnPause.doAction = false; if ( i->btnReset.doAction ) { wspawn_count = 0; seed_count = 0; i->btnReset.doAction = false; } if ( i->btnSave.doAction ) { i->btnSave.doAction = false; std::string pathFileName = pop_file_dialog( DIALOG_SAVE, "\\patterns\\", window->getSystemHandle() ); if ( pathFileName != "" ) { save_as_image( pathFileName, i->cellsInitial ); } } if ( i->btnLoad.doAction ) { i->btnLoad.doAction = false; // TODO -> Figure out how to update seed and fountain count after loading std::string pathFileName = pop_file_dialog( DIALOG_OPEN, "\\patterns\\", window->getSystemHandle() ); if ( pathFileName.find("GardenGrow.exe") != std::string::npos ) { i->flagHelp = true; } else { i->flagHelp = false; } if ( pathFileName != "" ) { load_from_image( pathFileName, i->cellsInitial ); updateCount(); i->panX = 0.0f; i->panY = 0.0f; i->zoomLevel = 1.0f; } } }
void PicsSelectWidget::pressedPicButton(int data, bool checked) { int g = (data >> 16) & 0xFFFF, p = data & 0xFFFF; const PicDef *pd = &(PicBucket::instance().getPic(g, p)); if (pd->getSelected() > 0) { pd->lastnSelected = pd->getSelected(); pd->setSelected(0); } else { pd->setSelected(pd->lastnSelected); } famSignalBlock(true); updatePic(g, p, pd->getSelected()); updateCount(); famSignalBlock(false); }
bool Packet::compress(Controller &_rctrl){ const uint32 updatesz = updateCount() * sizeof(uint32); const uint32 headersize = headerSize() - updatesz; PacketContext bctx(headersize); int32 datasz(dataSize() + updatesz); char *pd(data() - updatesz); uint32 tmpdatasz(datasz); char *tmppd(pd); vdbgx(Debug::ipc, "buffer before compress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize()); if(_rctrl.compressPacket(bctx, this->bufferSize(), tmppd, tmpdatasz)){ if(tmppd != pd){ if(bctx.reqbufid == (uint)-1){ THROW_EXCEPTION("Invalid buffer pointer returned"); } tmppd -= bctx.offset; memcpy(tmppd, pb, headersize); Specific::pushBuffer(this->pb, Specific::capacityToIndex(this->bc)); this->bc = Specific::indexToCapacity(bctx.reqbufid); this->pb = tmppd; }else{ //the compression was done on-place } this->flags(this->flags() | CompressedFlag); this->dl -= (datasz - tmpdatasz); vdbgx(Debug::ipc, "buffer success compress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize()); }else{ if(bctx.reqbufid != (uint)-1){ if(pd == tmppd){ THROW_EXCEPTION("Allocated buffer must be returned even on no compression"); } tmppd -= bctx.offset; Specific::pushBuffer(tmppd, bctx.reqbufid); } vdbgx(Debug::ipc, "buffer failed compress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize()); } optimize(); return true; }
void PicsSelectWidget::changeFamBox(int count, int f) // SLOT { if (m_bIncomingSignalsBlocked) return; if (count == -1) return; int g, p; const PicBucket& bucket = PicBucket::instance(); const PicFamily &fam = bucket.families[f]; for (g = fam.startIndex; g < fam.startIndex + fam.numGroups; ++g) { const PicGroupDef &grp = bucket.grps[g]; for (p = 0; p < grp.numPics(); ++p) { grp.getPic(p).setSelected(count); } } globalSignalBlock(true); setUpdatesEnabled(false); // we we got an external fam update, set the current fam to the one change if ((f != m_tabs->currentIndex()) && isVisible()) m_tabs->setCurrentIndex(f); for (g = fam.startIndex; g < fam.startIndex + fam.numGroups; ++g) { const PicGroupDef &grp = bucket.grps[g]; for (p = 0; p < grp.numPics(); ++p) { updatePic(g, p, count); // save all the UpdateCounts } } updateCount(); setUpdatesEnabled(true); globalSignalBlock(false); }
void slaveApp(void) { char myChar; char message[80]; uartTxPoll(UART0, "Hello this the slave talking..\n\r"); while(1) { myChar = uart5Rx(false); if (myChar != -1) { sprintf(message, "Received %d.. \n\r", (int)myChar); uartTxPoll(UART0, message); count = 77; //(int) myChar; } updateCount(); // while(OneSecond == false){}; // OneSecond = false; // uartTxPoll(UART0, "Sent clear..\n\r"); // uart2Tx(UART_CMD_WDT_CLEAR); } }
ReportedCount CardProbabilityCalculator::Calculate(std::ostream* os) { // 残り1種類から、最初の1セットまで降る for(CardNumber i=1; i<=(kindOfCards_ - cardsPerDraw_); ++i) { if ((i % g_progressPerLoop) == 0) { if (os) { (*os) << "*" << std::flush; } } setProbabilityArray(i); updateCount(i); } if (os) { (*os) << std::endl; } // 最初の1手は別に数える constexpr ReportedCount firstDraw = 1; // template method return calculate() + firstDraw; }
void PicsSelectWidget::changedGrpBox(int count, int g) { if (count == -1) return; int p; const PicBucket& bucket = PicBucket::instance(); const PicGroupDef &grp = bucket.grps[g]; for (p = 0; p < grp.numPics(); ++p) { grp.getPic(p).setSelected(count); } setUpdatesEnabled(false); for (p = 0; p < grp.numPics(); ++p) { updatePic(g, p, count); // save all the UpdateCounts } updateCount(); setUpdatesEnabled(true); }
/// update the view according to the current state in the PicBucket. void PicsSelectWidget::updateView(int hint) // SLOT { if (GET_PIC_HINT(hint) == HINT_PIC_NULL) return; // nothing to do here. move along if (!m_bFinishedCreate) return; const SlvCube* curslv = m_doc->getCurrentSolve(); const PicBucket& bucket = PicBucket::instance(); int pichint = GET_PIC_HINT(hint); bool doReadCheckFromSlv = ( (curslv != nullptr) && ((pichint & HINT_PIC_READSLVCHECK) != 0) ); bool doUpdateCheck = (pichint & HINT_PIC_UPDATECHECK) != 0; int g, p; // reset everything for (int pi = 0; pi < bucket.pdefs.size() ; ++pi) { const PicDef &def = bucket.pdefs[pi]; def.nUsed = 0; if (doReadCheckFromSlv) { def.setSelected(0); } } if (curslv != nullptr) { // make everybody in the solution light up for (int plci = 0; plci < curslv->dt.size(); ++plci) { int abs_sc = curslv->dt[plci].abs_sc; if (abs_sc == -1) continue; ++(bucket.pdefs[abs_sc].nUsed); } if (doReadCheckFromSlv) { // make everybody that is selected be pressed for (int pi = 0; pi < curslv->picdt.size(); ++pi) { bucket.getPic(curslv->picdt[pi].gind, curslv->picdt[pi].pind).addSelected(1); } } } // commit the information to the gui setUpdatesEnabled(false); // this needs to be outside since we may have zeroed something. and UpdateCount optimization. for (g = 0; g < bucket.grps.size() ; ++g) { for (p = 0; p < bucket.grps[g].numPics(); ++p) { const PicDef &def = bucket.getPic(g, p); updateSolNum(g, p, def.nUsed); if (doReadCheckFromSlv || doUpdateCheck) { updatePic(g, p, def.getSelected()); } } } if (curslv == nullptr) updateSolveText(-1, -1); else updateSolveText(m_doc->getCurrentSolveIndex() + 1, m_doc->getSolvesNumber()); m_currentGlobalCount = -1; // reset the optimization since the new number can be equal to the old updateCount(); setUpdatesEnabled(true); }
void Time::setHour(int hours) { h = hours; updateCount(); }
void ItemButton::setCount(int i){ updateCount(i); }
void Time::setMinute(int minutes) { m = minutes; updateCount(); }
std::string CallingRange::updateID(const std::string &objectID) { if (callerType_ == CallerType::Cell) return objectID + counterDelimiter + updateCount(); else return objectID; }
ProcessorDlg::ProcessorDlg(const QList<QUrl>& list) : QDialog(0), d(new Private) { setModal(false); setWindowTitle(QString::fromUtf8("Convert RAW files To PNG")); d->buttons = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Close, this); d->thread = new MyActionThread(this); d->list = list; d->count = d->list.count(); qDebug() << d->list; d->page = new QWidget(this); QVBoxLayout* const vbx = new QVBoxLayout(this); vbx->addWidget(d->page); vbx->addWidget(d->buttons); setLayout(vbx); int cpu = d->thread->maximumNumberOfThreads(); QGridLayout* const grid = new QGridLayout(d->page); QLabel* const pid = new QLabel(QString::fromUtf8("Main PID: %1").arg(QCoreApplication::applicationPid()), this); QLabel* const core = new QLabel(QString::fromUtf8("CPU cores available: %1").arg(cpu), this); QWidget* const hbox = new QWidget(this); d->items = new QLabel(this); QHBoxLayout* const hlay = new QHBoxLayout(hbox); QLabel* const coresLabel = new QLabel(QString::fromUtf8("Cores to use: "), this); d->usedCore = new QSpinBox(this); d->usedCore->setRange(1, cpu); d->usedCore->setSingleStep(1); d->usedCore->setValue(cpu); hlay->addWidget(coresLabel); hlay->addWidget(d->usedCore); hlay->setContentsMargins(QMargins()); d->progressView = new QScrollArea(this); QWidget* const progressbox = new QWidget(d->progressView->viewport()); QVBoxLayout* const progressLay = new QVBoxLayout(progressbox); d->progressView->setWidget(progressbox); d->progressView->setWidgetResizable(true); grid->addWidget(pid, 0, 0, 1, 1); grid->addWidget(core, 1, 0, 1, 1); grid->addWidget(hbox, 2, 0, 1, 1); grid->addWidget(d->items, 3, 0, 1, 1); grid->addWidget(d->progressView, 4, 0, 1, 1); foreach (const QUrl& url, d->list) { QProgressBar* const bar = new QProgressBar(progressbox); QString file = url.toLocalFile(); QFileInfo fi(file); bar->setMaximum(100); bar->setMinimum(0); bar->setValue(100); bar->setObjectName(file); bar->setFormat(fi.fileName()); progressLay->addWidget(bar); } progressLay->addStretch(); QPushButton* const applyBtn = d->buttons->button(QDialogButtonBox::Apply); QPushButton* const cancelBtn = d->buttons->button(QDialogButtonBox::Close); connect(applyBtn, SIGNAL(clicked()), this, SLOT(slotStart())); connect(cancelBtn, SIGNAL(clicked()), this, SLOT(slotStop())); connect(d->thread, SIGNAL(starting(QUrl)), this, SLOT(slotStarting(QUrl))); connect(d->thread, SIGNAL(finished(QUrl)), this, SLOT(slotFinished(QUrl))); connect(d->thread, SIGNAL(failed(QUrl,QString)), this, SLOT(slotFailed(QUrl,QString))); connect(d->thread, SIGNAL(progress(QUrl,int)), this, SLOT(slotProgress(QUrl,int))); updateCount(); resize(500, 400); }
void Time::setSecond(int seconds) { s = seconds; updateCount(); }