本文整理汇总了C++中Vocabulary::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ Vocabulary::getId方法的具体用法?C++ Vocabulary::getId怎么用?C++ Vocabulary::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vocabulary
的用法示例。
在下文中一共展示了Vocabulary::getId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool Vocabulary::load( const QString& filename ) {
QFile dataFile( filename );
if( !dataFile.open( QIODevice::ReadOnly ) )
return( false );
QByteArray compressedData( dataFile.readAll() );
QByteArray data( qUncompress( compressedData ) );
QDataStream in( data );
qint32 tempMagicNumber;
qint16 tempVersion;
Vocabulary tempVocab;
in >> tempMagicNumber >> tempVersion;
if( tempMagicNumber != Vocabulary::magicNumber ) {
cerr << "Wrong magic number: Incompatible vocabulary data file." << endl;
return( false );
}
if( tempVersion > 0x0010 ) {
cerr << "Vocabulary data file is from a more recent version. Upgrade toMOTko." << endl;
return( false );
}
in.setVersion( QDataStream::Qt_2_1 );
in >> tempVocab;
dataFile.close();
id = tempVocab.getId();
markedForStudy = tempVocab.isMarkedForStudy();
title = tempVocab.getTitle();
description = tempVocab.getDescription();
author = tempVocab.getAuthor();
creationDate = tempVocab.getCreationDate();
modificationDate = tempVocab.getModificationDate();
dirty = tempVocab.isDirty();
for( TermMap::ConstIterator it = tempVocab.begin(); it != tempVocab.end(); it++ ) {
const Term& term = *it;
addTerm( term );
}
return( true );
}
示例2: doRemoveTerms
void SearchDialog::doRemoveTerms( bool allowSelectTrans /* = true */, bool confirmBeforeRemove /* = true */ ) {
int selectedItemCount = 0;
// Find all the translation languages of the selected terms.
QStringList translationLanguages;
for( int i = 0; i < resultsListView->topLevelItemCount(); i++ ) {
ResultListItem* termItem = (ResultListItem*)resultsListView->topLevelItem( i );
if( termItem->isSelected() ) {
selectedItemCount++;
Term* term = termItem->getTerm();
for( Term::TranslationMap::ConstIterator it = term->translationsBegin(); it != term->translationsEnd(); it++ ) {
const Translation& trans = *it;
if( !translationLanguages.contains( trans.getLanguage() ) )
translationLanguages.append( trans.getLanguage() );
}
}
}
if( selectedItemCount == 0 )
return;
if( translationLanguages.count() <= 2 ) {
int response;
if( confirmBeforeRemove ) {
QMessageBox msgBox( QObject::tr( "Warning" ), tr( "ConfirmRemoveSelectedTerms" ),
QMessageBox::Warning,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Default | QMessageBox::Escape,
QMessageBox::NoButton,
this );
msgBox.setButtonText( QMessageBox::Yes, tr( "Yes" ) );
msgBox.setButtonText( QMessageBox::No, tr( "No" ) );
response = msgBox.exec();
}
else
response = QMessageBox::Yes;
if( response == QMessageBox::Yes ) {
for( int i = 0; i < resultsListView->topLevelItemCount(); i++ ) {
ResultListItem* termItem = (ResultListItem*)resultsListView->topLevelItem( i );
if( termItem->isSelected() ) {
Term* term = termItem->getTerm();
Vocabulary* vocab = controller->getVocabTree()->getVocabulary( term->getVocabId() );
if( !term->getImagePath().isNull() ) {
QDir imagePath( term->getImagePath() );
if( imagePath.isRelative() ) {
const QString& imagePath = controller->getApplicationDirName() + "/" + vocab->getParent()->getPath() +
"/v-" + QString::number( vocab->getId() ) + "/" + term->getImagePath();
QFile imageFile( imagePath );
if( imageFile.exists() ) {
if( !imageFile.remove() )
cerr << "Could not remove image " << qPrintable( imagePath ) << endl;
}
}
}
vocab->removeTerm( term->getId() );
delete( termItem );
vocab->setModificationDate( QDateTime::currentDateTime() );
vocab->setDirty( true );
}
}
resultsListView->clearSelection();
updateUi();
emit termsRemoved();
}
}
else {
int response;
QStringList selectedLanguages;
if( allowSelectTrans ) {
TranslationSelectionDialog msgBox( tr( "MultipleTranslationsDetectedForRemoveTermsCaption" ), tr( "MultipleTranslationsDetectedForRemoveTerms" ),
translationLanguages, TranslationSelectionDialog::selectionModeTargetLanguage, controller, this );
msgBox.setMaximumHeight( size().height() - 40 );
msgBox.setMaximumWidth( size().width() - 40 );
response = msgBox.exec();
if( response )
selectedLanguages = msgBox.getSelectedLanguages();
}
else {
selectedLanguages = QStringList();
selectedLanguages.append( controller->getPreferences().getFirstLanguage() );
selectedLanguages.append( controller->getPreferences().getTestLanguage() );
}
if( selectedLanguages.count() == 0 )
return;
for( int i = 0; i < resultsListView->topLevelItemCount(); i++ ) {
ResultListItem* termItem = (ResultListItem*)resultsListView->topLevelItem( i );
if( termItem->isSelected() ) {
Term* term = termItem->getTerm();
Vocabulary* vocab = controller->getVocabTree()->getVocabulary( term->getVocabId() );
for( QStringList::ConstIterator it = selectedLanguages.begin(); it != selectedLanguages.end(); it++ ) {
QString lang = *it;
term->removeTranslation( lang );
}
//.........这里部分代码省略.........