本文整理汇总了C++中QMap::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::begin方法的具体用法?C++ QMap::begin怎么用?C++ QMap::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseText
/*!
This function is used to parse the given QString for variables. If found the user will be prompted
for a replacement value. It returns the string text with all replacements made
*/
QString SnippetWidget::parseText(QString text, QString del)
{
QString str = text;
QString strName = "";
QString strNew = "";
QString strMsg="";
int iFound = -1;
int iEnd = -1;
QMap<QString, QString> mapVar;
int iInMeth = _SnippetConfig.getInputMethod();
QRect rSingle = _SnippetConfig.getSingleRect();
QRect rMulti = _SnippetConfig.getMultiRect();
do {
iFound = text.find(QRegExp("\\"+del+"[A-Za-z-_0-9\\s]*\\"+del), iEnd+1); //find the next variable by this QRegExp
if (iFound >= 0) {
iEnd = text.find(del, iFound+1)+1;
strName = text.mid(iFound, iEnd-iFound);
if ( strName != del+del ) { //if not doubel-delimiter
if (iInMeth == 0) { //if input-method "single" is selected
if ( mapVar[strName].length() <= 0 ) { // and not already in map
strMsg=i18n("Please enter the value for <b>%1</b>:").arg(strName);
strNew = showSingleVarDialog( strName, &_mapSaved, rSingle );
if (strNew=="")
return ""; //user clicked Cancle
} else {
continue; //we have already handled this variable
}
} else {
strNew = ""; //for inputmode "multi" just reset new valaue
}
} else {
strNew = del; //if double-delimiter -> replace by single character
}
if (iInMeth == 0) { //if input-method "single" is selected
str.replace(strName, strNew);
}
mapVar[strName] = strNew;
}
} while (iFound != -1);
if (iInMeth == 1) { //check config, if input-method "multi" is selected
int w, bh, oh;
w = rMulti.width();
bh = rMulti.height();
oh = rMulti.top();
if (showMultiVarDialog( &mapVar, &_mapSaved, w, bh, oh )) { //generate and show the dialog
QMap<QString, QString>::Iterator it;
for ( it = mapVar.begin(); it != mapVar.end(); ++it ) { //walk through the map and do the replacement
str.replace(it.key(), it.data());
}
} else {
return "";
}
rMulti.setWidth(w); //this is a hack to save the dialog's dimensions in only one QRect
rMulti.setHeight(bh);
rMulti.setTop(oh);
rMulti.setLeft(0);
_SnippetConfig.setMultiRect(rMulti);
}
_SnippetConfig.setSingleRect(rSingle);
return str;
}
示例2: write_xpm_image
// write XPM image data
static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const QString &fileName)
{
if (!device->isWritable())
return false;
QImage image;
if (sourceImage.depth() != 32)
image = sourceImage.convertToFormat(QImage::Format_RGB32);
else
image = sourceImage;
QMap<QRgb, int> colorMap;
int w = image.width(), h = image.height(), ncolors = 0;
int x, y;
// build color table
for(y=0; y<h; y++) {
QRgb * yp = (QRgb *)image.scanLine(y);
for(x=0; x<w; x++) {
QRgb color = *(yp + x);
if (!colorMap.contains(color))
colorMap.insert(color, ncolors++);
}
}
// number of 64-bit characters per pixel needed to encode all colors
int cpp = 1;
for (int k = 64; ncolors > k; k *= 64) {
++cpp;
// limit to 4 characters per pixel
// 64^4 colors is enough for a 4096x4096 image
if (cpp > 4)
break;
}
QString line;
// write header
QTextStream s(device);
s << "/* XPM */" << endl
<< "static char *" << fbname(fileName) << "[]={" << endl
<< '\"' << w << ' ' << h << ' ' << ncolors << ' ' << cpp << '\"';
// write palette
QMap<QRgb, int>::Iterator c = colorMap.begin();
while (c != colorMap.end()) {
QRgb color = c.key();
if (image.format() != QImage::Format_RGB32 && !qAlpha(color))
line.sprintf("\"%s c None\"",
xpm_color_name(cpp, *c));
else
line.sprintf("\"%s c #%02x%02x%02x\"",
xpm_color_name(cpp, *c),
qRed(color),
qGreen(color),
qBlue(color));
++c;
s << ',' << endl << line;
}
// write pixels, limit to 4 characters per pixel
line.truncate(cpp*w);
for(y=0; y<h; y++) {
QRgb * yp = (QRgb *) image.scanLine(y);
int cc = 0;
for(x=0; x<w; x++) {
int color = (int)(*(yp + x));
QByteArray chars(xpm_color_name(cpp, colorMap[color]));
line[cc++] = QLatin1Char(chars[0]);
if (cpp > 1) {
line[cc++] = QLatin1Char(chars[1]);
if (cpp > 2) {
line[cc++] = QLatin1Char(chars[2]);
if (cpp > 3) {
line[cc++] = QLatin1Char(chars[3]);
}
}
}
}
s << ',' << endl << '\"' << line << '\"';
}
s << "};" << endl;
return (s.status() == QTextStream::Ok);
}
示例3: GetRecordedList
DTC::ProgramList* Dvr::GetRecordedList( bool bDescending,
int nStartIndex,
int nCount,
const QString &sTitleRegEx,
const QString &sRecGroup,
const QString &sStorageGroup )
{
QMap< QString, ProgramInfo* > recMap;
if (gCoreContext->GetScheduler())
recMap = gCoreContext->GetScheduler()->GetRecording();
QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap();
QMap< QString, bool > isJobRunning= ProgramInfo::QueryJobsRunning(JOB_COMMFLAG);
ProgramList progList;
int desc = 1;
if (bDescending)
desc = -1;
LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, desc );
QMap< QString, ProgramInfo* >::iterator mit = recMap.begin();
for (; mit != recMap.end(); mit = recMap.erase(mit))
delete *mit;
// ----------------------------------------------------------------------
// Build Response
// ----------------------------------------------------------------------
DTC::ProgramList *pPrograms = new DTC::ProgramList();
int nAvailable = 0;
int nMax = (nCount > 0) ? nCount : progList.size();
nAvailable = 0;
nCount = 0;
QRegExp rTitleRegEx = QRegExp(sTitleRegEx, Qt::CaseInsensitive);
for( unsigned int n = 0; n < progList.size(); n++)
{
ProgramInfo *pInfo = progList[ n ];
if (pInfo->IsDeletePending() ||
(!sTitleRegEx.isEmpty() && !pInfo->GetTitle().contains(rTitleRegEx)) ||
(!sRecGroup.isEmpty() && sRecGroup != pInfo->GetRecordingGroup()) ||
(!sStorageGroup.isEmpty() && sStorageGroup != pInfo->GetStorageGroup()))
continue;
if ((nAvailable < nStartIndex) ||
(nCount >= nMax))
{
++nAvailable;
continue;
}
++nAvailable;
++nCount;
DTC::Program *pProgram = pPrograms->AddNewProgram();
FillProgramInfo( pProgram, pInfo, true );
}
// ----------------------------------------------------------------------
pPrograms->setStartIndex ( nStartIndex );
pPrograms->setCount ( nCount );
pPrograms->setTotalAvailable( nAvailable );
pPrograms->setAsOf ( MythDate::current() );
pPrograms->setVersion ( MYTH_BINARY_VERSION );
pPrograms->setProtoVer ( MYTH_PROTO_VERSION );
return pPrograms;
}
示例4: updateMetrics
void FillIn::updateMetrics()
{
QSharedPointer<Food> selectedFood = getSelectedFood();
if (!selectedFood) {
ui.btnFillIn->setEnabled(false);
ui.txtAmount->setText("");
ui.txtAverageError->setText("");
ui.txtLargestError->setText("");
ui.txtLargestErrorField->setText("");
ui.txtLargestErrorSelectedVal->setText("");
ui.txtLargestErrorYourVal->setText("");
ui.txtNumFields->setText("");
ui.txtStdDev->setText("");
fillinNutrients.clear();
} else {
ui.btnFillIn->setEnabled(true);
// TODO: Break this up into multiple methods
// Step 1. Compute the amount of the selected food needed to give the same
// number of calories as the original food
QSharedPointer<const Nutrient> calories = Nutrient::getNutrientByName(Nutrient::CALORIES_NAME);
FoodAmount selectedBaseAmount = selectedFood->getBaseAmount();
double caloriesInOriginal = originalNutrients[calories->getId()].getAmount();
double caloriesInSelectedBaseAmount =
selectedBaseAmount.getScaledNutrients()[calories->getId()].getAmount();
qDebug() << "Calories in original: " << caloriesInOriginal;
qDebug() << "Calories in selected base amount: " << selectedBaseAmount.getScaledNutrients()[calories->getId()].getAmount();
FoodAmount selectedAmount =
selectedBaseAmount * (caloriesInOriginal / caloriesInSelectedBaseAmount);
ui.txtAmount->setText(QString::number(selectedAmount.getAmount(), 'f', 2) + " " +
selectedAmount.getUnit()->getAbbreviation());
// Step 2. Determine which nutrients are in common, and which can be filled in
QMap<QString, NutrientAmount> selectedNutrients = selectedAmount.getScaledNutrients();
QSet<QString> originalNutrientIds = originalNutrients.keys().toSet();
QSet<QString> selectedNutrientIds = selectedNutrients.keys().toSet();
QSet<QString> commonNutrientIds = originalNutrientIds;
commonNutrientIds.intersect(selectedNutrientIds);
QSet<QString> fillinNutrientIds = selectedNutrientIds;
fillinNutrientIds.subtract(originalNutrientIds);
qDebug() << "Original nutrients: " << originalNutrientIds.size();
qDebug() << "Selected nutrients: " << selectedNutrientIds.size();
qDebug() << "Common nutrients: " << commonNutrientIds.size();
qDebug() << "Fill-in nutrients: " << fillinNutrientIds.size();
ui.txtNumFields->setText(QString::number(fillinNutrientIds.size()));
// Step 3. Compute the percent error for each common nutrient, and compute
// the average, also making note of the largest.
QMap<QString, double> pctError;
double sumOfErrors = 0;
QString largestErrorId;
double largestError = 0;
for (QSet<QString>::const_iterator i = commonNutrientIds.begin(); i != commonNutrientIds.end(); ++i) {
double originalValue = originalNutrients[*i].getAmount();
if (originalValue > 0) {
double selectedValue = selectedNutrients[*i].getAmount();
double error = std::fabs(originalValue - selectedValue) / originalValue;
pctError[*i] = error;
sumOfErrors += error;
if (error > largestError) {
largestErrorId = *i;
largestError = error;
}
qDebug() << "Error for common nutrient " << *i << " ("
<< originalNutrients[*i].getNutrient()->getName() << ") is "
<< error;
}
}
double avgError = sumOfErrors / pctError.size();
ui.txtAverageError->setText(QString::number(avgError * 100, 'f', 2) + " %");
ui.txtLargestError->setText(QString::number(largestError * 100, 'f', 2) + " %");
//.........这里部分代码省略.........
示例5: fileInfo
//.........这里部分代码省略.........
pDatasetLayout->setColumnStretch(0, 10);
QVBoxLayout* pInfoLayout = new QVBoxLayout(pInfoWidget);
pInfoLayout->setMargin(0);
pInfoLayout->setSpacing(10);
pInfoLayout->addWidget(mpClassificationLabel);
pInfoLayout->addWidget(mpTabWidget, 10);
QHBoxLayout* pButtonLayout = new QHBoxLayout();
pButtonLayout->setMargin(0);
pButtonLayout->setSpacing(5);
pButtonLayout->addWidget(mpValidationLabel, 10);
pButtonLayout->addWidget(mpOkButton, 0, Qt::AlignBottom);
pButtonLayout->addWidget(pCancelButton, 0, Qt::AlignBottom);
QVBoxLayout* pVBox = new QVBoxLayout(this);
pVBox->setMargin(10);
pVBox->setSpacing(10);
pVBox->addWidget(pSplitter, 10);
pVBox->addLayout(pButtonLayout);
// Initialization
setWindowTitle("Import Options");
setModal(true);
resize(700, 450);
pSplitter->addWidget(pDatasetWidget);
pSplitter->addWidget(pInfoWidget);
// Populate the data set tree widget
QTreeWidgetItem* pSelectItem = NULL;
QMap<QString, vector<ImportDescriptor*> >::const_iterator fileIter;
for (fileIter = files.begin(); fileIter != files.end(); ++fileIter)
{
// Filename item
QString filename = fileIter.key();
if (filename.isEmpty() == true)
{
continue;
}
QTreeWidgetItem* pFileItem = new QTreeWidgetItem(mpDatasetTree);
QFileInfo fileInfo(filename);
pFileItem->setText(0, fileInfo.fileName());
pFileItem->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon));
pFileItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
pFileItem->setToolTip(0, filename);
pFileItem->setCheckState(0, Qt::Unchecked);
// Dataset items
vector<ImportDescriptor*> fileDatasets = fileIter.value();
vector<ImportDescriptor*> datasets;
copy(fileDatasets.begin(), fileDatasets.end(), back_inserter(datasets));
stable_sort(datasets.begin(), datasets.end(), ElementDepthComparitor());
map<vector<string>, QTreeWidgetItem*> parentPaths;
vector<ImportDescriptor*>::iterator datasetIter;
for (datasetIter = datasets.begin(); datasetIter != datasets.end(); ++datasetIter)
{
ImportDescriptor* pImportDescriptor = *datasetIter;
if (pImportDescriptor == NULL)
{
continue;
示例6: loadAll
void ConfCertDialog::loadAll()
{
for(QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.begin(); it != instances_ssl.end(); ++it) it.value()->load();
for(QMap<RsPgpId , ConfCertDialog*>::iterator it = instances_pgp.begin(); it != instances_pgp.end(); ++it) it.value()->load();
}
示例7: synchronize
void QgsOfflineEditing::synchronize()
{
// open logging db
sqlite3* db = openLoggingDb();
if ( db == NULL )
{
return;
}
emit progressStarted();
// restore and sync remote layers
QList<QgsMapLayer*> offlineLayers;
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin() ; layer_it != mapLayers.end(); ++layer_it )
{
QgsMapLayer* layer = layer_it.value();
if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() )
{
offlineLayers << layer;
}
}
for ( int l = 0; l < offlineLayers.count(); l++ )
{
QgsMapLayer* layer = offlineLayers[l];
emit layerProgressUpdated( l + 1, offlineLayers.count() );
QString remoteSource = layer->customProperty( CUSTOM_PROPERTY_REMOTE_SOURCE, "" ).toString();
QString remoteProvider = layer->customProperty( CUSTOM_PROPERTY_REMOTE_PROVIDER, "" ).toString();
QString remoteName = layer->name();
remoteName.remove( QRegExp( " \\(offline\\)$" ) );
QgsVectorLayer* remoteLayer = new QgsVectorLayer( remoteSource, remoteName, remoteProvider );
if ( remoteLayer->isValid() )
{
// TODO: only add remote layer if there are log entries?
QgsVectorLayer* offlineLayer = qobject_cast<QgsVectorLayer*>( layer );
// copy style
copySymbology( offlineLayer, remoteLayer );
// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << remoteLayer, true );
// apply layer edit log
QString qgisLayerId = layer->id();
QString sql = QString( "SELECT \"id\" FROM 'log_layer_ids' WHERE \"qgis_id\" = '%1'" ).arg( qgisLayerId );
int layerId = sqlQueryInt( db, sql, -1 );
if ( layerId != -1 )
{
remoteLayer->startEditing();
// TODO: only get commitNos of this layer?
int commitNo = getCommitNo( db );
for ( int i = 0; i < commitNo; i++ )
{
// apply commits chronologically
applyAttributesAdded( remoteLayer, db, layerId, i );
applyAttributeValueChanges( offlineLayer, remoteLayer, db, layerId, i );
applyGeometryChanges( remoteLayer, db, layerId, i );
}
applyFeaturesAdded( offlineLayer, remoteLayer, db, layerId );
applyFeaturesRemoved( remoteLayer, db, layerId );
if ( remoteLayer->commitChanges() )
{
// update fid lookup
updateFidLookup( remoteLayer, db, layerId );
// clear edit log for this layer
sql = QString( "DELETE FROM 'log_added_attrs' WHERE \"layer_id\" = %1" ).arg( layerId );
sqlExec( db, sql );
sql = QString( "DELETE FROM 'log_added_features' WHERE \"layer_id\" = %1" ).arg( layerId );
sqlExec( db, sql );
sql = QString( "DELETE FROM 'log_removed_features' WHERE \"layer_id\" = %1" ).arg( layerId );
sqlExec( db, sql );
sql = QString( "DELETE FROM 'log_feature_updates' WHERE \"layer_id\" = %1" ).arg( layerId );
sqlExec( db, sql );
sql = QString( "DELETE FROM 'log_geometry_updates' WHERE \"layer_id\" = %1" ).arg( layerId );
sqlExec( db, sql );
// reset commitNo
QString sql = QString( "UPDATE 'log_indices' SET 'last_index' = 0 WHERE \"name\" = 'commit_no'" );
sqlExec( db, sql );
}
else
{
showWarning( remoteLayer->commitErrors().join( "\n" ) );
}
}
// remove offline layer
QgsMapLayerRegistry::instance()->removeMapLayers(
( QStringList() << qgisLayerId ) );
//.........这里部分代码省略.........
示例8: if
QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
{
if ( !vl )
return 0;
QWidget *myWidget = 0;
QgsVectorLayer::EditType editType = vl->editType( idx );
const QgsField &field = vl->pendingFields()[idx];
QVariant::Type myFieldType = field.type();
switch ( editType )
{
case QgsVectorLayer::UniqueValues:
{
QList<QVariant> values;
vl->dataProvider()->uniqueValues( idx, values );
QComboBox *cb = comboBox( editor, parent );
if ( cb )
{
cb->setEditable( false );
for ( QList<QVariant>::iterator it = values.begin(); it != values.end(); it++ )
cb->addItem( it->toString(), it->toString() );
myWidget = cb;
}
}
break;
case QgsVectorLayer::Enumeration:
{
QStringList enumValues;
vl->dataProvider()->enumValues( idx, enumValues );
QComboBox *cb = comboBox( editor, parent );
if ( cb )
{
QStringList::const_iterator s_it = enumValues.constBegin();
for ( ; s_it != enumValues.constEnd(); ++s_it )
{
cb->addItem( *s_it, *s_it );
}
myWidget = cb;
}
}
break;
case QgsVectorLayer::ValueMap:
{
const QMap<QString, QVariant> &map = vl->valueMap( idx );
QComboBox *cb = comboBox( editor, parent );
if ( cb )
{
for ( QMap<QString, QVariant>::const_iterator it = map.begin(); it != map.end(); it++ )
{
cb->addItem( it.key(), it.value() );
}
myWidget = cb;
}
}
break;
case QgsVectorLayer::ValueRelation:
{
QSettings settings;
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
const QgsVectorLayer::ValueRelationData &data = vl->valueRelation( idx );
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( data.mLayer ) );
QMap< QString, QString > map;
int fi = -1;
if ( layer )
{
int ki = layer->fieldNameIndex( data.mOrderByValue ? data.mValue : data.mKey );
int vi = layer->fieldNameIndex( data.mOrderByValue ? data.mKey : data.mValue );
if ( !data.mFilterAttributeColumn.isNull() )
fi = layer->fieldNameIndex( data.mFilterAttributeColumn );
if ( data.mAllowNull )
map.insert( nullValue, tr( "(no selection)" ) );
if ( ki >= 0 && vi >= 0 )
{
QgsAttributeList attributes;
attributes << ki;
attributes << vi;
if ( fi >= 0 )
attributes << fi;
layer->select( attributes, QgsRectangle(), false );
QgsFeature f;
while ( layer->nextFeature( f ) )
{
//.........这里部分代码省略.........
示例9: doJobQueueStatus
void StatusBox::doJobQueueStatus()
{
if (m_iconState)
m_iconState->DisplayState("jobqueue");
m_logList->Reset();
QString helpmsg(tr("Job Queue shows any jobs currently in "
"MythTV's Job Queue such as a commercial "
"detection job."));
if (m_helpText)
m_helpText->SetText(helpmsg);
if (m_justHelpText)
m_justHelpText->SetText(helpmsg);
QMap<int, JobQueueEntry> jobs;
QMap<int, JobQueueEntry>::Iterator it;
JobQueue::GetJobsInQueue(jobs,
JOB_LIST_NOT_DONE | JOB_LIST_ERROR |
JOB_LIST_RECENT);
if (jobs.size())
{
QString detail;
QString line;
for (it = jobs.begin(); it != jobs.end(); ++it)
{
ProgramInfo pginfo((*it).chanid, (*it).recstartts);
if (!pginfo.GetChanID())
continue;
detail = QString("%1\n%2 %3 @ %4\n%5 %6 %7 %8")
.arg(pginfo.GetTitle())
.arg(pginfo.GetChannelName())
.arg(pginfo.GetChanNum())
.arg(MythDateTimeToString(pginfo.GetRecordingStartTime(),
kDateTimeFull | kSimplify))
.arg(tr("Job:"))
.arg(JobQueue::JobText((*it).type))
.arg(tr("Status: "))
.arg(JobQueue::StatusText((*it).status));
if ((*it).status != JOB_QUEUED)
detail += " (" + (*it).hostname + ')';
if ((*it).schedruntime > QDateTime::currentDateTime())
detail += '\n' + tr("Scheduled Run Time:") + ' ' +
MythDateTimeToString((*it).schedruntime,
kDateTimeFull | kSimplify);
else
detail += '\n' + (*it).comment;
line = QString("%1 @ %2").arg(pginfo.GetTitle())
.arg(MythDateTimeToString(
pginfo.GetRecordingStartTime(),
kDateTimeFull | kSimplify));
QString font;
if ((*it).status == JOB_ERRORED)
font = "error";
else if ((*it).status == JOB_ABORTED)
font = "warning";
AddLogLine(line, helpmsg, detail, detail, font,
QString("%1").arg((*it).id));
}
}
else
AddLogLine(tr("Job Queue is currently empty."), helpmsg);
}
示例10: fillMainWindow
void MainWindow::fillMainWindow()
{
ui->listUV->clear();
ui->m_tree->clear();
for(int rows = 0; rows != ui->m_gridcursus->rowCount();rows++){
ui->m_gridcursus->removeItem(ui->m_gridcursus->itemAtPosition(rows,0));
ui->m_gridcursus->removeItem(ui->m_gridcursus->itemAtPosition(rows,1));
ui->m_gridcursus->removeItem(ui->m_gridcursus->itemAtPosition(rows,2));
}
/* ONGLET DOSSIER */
ui->m_tree->setColumnCount(5);
QTreeWidgetItem* headerItem = new QTreeWidgetItem();
headerItem->setText(0,QString("Nom"));
headerItem->setText(1,QString("Titre"));
headerItem->setText(2,QString("Crédits"));
headerItem->setText(3,QString("Catégories"));
headerItem->setText(4,QString("Résultat"));
ui->m_tree->setHeaderItem(headerItem);
ui->m_tree->header()->resizeSection(0, 150);
ui->m_tree->header()->resizeSection(1, 300);
ui->m_tree->header()->resizeSection(2, 70);
ui->m_tree->header()->resizeSection(3, 70);
ui->m_tree->header()->resizeSection(4, 40);
ui->m_tree->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->m_tree->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
QList <Dossier *> myDossiers = fac->getDossierDAO()->findAllByEtudiant(currentEtudiant->ID());
QMap<QString, Cursus*> cursusToCompute;
for (QList<Dossier *>::const_iterator d = myDossiers.begin(); d != myDossiers.end(); ++d) {
QTreeWidgetItem *folderWidget = new QTreeWidgetItem(ui->m_tree,QStringList( (*d)->getTitre() ));
QList<Semestre *> mySemestres = fac->getInscriptionDAO()->findSemestresByDossier( (*d)->ID() );
for(QList<Semestre *>::const_iterator s = mySemestres.begin(); s != mySemestres.end(); ++s){
QStringList columns;
columns << (*s)->getTitre()
<< (*s)->getComputedCode()
<< QString::number( fac->getSemestreDAO()->calculEcts( (*s)->ID() ) );
if((*s)->getCursus()){
columns << (*s)->getCursus()->getFull();
}
if((*d)->isCurrent()){
cursusToCompute.insert( (*s)->getCursus()->getCode(), (*s)->getCursus() );
}
QTreeWidgetItem *semWidget = new QTreeWidgetItem(folderWidget, columns );
QList<UV *> myUVs = fac->getInscriptionDAO()->findUvsBySemestre( (*s)->ID() );
qDebug()<<myUVs;
for(QList<UV *>::const_iterator u = myUVs.begin(); u != myUVs.end(); ++u){
QStringList columns;
columns << (*u)->getCode()
<< (*u)->getTitre()
<< (*u)->getCreditsString()
<< (*u)->getCursusString()
<< fac->getInscriptionDAO()->getResultat((*d)->ID(),(*s)->ID(),(*u)->ID());
QTreeWidgetItem *uvWidget = new QTreeWidgetItem(semWidget, columns);
}
}
}
/* ONGLET CURSUS */
int row = 0;
for(QMap<QString, Cursus*>::const_iterator i = cursusToCompute.begin(); i != cursusToCompute.end(); ++i){
QProgressBar* pb = new QProgressBar();
QLabel *lab = new QLabel(i.value()->getCode());
pb->setMaximum(i.value()->getEcts());
ui->m_gridcursus->addWidget(lab,row,0);
ui->m_gridcursus->addWidget(pb,row,1,1,2);
row++;
int somme =0;
QMap<QString, int> detail = fac->getCursusDAO()->computePercent(i.value()->ID());
for(QMap<QString, int>::const_iterator j = detail.begin(); j != detail.end(); ++j){
QProgressBar* pb = new QProgressBar();
int max = i.value()->getCredits().find(j.key()).value();
int val = j.value();
somme += val;
pb->setMaximum( max );
pb->setValue(val);
ui->m_gridcursus->addWidget(new QLabel(j.key() + "("+QString::number( val )+"/"+QString::number( max )+")"),row,1 );
//.........这里部分代码省略.........
示例11: saveNode
bool XMLerSaveFileThread::saveNode ( QXmlStreamWriter &writer, BaseXMLNode *node, qint64 &pos )
{
bool result = true;
pos += 1;
if ( ElementXMLNode *element = qobject_cast<ElementXMLNode *>(node) ) {
/* prefix mapping */
if ( element->hasPrefixMapping() ) {
QMap<QString,QString> prefixMapping = element->prefixMapping();
QMap<QString,QString>::const_iterator it;
for ( it = prefixMapping.begin(); it != prefixMapping.end(); ++it )
writer.writeNamespace ( it.value(), it.key() );
}
if ( element->namespaceURI().isEmpty () )
writer.writeStartElement ( element->qName() );
else
writer.writeStartElement ( element->namespaceURI(), element->name() );
XMLNodePtrList chlist = element->childs();
XMLNodePtrList::iterator it;
for ( it = chlist.begin(); it != chlist.end(); ++it ) {
BaseXMLNode *child_node = (*it);
result &= saveNode ( writer, child_node, pos );
}
writer.writeEndElement();
}
else if ( AttrXMLNode *attr = qobject_cast<AttrXMLNode *>(node) ) {
if ( attr->namespaceURI().isEmpty() )
writer.writeAttribute ( attr->qName(), attr->value() );
else
writer.writeAttribute ( attr->namespaceURI(), attr->name(), attr->value() );
}
else if ( DataXMLNode *data = qobject_cast<DataXMLNode *>(node) ) {
writer.writeCharacters ( data->data() );
}
else if ( DocumentXMLNode *doc = qobject_cast<DocumentXMLNode *>(node) ) {
writer.writeStartDocument( doc->version() );
if ( doc->hasPI() ) {
const QMap<QString,QString> &pi = _document->processingInstructions();
QMap<QString,QString>::const_iterator it;
for ( it = pi.begin(); it != pi.end(); ++it ) {
if ( it.key().trimmed().isEmpty() )
continue;
writer.writeProcessingInstruction ( it.key(), it.value() );
}
}
if ( doc->documentNode() )
result &= saveNode ( writer, doc->documentNode(), pos );
writer.writeEndDocument();
}
emit progress ( pos );
return result;
}
示例12: main
//.........这里部分代码省略.........
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
cerr << "Unable to ignore SIGPIPE\n";
if (!cmdline.GetDisplay().isEmpty())
{
MythUIHelper::SetX11Display(cmdline.GetDisplay());
}
if (!cmdline.GetGeometry().isEmpty())
{
MythUIHelper::ParseGeometryOverride(cmdline.GetGeometry());
}
CleanupGuard callCleanup(cleanup);
gContext = new MythContext(MYTH_BINARY_VERSION);
if (cmdline.IsUPnPEnabled())
{
g_pUPnp = new MediaRenderer();
if (!g_pUPnp->initialized())
{
delete g_pUPnp;
g_pUPnp = NULL;
}
}
// Override settings as early as possible to cover bootstrapped screens
// such as the language prompt
settingsOverride = cmdline.GetSettingsOverride();
if (settingsOverride.size())
{
QMap<QString, QString>::iterator it;
for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}
if (!gContext->Init(true, bPromptForBackend, bBypassAutoDiscovery))
{
VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting.");
return GENERIC_EXIT_NO_MYTHCONTEXT;
}
if (!GetMythDB()->HaveSchema())
{
if (!InitializeMythSchema())
return GENERIC_EXIT_DB_ERROR;
}
for(int argpos = 1; argpos < a.argc(); ++argpos)
{
if (!strcmp(a.argv()[argpos],"-l") ||
!strcmp(a.argv()[argpos],"--logfile"))
{
// Arg processing for logfile already done (before MythContext)
++argpos;
} else if (!strcmp(a.argv()[argpos],"-v") ||
!strcmp(a.argv()[argpos],"--verbose"))
{
// Arg processing for verbose already done (before MythContext)
++argpos;
}
示例13: updateTransitionParams
void TransitionHandler::updateTransitionParams(QString type, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml)
{
QScopedPointer<Mlt::Field> field(m_tractor->field());
field->lock();
double fps = m_tractor->get_fps();
mlt_service nextservice = mlt_service_get_producer(field->get_service());
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString resource = mlt_properties_get(properties, "mlt_service");
int in_pos = (int) in.frames(fps);
int out_pos = (int) out.frames(fps) - 1;
mlt_service_type mlt_type = mlt_service_identify( nextservice );
while (mlt_type == transition_type) {
mlt_transition tr = (mlt_transition) nextservice;
int currentTrack = mlt_transition_get_b_track(tr);
int currentBTrack = mlt_transition_get_a_track(tr);
int currentIn = (int) mlt_transition_get_in(tr);
int currentOut = (int) mlt_transition_get_out(tr);
// //qDebug()<<"Looking for transition : " << currentIn <<'x'<<currentOut<< ", OLD oNE: "<<in_pos<<'x'<<out_pos;
if (resource == type && b_track == currentTrack && currentIn == in_pos && currentOut == out_pos) {
QMap<QString, QString> map = getTransitionParamsFromXml(xml);
QMap<QString, QString>::Iterator it;
QString key;
mlt_properties transproperties = MLT_TRANSITION_PROPERTIES(tr);
QString currentId = mlt_properties_get(transproperties, "kdenlive_id");
if (currentId != xml.attribute(QStringLiteral("id"))) {
// The transition ID is not the same, so reset all properties
mlt_properties_set(transproperties, "kdenlive_id", xml.attribute(QStringLiteral("id")).toUtf8().constData());
// Cleanup previous properties
QStringList permanentProps;
permanentProps << QStringLiteral("factory") << QStringLiteral("kdenlive_id") << QStringLiteral("mlt_service") << QStringLiteral("mlt_type") << QStringLiteral("in");
permanentProps << QStringLiteral("out") << QStringLiteral("a_track") << QStringLiteral("b_track");
for (int i = 0; i < mlt_properties_count(transproperties); ++i) {
QString propName = mlt_properties_get_name(transproperties, i);
if (!propName.startsWith('_') && ! permanentProps.contains(propName)) {
mlt_properties_set(transproperties, propName.toUtf8().constData(), "");
}
}
}
mlt_properties_set_int(transproperties, "force_track", xml.attribute(QStringLiteral("force_track")).toInt());
mlt_properties_set_int(transproperties, "automatic", xml.attribute(QStringLiteral("automatic"), QStringLiteral("0")).toInt());
if (currentBTrack != a_track) {
mlt_properties_set_int(transproperties, "a_track", a_track);
}
for (it = map.begin(); it != map.end(); ++it) {
key = it.key();
mlt_properties_set(transproperties, key.toUtf8().constData(), it.value().toUtf8().constData());
//qDebug() << " ------ UPDATING TRANS PARAM: " << key.toUtf8().constData() << ": " << it.value().toUtf8().constData();
//filter->set("kdenlive_id", id);
}
break;
}
nextservice = mlt_service_producer(nextservice);
if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
mlt_type = mlt_service_identify( nextservice );
resource = mlt_properties_get(properties, "mlt_service");
}
field->unlock();
//askForRefresh();
//if (m_isBlocked == 0) m_mltConsumer->set("refresh", 1);
}
示例14: setFields
void Incidence::setFields(const KCal::Incidence *incidence)
{
KolabBase::setFields(incidence);
if(incidence->doesFloat())
{
// This is a floating event. Don't timezone move this one
mFloatingStatus = AllDay;
setStartDate(incidence->dtStart().date());
}
else
{
mFloatingStatus = HasTime;
setStartDate(localToUTC(incidence->dtStart()));
}
setSummary(incidence->summary());
setLocation(incidence->location());
// Alarm
mHasAlarm = false; // Will be set to true, if we actually have one
if(incidence->isAlarmEnabled())
{
const KCal::Alarm::List &alarms = incidence->alarms();
if(!alarms.isEmpty())
{
const KCal::Alarm *alarm = alarms.first();
if(alarm->hasStartOffset())
{
int dur = alarm->startOffset().asSeconds();
setAlarm((float)dur / 60.0);
}
}
}
Email org(incidence->organizer().name(), incidence->organizer().email());
setOrganizer(org);
// Attendees:
KCal::Attendee::List attendees = incidence->attendees();
KCal::Attendee::List::ConstIterator it;
for(it = attendees.begin(); it != attendees.end(); ++it)
{
KCal::Attendee *kcalAttendee = *it;
Attendee attendee;
attendee.displayName = kcalAttendee->name();
attendee.smtpAddress = kcalAttendee->email();
attendee.status = attendeeStatusToString(kcalAttendee->status());
attendee.requestResponse = kcalAttendee->RSVP();
// TODO: KCal::Attendee::mFlag is not accessible
// attendee.invitationSent = kcalAttendee->mFlag;
// DF: Hmm? mFlag is set to true and never used at all.... Did you mean another field?
attendee.role = attendeeRoleToString(kcalAttendee->role());
attendee.delegate = kcalAttendee->delegate();
attendee.delegator = kcalAttendee->delegator();
addAttendee(attendee);
}
mAttachments.clear();
// Attachments
KCal::Attachment::List attachments = incidence->attachments();
KCal::Attachment::List::ConstIterator it2;
for(it2 = attachments.begin(); it2 != attachments.end(); ++it2)
{
KCal::Attachment *a = *it2;
mAttachments.push_back(a);
}
if(incidence->doesRecur())
{
setRecurrence(incidence->recurrence());
mRecurrence.exclusions = incidence->recurrence()->exDates();
}
// Handle the scheduling ID
if(incidence->schedulingID() == incidence->uid())
{
// There is no scheduling ID
setInternalUID(QString::null);
}
else
{
// We've internally been using a different uid, so save that as the
// temporary (internal) uid and restore the original uid, the one that
// is used in the folder and the outside world
setUid(incidence->schedulingID());
setInternalUID(incidence->uid());
}
// Unhandled tags and other custom properties (see libkcal/customproperties.h)
const QMap<QCString, QString> map = incidence->customProperties();
QMap<QCString, QString>::ConstIterator cit = map.begin();
for(; cit != map.end() ; ++cit)
{
Custom c;
c.key = cit.key();
c.value = cit.data();
//.........这里部分代码省略.........
示例15: cmdLogin
Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd, ResponseContainer &rc)
{
QString userName = QString::fromStdString(cmd.user_name()).simplified();
QString clientId = QString::fromStdString(cmd.clientid()).simplified();
QString clientVersion = QString::fromStdString(cmd.clientver()).simplified();
if (userInfo != 0)
return Response::RespContextError;
// check client feature set against server feature set
FeatureSet features;
QMap<QString, bool> receivedClientFeatures;
QMap<QString, bool> missingClientFeatures;
for (int i = 0; i < cmd.clientfeatures().size(); ++i)
receivedClientFeatures.insert(QString::fromStdString(cmd.clientfeatures(i)).simplified(), false);
missingClientFeatures = features.identifyMissingFeatures(receivedClientFeatures, server->getServerRequiredFeatureList());
if (!missingClientFeatures.isEmpty()) {
if (features.isRequiredFeaturesMissing(missingClientFeatures, server->getServerRequiredFeatureList())) {
Response_Login *re = new Response_Login;
re->set_denied_reason_str("Client upgrade required");
QMap<QString, bool>::iterator i;
for (i = missingClientFeatures.begin(); i != missingClientFeatures.end(); ++i)
re->add_missing_features(i.key().toStdString().c_str());
rc.setResponseExtension(re);
return Response::RespClientUpdateRequired;
}
}
QString reasonStr;
int banSecondsLeft = 0;
AuthenticationResult res = server->loginUser(this, userName, QString::fromStdString(cmd.password()), reasonStr, banSecondsLeft, clientId, clientVersion);
switch (res) {
case UserIsBanned: {
Response_Login *re = new Response_Login;
re->set_denied_reason_str(reasonStr.toStdString());
if (banSecondsLeft != 0)
re->set_denied_end_time(QDateTime::currentDateTime().addSecs(banSecondsLeft).toTime_t());
rc.setResponseExtension(re);
return Response::RespUserIsBanned;
}
case NotLoggedIn: return Response::RespWrongPassword;
case WouldOverwriteOldSession: return Response::RespWouldOverwriteOldSession;
case UsernameInvalid: {
Response_Login *re = new Response_Login;
re->set_denied_reason_str(reasonStr.toStdString());
rc.setResponseExtension(re);
return Response::RespUsernameInvalid;
}
case RegistrationRequired: return Response::RespRegistrationRequired;
case ClientIdRequired: return Response::RespClientIdRequired;
case UserIsInactive: return Response::RespAccountNotActivated;
default: authState = res;
}
userName = QString::fromStdString(userInfo->name());
Event_ServerMessage event;
event.set_message(server->getLoginMessage().toStdString());
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, prepareSessionEvent(event));
Response_Login *re = new Response_Login;
re->mutable_user_info()->CopyFrom(copyUserInfo(true));
if (authState == PasswordRight) {
QMapIterator<QString, ServerInfo_User> buddyIterator(databaseInterface->getBuddyList(userName));
while (buddyIterator.hasNext())
re->add_buddy_list()->CopyFrom(buddyIterator.next().value());
QMapIterator<QString, ServerInfo_User> ignoreIterator(databaseInterface->getIgnoreList(userName));
while (ignoreIterator.hasNext())
re->add_ignore_list()->CopyFrom(ignoreIterator.next().value());
}
// return to client any missing features the server has that the client does not
if (!missingClientFeatures.isEmpty()) {
QMap<QString, bool>::iterator i;
for (i = missingClientFeatures.begin(); i != missingClientFeatures.end(); ++i)
re->add_missing_features(i.key().toStdString().c_str());
}
joinPersistentGames(rc);
rc.setResponseExtension(re);
return Response::RespOk;
}