int MAX::renew() { BufIn(GPSBuf); int i = getPhrase(GPSBuf, GPSPhr); if(i == 1) return 0; //not renewed else{ String tempLat = getLat(GPSPhr); String tempLng = getLong(GPSPhr); String temphgt = getHigh(GPSPhr); int a = spellCheck(tempLat); int b = spellCheck(tempLng); int c = spellCheck(temphgt); if(a == 0) {sLatitude = tempLat;} if(b == 0) sLongitude = tempLng; if(c == 0) sHeight = temphgt; int r = StoF(); if(r==0){ count ++; return 1; } else if(r==-1) {return 0;} } }
void TCommandLine::processNormalKey(QEvent* event) { QPlainTextEdit::event(event); adjustHeight(); if (mpHost->mAutoClearCommandLineAfterSend) { mHistoryBuffer = -1; } else { mHistoryBuffer = 0; } if (mTabCompletionOld != toPlainText()) { mUserKeptOnTyping = true; mAutoCompletionCount = -1; } else { mUserKeptOnTyping = false; } spellCheck(); }
bool TouchEventHandler::handleTouchPoint(Platform::TouchPoint& point) { // Enable input mode on any touch event. m_webPage->m_inputHandler->enableInputMode(); switch (point.m_state) { case Platform::TouchPoint::TouchPressed: { m_lastFatFingersResult.reset(); // Theoretically this shouldn't be required. Keep it just in case states get mangled. m_didCancelTouch = false; m_lastScreenPoint = point.m_screenPos; IntPoint contentPos(m_webPage->mapFromViewportToContents(point.m_pos)); m_lastFatFingersResult = FatFingers(m_webPage, contentPos, FatFingers::ClickableElement).findBestPoint(); Element* elementUnderFatFinger = 0; if (m_lastFatFingersResult.positionWasAdjusted() && m_lastFatFingersResult.node()) { ASSERT(m_lastFatFingersResult.node()->isElementNode()); elementUnderFatFinger = m_lastFatFingersResult.nodeAsElementIfApplicable(); } // Set or reset the touch mode. Element* possibleTargetNodeForMouseMoveEvents = static_cast<Element*>(m_lastFatFingersResult.positionWasAdjusted() ? elementUnderFatFinger : m_lastFatFingersResult.node()); m_convertTouchToMouse = shouldConvertTouchToMouse(possibleTargetNodeForMouseMoveEvents); if (elementUnderFatFinger) drawTapHighlight(); // Lets be conservative here: since we have problems on major website having // mousemove listener for no good reason (e.g. google.com, desktop edition), // let only delay client notifications when there is not input text node involved. if (m_convertTouchToMouse && (m_webPage->m_inputHandler->isInputMode() && !m_lastFatFingersResult.isTextInput())) { m_webPage->m_inputHandler->setDelayKeyboardVisibilityChange(true); handleFatFingerPressed(); } else if (!shouldSuppressMouseDownOnTouchDown()) handleFatFingerPressed(); return true; } case Platform::TouchPoint::TouchReleased: { unsigned spellLength = spellCheck(point); // Apply any suppressed changes. This does not eliminate the need // for the show after the handling of fat finger pressed as it may // have triggered a state change. m_webPage->m_inputHandler->processPendingKeyboardVisibilityChange(); if (shouldSuppressMouseDownOnTouchDown()) handleFatFingerPressed(); // The rebase has eliminated a necessary event when the mouse does not // trigger an actual selection change preventing re-showing of the // keyboard. If input mode is active, call showVirtualKeyboard which // will update the state and display keyboard if needed. if (m_webPage->m_inputHandler->isInputMode()) m_webPage->m_inputHandler->notifyClientOfKeyboardVisibilityChange(true); IntPoint adjustedPoint; if (m_convertTouchToMouse) { adjustedPoint = point.m_pos; m_convertTouchToMouse = false; } else // Fat finger point in viewport coordinates. adjustedPoint = m_webPage->mapFromContentsToViewport(m_lastFatFingersResult.adjustedPosition()); PlatformMouseEvent mouseEvent(adjustedPoint, m_lastScreenPoint, PlatformEvent::MouseReleased, 1, LeftButton, TouchScreen); m_webPage->handleMouseEvent(mouseEvent); m_lastFatFingersResult.reset(); // Reset the fat finger result as its no longer valid when a user's finger is not on the screen. if (spellLength) { unsigned end = m_webPage->m_inputHandler->caretPosition(); unsigned start = end - spellLength; m_webPage->m_client->requestSpellingSuggestionsForString(start, end); } return true; } case Platform::TouchPoint::TouchMoved: if (m_convertTouchToMouse) { PlatformMouseEvent mouseEvent(point.m_pos, m_lastScreenPoint, PlatformEvent::MouseMoved, 1, LeftButton, TouchScreen); m_lastScreenPoint = point.m_screenPos; if (!m_webPage->handleMouseEvent(mouseEvent)) { m_convertTouchToMouse = false; return false; } return true; } break; default: break; } return false; }
bool TCommandLine::event( QEvent * event ) { if( event->type() == QEvent::KeyPress ) { QKeyEvent *ke = static_cast<QKeyEvent *>( event ); //qDebug()<<"modifier="<<ke->modifiers()<<" key="<<ke->key(); switch( ke->key() ) { case Qt::Key_Space: mTabCompletionCount = -1; mAutoCompletionCount = -1; mTabCompletionTyped = ""; mAutoCompletionTyped = ""; if( mpHost->mAutoClearCommandLineAfterSend ) mHistoryBuffer = -1; else mHistoryBuffer = 0; mLastCompletion = ""; break; case Qt::Key_Backtab: handleTabCompletion( false ); ke->accept(); adjustHeight(); return true; break; case Qt::Key_Tab: handleTabCompletion( true ); ke->accept(); return true; break; case Qt::Key_unknown: qWarning()<<"ERROR: key unknown!"; break; case Qt::Key_Backspace: if( mpHost->mAutoClearCommandLineAfterSend ) mHistoryBuffer = -1; else mHistoryBuffer = 0; if( mTabCompletionTyped.size() >= 1 ) { mTabCompletionTyped.chop(1); mAutoCompletionTyped.chop(1); mTabCompletionCount = -1; mAutoCompletionCount = -1; mLastCompletion = ""; } else { mTabCompletionCount = -1; mAutoCompletionCount = -1; mLastCompletion = ""; } QPlainTextEdit::event(event); adjustHeight(); return true; case Qt::Key_Delete: if( mpHost->mAutoClearCommandLineAfterSend ) mHistoryBuffer = -1; else mHistoryBuffer = 0; if( mTabCompletionTyped.size() >= 1 ) { mTabCompletionTyped.chop(1); mAutoCompletionTyped.chop(1); mTabCompletionCount = -1; mAutoCompletionCount = -1; mLastCompletion = ""; } else { mTabCompletionCount = -1; mAutoCompletionCount = -1; mLastCompletion = ""; mTabCompletionTyped = ""; mAutoCompletionTyped = ""; mUserKeptOnTyping = false; mTabCompletionCount = -1; mAutoCompletionCount = -1; } QPlainTextEdit::event(event); adjustHeight(); return true; break; case Qt::Key_Return: if( ke->modifiers() & Qt::ControlModifier ) { mpConsole->console2->mCursorY = mpConsole->buffer.size();// mpConsole->console2->hide(); mpConsole->buffer.mCursorY = mpConsole->buffer.size(); mpConsole->console->mCursorY = mpConsole->buffer.size();// mpConsole->console->mIsTailMode = true; mpConsole->console->updateScreenView(); mpConsole->console->forceUpdate(); ke->accept(); return true; } else if( ke->modifiers() & Qt::ShiftModifier ) { textCursor().insertBlock(); /*if( ! textCursor().movePosition(QTextCursor::Down, QTextCursor::KeepAnchor) ) { textCursor().insertBlock(); }*/ ke->accept(); return true; } else { enterCommand(ke); mTabCompletionCount = -1; mAutoCompletionCount = -1; mLastCompletion = ""; mTabCompletionTyped = ""; mAutoCompletionTyped = ""; mUserKeptOnTyping = false; mTabCompletionCount = -1; mAutoCompletionCount = -1; if( mpHost->mAutoClearCommandLineAfterSend ) { clear(); mHistoryBuffer = -1; } else mHistoryBuffer = 0; adjustHeight(); ke->accept(); return true; } break; case Qt::Key_Enter: enterCommand(ke); mTabCompletionCount = -1; mAutoCompletionCount = -1; mLastCompletion = ""; mTabCompletionTyped = ""; mAutoCompletionTyped = ""; mUserKeptOnTyping = false; mTabCompletionCount = -1; mAutoCompletionCount = -1; if( mpHost->mAutoClearCommandLineAfterSend ) { clear(); mHistoryBuffer = -1; } else mHistoryBuffer = 0; adjustHeight(); ke->accept(); return true; break; case Qt::Key_Down: if( ke->modifiers() & Qt::ControlModifier ) { moveCursor(QTextCursor::Down, QTextCursor::MoveAnchor); ke->accept(); return true; } else { historyDown(ke); ke->accept(); return true; } break; case Qt::Key_Up: if( ke->modifiers() & Qt::ControlModifier ) { moveCursor(QTextCursor::Up, QTextCursor::MoveAnchor ); ke->accept(); return true; } else { historyUp(ke); ke->accept(); return true; } break; case Qt::Key_Escape: selectAll(); mAutoCompletion = false; mTabCompletion = false; mTabCompletionTyped = ""; mAutoCompletionTyped = ""; mUserKeptOnTyping = false; mTabCompletionCount = -1; mAutoCompletionCount = -1; setPalette( mRegularPalette ); if( mpHost->mAutoClearCommandLineAfterSend ) mHistoryBuffer = -1; else mHistoryBuffer = 0; ke->accept(); return true; break; case Qt::Key_PageUp: mpConsole->scrollUp( mpHost->mScreenHeight ); ke->accept(); return true; break; case Qt::Key_PageDown: mpConsole->scrollDown( mpHost->mScreenHeight ); ke->accept(); return true; break; case Qt::Key_C: if( ke->modifiers() & Qt::ControlModifier ) { if( mpConsole->console->mSelectedRegion != QRegion( 0, 0, 0, 0 ) ) { mpConsole->console->copySelectionToClipboard(); ke->accept(); return true; } } break; default: if( mpKeyUnit->processDataStream( ke->key(), (int)ke->modifiers() ) ) { ke->accept(); return true; } else { QPlainTextEdit::event( event ); adjustHeight(); if( mpHost->mAutoClearCommandLineAfterSend ) mHistoryBuffer = -1; else mHistoryBuffer = 0; if( mTabCompletionOld != toPlainText() )//text() ) { mUserKeptOnTyping = true; mAutoCompletionCount = -1; } else { mUserKeptOnTyping = false; } spellCheck(); return false; } } } return QPlainTextEdit::event( event ); }
TextRoom::TextRoom(QWidget *parent, Qt::WFlags f) : QWidget(parent, f), sentenceTally(0) { setupUi(this); setObjectName("textroom"); // Set the default values for variables. numChanges = 0; prevLength = 0; wordcount = 0; alarm = 0; parasold = 0; isHighlighted = false; #ifdef Q_OS_MACX // Find the path for the app path QDir tmpDir = QDir(QCoreApplication::applicationDirPath()); // go into Resources folder tmpDir.cdUp(); tmpDir.cd("Resources"); // get the full path for the resources resourcesDir = tmpDir.path(); #endif // Create the dialog windows. optionsDialog = new OptionsDialog(this); helpDialog = new HelpDialog(this); selectFont = new SelectFont(this); aboutDialog = new AboutDialog(this); scratchDialog = new ScratchDialog(this); miniFlo = new MiniFlo(this); getAWord = new GetAWord(this); musicRoom = new MusicRoom(this); googleDocsDialog = new GoogleDocsDialog(this); // Read settings saved by Options Dialog. #ifdef Q_OS_WIN32 settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationName()); #else settings = new QSettings(); #endif readSettings(); // Sound adjustments. int audio_rate = 11025; Uint16 audio_format = AUDIO_S16SYS; int audio_channels = 2; int audio_buffers = 1024; if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) { printf("Unable to initialize audio: %s\n", Mix_GetError()); exit(1); } // Load sounds. #ifdef Q_OS_WIN32 soundenter = Mix_LoadWAV("keyenter.wav"); #elif defined(Q_OS_MACX) QString tmp = resourcesDir; tmp.append("/sounds/keyenter.wav"); soundenter = Mix_LoadWAV(tmp.toAscii()); #else soundenter = Mix_LoadWAV("/usr/share/sounds/keyenter.wav"); #endif if(soundenter == NULL) { printf("Unable to load WAV file: %s\n", Mix_GetError()); } #ifdef Q_OS_WIN32 soundany = Mix_LoadWAV("keyany.wav"); #elif defined(Q_OS_MACX) tmp = resourcesDir; tmp.append("/sounds/keyany.wav"); soundany = Mix_LoadWAV(tmp.toAscii()); #else soundany = Mix_LoadWAV("/usr/share/sounds/keyany.wav"); #endif if(soundany == NULL) { printf("Unable to load WAV file: %s\n", Mix_GetError()); } // Create the keyboard shortcuts. new QShortcut ( QKeySequence(QKeySequence::New), this, SLOT( newFile() ) ); new QShortcut ( QKeySequence(QKeySequence::Open), this, SLOT( open() ) ); new QShortcut ( QKeySequence(QKeySequence::Save), this, SLOT( save() ) ); new QShortcut ( QKeySequence(QKeySequence::HelpContents), this, SLOT( help() ) ); #ifdef Q_OS_MACX new QShortcut ( QKeySequence(tr("F1", "Help")), this, SLOT( help() ) ); #endif new QShortcut ( QKeySequence(tr("F2", "Options")), this, SLOT( options() ) ); new QShortcut ( QKeySequence(tr("F3", "About")), this, SLOT( about() ) ); new QShortcut ( QKeySequence(tr("F5", "Spell Check")), this, SLOT( spellCheck() ) ); new QShortcut ( QKeySequence(tr("F6", "Scratch Pad")), this, SLOT( showScratchPad() ) ); new QShortcut ( QKeySequence(tr("Ctrl+P", "Print")), this, SLOT( print() ) ); new QShortcut ( QKeySequence(tr("Shift+Ctrl+S", "Save As")), this, SLOT( saveAs() ) ); new QShortcut ( QKeySequence(tr("Ctrl+D", "Insert Date")), this, SLOT( insertDate() ) ); new QShortcut ( QKeySequence(tr("Ctrl+T", "Insert Time")), this, SLOT( insertTime() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Q", "Quit Application")) , this, SLOT( close() ) ); new QShortcut ( QKeySequence(tr("Alt+F4", "Quit Application")) , this, SLOT( close() ) ); new QShortcut ( QKeySequence(tr("Ctrl+F", "Find Text")) , this, SLOT( find() ) ); new QShortcut ( QKeySequence(tr("F11", "Toggle Fullscreen")) , this, SLOT( toggleFullScreen() ) ); new QShortcut ( QKeySequence(tr("Esc", "Toggle Fullscreen")) , this, SLOT( toggleEscape() ) ); new QShortcut ( QKeySequence(tr("Ctrl+M", "Minimize TextRoom")) , this, SLOT( showMinimized() ) ); new QShortcut ( QKeySequence(tr("F4", "Find Next")) , this, SLOT( find_next() ) ); new QShortcut ( QKeySequence(tr("Ctrl+F4", "Find Previous")) , this, SLOT( find_previous() ) ); new QShortcut ( QKeySequence(tr("Ctrl+B", "Bold")) , this, SLOT( textBold() ) ); new QShortcut ( QKeySequence(tr("Ctrl+I", "Italic")) , this, SLOT( textItalic() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Up", "Increase Text Size")) , this, SLOT( textSizeUp() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Down", "Decrease Text Size")) , this, SLOT( textSizeDown() ) ); new QShortcut ( QKeySequence(tr("Ctrl+W", "Select Font")) , this, SLOT( changeFont() ) ); new QShortcut ( QKeySequence(tr("Ctrl+R", "Align Right")) , this, SLOT( alignRight() ) ); new QShortcut ( QKeySequence(tr("Ctrl+L", "Align Left")) , this, SLOT( alignLeft() ) ); new QShortcut ( QKeySequence(tr("Ctrl+J", "Align Justify")) , this, SLOT( alignJustify() ) ); new QShortcut ( QKeySequence(tr("Ctrl+E", "Align Center")) , this, SLOT( alignCenter() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Alt+I", "Insert Image")) , this, SLOT( insertImage() ) ); new QShortcut ( QKeySequence(tr("F7", "Show MiniFlo")) , this, SLOT( showMiniFlo() ) ); new QShortcut ( QKeySequence(tr("F8", "Get A Word")) , this, SLOT( showGetAWord() ) ); new QShortcut ( QKeySequence(tr("F9", "MusicRoom")) , this, SLOT( showMusicRoom() ) ); new QShortcut ( QKeySequence(tr("F10", "Google Docs")) , this, SLOT( exportToGoogle() ) ); // Service: show cursor new QShortcut ( QKeySequence(tr("Shift+F4", "Show Cursor")) , this, SLOT( sCursor() ) ); //fw = new QFileSystemWatcher(this); //fw->addPath( settings->fileName() ); // If file is changed, read the settings-> //connect(fw, SIGNAL(fileChanged(const QString)), // this, SLOT(readSettings())); // If the document is changed, do some stuff. connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); // If position is changed, scroll. connect(textEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(vPositionChanged())); // If horizontal scrollar is changed, scroll. connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(hSliderPositionChanged())); connect(textEdit, SIGNAL(anchorClicked(QUrl)), this, SLOT(showScratchPad())); // check if we need to open some file at startup const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) { QFile file( args.at(1) ); if ( file.exists() ) curFile = args.at(1); } if (!curFile.isEmpty()) loadFile(curFile); else newFile(); // set cursor position if ( isSaveCursor ) { textEdit->textCursor().setPosition(cPosition); } writeSettings(); // Refresh the file status every second. QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(getFileStatus())); timer->start(1000); }
void Highlighter::highlightBlock(const QString &text) { spellCheck(text); }
void highlighterClass::highlightBlock(const QString& text) { spellCheck(text); }