⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trwindow.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	// message list.	if( (mItem == 0) && !(mItem = slv->firstChild()) ) {	    if( (cItem == 0) && !(cItem = lv->firstChild()) ) {		statusBar()->message( tr("No phrase to translate."),				      MessageMS );		qApp->beep();		return;	    } else {		showNewScope( cItem );		while( cItem && !(mItem = slv->firstChild()) ) {		    // no children in this node - try next one		    cItem = cItem->nextSibling();		    showNewScope( cItem );		}		setCurrentContextItem( cItem );		if( mItem ) {		    setCurrentMessageItem( cItem );		} else {		    statusBar()->message( tr("No phrase to translate."),					  MessageMS );		    qApp->beep();		    return;		}	    }	} else {	    setCurrentMessageItem( mItem );	}	MessageLVI * m = (MessageLVI *) mItem;	MessageLVI * n;	ContextLVI * p = (ContextLVI *) cItem;	ContextLVI * q;	// Find the next Unfinished sibling within the same context.	n = m;	do {	    n = (MessageLVI * ) n->itemAbove();	    if ( n == 0 )		break;	    if ( n && !n->finished() ) {		setCurrentMessageItem( n );		return;	    }	} while ( !((ContextLVI *) cItem)->finished() && n != 0 );	// If all siblings are Finished or Obsolete, look in the prev	// Unfinished context.	q = p;	do {	    q = (ContextLVI *) q->itemAbove();	    if ( q == 0 )		q = (ContextLVI *) lastChild( lv );	    if ( q && !q->finished() ) {		showNewScope( q );		setCurrentContextItem( q );		n = (MessageLVI *) lastChild( slv );		while ( n && n->finished() )		    n = (MessageLVI *) n->itemAbove();		if ( n && q ) {		    setCurrentMessageItem( n );		    return;		}	    }	} while ( q != 0 );    }    statusBar()->message( tr("No untranslated phrases left."), MessageMS );    qApp->beep();}void TrWindow::prev(){    QListViewItem * cItem = lv->currentItem();  // context item    QListViewItem * mItem = slv->currentItem(); // message item    QListViewItem * tmp;    if ( !cItem ) {	cItem = lv->firstChild();	if ( !cItem ) return;	setCurrentContextItem( cItem );    }    if ( !mItem ) {	mItem = lastChild( slv );	if ( !mItem ) return;	setCurrentMessageItem( mItem );    } else {	if ( (tmp = mItem->itemAbove()) != 0 ) {	    setCurrentMessageItem( tmp );	    return;	} else {	    if ( (tmp = cItem->itemAbove()) == 0 ) {		tmp = lastChild( lv );	    }	    if ( !tmp ) return;	    setCurrentContextItem( tmp );	    setCurrentMessageItem( lastChild( slv ) );	}    }}void TrWindow::next(){    QListViewItem * cItem = lv->currentItem();  // context item    QListViewItem * mItem = slv->currentItem(); // message item    QListViewItem * tmp;    if ( !cItem ) {	cItem = lv->firstChild();	if ( !cItem ) return;	setCurrentContextItem( cItem );    }    if ( !mItem ) {	mItem = slv->firstChild();	if ( !mItem ) return;	setCurrentMessageItem( mItem );    } else {	if ( (tmp = mItem->nextSibling()) != 0 ) {	    setCurrentMessageItem( tmp );	    return;	} else {	    if ( (tmp = cItem->nextSibling()) == 0 ) {		tmp = lv->firstChild();	    }	    if ( !tmp ) return;	    setCurrentContextItem( tmp );	    setCurrentMessageItem( slv->firstChild() );	}    }}void TrWindow::findNext( const QString& text, int where, bool matchCase ){    findText = text;    if ( findText.isEmpty() )	findText = QString( "magicwordthatyoushouldavoid" );    findWhere = where;    findMatchCase = matchCase;    findAgainAct->setEnabled( TRUE );    findAgain();}void TrWindow::revalidate(){    ContextLVI *c = (ContextLVI *) lv->firstChild();    QListViewItem * oldScope = lv->currentItem();    int oldItemNo = itemToIndex( slv, slv->currentItem() );    slv->setUpdatesEnabled( FALSE );    while ( c != 0 ) {	showNewScope( c );	MessageLVI *m = (MessageLVI *) slv->firstChild();	while ( m != 0 ) {	    m->setDanger( danger(m->sourceText(), m->translation()) &&		    m->message().type() == MetaTranslatorMessage::Finished );	    m = (MessageLVI *) m->nextSibling();	}	c = (ContextLVI *) c->nextSibling();    }    if ( oldScope ){	showNewScope( oldScope );	QListViewItem * tmp = indexToItem( slv, oldItemNo );	if( tmp )	    setCurrentMessageItem( tmp );    }    slv->setUpdatesEnabled( TRUE );    slv->triggerUpdate();}QString TrWindow::friendlyString( const QString& str ){    QString f = str.lower();    f.replace( QRegExp(QString("[.,:;!?()-]")), QString(" ") );    f.replace( "&", QString("") );    f = f.simplifyWhiteSpace();    f = f.lower();    return f;}void TrWindow::setupMenuBar(){    QMenuBar * m = menuBar();    QPopupMenu * filep = new QPopupMenu( this );    QPopupMenu * editp  = new QPopupMenu( this );    QPopupMenu * translationp = new QPopupMenu( this );    QPopupMenu * validationp = new QPopupMenu( this );    validationp->setCheckable( TRUE );    phrasep = new QPopupMenu( this );    closePhraseBookp = new QPopupMenu( this );    editPhraseBookp = new QPopupMenu( this );    printPhraseBookp = new QPopupMenu( this );    QPopupMenu * viewp = new QPopupMenu( this );    viewp->setCheckable( TRUE );    QPopupMenu * helpp = new QPopupMenu( this );    m->insertItem( tr("&File"), filep );    m->insertItem( tr("&Edit"), editp );    m->insertItem( tr("&Translation"), translationp );    m->insertItem( tr("V&alidation"), validationp );    m->insertItem( tr("&Phrases"), phrasep );    m->insertItem( tr("&View"), viewp );    m->insertSeparator();    m->insertItem( tr("&Help"), helpp );    connect( closePhraseBookp, SIGNAL(activated(int)),	     this, SLOT(closePhraseBook(int)) );    connect( closePhraseBookp, SIGNAL(aboutToShow()),	     this, SLOT(updateClosePhraseBook()) );    connect( editPhraseBookp, SIGNAL(activated(int)),	     this, SLOT(editPhraseBook(int)) );    connect( printPhraseBookp, SIGNAL(activated(int)),	     this, SLOT(printPhraseBook(int)) );    // File menu    openAct = new Action( filep, tr("&Open..."), this, SLOT(open()),			  "fileopen.png", QAccel::stringToKey(tr("Ctrl+O")) );    filep->insertSeparator();    saveAct = new Action( filep, tr("&Save"), this, SLOT(save()),			  "filesave.png", QAccel::stringToKey(tr("Ctrl+S")) );    saveAsAct = new Action( filep, tr("Save &As..."), this, SLOT(saveAs()) );    releaseAct = new Action( filep, tr("&Release..."), this, SLOT(release()) );    filep->insertSeparator();    printAct = new Action( filep, tr("&Print..."), this, SLOT(print()),			   "print.png", QAccel::stringToKey(tr("Ctrl+P")) );    filep->insertSeparator();    recentFilesMenu = new QPopupMenu( this );    filep->insertItem( tr("Re&cently opened files"), recentFilesMenu );    connect( recentFilesMenu, SIGNAL(aboutToShow()), this,	     SLOT(setupRecentFilesMenu()) );    connect( recentFilesMenu, SIGNAL(activated( int )), this,	     SLOT(recentFileActivated( int )) );    filep->insertSeparator();    exitAct = new Action( filep, tr("E&xit"), this, SLOT(close()),			  QString::null, QAccel::stringToKey(tr("Ctrl+Q")) );    // Edit menu    undoAct = new Action( editp, tr("&Undo"), me, SLOT(undo()),			  "undo.png", QAccel::stringToKey(tr("Ctrl+Z")) );    undoAct->setEnabled( FALSE );    connect( me, SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool)) );    redoAct = new Action( editp, tr("&Redo"), me, SLOT(redo()),			  "redo.png", QAccel::stringToKey(tr("Ctrl+Y")) );    redoAct->setEnabled( FALSE );    connect( me, SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool)) );    editp->insertSeparator();    cutAct = new Action( editp, tr("Cu&t"), me, SLOT(cut()),			 "editcut.png", QAccel::stringToKey(tr("Ctrl+X")) );    cutAct->setEnabled( FALSE );    connect( me, SIGNAL(cutAvailable(bool)), cutAct, SLOT(setEnabled(bool)) );    copyAct = new Action( editp, tr("&Copy"), me, SLOT(copy()),			  "editcopy.png", QAccel::stringToKey(tr("Ctrl+C")) );    copyAct->setEnabled( FALSE );    connect( me, SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool)) );    pasteAct = new Action( editp, tr("&Paste"), me, SLOT(paste()),			   "editpaste.png", QAccel::stringToKey(tr("Ctrl+V")) );    pasteAct->setEnabled( FALSE );    connect( me, SIGNAL(pasteAvailable(bool)),	     pasteAct, SLOT(setEnabled(bool)) );    selectAllAct = new Action( editp, tr("Select &All"), me, SLOT(selectAll()),			       QString::null, QAccel::stringToKey(tr("Ctrl+A")) );    selectAllAct->setEnabled( FALSE );    editp->insertSeparator();    findAct = new Action( editp, tr("&Find..."), this, SLOT(find()),			  "searchfind.png", QAccel::stringToKey(tr("Ctrl+F")) );    findAct->setEnabled( FALSE );    findAgainAct = new Action( editp, tr("Find &Next"),			       this, SLOT(findAgain()), QString::null, Key_F3 );    findAgainAct->setEnabled( FALSE );#ifdef notyet    replaceAct = new Action( editp, tr("&Replace..."), this, SLOT(replace()),			     QAccel::stringToKey(tr("Ctrl+H")) );    replaceAct->setEnabled( FALSE );#endif    // Translation menu    // when updating the accelerators, remember the status bar    prevUnfinishedAct = new Action( translationp, tr("&Prev Unfinished"),				    this, SLOT(prevUnfinished()),				    "prevunfinished.png", QAccel::stringToKey(tr("Ctrl+K")) );    nextUnfinishedAct = new Action( translationp, tr("&Next Unfinished"),				    this, SLOT(nextUnfinished()),				    "nextunfinished.png", QAccel::stringToKey(tr("Ctrl+L")) );    prevAct = new Action( translationp, tr("P&rev"),			  this, SLOT(prev()), "prev.png",			  QAccel::stringToKey(tr("Ctrl+Shift+K")) );    nextAct = new Action( translationp, tr("Ne&xt"),			  this, SLOT(next()), "next.png",			  QAccel::stringToKey(tr("Ctrl+Shift+L")) );    doneAndNextAct = new Action( translationp, tr("Done and &Next"),				 this, SLOT(doneAndNext()), "doneandnext.png",				 QAccel::stringToKey(tr("Ctrl+Enter")) );    doneAndNextAlt = new QAction( this );    doneAndNextAlt->setAccel( QAccel::stringToKey(tr("Ctrl+Return")) );    connect( doneAndNextAlt, SIGNAL(activated()), this, SLOT(doneAndNext()) );    beginFromSourceAct = new Action( translationp, tr("&Begin from Source"),				     me, SLOT(beginFromSource()),				     QString::null, QAccel::stringToKey(tr("Ctrl+B")) );    connect( me, SIGNAL(updateActions(bool)), beginFromSourceAct,	     SLOT(setEnabled(bool)) );    // Phrasebook menu    newPhraseBookAct = new Action( phrasep, tr("&New Phrase Book..."),				   this, SLOT(newPhraseBook()),				   QString::null, QAccel::stringToKey(tr("Ctrl+N")) );    openPhraseBookAct = new Action( phrasep, tr("&Open Phrase Book..."),				    this, SLOT(openPhraseBook()),				    "book.png", QAccel::stringToKey(tr("Ctrl+H")) );    closePhraseBookId = phrasep->insertItem( tr("&Close Phrase Book"),					     closePhraseBookp );    phrasep->insertSeparator();    editPhraseBookId = phrasep->insertItem( tr("&Edit Phrase Book..."),					    editPhraseBookp );    printPhraseBookId = phrasep->insertItem( tr("&Print Phrase Book..."),					     printPhraseBookp );    connect( phrasep, SIGNAL(aboutToShow()), this, SLOT(setupPhrase()) );    // Validation menu    acceleratorsAct = new Action( validationp, tr("&Accelerators"),				  this, SLOT(revalidate()), "accelerator.png", 0, TRUE );    acceleratorsAct->setOn( TRUE );    endingPunctuationAct = new Action( validationp, tr("&Ending Punctuation"),				       this, SLOT(revalidate()), "punctuation.png", 0, TRUE );    endingPunctuationAct->setOn( TRUE );    phraseMatchesAct = new Action( validationp, tr("&Phrase Matches"),				   this, SLOT(revalidate()), "phrase.png", 0, TRUE );    phraseMatchesAct->setOn( TRUE );    // View menu    revertSortingAct = new Action( viewp, tr("&Revert Sorting"),				   this, SLOT(revertSorting()) );    doGuessesAct = new Action( viewp, tr("&Display guesses"),			       this, SLOT(toggleGuessing()) );    doGuessesAct->setToggleAction( TRUE );    doGuessesAct->setOn( TRUE );    viewp->insertSeparator();    viewp->insertItem( tr("Vie&ws"), createDockWindowMenu( NoToolBars ) );    viewp->insertItem( tr("&Toolbars"), createDockWindowMenu( OnlyToolBars ) );    // Help    manualAct = new Action( helpp, tr("&Manual"), this, SLOT(manual()), 0,			    Key_F1 );    helpp->insertSeparator();    aboutAct = new Action( helpp, tr("&About"), this, SLOT(about()) );    aboutQtAct = new Action( helpp, tr("About &Qt"), this, SLOT(aboutQt()) );    helpp->insertSeparator();    whatsThisAct = new Action( helpp, tr("&What's This?"),			       this, SLOT(whatsThis()), "whatsthis.xpm", SHIFT + Key_F1 );    openAct->setWhatsThis( tr("Open a Qt translation source file (TS file) for"			      " editing.") );    saveAct->setWhatsThis( tr("Save changes made to this Qt translation "				"source file.") );    saveAsAct->setWhatsThis( tr("Save changes made to this Qt translation"				"source file into a new file.") );    releaseAct->setWhatsThis( tr("Create a Qt message file suitable for"				 " released applications"				 " from the current message file.") );    printAct->setWhatsThis( tr("Print a list of all the phrases in the current"			       " Qt translation source file.") );    exitAct->setWhatsThis( tr("Close this window and exit.") );    undoAct->setWhatsThis( tr("Undo the last editing operation performed on the"			      " translation.") );    redoAct->setWhatsThis( tr("Redo an undone editing operation performed on"			      " the translation.") );    cutAct->setWhatsThis( tr("Copy the selected translation text to the"			     " clipboard and deletes it.") );    copyAct->setWhatsThis( tr("Copy the selected translation text to the"			      " clipboard.") );    pasteAct->setWhatsThis( tr("Paste the clipboard text into the"			       " translation.") );    selectAllAct->setWhatsThis( tr("Select the whole translation text.") );    findAct->setWhatsThis( tr("Search for some text in the translation "				"source file.") );    findAgainAct->setWhatsThis( tr("Continue the search where it was left.") );#ifdef notyet    replaceAct->setWhatsThis( tr("Search for some text in the translation"				 " source file and replace it by another"				 " text.") );#endif    newPhraseBookAct->setWhatsThis( tr("Create a new phrase book.") );    openPhraseBookAct->setWhatsThis( tr("Open a phrase book to assist"					" translation.") );    acceleratorsAct->setWhatsThis( tr("Toggle validity checks of"				      " accelerators.") );    endingPunctuationAct->setWhatsThis( tr("Toggle validity checks"					   " of ending punctuation.") );    phraseMatchesAct->setWhatsThis( tr("Toggle checking that phrase"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -