GPS_Filter::GPS_Filter_Result GPS_Filter::filter(const GPS_Info &info_read, GPS_Info &info_refined) { m_last_info = info_read; // zgr, 2008-01-28,先判断是否有效GPS_Info if(isInfoBad(info_read)) { info_refined = info_read; m_lasted_times++; return GPSFR_BAD; } // zgr, 第一次有效值当作正常处理,即使停止也没关系 if(noLastUsed()) { addToHistory(info_read); m_last_used = info_read; m_lasted_times = 0; info_refined = info_read; return GPSFR_NORMAL; } if(isStoping(info_read)) { addToHistory(info_read); info_refined = info_read; if(!noLastUsed()) { m_lasted_times++; info_refined.heading = m_last_used.heading; // zgr, 停止时使用上次的有效方向值 } return GPSFR_STOP; } // zgr, 低速:考虑两种状态;1. 刚刚启动,2.刹车停止 if(isDrivingSlow(info_read)) { info_refined = info_read; // zgr, 2008-01-28 double angle_off_set = fabs(info_read.heading - getHistoryAvgHeading() ); if(angle_off_set > 180) angle_off_set = 360 - angle_off_set; if(angle_off_set > min(90.0f, m_para.m_history_size * m_para.m_max_ang_offset_slow)) // zgr,低速时如果角度偏移过大,如刹车时突然反向,对修正影响过大,过滤掉 info_refined.heading = m_last_used.heading; else if(angle_off_set > m_para.m_max_ang_offset_slow) // zgr, 角度有一定偏移,修正 info_refined.heading = getRefinedHeading(info_read); addToHistory(info_refined); m_last_used = info_refined; m_lasted_times = 0; return GPSFR_REFINED; } addToHistory(info_read); m_last_used = info_read; m_lasted_times = 0; info_refined = info_read; return GPSFR_NORMAL; }
void PrinterWidget::scale() { if (ui->print_list->count() == 0) { return; } double sx, sy; sx = (sender() == ui->scale_plus_button) ? sy = 1.1 : sy = 0.9; const QString& path = currentItem->data(3).toString(); addToHistory(path, *work_pix); QSize size(sx*work_pix->width(),sy*work_pix->height()); QPixmap* pix = new QPixmap( work_pix->scaled(size,Qt::KeepAspectRatio) ); resetCurrentState(path,*pix); delete work_pix; work_pix = pix; if (cut_rect_show_pix != NULL) { delete cut_rect_show_pix; } cut_rect_show_pix = new QPixmap(*work_pix); setRedBox(cut_rect_show_pix, cut_rect_show_pix->rect()); QLabel* l = dynamic_cast<QLabel*>(ui->monitor_area->widget()); l->setPixmap(*cut_rect_show_pix); resetCutParameters(cut_rect_show_pix->width(), cut_rect_show_pix->height()); }
void PrinterWidget::rotateRight() { if (ui->print_list->count() == 0) { return; } const QString& path = currentItem->data(3).toString(); addToHistory(path, *work_pix); QPixmap* pix = new QPixmap(work_pix->height(), work_pix->width()); QPainter p(pix); p.translate(work_pix->height(),0); p.rotate(90); p.drawPixmap(work_pix->rect(), *work_pix); resetCurrentState(path,*pix); delete work_pix; work_pix = pix; if (cut_rect_show_pix != NULL) { delete cut_rect_show_pix; } cut_rect_show_pix = new QPixmap(*work_pix); setRedBox(cut_rect_show_pix, cut_rect_show_pix->rect()); QLabel* l = dynamic_cast<QLabel*>(ui->monitor_area->widget()); l->setPixmap(*cut_rect_show_pix); resetCutParameters(cut_rect_show_pix->width(), cut_rect_show_pix->height()); }
void PrinterWidget::cut() { if (ui->print_list->count() == 0) { return; } int x = ui->corner_coord_x->value(); int y = ui->corner_coord_y->value(); int w = ui->new_size_x->value(); int h = ui->new_size_y->value(); if (x == 0 && y == 0 && w == work_pix->width() && h == work_pix->height()) { return; } const QString& path = currentItem->data(3).toString(); QPixmap* p = new QPixmap(work_pix->copy(x,y,w,h)); addToHistory(path, *work_pix); resetCurrentState(path, *p); delete work_pix; work_pix = p; if (cut_rect_show_pix != NULL) { delete cut_rect_show_pix; } cut_rect_show_pix = new QPixmap(*work_pix); setRedBox(cut_rect_show_pix, cut_rect_show_pix->rect()); QLabel* l = dynamic_cast<QLabel*>(ui->monitor_area->widget()); l->setPixmap(*cut_rect_show_pix); resetCutParameters(work_pix->width(), work_pix->height()); }
void PrinterWidget::discolor() { if (ui->print_list->count() == 0) { return; } const QString& path = currentItem->data(3).toString(); addToHistory(path, *work_pix); QImage img = work_pix->toImage(); for( int w = 0; w < img.width(); ++w ) { for( int h = 0; h < img.height(); ++h ) { QColor col( img.pixel(w,h) ); col.setHsv(col.hue(), 0, col.value(), col.alpha()); img.setPixel(w,h,col.rgb()); } } QPixmap* pix = new QPixmap( QPixmap::fromImage(img) ); resetCurrentState(path,*pix); delete work_pix; work_pix = pix; if (cut_rect_show_pix != NULL) { delete cut_rect_show_pix; } cut_rect_show_pix = new QPixmap(*work_pix); setRedBox(cut_rect_show_pix, cut_rect_show_pix->rect()); QLabel* l = dynamic_cast<QLabel*>(ui->monitor_area->widget()); l->setPixmap(*cut_rect_show_pix); resetCutParameters(cut_rect_show_pix->width(), cut_rect_show_pix->height()); }
bool ChatbarTextEdit::event(QEvent *evt) { if (evt->type() == QEvent::ShortcutOverride) { return false; } if (evt->type() == QEvent::KeyPress) { QKeyEvent *kev = static_cast<QKeyEvent*>(evt); if ((kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return) && !(kev->modifiers() & Qt::ShiftModifier)) { const QString msg = toPlainText(); if (!msg.isEmpty()) { addToHistory(msg); emit entered(msg); } return true; } if (kev->key() == Qt::Key_Tab) { emit tabPressed(); return true; } else if (kev->key() == Qt::Key_Space && kev->modifiers() == Qt::ControlModifier) { emit ctrlSpacePressed(); return true; } else if (kev->key() == Qt::Key_Up && kev->modifiers() == Qt::ControlModifier) { historyUp(); return true; } else if (kev->key() == Qt::Key_Down && kev->modifiers() == Qt::ControlModifier) { historyDown(); return true; } } return QTextEdit::event(evt); }
void MainWindow::on_actionOpenPicture_triggered() { QStringList files = QFileDialog::getOpenFileNames(this, tr("Select image files"), QStandardPaths::writableLocation( QStandardPaths::PicturesLocation ) ); quint64 i = 0; QProgressDialog progress(this); progress.setMaximum( files.count() ); progress.setModal( true ); progress.setLabelText( tr("Files opening...") ); progress.show(); foreach (QString filePath, files) { if( ! progress.isVisible() ) return; if( openPicture(filePath) ) addToHistory( filePath ); progress.setValue( ++i ); qApp->processEvents(); } }
void MultiLineEdit::historyMoveForward() { addToHistory(convertRichtextToMircCodes(), true); if (_idx < _history.count()) { _idx++; if (_idx < _history.count() || _tempHistory.contains(_idx)) // tempHistory might have an entry for idx == history.count() + 1 showHistoryEntry(); else reset(); // equals clear() in this case } else { addToHistory(convertRichtextToMircCodes()); reset(); } }
dockListUpdate mutableSquareImageContainer::replaceRareColors() { QHash<QRgb, int> countHash; ::colorCounts(image_, originalDimension_, &countHash); rareColorsDialog countDialog(countHash); const int dialogReturnCode = countDialog.exec(); QList<QRgbPair> pairs = countDialog.colorsToChange(); if (dialogReturnCode == QDialog::Accepted && pairs.size() > 0) { QList<colorChange> changeHistories; QSet<flossColor> oldFloss; QVector<triC> oldColors; for (int i = 0, size = pairs.size(); i < size; ++i) { const QRgb oldColor = pairs[i].first; const triC oldTriColor(oldColor); oldColors.push_back(oldTriColor); oldFloss.insert(getFlossColorFromColor(oldTriColor)); const QRgb newColor = pairs[i].second; const QVector<pairOfInts> changedSquares = ::changeColor(&image_, oldColor, newColor, originalDimension_); if (!changedSquares.empty()) { removeColor(oldColor); changeHistories.push_back(colorChange(oldColor, newColor, changedSquares)); } } addToHistory(historyItemPtr(new rareColorsHistoryItem(changeHistories, oldFloss))); return dockListUpdate(oldColors, true); } else { return dockListUpdate(); } }
void loadHistory() { mkdir("/data/anr", 0777); FILE* hist = fopen(DIMHISTFILE, "r"); if (hist == NULL) { LOGD("empty deadlock history"); return; } LOGD("loading deadlock history"); char buf[4* STACKSIZE+ 1]; while (fscanf(hist, "%s", buf) != EOF) { struct Template sig; char* tok = strtok(buf, ";"); int i = 0; while (tok != NULL) { sig.positions[i] = getPosition(tok); sig.positions[i]->inHist = true; tok = strtok(NULL, ";"); i++; } sig.size = i; addToHistory(&sig); toString(&sig, buf); LOGD(buf); } fclose(hist); }
bool DocumentationViewer::urlSelected(const QString &url, int button, int state, const QString &_target, const KParts::OpenUrlArguments &args, const KParts::BrowserArguments & /* browserArgs */) { KUrl cURL = completeURL(url); QString mime = KMimeType::findByUrl(cURL).data()->name(); //load this URL in the embedded viewer if KHTML can handle it, or when mimetype detection failed KService::Ptr service = KService::serviceByDesktopName("khtml"); if(( mime == KMimeType::defaultMimeType() ) || (service && service->hasServiceType(mime))) { KHTMLPart::urlSelected(url, button, state, _target, args); openUrl(cURL); addToHistory(cURL.url()); } //KHTML can't handle it, look for an appropriate application else { KService::List offers = KMimeTypeTrader::self()->query(mime, "Type == 'Application'"); if(offers.isEmpty()) { KMessageBox::error(view(), i18n("No KDE service found for the MIME type \"%1\".", mime)); return false; } KUrl::List lst; lst.append(cURL); KRun::run(*(offers.first()), lst, view()); } return true; }
void MainWindow::executeCommand(bool withClear) { QString command = m_inputEdit->text(); // A blank command is a "silent step" if (command == "") { m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step(); return; } // Send along the command m_machine->debugger().console().execute_command(command.toLocal8Bit().data(), true); // Add history & set the index to be the top of the stack addToHistory(command); // Clear out the text and reset the history pointer only if asked if (withClear) { m_inputEdit->clear(); m_historyIndex = m_inputHistory.size(); } // Refresh m_consoleView->viewport()->update(); refreshAll(); }
void Console::resolveCommand_() // Enter { addToHistory( currentCommand_ ); handleCommandString( currentCommand_ ); currentCommand_ = ""; consoleHistoryIndex_ = 0; cursorPos_ = 1; }
void KonferencePart::connectClicked() {//TODO enabling buttons needs fix //TODO Mode not used? kdDebug() << "moooh" << endl; sipStack->PlaceNewCall("CIF", m_location->currentText(), "", 1); m_cancelAction->setEnabled(true); m_connectAction->setEnabled(false); addToHistory(KURL(m_location->currentText())); }
void MultiLineEdit::historyMoveBack() { addToHistory(convertRichtextToMircCodes(), true); if (_idx > 0) { _idx--; showHistoryEntry(); } }
int WINAPI WIDE_SUFFIX(ProcessPanelEvent)(const struct ProcessPanelEventInfo *Info) { if (Info->Event == FE_COMMAND) { LPCTSTR szCmdLine = (LPCTSTR)Info->Param; addToHistory(szCmdLine); } return FALSE; }
void CommandInterpreter::execute() { mLine[mLineLen] = 0; addToHistory(mLine); // first we split our line into seperate strings (by replacing whitespace with binary 0) unsigned int argc = findArguments(true); if (mArguments[0].value.s[0] == 0) return; Possibilities possible; Command* cmd = findCommand(mArguments[0].value.s, strlen(mArguments[0].value.s), possible); if (cmd == nullptr) { printf("Unknown command: %s", mArguments[0].value.s); // const char* p = mArguments[0].value.s; // while (*p != 0) // { // printf(" %02x", *p++); // } printf(", try help.\n"); return; } unsigned int maxArgc = std::min(static_cast<unsigned int>(MAX_ARG_LEN), cmd->argumentCount() + 1); unsigned int minArgc = 1; bool failed = false; // If everything is fine so far we parse our arguments and check if they are valid. for (unsigned int i = 1; i < argc; ++i) { mArguments[i].name = cmd->argument(i - 1); //printf("Parsing %s/%s: ", argv[i].name, argv[i].value.s); if (!parseArgument(mArguments[i])) { failed = true; break; } //printf("%u\n", argv[i].value.u); if (!mArguments[i].optional) ++minArgc; } // If we fond a problem print a usage message. if (failed || argc < minArgc || argc > maxArgc) { if (argc > maxArgc || argc < minArgc) printf("Wrong argument count (%i != [%i, %i]).\n", argc - 1, minArgc - 1, maxArgc - 1); printUsage(cmd); return; } // Everything is fine, execute it. if (cmd != nullptr) { uint64_t start = System::instance()->ns(); cmd->execute(*this, argc, mArguments); if (mCommandTime) { uint64_t delta = System::instance()->ns() - start; printf("Command took %u.%06us\n", static_cast<unsigned int>(delta / 1000000000), static_cast<unsigned int>((delta / 1000) % 1000000)); } } }
void NodeNameDialog::on_listWidget_itemActivated( QListWidgetItem *item ) { mNodeUuid = item->data( Qt::UserRole ).toUuid(); if( !mNodeUuid.isNull() ) { addToHistory( mNodeUuid ); accept(); } }
void shell(){ clearScreen(); splash(); welcome(); while(1){ typePrompt(); readCommand(); addToHistory(textBuffer); runCommand(); } }
void NodeNameDialog::on_listWidget_doubleClicked( const QModelIndex &index ) { mNodeUuid = index.data( Qt::UserRole ).toUuid(); if( !mNodeUuid.isNull() ) { addToHistory( mNodeUuid ); accept(); } }
void frmSearchReplace::addToReplaceHistory(QString string) { NqqSettings& s = NqqSettings::getInstance(); auto history = s.Search.getSaveHistory() ? s.Search.getReplaceHistory() : getComboBoxContents(ui->cmbReplace); addToHistory(history, string, ui->cmbReplace); if (s.Search.getSaveHistory()) { s.Search.setReplaceHistory(history); } }
void planet::updatePosition(double x, double y) { // update the position to the specified coordinates position[0] = x; position[1] = y; // add the current position to the tail addToHistory(); // if our tail is too long, cut off the "oldest element" (that shouldn't be in the tail) // we want recent elements to be in the tail if (history.size() > TAIL_LENGTH) { deleteFromHistory(); } }
dockListUpdate mutableSquareImageContainer:: performDetailing(const QImage& originalImage, const QList<pixel>& detailSquares, int numColors, flossType type) { if (detailSquares.empty()) { qWarning() << "Detail squares empty" << numColors; return dockListUpdate(QVector<triC>()); } QVector<historyPixel> history; //// start the history by collecting the old pixels for (QList<pixel>::const_iterator it = detailSquares.constBegin(), end = detailSquares.constEnd(); it != end; ++it) { // we'll have to go back later and insert the new color for this pixel history.push_back(historyPixel(*it)); } //// do the processing colorTransformerPtr transformer = colorTransformer::createColorTransformer(type); const QVector<triC> colors = ::chooseColors(originalImage, detailSquares, originalDimension_, numColors, transformer); // this paints over our squareDetail marks (that's good) ::segment(originalImage, &image_, detailSquares, originalDimension_, colors); // median returns colors in the same order as detailSquares lists squares const QVector<triC> newColors = ::median(&image_, originalImage, detailSquares, history, originalDimension_); //// complete the history QVector<triC> colorsToAdd; // just return the new ones for (int i = 0, size = history.size(); i < size; ++i) { const triC thisColor(newColors[i]); history[i].setNewColor(thisColor.qrgb()); const flossColor thisFlossColor(thisColor, type); if (!flossColors_.contains(thisFlossColor)) { history[i].setNewColorIsNew(true); colorsToAdd.push_back(thisColor); flossColors_.push_back(thisFlossColor); } } colorListCheckNeeded_ = true; addToHistory(historyItemPtr(new detailHistoryItem(history, type))); return dockListUpdate(colorsToAdd); }
void HistoryLineEdit::setHistory(const QStringList& hist) { myDebug() << hist; if(m_model != nullptr) { delete m_model; m_model = nullptr; } if(m_completer != nullptr) { delete m_completer; m_completer = nullptr; } m_model = new QStringListModel(hist); m_completer = new QCompleter(m_model, this); setCompleter(m_completer); //connect(m_completer, SIGNAL(activated(const QString&)), this, SLOT(insertCompletion(const QString&))); connect(this, SIGNAL(editingFinished()), this, SLOT(addToHistory())); }
void saveTemplate(struct Template* _tmpl) { if(addToHistory(_tmpl) == true){ LOGD("saving new deadlock signature"); char sig[4*STACKSIZE+1]; toString(_tmpl, sig); LOGD(sig); FILE *hist; hist = fopen(DIMHISTFILE, "a"); if (hist==NULL) { LOGD("Can't open history file"); } else { fprintf(hist, "%s\n", sig); fclose(hist); } } }
dockListUpdate mutableSquareImageContainer::fillRegion(int x, int y, flossColor newColor) { const triC oldColor = image_.pixel(x, y); if (newColor == oldColor) { return dockListUpdate(); } const QVector<pairOfInts> coordinates = ::fillRegion(&image_, x, y, newColor.qrgb(), originalDimension_); const bool colorAdded = addColor(newColor); const flossColor oldFlossColor = getFlossColorFromColor(oldColor); addToHistory(historyItemPtr(new fillRegionHistoryItem(oldFlossColor, newColor, colorAdded, coordinates))); colorListCheckNeeded_ = true; return dockListUpdate(newColor.color(), colorAdded); }
void InputTag::emitData() { KILE_DEBUG() << "InputTag::emitData() " << m_ki->getName(); InputDialog *dlg = new InputDialog(m_data.text, m_options, m_history, m_hint, m_alter, m_ki, m_parent, "input_dialog"); if (dlg->exec()) { if((!dlg->tag().isEmpty()) && hasHistory()) { addToHistory(dlg->tag()); } TagData td(m_data); td.tagBegin.replace("%R",dlg->tag()); td.tagEnd.replace("%R",dlg->tag()); QString alt = dlg->useAlternative() ? "*" : ""; td.tagBegin.replace("%A", alt); td.tagEnd.replace("%A", alt); if(dlg->useLabel()) { td.tagEnd += dlg->label(); td.dy++; } if(dlg->usedSelection()) { m_ki->clearSelection(); } // if a filename was given for a \input- or \include-command, // the cursor is moved out of the braces if ( (m_options & (KileAction::ShowBrowseButton | KileAction::FromLabelList | KileAction::FromBibItemList)) && !dlg->tag().isEmpty() ) { td.dx += dlg->tag().length() + 1; } // insert tag emit(triggered(td)); // refresh document structure and project tree when a file was inserted if(dlg->useAddProjectFile()) { m_ki->docManager()->projectAddFile(QFileInfo(m_ki->getCompileName()).absolutePath() + '/' + dlg->tag()); } } delete dlg; }
void DBWorker::navigateTo(int tabId, QString url, QString title, QString path) { // TODO: rollback in case of failure if (url.isEmpty()) { return; } int linkId = 0; Link tmp = getLink(url); if (tmp.isValid()) { linkId = tmp.linkId(); } // Return if the current url of the tab is the same as the parameter url Link currentLink = getCurrentLink(tabId); if (currentLink.isValid() && currentLink.url() == url) { return; } clearDeprecatedTabHistory(tabId, currentLink.linkId()); if (linkId == 0) { linkId = createLink(url, title, path); } else { updateLink(linkId, url, title, path); } if (!addToHistory(linkId)) { qWarning() << Q_FUNC_INFO << "failed to add url to history" << url; } int historyId = addToTabHistory(tabId, linkId); if (historyId > 0) { updateTab(tabId, historyId); } else { qWarning() << Q_FUNC_INFO << "failed to add url to tab history" << url; } #ifdef DEBUG_LOGS qDebug() << "emit tab changed:" << tabId << historyId << title << url; #endif emit navigated(getTabData(tabId, historyId)); }
void NodeNameDialog::on_lineEdit_returnPressed() { if( ui->lineEdit->text().isEmpty() ) { mNodeUuid = mNodeList.first(); if( !mNodeUuid.isNull() ) { accept(); } } else if( ui->listWidget->count() > 0 ) { mNodeUuid = ui->listWidget->item( 0 )->data( Qt::UserRole ).toUuid(); addToHistory( mNodeUuid ); accept(); } }
dockListUpdate mutableSquareImageContainer:: commitChangeOneDrag(const QSet<pairOfInts>& squares, flossColor newColor) { const QRgb newRgbColor = newColor.qrgb(); const bool colorAdded = addColor(newColor); QVector<pixel> historyPixels; QVector<triC> pixelColors; for (QSet<pairOfInts>::const_iterator it = squares.begin(), end = squares.end(); it != end; ++it) { const int x = it->x() * originalDimension_; const int y = it->y() * originalDimension_; const QRgb thisColor = image_.pixel(x, y); pixelColors.push_back(thisColor); historyPixels.push_back(pixel(thisColor, pairOfInts(x, y))); } ::changeBlocks(&image_, historyPixels, newRgbColor, originalDimension_); addToHistory(historyItemPtr(new changeOneHistoryItem(newColor, colorAdded, historyPixels))); colorListCheckNeeded_ = true; return dockListUpdate(newRgbColor, colorAdded); }