📄 charsetedit.cpp
字号:
for ( ; it.current(); ++it ) { if ( !found && it.current() == currentChar ) found = TRUE; else if ( found && it.current()->character() == currentCode && !it.current()->testFlag( QIMPenChar::Deleted ) ) { return it.current(); } } return 0;}void CharSetEdit::setCurrentChar( QIMPenChar *pc ){ currentChar = pc; pw->showCharacter( currentChar ); if ( currentChar ) { if (currentChar->testFlag(QIMPenChar::System)) { delCharBtn->setEnabled(FALSE); resetCharBtn->setEnabled(FALSE); bool haveMissing = FALSE; QIMPenCharIterator it(currentSet->characters() ); for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode && it.current()->testFlag( QIMPenChar::Deleted ) ) { haveMissing = TRUE; break; } } resetCharBtn->setEnabled(haveMissing); } else { bool haveSystem = FALSE; QIMPenCharIterator it(currentSet->characters() ); for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode && it.current()->testFlag( QIMPenChar::System ) ) { haveSystem = TRUE; break; } } delCharBtn->setEnabled(!haveSystem); resetCharBtn->setEnabled(haveSystem); } }}void CharSetEdit::prevMatch(){ // if not adding, or adding and something to add. if (!addFlag || !inputChar->isEmpty()) { if (addFlag) { appendMatch(); pw->setReadOnly(TRUE); addFlag = FALSE; } QIMPenChar *pc = findPrev(); if ( pc ) { setCurrentChar( pc ); --matchIndex; } } else if (addFlag) { // adding and something to add, (or would have met prev) matchCount--; matchIndex = matchCount; pw->showCharacter(currentChar); pw->setReadOnly(TRUE); addFlag = FALSE; } updateLabel();}void CharSetEdit::nextMatch(){ QIMPenChar *pc = findNext(); if ( pc ) { setCurrentChar( pc ); ++matchIndex; updateLabel(); }}void CharSetEdit::firstMatch(){ QIMPenCharIterator it( currentSet->characters() ); for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode) { if (it.current() != currentChar) setCurrentChar(it.current()); return; } }}void CharSetEdit::lastMatch(){ QIMPenCharIterator it( currentSet->characters() ); QIMPenChar *lastFound = 0; for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode) { lastFound = it.current(); } } if (lastFound && lastFound != currentChar) setCurrentChar(lastFound);}void CharSetEdit::clearMatch(){ inputChar->clear(); pw->clear(); enableButtons();}void CharSetEdit::selectCode( int i ){ checkStoreMatch(); currentChar = 0; currentCode = ((CharListItem *)charList->item(i))->code(); QIMPenCharIterator it(currentSet->characters() ); matchCount = 0; matchIndex = 0; for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode && !it.current()->testFlag( QIMPenChar::Deleted ) ) { if (matchCount == 0) { setCurrentChar( it.current() ); matchIndex = 1; } matchCount++; } } updateLabel(); if ( matchCount == 0 ) setCurrentChar( 0 ); inputChar->clear(); enableButtons(); lastCh = i;}void CharSetEdit::updateLabel(){ QString itemText = tr("%1/%2", "way %1 of drawing character out of a total %2 ways of drawing character"); itemDisplay->setText(itemText.arg(matchIndex).arg(matchCount)); prevBtn->setEnabled( matchIndex > 1 ); nextBtn->setEnabled( matchIndex < matchCount ); removeBtn->setEnabled( matchCount > 0 );}/* Action should be: clearMatch, flag that what is drawn will be a new match*/void CharSetEdit::addMatch(){ checkStoreMatch(); lastMatch(); pw->setReadOnly(FALSE); addFlag = TRUE; matchCount++; matchIndex = matchCount; updateLabel(); clearMatch(); addBtn->setEnabled(FALSE);} void CharSetEdit::checkStoreMatch(){ if (addFlag) { addFlag = FALSE; appendMatch(); pw->setReadOnly(TRUE); }}void CharSetEdit::appendMatch(){ // should be more of an assert. if ( !inputChar->isEmpty() ) { QIMPenChar *pc = new QIMPenChar( *inputChar ); pc->setCharacter( currentCode ); // User characters override all matching system characters. // Copy and mark deleted identical system characters. QIMPenCharIterator it(currentSet->characters() ); QIMPenChar *sc = 0; while ( (sc = it.current()) != 0 ) { ++it; if ( sc->character() == currentCode && sc->testFlag( QIMPenChar::System ) && !sc->testFlag( QIMPenChar::Deleted ) ) { QIMPenChar *cc = new QIMPenChar( *sc ); cc->clearFlag( QIMPenChar::System ); currentSet->addChar( cc ); sc->setFlag( QIMPenChar::Deleted ); } } currentSet->addChar( pc ); setCurrentChar( pc ); inputChar->clear(); enableButtons(); }}/* adds a whole new code */void CharSetEdit::addChar(){ checkStoreMatch(); //if ( !inputChar->isEmpty() ) { QIMPenInputCharDlg dlg( 0, "newchar", TRUE , mIsFS ); if (QPEApplication::execDialog(&dlg)) { currentCode = dlg.unicode(); // update combo now? disable combo? // if added an existing char, do a new 'match' // if new code, then add code, set to current, add new match. bool foundMatch = FALSE; for (uint i = 0; i < charList->count(); ++i) { if (((CharListItem *)charList->item(i))->code() == currentCode) { foundMatch = TRUE; charList->setCurrentItem(charList->item(i)); break; } } if (!foundMatch) { // create a blank one. QIMPenChar *pc = new QIMPenChar( *inputChar ); pc->setCharacter( currentCode ); CharListItem *cli = new CharListItem( pc->name(), currentCode); charList->insertItem(cli); charList->setCurrentItem(cli); } addMatch(); updateLabel(); }}/* removes a user added char */void CharSetEdit::removeChar(){ addFlag = FALSE; // if was adding, just removed the char... can't add now pw->setReadOnly(TRUE); QIMPenCharIterator it(currentSet->characters() ); it.toFirst(); while ( it.current() ) { QIMPenChar *pc = it.current(); ++it; if ( pc->character() == currentCode ) { if ( !pc->testFlag( QIMPenChar::System ) ) { currentSet->removeChar( pc ); } } } for (uint i = 0; i < charList->count();++i) { if (((CharListItem *)charList->item(i))->code() == currentCode) { charList->removeItem(i); break; } } updateLabel();}void CharSetEdit::removeMatch(){ if (addFlag) { // assume user meant cancel add match /// same as match prev when not added... //matchCount--; //matchIndex = matchCount; pw->showCharacter(currentChar); pw->setReadOnly(TRUE); addFlag = FALSE; } else { if ( currentChar ) { QIMPenChar *pc = findPrev(); if ( !pc ) pc = findNext(); if ( currentChar->testFlag( QIMPenChar::System ) ) currentChar->setFlag( QIMPenChar::Deleted ); else currentSet->removeChar( currentChar ); setCurrentChar( pc ); } } if (matchIndex == matchCount) matchIndex--; matchCount--; updateLabel();}void CharSetEdit::resetMatches(){ if (addFlag) { addFlag = FALSE; pw->setReadOnly(TRUE); } if ( currentCode ) { currentChar = 0; bool haveSystem = FALSE; QIMPenCharIterator it(currentSet->characters() ); for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode && it.current()->testFlag( QIMPenChar::System ) ) { haveSystem = TRUE; break; } } if ( haveSystem ) { it.toFirst(); while ( it.current() ) { QIMPenChar *pc = it.current(); ++it; if ( pc->character() == currentCode ) { if ( pc->testFlag( QIMPenChar::System ) ) { pc->clearFlag( QIMPenChar::Deleted ); if ( !currentChar ) currentChar = pc; } else { currentSet->removeChar( pc ); } } } setCurrentChar( currentChar ); } } selectCode(charList->currentItem());}void CharSetEdit::newStroke( QIMPenStroke *st ){ inputChar->addStroke( st ); addBtn->setEnabled(TRUE); if ( currentChar ) { bool haveSystem = FALSE; QIMPenCharIterator it(currentSet->characters() ); for ( ; it.current(); ++it ) { if ( it.current()->character() == currentCode && it.current()->testFlag( QIMPenChar::System ) ) { haveSystem = TRUE; break; } } delCharBtn->setEnabled(!haveSystem); resetCharBtn->setEnabled(haveSystem); } else { // new Stroke on a new character.... // can delete and delets troke and add match etc. delCharBtn->setEnabled(TRUE); resetCharBtn->setEnabled(FALSE); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -