void IqtFit::singleFit() { if (!validate()) return; // Don't plot a new guess curve until there is a fit disconnect(m_dblManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(plotGuess(QtProperty *))); // First create the function auto function = createFunction(); const int fitType = m_uiForm.cbFitType->currentIndex(); if (m_uiForm.ckConstrainIntensities->isChecked()) { switch (fitType) { case 0: // 1 Exp case 2: // 1 Str m_ties = "f1.Intensity = 1-f0.A0"; break; case 1: // 2 Exp case 3: // 1 Exp & 1 Str m_ties = "f1.Intensity=1-f2.Intensity-f0.A0"; break; default: break; } } QString ftype = fitTypeString(); updatePlot(); if (m_ffInputWS == NULL) { return; } QString pyInput = "from IndirectCommon import getWSprefix\nprint getWSprefix('%1')\n"; pyInput = pyInput.arg(m_ffInputWSName); m_singleFitOutputName = runPythonCode(pyInput).trimmed() + QString("fury_") + ftype + m_uiForm.spPlotSpectrum->text(); // Create the Fit Algorithm m_singleFitAlg = AlgorithmManager::Instance().create("Fit"); m_singleFitAlg->initialize(); m_singleFitAlg->setPropertyValue("Function", function->asString()); m_singleFitAlg->setPropertyValue("InputWorkspace", m_ffInputWSName.toStdString()); m_singleFitAlg->setProperty("WorkspaceIndex", m_uiForm.spPlotSpectrum->text().toInt()); m_singleFitAlg->setProperty("StartX", m_ffRangeManager->value(m_properties["StartX"])); m_singleFitAlg->setProperty("EndX", m_ffRangeManager->value(m_properties["EndX"])); m_singleFitAlg->setProperty( "MaxIterations", static_cast<int>(m_dblManager->value(m_properties["MaxIterations"]))); m_singleFitAlg->setProperty( "Minimizer", minimizerString(m_singleFitOutputName).toStdString()); m_singleFitAlg->setProperty("Ties", m_ties.toStdString()); m_singleFitAlg->setPropertyValue("Output", m_singleFitOutputName.toStdString()); connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(singleFitComplete(bool))); m_batchAlgoRunner->addAlgorithm(m_singleFitAlg); m_batchAlgoRunner->executeBatchAsync(); }
tSunMoonDialog::tSunMoonDialog( tMCoord Position, QDateTime Date, QWidget* pParent ) : tDialog( tDialog::Full, pParent ), m_Date( Date ), m_Position( Position ) { //JR 2/17/10, NSW-4850, append the GMT offset to the title QString titleAppend; tDSTCalculator dstCalc(tPath::GMTDataDir(), m_Position.X(), m_Position.Y(), false); tDSTResults results; if(dstCalc.CalculateDST(QDateTime(), results, false, true, false, true)) { int minutes_offset = tSystemSettings::Instance()->LocalTimeOffset(); bool negative_offset = minutes_offset < 0; minutes_offset = negative_offset ? -minutes_offset : minutes_offset; int hours_offset = minutes_offset / 60; minutes_offset -= hours_offset * 60; titleAppend = " (GMT %1%2:%3)"; titleAppend = titleAppend.arg(negative_offset?QString("-"):QString("")).arg(hours_offset, 1, 10, QChar('0')).arg(minutes_offset, 2, 10, QChar('0')); } else { titleAppend = " (LST)"; } setWindowTitle( tr( "Sun and Moon", "[title]" ) + titleAppend); m_pMoonRiseTime = new QLabel( this ); m_pMoonSetTime = new QLabel( this ); m_pMoonPhase = new QLabel( this ); m_pSunRiseTime = new QLabel( this ); m_pSunSetTime = new QLabel( this ); RunCalculations(); // grab the sun and moon images QPixmap moonPixmap( tPath::ResourceFile("moon.PNG") ); QPixmap sunPixmap( tPath::ResourceFile("sun.PNG") ); if( tProductSettings::Instance().ScreenPixelWidth() <= 640 ) { moonPixmap = moonPixmap.scaledToWidth( moonPixmap.width() * 3 / 4, Qt::SmoothTransformation ); sunPixmap = sunPixmap.scaledToWidth( sunPixmap.width() * 3 / 4, Qt::SmoothTransformation ); } ProcessMoonPixmap( moonPixmap ); // make the moon info QLabel* pMoonRiseTitle = new QLabel( tr( "Rise", "Moon Rise" ), this ); QLabel* pMoonSetTitle = new QLabel( tr( "Set", "Moon Set" ), this ); QLabel* pMoonPhaseTitle = new QLabel( tr( "Phase", "Moon Phase" ), this ); QFrame* pMoonFrame = new QFrame( this ); m_pMoonImage = new QLabel( this ); m_pMoonImage->setPixmap( moonPixmap ); pMoonFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); pMoonFrame->setLineWidth( 1 ); // lay out the moon items QGridLayout* moonDataLayout = new QGridLayout(); moonDataLayout->setContentsMargins( 0, 0, 0, 0 ); moonDataLayout->setHorizontalSpacing( 10 ); moonDataLayout->setVerticalSpacing( 0 ); moonDataLayout->setColumnStretch( 0, 1 ); moonDataLayout->setRowMinimumHeight( 0, moonPixmap.height() / 2 ); moonDataLayout->setRowStretch( 1, 1 ); moonDataLayout->addWidget( pMoonRiseTitle, 2, 1 ); moonDataLayout->addWidget( m_pMoonRiseTime, 2, 2 ); moonDataLayout->addWidget( pMoonSetTitle, 3, 1 ); moonDataLayout->addWidget( m_pMoonSetTime, 3, 2 ); moonDataLayout->addWidget( pMoonPhaseTitle, 4, 1 ); moonDataLayout->addWidget( m_pMoonPhase, 4, 2 ); moonDataLayout->setRowStretch( 5, 1 ); moonDataLayout->setColumnStretch( 3, 1 ); pMoonFrame->setLayout( moonDataLayout ); QGridLayout* moonLayout = new QGridLayout(); moonLayout->setContentsMargins( 0, 0, 0, 0 ); moonLayout->addWidget( m_pMoonImage, 0, 0, 2, 1, Qt::AlignCenter ); moonLayout->addWidget( pMoonFrame, 1, 0, 2, 1 ); moonLayout->setRowMinimumHeight( 0, moonPixmap.height() / 2 ); // make the sun info QLabel* pSunRiseTitle = new QLabel( tr( "Rise", "Sun Rise" ), this ); QLabel* pSunSetTitle = new QLabel( tr( "Set", "Sun Set" ), this ); QLabel* pSunImage = new QLabel( this ); pSunImage->setPixmap( sunPixmap ); QFrame* pSunFrame = new QFrame( this ); pSunFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); pSunFrame->setLineWidth( 1 ); // lay out the sun items QGridLayout* sunDataLayout = new QGridLayout(); sunDataLayout->setContentsMargins( 0, 0, 0, 0 ); sunDataLayout->setHorizontalSpacing( 10 ); sunDataLayout->setVerticalSpacing( 0 ); sunDataLayout->setColumnStretch( 0, 1 ); sunDataLayout->setRowMinimumHeight( 0, sunPixmap.height() / 2 ); sunDataLayout->setRowStretch( 1, 1 ); sunDataLayout->addWidget( pSunRiseTitle, 2, 1 ); sunDataLayout->addWidget( m_pSunRiseTime, 2, 2 ); sunDataLayout->addWidget( pSunSetTitle, 3, 1 ); sunDataLayout->addWidget( m_pSunSetTime, 3, 2 ); sunDataLayout->setRowStretch( 4, 1 ); sunDataLayout->setColumnStretch( 3, 1 ); pSunFrame->setLayout( sunDataLayout ); QGridLayout* sunLayout = new QGridLayout(); sunLayout->setContentsMargins( 0, 0, 0, 0 ); sunLayout->addWidget( pSunImage, 0, 0, 2, 1, Qt::AlignCenter ); sunLayout->addWidget( pSunFrame, 1, 0, 2, 1 ); sunLayout->setRowMinimumHeight( 0, sunPixmap.height() / 2 ); // make the input boxes QLabel* pDateTitle = new QLabel( tr( "Date" ), this ); QLabel* pPositionTitle = new QLabel( tr( "Position" ), this ); m_pPositionEdit = new tPositionEdit( m_Position, this ); m_pPositionEdit->SetTitle( QString( tr("Position for Sun and Moon") ) ); m_pPositionEdit->setDisabled( false ); m_pDateLineEdit = new tDateLineEdit( m_Date.date(), tSystemSettings::Instance()->DateFormatString(), this ); m_pDateLineEdit->SetTitle( tr("Date for Sun and Moon") ); // lay out the input boxes QHBoxLayout* inputLayout = new QHBoxLayout(); inputLayout->setContentsMargins( 0, 0, 0, 0 ); inputLayout->addWidget( pDateTitle ); inputLayout->addWidget( m_pDateLineEdit ); inputLayout->addStretch(); inputLayout->addWidget( pPositionTitle ); inputLayout->addWidget( m_pPositionEdit ); // lay out all the items QGridLayout* pGridLayout = new QGridLayout( this ); QWidget* inputWidget = new QWidget(); inputWidget->setLayout( inputLayout ); pGridLayout->addWidget( inputWidget, 0, 0, 1, 2 ); QWidget* sunWidget = new QWidget(); sunWidget->setLayout( sunLayout ); sunWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); pGridLayout->addWidget( sunWidget, 1, 0 ); QWidget* moonWidget = new QWidget(); moonWidget->setLayout( moonLayout ); moonWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); pGridLayout->addWidget( moonWidget, 1, 1 ); pGridLayout->setAlignment( Qt::AlignCenter ); setLayout( pGridLayout ); // ensure the images appear on top m_pMoonImage->raise(); pSunImage->raise(); CreateSoftKeys(); Connect( m_pPositionEdit, SIGNAL( ValueChanged() ), this, SLOT( NewInputs() ) ); Connect( m_pDateLineEdit, SIGNAL( ValueChanged() ), this, SLOT( NewInputs() ) ); }
void SeasideCache::reset() { for (int i = 0; i < FilterTypesCount; ++i) { m_contacts[i].clear(); m_populated[i] = false; m_models[i] = 0; } m_cache.clear(); #ifdef USING_QTPIM m_cacheIndices.clear(); #endif for (uint i = 0; i < sizeof(contactsData) / sizeof(Contact); ++i) { QContact contact; #ifdef USING_QTPIM // This is specific to the qtcontacts-sqlite backend: const QString idStr(QString::fromLatin1("qtcontacts:org.nemomobile.contacts.sqlite::sql-%1")); contact.setId(QContactId::fromString(idStr.arg(i + 1))); #else QContactId contactId; contactId.setLocalId(i + 1); contact.setId(contactId); #endif QContactName name; name.setFirstName(QLatin1String(contactsData[i].firstName)); name.setLastName(QLatin1String(contactsData[i].lastName)); contact.saveDetail(&name); if (contactsData[i].avatar) { QContactAvatar avatar; avatar.setImageUrl(QUrl(QLatin1String(contactsData[i].avatar))); contact.saveDetail(&avatar); } QContactStatusFlags statusFlags; if (contactsData[i].email) { QContactEmailAddress email; email.setEmailAddress(QLatin1String(contactsData[i].email)); contact.saveDetail(&email); statusFlags.setFlag(QContactStatusFlags::HasEmailAddress, true); } if (contactsData[i].phoneNumber) { QContactPhoneNumber phoneNumber; phoneNumber.setNumber(QLatin1String(contactsData[i].phoneNumber)); contact.saveDetail(&phoneNumber); statusFlags.setFlag(QContactStatusFlags::HasPhoneNumber, true); } contact.saveDetail(&statusFlags); #ifdef USING_QTPIM m_cacheIndices.insert(internalId(contact), m_cache.count()); #endif m_cache.append(CacheItem(contact)); QString fullName = name.firstName() + QChar::fromLatin1(' ') + name.lastName(); CacheItem &cacheItem = m_cache.last(); cacheItem.nameGroup = determineNameGroup(&cacheItem); cacheItem.displayLabel = fullName; } insert(FilterAll, 0, getContactsForFilterType(FilterAll)); insert(FilterFavorites, 0, getContactsForFilterType(FilterFavorites)); insert(FilterOnline, 0, getContactsForFilterType(FilterOnline)); }
void VnaTimeDomain::adjustChannelPoints() { QString scpi = ":CALC%1:TRAN:TIME:LPAS KSDF\n"; scpi = scpi.arg(_trace->channel()); _vna->write(scpi); }
/** * Generates a text proposal that the user should announce when calling a match * * @param ma the match to call * @param co the court the match shall be played on * * @return a string with the announcement */ QString GuiHelpers::prepCall(const QTournament::Match &ma, const QTournament::Court &co, int nCall) { int maNum = ma.getMatchNumber(); int coNum = co.getNumber(); QString call = "<i><font color=\"blue\">" + QObject::tr("Please announce:") + "</font></i><br><br><br>"; call += "<big>"; if (nCall == 0) { call += QObject::tr("Next match,<br><br>"); } else { call += "<b><font color=\"darkRed\">%1. "; call = call.arg(QString::number(nCall + 1)); call += QObject::tr("call"); call += "</font></b>"; call += QObject::tr(" for "); } call += QObject::tr("match number ") + "<b><font color=\"darkRed\">%1</font></b>"; call += QObject::tr(" on court number ") + "<b><font color=\"darkRed\">%2</font></b><br><br>"; call = call.arg(maNum); call = call.arg(coNum); call += "<center><b>"; call += ma.getCategory().getName() + ",<br><br>"; int winnerRank = ma.getWinnerRank(); if (winnerRank > 0) { call += "<font color=\"darkRed\">"; if (winnerRank == 1) { call += QObject::tr("FINAL"); } else { call += QObject::tr("MATCH FOR PLACE %1"); call = call.arg(winnerRank); } call += "</font>"; call += ",<br><br>"; } call += ma.getPlayerPair1().getCallName(QObject::tr("and")) + "<br><br>"; call += QObject::tr("versus<br><br>"); call += ma.getPlayerPair2().getCallName(QObject::tr("and")) + ",<br><br></b></center>"; call += QObject::tr("match number ") + "<b><font color=\"darkRed\">%1</font></b>"; call += QObject::tr(" on court number ") + "<b><font color=\"darkRed\">%2</font></b>"; call = call.arg(maNum); call = call.arg(coNum); call += "."; // add the umpire's name, if necessary QTournament::REFEREE_MODE refMode = ma.get_EFFECTIVE_RefereeMode(); if ((refMode != QTournament::REFEREE_MODE::NONE) && ((refMode != QTournament::REFEREE_MODE::HANDWRITTEN))) { QTournament::upPlayer referee = ma.getAssignedReferee(); if (referee != nullptr) { call += "<br><br><br><b>"; call += QObject::tr("Umpire is %1."); call = call.arg(referee->getDisplayName_FirstNameFirst()); call += "</b><br>"; } } // add additional calls, if applicable if (nCall > 0) { call += "<br><br>"; call += "<b><font color=\"darkRed\">"; call += QObject::tr("THIS IS THE %1. CALL!"); call += "</font></b>"; call = call.arg(nCall + 1); } call += "</big><br><br><br>"; call += "<i><font color=\"blue\">" + QObject::tr("Call executed?") + "</font></i><br><br><br>"; return call; }
RecorderBase *RecorderBase::CreateRecorder( TVRec *tvrec, ChannelBase *channel, const RecordingProfile &profile, const GeneralDBOptions &genOpt, const DVBDBOptions &dvbOpt) { if (!channel) return NULL; RecorderBase *recorder = NULL; if (genOpt.cardtype == "MPEG") { #ifdef USING_IVTV recorder = new MpegRecorder(tvrec); #endif // USING_IVTV } else if (genOpt.cardtype == "HDPVR") { #ifdef USING_HDPVR recorder = new MpegRecorder(tvrec); #endif // USING_HDPVR } else if (genOpt.cardtype == "FIREWIRE") { #ifdef USING_FIREWIRE recorder = new FirewireRecorder( tvrec, dynamic_cast<FirewireChannel*>(channel)); #endif // USING_FIREWIRE } else if (genOpt.cardtype == "HDHOMERUN") { #ifdef USING_HDHOMERUN recorder = new HDHRRecorder( tvrec, dynamic_cast<HDHRChannel*>(channel)); recorder->SetOption("wait_for_seqstart", genOpt.wait_for_seqstart); #endif // USING_HDHOMERUN } else if (genOpt.cardtype == "CETON") { #ifdef USING_CETON recorder = new CetonRecorder( tvrec, dynamic_cast<CetonChannel*>(channel)); recorder->SetOption("wait_for_seqstart", genOpt.wait_for_seqstart); #endif // USING_CETON } else if (genOpt.cardtype == "DVB") { #ifdef USING_DVB recorder = new DVBRecorder( tvrec, dynamic_cast<DVBChannel*>(channel)); recorder->SetOption("wait_for_seqstart", genOpt.wait_for_seqstart); #endif // USING_DVB } else if (genOpt.cardtype == "FREEBOX") { #ifdef USING_IPTV recorder = new IPTVRecorder( tvrec, dynamic_cast<IPTVChannel*>(channel)); recorder->SetOption("mrl", genOpt.videodev); #endif // USING_IPTV } else if (genOpt.cardtype == "ASI") { #ifdef USING_ASI recorder = new ASIRecorder( tvrec, dynamic_cast<ASIChannel*>(channel)); recorder->SetOption("wait_for_seqstart", genOpt.wait_for_seqstart); #endif // USING_ASI } else if (genOpt.cardtype == "IMPORT") { recorder = new ImportRecorder(tvrec); } else if (genOpt.cardtype == "DEMO") { #ifdef USING_IVTV recorder = new MpegRecorder(tvrec); #else recorder = new ImportRecorder(tvrec); #endif } else if (CardUtil::IsV4L(genOpt.cardtype)) { #ifdef USING_V4L2 // V4L/MJPEG/GO7007 from here on recorder = new NuppelVideoRecorder(tvrec, channel); recorder->SetOption("skipbtaudio", genOpt.skip_btaudio); #endif // USING_V4L2 } else if (genOpt.cardtype == "EXTERNAL") { recorder = new ExternalRecorder(tvrec, dynamic_cast<ExternalChannel*>(channel)); } if (recorder) { recorder->SetOptionsFromProfile( const_cast<RecordingProfile*>(&profile), genOpt.videodev, genOpt.audiodev, genOpt.vbidev); // Override the samplerate defined in the profile if this card // was configured with a fixed rate. if (genOpt.audiosamplerate) recorder->SetOption("samplerate", genOpt.audiosamplerate); } else { QString msg = "Need %1 recorder, but compiled without %2 support!"; msg = msg.arg(genOpt.cardtype).arg(genOpt.cardtype); LOG(VB_GENERAL, LOG_ERR, "RecorderBase::CreateRecorder() Error, " + msg); } return recorder; }
// Harmonic grid: void VnaTimeDomain::adjustChannelFrequencySpacing() { QString scpi = ":CALC%1:TRAN:TIME:LPAS KFST\n"; scpi = scpi.arg(_trace->channel()); }
SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent), ui_(new Ui_SettingsDialog), settingsViewMenu_(new QMenu(this)), settingsViewGroup_(new QActionGroup(this)), treeView_(new QAction(this)), iconView_(new QAction(this)), generalSettingsModel_(new QStandardItemModel(this)), tableSettingsModel_(new QStandardItemModel(this)), plot2dSettingsModel_(new QStandardItemModel(this)), plot3dSettingsModel_(new QStandardItemModel(this)), fittingSettingsModel_(new QStandardItemModel(this)), scriptingSettingsModel_(new QStandardItemModel(this)) { ui_->setupUi(this); setWindowTitle(tr("Settings")); setWindowIcon(IconLoader::load("edit-preference", IconLoader::LightDark)); setModal(true); setMinimumSize(sizeHint()); // Colors (TODO: use some central qpalette handling) baseColor_ = palette().color(QPalette::Base); fontColor_ = palette().color(QPalette::Text); // adjust layout spacing & margins. ui_->settingGridLayout->setSpacing(3); ui_->settingGridLayout->setContentsMargins(0, 0, 0, 0); ui_->headerHorizontalLayout->setSpacing(0); ui_->scrollVerticalLayout->setSpacing(0); ui_->scrollVerticalLayout->setContentsMargins(3, 3, 3, 3); ui_->scrollVerticalLayout->setContentsMargins(0, 0, 0, 0); ui_->stackGridLayout->setSpacing(0); ui_->stackGridLayout->setContentsMargins(0, 0, 0, 0); // Setup search box. ui_->searchBox->setMaximumWidth(300); ui_->searchBox->setToolTip(tr("search")); // Prepare buttons ui_->configureButton->setIcon( IconLoader::load("edit-preference", IconLoader::LightDark)); ui_->settingsButton->setIcon( IconLoader::load("go-previous", IconLoader::LightDark)); ui_->settingsButton->setEnabled(false); // Add settings configure menu items(tree/icon view) settingsViewGroup_->addAction(treeView_); settingsViewGroup_->addAction(iconView_); treeView_->setText(tr("Tree view")); iconView_->setText(tr("Icon view")); treeView_->setCheckable(true); iconView_->setCheckable(true); settingsViewMenu_->addAction(treeView_); settingsViewMenu_->addAction(iconView_); ui_->configureButton->setMenu(settingsViewMenu_); // Prepare scrollarea. QString scrollbackcol = "QScrollArea {background-color : " "rgba(%1,%2,%3,%4); border: 0;}"; ui_->scrollArea->setStyleSheet(scrollbackcol.arg(baseColor_.red()) .arg(baseColor_.green()) .arg(baseColor_.blue()) .arg(baseColor_.alpha())); // Prepare label. QString label_font_color = "QLabel {color : rgba(%1,%2,%3,%4);" " padding-left: 10px;" " padding-right: 10px;" " padding-top: 10px;" " padding-bottom: 10px}"; ui_->generalLabel->setStyleSheet(label_font_color.arg(fontColor_.red()) .arg(fontColor_.green()) .arg(fontColor_.blue()) .arg(150)); ui_->plot2dLabel->setStyleSheet(label_font_color.arg(fontColor_.red()) .arg(fontColor_.green()) .arg(fontColor_.blue()) .arg(150)); ui_->generalLabel->hide(); ui_->tableLabel->hide(); ui_->plot2dLabel->hide(); ui_->plot3dLabel->hide(); ui_->fittingLabel->hide(); ui_->scriptingLabel->hide(); // Add pages to stack widget addPage(General, Page_GeneralApplication, new ApplicationSettingsPage(this)); addPage(General, Page_GeneralConfirmation, new ApplicationSettingsPage(this)); addPage(General, Page_GeneralAppearance, new GeneralAppreanceSettings(this)); // Make standard item models for listviews & add items QStandardItemModel* iStandardModel = new QStandardItemModel(this); QStandardItem* item1 = new QStandardItem(QIcon(":/data/document-open-remote.png"), "Open"); QStandardItem* item2 = new QStandardItem(QIcon(":/data/document-save.png"), "Save"); QStandardItem* item3 = new QStandardItem(QIcon(":/data/drive-removable-media-usb-pendrive.png"), "Removable Drive"); QStandardItem* item4 = new QStandardItem(QIcon(":/data/download.png"), "Download"); QStandardItem* item5 = new QStandardItem(QIcon(":/data/ipodtouchicon.png"), "Ipod Touch Device"); QStandardItem* item6 = new QStandardItem( QIcon(":/data/multimedia-player-ipod-mini-pink.png"), "Ipod Mini"); QStandardItem* item7 = new QStandardItem(QIcon(":/data/qtlogo.png"), "Qt"); iStandardModel->appendRow(item1); iStandardModel->appendRow(item2); iStandardModel->appendRow(item3); iStandardModel->appendRow(item4); iStandardModel->appendRow(item5); iStandardModel->appendRow(item6); iStandardModel->appendRow(item7); // Set model to the view ui_->generalListView->setModel(generalSettingsModel_); ui_->tableListView->setModel(tableSettingsModel_); ui_->plot2dListView->setModel(iStandardModel); ui_->plot3dListView->setModel(plot3dSettingsModel_); ui_->fittingListView->setModel(fittingSettingsModel_); ui_->scriptingListView->setModel(scriptingSettingsModel_); // Signals & slot connections connect(ui_->settingsButton, SIGNAL(clicked()), this, SLOT(getBackToRootSettingsPage())); connect(ui_->generalListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(generalEnsureSelection(const QModelIndex&))); connect(ui_->plot2dListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(plot2dEnsureSelection(const QModelIndex&))); connect(ui_->generalListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(test(QModelIndex))); }
bool QFile::copy(const QString &newName) { Q_D(QFile); if (d->fileName.isEmpty()) { qWarning("QFile::copy: Empty or null file name"); return false; } if (QFile(newName).exists()) { // ### Race condition. If a file is moved in after this, it /will/ be // overwritten. On Unix, the proper solution is to use hardlinks: // return ::link(old, new) && ::remove(old); See also rename(). d->setError(QFile::CopyError, tr("Destination file exists")); return false; } unsetError(); close(); if(error() == QFile::NoError) { if(fileEngine()->copy(newName)) { unsetError(); return true; } else { bool error = false; if(!open(QFile::ReadOnly)) { error = true; d->setError(QFile::CopyError, tr("Cannot open %1 for input").arg(d->fileName)); } else { QString fileTemplate = QLatin1String("%1/qt_temp.XXXXXX"); #ifdef QT_NO_TEMPORARYFILE QFile out(fileTemplate.arg(QFileInfo(newName).path())); if (!out.open(QIODevice::ReadWrite)) error = true; #else QTemporaryFile out(fileTemplate.arg(QFileInfo(newName).path())); if (!out.open()) { out.setFileTemplate(fileTemplate.arg(QDir::tempPath())); if (!out.open()) error = true; } #endif if (error) { out.close(); d->setError(QFile::CopyError, tr("Cannot open for output")); } else { char block[4096]; qint64 totalRead = 0; while(!atEnd()) { qint64 in = read(block, sizeof(block)); if (in <= 0) break; totalRead += in; if(in != out.write(block, in)) { d->setError(QFile::CopyError, tr("Failure to write block")); error = true; break; } } if (totalRead != size()) { // Unable to read from the source. The error string is // already set from read(). error = true; } if (!error && !out.rename(newName)) { error = true; d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName)); } #ifdef QT_NO_TEMPORARYFILE if (error) out.remove(); #else if (!error) out.setAutoRemove(false); #endif } close(); } if(!error) { QFile::setPermissions(newName, permissions()); unsetError(); return true; } } } return false; }
void DspMakefileGenerator::init() { if(init_flag) return; QStringList::Iterator it; init_flag = TRUE; const bool thread = project->isActiveConfig("thread"); if ( project->isActiveConfig("stl") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"]; } if ( project->isActiveConfig("exceptions") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; } if ( project->isActiveConfig("rtti") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; } /* this should probably not be here, but I'm using it to wrap the .t files */ if(project->first("TEMPLATE") == "vcapp" ) project->variables()["QMAKE_APP_FLAG"].append("1"); else if(project->first("TEMPLATE") == "vclib") project->variables()["QMAKE_LIB_FLAG"].append("1"); if ( project->variables()["QMAKESPEC"].isEmpty() ) project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; QStringList &configs = project->variables()["CONFIG"]; if (project->isActiveConfig("shared")) project->variables()["DEFINES"].append("QT_DLL"); if (project->isActiveConfig("qt_dll")) if(configs.findIndex("qt") == -1) configs.append("qt"); if ( project->isActiveConfig("qtopia") ) { if(configs.findIndex("qtopialib") == -1) configs.append("qtopialib"); if(configs.findIndex("qtopiainc") == -1) configs.append("qtopiainc"); } if ( project->isActiveConfig("qt") ) { if ( project->isActiveConfig( "plugin" ) ) { project->variables()["CONFIG"].append("dll"); project->variables()["DEFINES"].append("QT_PLUGIN"); } if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { project->variables()["QMAKE_QT_DLL"].append("1"); if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) project->variables()["CONFIG"].append("dll"); } } if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { project->variables()["CONFIG"].remove("staticlib"); project->variables()["QMAKE_APP_OR_DLL"].append("1"); } else { project->variables()["CONFIG"].append("staticlib"); } if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { project->variables()["CONFIG"].append("windows"); } if ( !project->variables()["VERSION"].isEmpty() ) { QString version = project->variables()["VERSION"][0]; int firstDot = version.find( "." ); QString major = version.left( firstDot ); QString minor = version.right( version.length() - firstDot - 1 ); minor.replace( ".", "" ); project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); } if ( project->isActiveConfig("qtopiainc") ) project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"]; if ( project->isActiveConfig("qtopialib") ) { if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA")) project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"]; project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"]; } if ( project->isActiveConfig("qt") ) { project->variables()["CONFIG"].append("moc"); project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { project->variables()["DEFINES"].append("QT_MAKEDLL"); project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\""); } } else { if( thread ) project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; else project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); if ( hver == -1 ) hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); if(hver != -1) { QString ver; ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (thread ? "-mt" : ""), hver); QStringList &libs = project->variables()["QMAKE_LIBS"]; for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); } } if ( project->isActiveConfig( "activeqt" ) ) { project->variables().remove("QMAKE_LIBS_QT_ENTRY"); project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; if ( project->isActiveConfig( "dll" ) ) project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; } if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; } } } if ( project->isActiveConfig("debug") ) { if ( !project->first("OBJECTS_DIR").isEmpty() ) project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR"); else project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; if ( !project->first("DESTDIR").isEmpty() ) project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR"); else project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; } else { if ( !project->first("OBJECTS_DIR").isEmpty() ) project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); else project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; if ( !project->first("DESTDIR").isEmpty() ) project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); else project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; } if ( project->isActiveConfig("opengl") ) { project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; } if ( thread ) { if(project->isActiveConfig("qt")) project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain" || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; } else { // YES we want to use the DLL even in a static build project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"]; } if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt && project->first("TARGET") != "qtmain" ) project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); } if(project->isActiveConfig("qt")) { if ( project->isActiveConfig("accessibility" ) ) project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); if ( project->isActiveConfig("tablet") ) project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); } if ( project->isActiveConfig("dll") ) { project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"]; project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"]; if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { QString ver_xyz(project->first("VERSION")); ver_xyz.replace(".", ""); project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); } else { project->variables()["TARGET_EXT"].append(".dll"); } } else { project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"]; project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"]; project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) project->variables()["TARGET_EXT"].append(".exe"); else project->variables()["TARGET_EXT"].append(".lib"); } if ( project->isActiveConfig("windows") ) { if ( project->isActiveConfig("console") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; } else { project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; } project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; } project->variables()["MSVCDSP_VER"] = "6.00"; project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI"; if(!project->isActiveConfig("incremental")) { project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); if ( is_qt ) project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /Zi"; } QString msvcdsp_project; if ( project->variables()["TARGET"].count() ) msvcdsp_project = project->variables()["TARGET"].first(); QString targetfilename = project->variables()["TARGET"].first(); project->variables()["TARGET"].first() += project->first("TARGET_EXT"); if ( project->isActiveConfig("moc") ) setMocAware(TRUE); project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); QStringList &l = project->variables()["QMAKE_FILETAGS"]; for(it = l.begin(); it != l.end(); ++it) { QStringList &gdmf = project->variables()[(*it)]; for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) (*inner) = Option::fixPathToTargetOS((*inner), FALSE); } MakefileGenerator::init(); if ( msvcdsp_project.isEmpty() ) msvcdsp_project = Option::output.name(); msvcdsp_project = msvcdsp_project.right( msvcdsp_project.length() - msvcdsp_project.findRev( "\\" ) - 1 ); msvcdsp_project = msvcdsp_project.left( msvcdsp_project.findRev( "." ) ); msvcdsp_project.replace("-", ""); project->variables()["MSVCDSP_PROJECT"].append(msvcdsp_project); QStringList &proj = project->variables()["MSVCDSP_PROJECT"]; for(it = proj.begin(); it != proj.end(); ++it) (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { project->variables()["MSVCDSP_TEMPLATE"].append("win32app" + project->first( "DSP_EXTENSION" ) ); if ( project->isActiveConfig("console") ) { project->variables()["MSVCDSP_CONSOLE"].append("Console"); project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE"); project->variables()["MSVCDSP_DSPTYPE"].append("0x0103"); } else { project->variables()["MSVCDSP_CONSOLE"].clear(); project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); } } else { if ( project->isActiveConfig("dll") ) { project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) ); } else { project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) ); } } project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; processPrlFiles(); // Update -lname to name.lib, QStringList &libList = project->variables()["QMAKE_LIBS"]; for( QStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) { QString s = *stIt; if( s.startsWith( "-l" ) ) { stIt = libList.remove( stIt ); stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" ); } else if( s.startsWith( "-L" ) ) { stIt = libList.remove( stIt ); project->variables()["QMAKE_LIBDIR"].append(QDir::convertSeparators(s.mid( 2 ))); } else { stIt++; } } project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); if (!project->variables()["RES_FILE"].isEmpty()) project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; QStringList &libs = project->variables()["QMAKE_LIBS"]; for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { QString lib = (*libit); lib.replace(QRegExp("\""), ""); project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\""); } QStringList &incs = project->variables()["INCLUDEPATH"]; for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { QString inc = (*incit); inc.replace("\"", ""); if(inc.endsWith("\\")) // Remove trailing \'s from paths inc.truncate(inc.length()-1); if (inc.startsWith("\"") && inc.endsWith("\"")) inc = inc.mid(1, inc.length() - 2); project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); } project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\""); if ( project->isActiveConfig("qt") ) { project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\""); } else { project->variables()["MSVCDSP_RELDEFS"].clear(); } QString dest; QString postLinkStep; QString copyDllStep; QString activeQtStepPreCopyDll; QString activeQtStepPostCopyDll; QString activeQtStepPreCopyDllDebug; QString activeQtStepPostCopyDllDebug; QString activeQtStepPreCopyDllRelease; QString activeQtStepPostCopyDllRelease; if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) postLinkStep += var("QMAKE_POST_LINK"); if ( !project->variables()["DESTDIR"].isEmpty() ) { project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); Option::fixPathToTargetOS(project->first("TARGET")); dest = project->first("TARGET"); if ( project->first("TARGET").startsWith("$(QTDIR)") ) dest.replace( "$(QTDIR)", getenv("QTDIR") ); project->variables()["MSVCDSP_TARGET"].append( QString("/out:\"") + dest + "\""); if ( project->isActiveConfig("dll") ) { QString imp = dest; imp.replace(".dll", ".lib"); project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\""); } } if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { QStringList dlldirs = project->variables()["DLLDESTDIR"]; if ( dlldirs.count() ) copyDllStep += "\t"; for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { copyDllStep += "copy \"$(TargetPath)\" \"" + *dlldir + "\"\t"; } } if ( project->isActiveConfig("activeqt") ) { QString idl = project->variables()["QMAKE_IDL"].first(); QString idc = project->variables()["QMAKE_IDC"].first(); QString version = project->variables()["VERSION"].first(); if ( version.isEmpty() ) version = "1.0"; project->variables()["MSVCDSP_IDLSOURCES"].append( var("OBJECTS_DIR") + targetfilename + ".idl" ); if ( project->isActiveConfig( "dll" ) ) { activeQtStepPreCopyDll += "\t" + idc + " %1 -idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version + "\t" + idl + " /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb" + "\t" + idc + " %2 /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"; activeQtStepPostCopyDll += "\t" + idc + " %1 /regserver\n"; QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".dll"; activeQtStepPreCopyDllRelease = activeQtStepPreCopyDll.arg(executable).arg(executable); activeQtStepPostCopyDllRelease = activeQtStepPostCopyDll.arg(executable); executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".dll"; activeQtStepPreCopyDllDebug = activeQtStepPreCopyDll.arg(executable).arg(executable); activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable); } else { activeQtStepPreCopyDll += "\t%1 -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version + "\t" + idl + " /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb" + "\t" + idc + " %2 /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"; activeQtStepPostCopyDll += "\t%1 -regserver\n"; QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".exe"; activeQtStepPreCopyDllRelease = activeQtStepPreCopyDll.arg(executable).arg(executable); activeQtStepPostCopyDllRelease = activeQtStepPostCopyDll.arg(executable); executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".exe"; activeQtStepPreCopyDllDebug = activeQtStepPreCopyDll.arg(executable).arg(executable); activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable); } } if ( !postLinkStep.isEmpty() || !copyDllStep.isEmpty() || !activeQtStepPreCopyDllDebug.isEmpty() || !activeQtStepPreCopyDllRelease.isEmpty() ) { project->variables()["MSVCDSP_POST_LINK_DBG"].append( "# Begin Special Build Tool\n" "SOURCE=$(InputPath)\n" "PostBuild_Desc=Post Build Step\n" "PostBuild_Cmds=" + postLinkStep + activeQtStepPreCopyDllDebug + copyDllStep + activeQtStepPostCopyDllDebug + "\n" "# End Special Build Tool\n" ); project->variables()["MSVCDSP_POST_LINK_REL"].append( "# Begin Special Build Tool\n" "SOURCE=$(InputPath)\n" "PostBuild_Desc=Post Build Step\n" "PostBuild_Cmds=" + postLinkStep + activeQtStepPreCopyDllRelease + copyDllStep + activeQtStepPostCopyDllRelease + "\n" "# End Special Build Tool\n" ); } if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) { project->variables()["SOURCES"] += project->variables()["RC_FILE"]; } QStringList &list = project->variables()["FORMS"]; for( it = list.begin(); it != list.end(); ++it ) { if ( QFile::exists( *it + ".h" ) ) project->variables()["SOURCES"].append( *it + ".h" ); } project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS"; }
bool DspMakefileGenerator::writeDspParts(QTextStream &t) { QString dspfile; if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) { dspfile = project->first("DSP_TEMPLATE"); } else { dspfile = project->first("MSVCDSP_TEMPLATE"); } if (dspfile.startsWith("\"") && dspfile.endsWith("\"")) dspfile = dspfile.mid(1, dspfile.length() - 2); QString dspfile_loc = findTemplate(dspfile); QFile file(dspfile_loc); if(!file.open(IO_ReadOnly)) { fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1()); return FALSE; } QTextStream dsp(&file); QString platform = "Win32"; if ( !project->variables()["QMAKE_PLATFORM"].isEmpty() ) platform = varGlue("QMAKE_PLATFORM", "", " ", ""); // Setup PCH variables precompH = project->first("PRECOMPILED_HEADER"); QString namePCH = QFileInfo(precompH).fileName(); usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); if (usePCH) { // Created files QString origTarget = project->first("QMAKE_ORIG_TARGET"); origTarget.replace(QRegExp("-"), "_"); precompObj = "\"$(IntDir)\\" + origTarget + Option::obj_ext + "\""; precompPch = "\"$(IntDir)\\" + origTarget + ".pch\""; // Add PRECOMPILED_HEADER to HEADERS if (!project->variables()["HEADERS"].contains(precompH)) project->variables()["HEADERS"] += precompH; // Add precompile compiler options project->variables()["PRECOMPILED_FLAGS_REL"] = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" "; project->variables()["PRECOMPILED_FLAGS_DEB"] = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" "; // Return to variable pool project->variables()["PRECOMPILED_OBJECT"] = precompObj; project->variables()["PRECOMPILED_PCH"] = precompPch; } int rep; QString line; while ( !dsp.eof() ) { line = dsp.readLine(); while((rep = line.find(QRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) { QString torep = line.mid(rep, line.find(QRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep); QString variable = torep.right(torep.length()-2); t << line.left(rep); //output the left side line = line.right(line.length() - (rep + torep.length())); //now past the variable if(variable == "MSVCDSP_SOURCES") { if(project->variables()["SOURCES"].isEmpty()) continue; QString mocpath = var( "QMAKE_MOC" ); mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; QStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"]; if(!project->isActiveConfig("flat")) list.sort(); QStringList::Iterator it; for( it = list.begin(); it != list.end(); ++it) { beginGroupForFile((*it), t); t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; if (usePCH && (*it).endsWith(".c")) t << "# SUBTRACT CPP /FI\"" << namePCH << "\" /Yu\"" << namePCH << "\" /Fp" << endl; if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) { QString base = (*it); base.replace(QRegExp("\\..*$"), "").upper(); base.replace(QRegExp("[^a-zA-Z]"), "_"); QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" "\t" + mocpath + findMocSource((*it)) + " -o " + (*it) + "\n\n" "# End Custom Build\n\n"; t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build << "!ENDIF " << endl << endl; } t << "# End Source File" << endl; } endGroups(t); } else if(variable == "MSVCDSP_IMAGES") { if(project->variables()["IMAGES"].isEmpty()) continue; t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl; t << "# End Source File" << endl; } else if(variable == "MSVCDSP_HEADERS") { if(project->variables()["HEADERS"].isEmpty()) continue; QStringList list = project->variables()["HEADERS"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { // beginGroupForFile((*it), t); t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl; QString compilePCH; QStringList customDependencies; QString createMOC; QString buildCmdsR, buildCmdsD; QString buildCmds = "\nBuildCmds= \\\n"; // Create unique baseID QString base = (*it); { base.replace(QRegExp("\\..*$"), "").upper(); base.replace(QRegExp("[^a-zA-Z]"), "_"); } if (usePCH && precompH.endsWith(*it)) { QString basicBuildCmd = QString("\tcl.exe /TP /W3 /FD /c /D \"WIN32\" /Yc /Fp\"%1\" /Fo\"%2\" %3 %4 %5 %6 %7 %8 %9 /D \"") .arg(precompPch) .arg(precompObj) .arg(var("MSVCDSP_INCPATH")) .arg(var("MSVCDSP_DEFINES")) .arg(var("MSVCDSP_CXXFLAGS")); buildCmdsR = basicBuildCmd .arg("/D \"NDEBUG\"") .arg(var("QMAKE_CXXFLAGS_RELEASE")) .arg(var("MSVCDSP_MTDEF")) .arg(var("MSVCDSP_RELDEFS")); buildCmdsD = basicBuildCmd .arg("/D \"_DEBUG\" /Od") .arg(var("QMAKE_CXXFLAGS_DEBUG")) .arg(var("MSVCDSP_MTDEFD")) .arg(var("MSVCDSP_DEBUG_OPT")); if (project->first("TEMPLATE") == "vcapp") { // App buildCmdsR += var("MSVCDSP_WINCONDEF"); buildCmdsD += var("MSVCDSP_WINCONDEF"); } else if (project->isActiveConfig("dll")) { // Dll buildCmdsR += "_WINDOWS\" /D \"_USRDLL"; buildCmdsD += "_WINDOWS\" /D \"_USRDLL"; } else { // Lib buildCmdsR += "_LIB"; buildCmdsD += "_LIB"; } buildCmdsR += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n"; buildCmdsD += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n"; compilePCH = precompPch + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n $(BuildCmds)\n\n"; QStringList &tmp = findDependencies(precompH); if(!tmp.isEmpty()) // Got Deps for PCH customDependencies += tmp; } if (project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) { QString mocpath = var( "QMAKE_MOC" ); mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; buildCmds += "\t" + mocpath + (*it) + " -o " + findMocDestination((*it)) + " \\\n"; createMOC = "\"" + findMocDestination((*it)) + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n $(BuildCmds)\n\n"; customDependencies += "\"$(QTDIR)\\bin\\moc.exe\""; } if (!createMOC.isEmpty() || !compilePCH.isEmpty()) { bool doMOC = !createMOC.isEmpty(); bool doPCH = !compilePCH.isEmpty(); QString build = "\n\n# Begin Custom Build - "+ QString(doMOC?"Moc'ing ":"") + QString((doMOC&&doPCH)?" and ":"") + QString(doPCH?"Creating PCH cpp from ":"") + (*it) + "...\nInputPath=.\\" + (*it) + "\n\n" + buildCmds + "%1\n" + createMOC + compilePCH + "# End Custom Build\n\n"; t << "USERDEP_" << base << "=" << valGlue(customDependencies, "\"", "\" \"", "\"") << endl << endl; t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build.arg(buildCmdsR) << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build.arg(buildCmdsD) << "!ENDIF " << endl << endl; } t << "# End Source File" << endl; } // endGroups(t); } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") { if(project->variables()["FORMS"].isEmpty()) continue; QString uiSourcesDir; QString uiHeadersDir; if(!project->variables()["UI_DIR"].isEmpty()) { uiSourcesDir = project->first("UI_DIR"); uiHeadersDir = project->first("UI_DIR"); } else { if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) uiSourcesDir = project->first("UI_SOURCES_DIR"); else uiSourcesDir = ""; if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) uiHeadersDir = project->first("UI_HEADERS_DIR"); else uiHeadersDir = ""; } QStringList list = project->variables()["FORMS"]; if(!project->isActiveConfig("flat")) list.sort(); QString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h"; for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { QString base = (*it); int dot = base.findRev("."); base.replace( dot, base.length() - dot, ext ); QString fname = base; int lbs = fname.findRev( "\\" ); QString fpath; if ( lbs != -1 ) fpath = fname.left( lbs + 1 ); fname = fname.right( fname.length() - lbs - 1 ); if ( ext == ".cpp" && !uiSourcesDir.isEmpty() ) fname.prepend(uiSourcesDir); else if ( ext == ".h" && !uiHeadersDir.isEmpty() ) fname.prepend(uiHeadersDir); else fname = base; // beginGroupForFile(fname, t); t << "# Begin Source File\n\nSOURCE=" << fname << "\n# End Source File" << endl; } // endGroups(t); } else if(variable == "MSVCDSP_TRANSLATIONS" ) { if(project->variables()["TRANSLATIONS"].isEmpty()) continue; t << "# Begin Group \"Translations\"\n"; t << "# Prop Default_Filter \"ts\"\n"; QStringList list = project->variables()["TRANSLATIONS"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { QString sify = *it; sify.replace('/', '\\' ); QString base = (*it); base.replace(QRegExp("\\..*$"), "").upper(); base.replace(QRegExp("[^a-zA-Z]"), "_"); // beginGroupForFile(sify, t); t << "# Begin Source File\n\nSOURCE=" << sify << endl; t << "\n# End Source File" << endl; } // endGroups(t); t << "\n# End Group\n"; } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) { if ( project->variables()["SRCMOC"].isEmpty()) continue; QString mocpath = var( "QMAKE_MOC" ); mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; QStringList list = project->variables()["SRCMOC"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { // beginGroupForFile((*it), t); t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) { QString base = (*it); base.replace(QRegExp("\\..*$"), "").upper(); base.replace(QRegExp("[^a-zA-Z]"), "_"); QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" "\t" + mocpath + findMocSource((*it)) + " -o " + (*it) + "\n\n" "# End Custom Build\n\n"; t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build << "!ENDIF " << endl << endl; } t << "# End Source File" << endl; } // endGroups(t); } else if(variable == "MSVCDSP_PICTURES") { if(project->variables()["IMAGES"].isEmpty()) continue; t << "# Begin Group \"Images\"\n" << "# Prop Default_Filter \"png jpeg bmp xpm\"\n"; QStringList list = project->variables()["IMAGES"]; if(!project->isActiveConfig("flat")) list.sort(); QStringList::Iterator it; // dump the image list to a file UIC can read. QFile f( "images.tmp" ); f.open( IO_WriteOnly ); QTextStream ts( &f ); for( it = list.begin(); it != list.end(); ++it ) ts << " " << *it; f.close(); // create an output step for images not more than once bool imagesBuildDone = FALSE; for( it = list.begin(); it != list.end(); ++it ) { // beginGroupForFile((*it), t); t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; QString base = (*it); QString uicpath = var("QMAKE_UIC"); uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " "; if ( !imagesBuildDone ) { imagesBuildDone = TRUE; QString build = "\n\n# Begin Custom Build - Creating image collection...\n" "InputPath=.\\" + base + "\n\n"; build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"; build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o " + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n"; build.append("# End Custom Build\n\n"); t << "USERDEP_" << base << "="; QStringList::Iterator it2 = list.begin(); while ( it2 != list.end() ) { t << "\"" << (*it2) << "\""; it2++; if ( it2 != list.end() ) t << "\\\n"; } t << endl << endl; t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build << "!ENDIF \n\n" << endl; } t << "# End Source File" << endl; } // endGroups(t); t << "\n# End Group\n"; } else if(variable == "MSVCDSP_FORMS") { if(project->variables()["FORMS"].isEmpty()) continue; t << "# Begin Group \"Forms\"\n" << "# Prop Default_Filter \"ui\"\n"; QString uicpath = var("QMAKE_UIC"); uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " "; QString mocpath = var( "QMAKE_MOC" ); mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; QStringList list = project->variables()["FORMS"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { QString base = (*it); // beginGroupForFile(base, t); t << "# Begin Source File\n\nSOURCE=" << base << endl; QString fname = base; fname.replace(".ui", ""); int lbs = fname.findRev( "\\" ); QString fpath; if ( lbs != -1 ) fpath = fname.left( lbs + 1 ); fname = fname.right( fname.length() - lbs - 1 ); QString mocFile; if(!project->variables()["MOC_DIR"].isEmpty()) mocFile = project->first("MOC_DIR"); else mocFile = fpath; QString uiSourcesDir; QString uiHeadersDir; if(!project->variables()["UI_DIR"].isEmpty()) { uiSourcesDir = project->first("UI_DIR"); uiHeadersDir = project->first("UI_DIR"); } else { if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) uiSourcesDir = project->first("UI_SOURCES_DIR"); else uiSourcesDir = fpath; if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) uiHeadersDir = project->first("UI_HEADERS_DIR"); else uiHeadersDir = fpath; } t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\" \"$(QTDIR)\\bin\\uic.exe\"" << endl << endl; QString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n" "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base + " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base + " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n" "\t" + mocpath + " " + uiHeadersDir + fname + ".h -o " + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + " \\\n"; build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" "\t$(BuildCmds)\n\n" "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" "\t$(BuildCmds)\n\n" "\"" + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" "\t$(BuildCmds)\n\n"); build.append("# End Custom Build\n\n"); t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build << "!ENDIF \n\n" << "# End Source File" << endl; } // endGroups(t); t << "\n# End Group\n"; } else if(variable == "MSVCDSP_LEXSOURCES") { if(project->variables()["LEXSOURCES"].isEmpty()) continue; t << "# Begin Group \"Lexables\"\n" << "# Prop Default_Filter \"l\"\n"; QString lexpath = var("QMAKE_LEX") + varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " "; QStringList list = project->variables()["LEXSOURCES"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { QString fname = (*it); // beginGroupForFile(fname, t); t << "# Begin Source File\n\nSOURCE=" << fname << endl; fname.replace(".l", Option::lex_mod + Option::cpp_ext.first()); QString build = "\n\n# Begin Custom Build - Lex'ing " + (*it) + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + fname + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" "\t" + lexpath + (*it) + "\\\n" "\tdel " + fname + "\\\n" "\tcopy lex.yy.c " + fname + "\n\n" + "# End Custom Build\n\n"; t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build << "!ENDIF \n\n" << build << "# End Source File" << endl; } // endGroups(t); t << "\n# End Group\n"; } else if(variable == "MSVCDSP_YACCSOURCES") { if(project->variables()["YACCSOURCES"].isEmpty()) continue; t << "# Begin Group \"Yaccables\"\n" << "# Prop Default_Filter \"y\"\n"; QString yaccpath = var("QMAKE_YACC") + varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " "; QStringList list = project->variables()["YACCSOURCES"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { QString fname = (*it); // beginGroupForFile(fname, t); t << "# Begin Source File\n\nSOURCE=" << fname << endl; fname.replace(".y", Option::yacc_mod); QString build = "\n\n# Begin Custom Build - Yacc'ing " + (*it) + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + fname + Option::cpp_ext.first() + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" "\t" + yaccpath + (*it) + "\\\n" "\tdel " + fname + Option::h_ext.first() + "\\\n" "\tmove y.tab.h " + fname + Option::h_ext.first() + "\n\n" + "\tdel " + fname + Option::cpp_ext.first() + "\\\n" "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" + "# End Custom Build\n\n"; t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build << "!ENDIF \n\n" << "# End Source File" << endl; } // endGroups(t); t << "\n# End Group\n"; } else if( variable == "MSVCDSP_CONFIGMODE" ) { if( project->isActiveConfig( "debug" ) ) t << "Debug"; else t << "Release"; } else if( variable == "MSVCDSP_IDLSOURCES" ) { QStringList list = project->variables()["MSVCDSP_IDLSOURCES"]; if(!project->isActiveConfig("flat")) list.sort(); for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { t << "# Begin Source File" << endl << endl; t << "SOURCE=" << (*it) << endl; t << "# PROP Exclude_From_Build 1" << endl; t << "# End Source File" << endl << endl; } } else t << var(variable); } t << line << endl; } t << endl; file.close(); return TRUE; }
QString Room_Reservation_Base::Ident() const { QString out = "<Room_Reservation @%1 room#=%2 created=%3>"; out = out.arg( dbid ).arg( roomNumber ); return out.arg( dateCreated.toString("yyyy-MM-dd") ); }
void UIItemHostNetwork::updateFields() { /* Compose item fields: */ setText(Column_Name, m_interface.m_strName); setText(Column_IPv4, m_interface.m_strAddress.isEmpty() ? QString() : QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask))); setText(Column_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() : QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt())); setText(Column_DHCP, tr("Enable", "DHCP Server")); setCheckState(Column_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked); /* Compose item tool-tip: */ const QString strTable("<table cellspacing=5>%1</table>"); const QString strHeader("<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>"); const QString strSubHeader("<tr><td><nobr> %1: </nobr></td><td><nobr>%2</nobr></td></tr>"); QString strToolTip; /* Interface information: */ strToolTip += strHeader.arg(tr("Adapter")) .arg(m_interface.m_fDHCPEnabled ? tr("Automatically configured", "interface") : tr("Manually configured", "interface")); strToolTip += strSubHeader.arg(tr("IPv4 Address")) .arg(m_interface.m_strAddress.isEmpty() ? tr ("Not set", "address") : m_interface.m_strAddress) + strSubHeader.arg(tr("IPv4 Network Mask")) .arg(m_interface.m_strMask.isEmpty() ? tr ("Not set", "mask") : m_interface.m_strMask); if (m_interface.m_fSupportedIPv6) { strToolTip += strSubHeader.arg(tr("IPv6 Address")) .arg(m_interface.m_strAddress6.isEmpty() ? tr("Not set", "address") : m_interface.m_strAddress6) + strSubHeader.arg(tr("IPv6 Prefix Length")) .arg(m_interface.m_strPrefixLength6.isEmpty() ? tr("Not set", "length") : m_interface.m_strPrefixLength6); } /* DHCP server information: */ strToolTip += strHeader.arg(tr("DHCP Server")) .arg(m_dhcpserver.m_fEnabled ? tr("Enabled", "server") : tr("Disabled", "server")); if (m_dhcpserver.m_fEnabled) { strToolTip += strSubHeader.arg(tr("Address")) .arg(m_dhcpserver.m_strAddress.isEmpty() ? tr("Not set", "address") : m_dhcpserver.m_strAddress) + strSubHeader.arg(tr("Network Mask")) .arg(m_dhcpserver.m_strMask.isEmpty() ? tr("Not set", "mask") : m_dhcpserver.m_strMask) + strSubHeader.arg(tr("Lower Bound")) .arg(m_dhcpserver.m_strLowerAddress.isEmpty() ? tr("Not set", "bound") : m_dhcpserver.m_strLowerAddress) + strSubHeader.arg(tr("Upper Bound")) .arg(m_dhcpserver.m_strUpperAddress.isEmpty() ? tr("Not set", "bound") : m_dhcpserver.m_strUpperAddress); } /* Assign tool-tip finally: */ setToolTip(Column_Name, strTable.arg(strToolTip)); }
void TopSceneParameter::displayLanguageTop(const QString &_value) { QString sql = "SELECT a.* FROM Song AS a where a.songLanguage='%1' ORDER BY a.songPlayCount DESC"; displayTop(sql.arg(_value)); }
void AddIntervalDialog::createClicked() { const RideFile *ride = context->currentRide(); if (!ride) { QMessageBox::critical(this, tr("Select Ride"), tr("No ride selected!")); return; } int maxIntervals = (int) countSpinBox->value(); double windowSizeSecs = (hrsSpinBox->value() * 3600.0 + minsSpinBox->value() * 60.0 + secsSpinBox->value()); double windowSizeMeters = (kmsSpinBox->value() * 1000.0 + msSpinBox->value()); if (windowSizeSecs == 0.0) { QMessageBox::critical(this, tr("Bad Interval Length"), tr("Interval length must be greater than zero!")); return; } bool byTime = typeTime->isChecked(); QList<AddedInterval> results; if (methodBestPower->isChecked()) { if (peakPowerStandard->isChecked()) findPeakPowerStandard(ride, results); else findBests(byTime, ride, (byTime?windowSizeSecs:windowSizeMeters), maxIntervals, results, ""); } else findFirsts(byTime, ride, (byTime?windowSizeSecs:windowSizeMeters), maxIntervals, results); // clear the table clearResultsTable(resultsTable); // populate the table resultsTable->setRowCount(results.size()); int row = 0; foreach (const AddedInterval &interval, results) { double secs = interval.start; double mins = floor(secs / 60); secs = secs - mins * 60.0; double hrs = floor(mins / 60); mins = mins - hrs * 60.0; // check box QCheckBox *c = new QCheckBox; c->setCheckState(Qt::Checked); resultsTable->setCellWidget(row, 0, c); // start time QString start = "%1:%2:%3"; start = start.arg(hrs, 0, 'f', 0); start = start.arg(mins, 2, 'f', 0, QLatin1Char('0')); start = start.arg(round(secs), 2, 'f', 0, QLatin1Char('0')); QTableWidgetItem *t = new QTableWidgetItem; t->setText(start); t->setFlags(t->flags() & (~Qt::ItemIsEditable)); resultsTable->setItem(row, 1, t); QTableWidgetItem *n = new QTableWidgetItem; n->setText(interval.name); n->setFlags(n->flags() | (Qt::ItemIsEditable)); resultsTable->setItem(row, 2, n); // hidden columns - start, stop QString strt = QString("%1").arg(interval.start); // can't use secs as it gets modified QTableWidgetItem *st = new QTableWidgetItem; st->setText(strt); resultsTable->setItem(row, 3, st); QString stp = QString("%1").arg(interval.stop); // was interval.start+x QTableWidgetItem *sp = new QTableWidgetItem; sp->setText(stp); resultsTable->setItem(row, 4, sp); row++; }
void MythUIText::FillCutMessage() { m_CutMessage.clear(); if (m_Message != m_DefaultMessage) { bool isNumber; int value = m_Message.toInt(&isNumber); if (isNumber && m_TemplateText.contains("%n")) { m_CutMessage = qApp->translate("ThemeUI", m_TemplateText.toUtf8(), NULL, QCoreApplication::UnicodeUTF8, qAbs(value)); } else if (m_TemplateText.contains("%1")) { QString tmp = qApp->translate("ThemeUI", m_TemplateText.toUtf8(), NULL, QCoreApplication::UnicodeUTF8); m_CutMessage = tmp.arg(m_Message); } } if (m_CutMessage.isEmpty()) m_CutMessage = m_Message; if (m_CutMessage.isEmpty()) return; QStringList templist; QStringList::iterator it; switch (m_textCase) { case CaseUpper : m_CutMessage = m_CutMessage.toUpper(); break; case CaseLower : m_CutMessage = m_CutMessage.toLower(); break; case CaseCapitaliseFirst : //m_CutMessage = m_CutMessage.toLower(); templist = m_CutMessage.split(". "); for (it = templist.begin(); it != templist.end(); ++it) (*it).replace(0,1,(*it).left(1).toUpper()); m_CutMessage = templist.join(". "); break; case CaseCapitaliseAll : //m_CutMessage = m_CutMessage.toLower(); templist = m_CutMessage.split(" "); for (it = templist.begin(); it != templist.end(); ++it) (*it).replace(0,1,(*it).left(1).toUpper()); m_CutMessage = templist.join(" "); break; } if (m_MinSize.x() > 0) { QRect rect; MakeNarrow(rect); // Record the minimal area needed for the message. SetMinArea(rect.size()); if (m_MinArea.width() > 0) SetDrawRectSize(m_MinArea.width(), m_MinArea.height()); } if (m_Cutdown) m_CutMessage = cutDown(m_CutMessage, m_Font, m_MultiLine); }
// == PRIVATE FUNCTIONS == void DeviceWidget::doUpdate(){ bool firstrun = type().isEmpty(); //qDebug() << "Update Item:" << firstrun << quickupdates << node(); if(firstrun || !quickupdates){ QStringList info = pcbsd::Utils::runShellCommand("pc-sysconfig \"devinfo "+node()+"\"").join("").split(", "); if(info.length() < 3){ emit RefreshDeviceList(); return; } //invalid device - will probably get removed here in a moment //Info Output: <filesystem>, <label>, <type> //qDebug() << " - info:" << info; //Save this into the internal variables ui->label_icon->setWhatsThis(info[2]); //type ui->label_dev->setText(info[1]); //label ui->tool_mount->setWhatsThis(info[0]); //filesystem if(info[0].toLower()=="zfs"){ ui->label_icon->setToolTip(node()+" ("+info[0]+")"); } else{ ui->label_icon->setToolTip("/dev/"+node()+" ("+info[0]+")"); } //Now go through and set all the various icons and such QString icon = ":icons/%1.png"; if(type()=="SATA"){ icon = icon.arg("harddrive"); } else if(type()=="USB"){ icon = icon.arg("usb"); } else if(type()=="SD"){ icon = icon.arg("sdcard"); } else if(type()=="CD-AUDIO"){ icon = icon.arg("musiccd"); } else if(type()=="CD-VIDEO"){ icon = icon.arg("cd-video"); } else if(type().startsWith("CD")){ icon = icon.arg("cd-generic"); } else if(type()=="ISO"){ icon = icon.arg("dvd"); } else{ icon = icon.arg("CDdevices"); } if(filesystem()=="NONE" && !type().startsWith("CD")){ //Add the question-mark overlay to the icon, signifying that it is an unknown filesystem QPixmap tmp(icon); QPixmap overlay(":icons/question-overlay.png"); QPainter paint(&tmp); paint.drawPixmap(ui->label_icon->width()-20, ui->label_icon->height()-20, overlay ); //put it in the bottom-right corner ui->label_icon->setPixmap(tmp); }else{ //Just the normal icon ui->label_icon->setPixmap(QPixmap(icon)); } if(type()=="CD-AUDIO" || type()=="CD-VIDEO"){ ui->tool_run->setIcon(QIcon(":icons/play.png")); ui->tool_run->setText(tr("Play")); }else{ ui->tool_run->setIcon(QIcon(":icons/folder.png") ); ui->tool_run->setText(tr("Browse")); } ui->tool_tray->setVisible(type().startsWith("CD")); //This is a CD tray canmount = filesystem()!="NONE" || !type().startsWith("CD"); //has a detected filesystem or is not a CD ui->tool_mount->setVisible(canmount); ui->check_auto->setVisible(canmount && !type().startsWith("CD")); } //Update the status of the mount button (TO DO - special ISO handling) if(isMounted){ ui->tool_mount->setText(tr("Unmount")); ui->tool_mount->setIcon(QIcon(":icons/eject.png")); QString devsize = pcbsd::Utils::runShellCommand("pc-sysconfig \"devsize "+node()+"\"").join(""); if(devsize.contains("??")){ ui->progressBar->setRange(0,0); }else{ ui->progressBar->setRange(0,100); ui->progressBar->setValue(devsize.section("(",1,1).section("%",0,0).toInt()); ui->progressBar->setToolTip(devsize); } }else{ ui->tool_mount->setText(tr("Mount")); ui->tool_mount->setIcon(QIcon(":icons/mount.png")); } ui->label_icon->setEnabled(isMounted || !canmount); ui->tool_run->setVisible( (isMounted && !mountpoint().isEmpty()) || type()=="CD-AUDIO" || type()=="CD-VIDEO" ); //if it is mounted, it can also be run ui->progressBar->setVisible(isMounted && ui->progressBar->maximum()==100); if(firstrun){ if(canmount && !type().startsWith("CD") ){ //Load auto-mount database and act appropriately QString AMFILE = QDir::homePath() + "/.pc-automounttray"; if(QFile::exists(AMFILE)){ QString cmd = "cat "+AMFILE; QString search = label() +" "+ type()+" "+ filesystem(); bool amount = !pcbsd::Utils::runShellCommandSearch(cmd, search).isEmpty(); ui->check_auto->setChecked(amount); if(amount){ mountButtonClicked(); if(isMounted){ emit ShowMessage(tr("Device Mounted"), QString(tr("%1 has been automatically mounted on %2")).arg(label(), mountpoint()) ); runButtonClicked(); //also open the directory } } } }else if(canmount){ //This is some kind of optical disk that can also be mounted (Blueray/DVD, or data disk for instance) if(type()!="CD-DATA"){ runButtonClicked(); } //not a pure data disk - go ahead and prompt to run it }else if(autoplay){ //Always try to "play" a non-mountable device when it is first connected (AUDIO/VIDEO CD usually) runButtonClicked(); } } }
void TvDBModel::setupModelData(void) { TvDBItem *show, *season, *episode; QSqlQuery queryShow, querySeason, queryEpisode; QString sql; sql = "SELECT shows.name, shows.id FROM shows GROUP BY shows.id"; queryShow.exec(sql); while (queryShow.next()) { show = new TvDBItem(TvDBItem::Show, rootItem); show->id = queryShow.record().value("id").toInt(); show->name = queryShow.record().value("name").toString(); sql = "SELECT episodes.season, episodes.seasonId FROM episodes "; sql += "WHERE episodes.showId = %1 "; sql += "GROUP BY episodes.season "; sql += "ORDER BY episodes.season ASC"; sql = sql.arg(show->id); querySeason.exec(sql); while (querySeason.next()) { season = new TvDBItem(TvDBItem::Season, show); season->id = querySeason.record().value("seasonId").toInt(); season->name = querySeason.record().value("season").toString(); sql = "SELECT episodes.name, episodes.id, episodes_extra.watched, "; sql += "episodes.firstAired "; sql += "FROM episodes LEFT JOIN episodes_extra "; sql += "ON episodes.id = episodes_extra.id "; sql += "WHERE episodes.showId = %1 AND episodes.season = %2 "; sql += "ORDER BY episodes.episode ASC"; sql = sql.arg(show->id).arg(season->name.toInt()); queryEpisode.exec(sql); while (queryEpisode.next()) { episode = new TvDBItem(TvDBItem::Episode, show); episode->id = queryEpisode.record().value("id").toInt(); episode->name = queryEpisode.record().value("name").toString(); episode->nextEpisodeName = episode->name; episode->nextEpisodeDate = QDateTime::fromTime_t(queryEpisode.record().value("firstAired").toULongLong()); episode->episodesWatched = queryEpisode.record().value("watched").toBool(); episode->episodes = 1; if (!episode->nextEpisodeDate.isNull() && episode->nextEpisodeDate < QDateTime::currentDateTime() && !episode->episodesWatched) episode->episodesNew = true; season->appendChild(episode); } show->appendChild(season); } rootItem->appendChild(show); } }
double VnaTimeDomain::stopValue() { QString scpi = ":CALC%1:TRAN:TIME:STOP?\n"; scpi = scpi.arg(_trace->channel()); return(_vna->query(scpi).trimmed().toDouble()); }
QString get_disk_statistic() { QString cmd, s, msg; int i=0; cmd = QString("df 2>&1"); FILE *fdisk=popen(cmd, "r"); char *buf=(char *) malloc(1024); QString dev; while(fgets(buf, 1024, fdisk)) { if(strlen(buf)<=1) continue; if(strncmp("/dev/", buf, 5)==0) { //while(isspace(*buf)) strcpy(buf, buf+1); while(strchr(buf, '\t')) *strchr(buf, '\t')=' ';//replease all symbol \n in space // Get the device *strchr(buf, ' ')=0; //mid first string s = buf;//device msg +="<tr bgcolor=\"#EEF6FF\"><td>"+s+"</td>"; strcpy(buf, buf+strlen(buf)+1); //step next word while(isspace(*buf)) strcpy(buf, buf+1); *strchr(buf, ' ')=0; s = buf; i = s.toInt(); msg +="<td>"+convert_size_disk(i)+"</td>";//size strcpy(buf, buf+strlen(buf)+1); while(isspace(*buf)) strcpy(buf, buf+1); strcpy(buf, strchr(buf, ' ')); // skip used while(isspace(*buf)) strcpy(buf, buf+1); *strchr(buf, ' ')=0; s = buf;//Available i = s.toInt(); msg +="<td>"+convert_size_disk(i)+"</td>"; strcpy(buf, buf+strlen(buf)+1); while(isspace(*buf)) strcpy(buf, buf+1); strcpy(buf, strchr(buf, ' ')); // skip procent while(isspace(*buf)) strcpy(buf, buf+1); //*strchr(buf, ' ')=0; s = buf; trimStr(s,"\n"); msg +="<td>"+s+"</td></tr>";//mounted } } pclose(fdisk); free(buf); QString font = "<font size=+1 color=\"blue\"><b>%1</b> : </font><br><br><br>"; QString s_msg = font.arg(QObject::tr("Disk's statistic")); s_msg += "<table border=0 width=100%>"; s_msg += QString("<tr bgcolor=\"lightGray\"><th>%1</th><th>%2</th><th>%3</th><th>%4</th></tr>") .arg(QObject::tr("Device")).arg(QObject::tr("Size")).arg(QObject::tr("Available")).arg(QObject::tr("Mounted to")); s_msg += msg; s_msg += "</table>"; return s_msg; }
void VnaTimeDomain::adjustChannelStopFrequency() { QString scpi = ":CALC%1:TRAN:TIME:LPAS KDFR\n"; scpi = scpi.arg(_trace->channel()); _vna->write(scpi); }
QString get_system_statistic() { QString line; QString font = "<font size=+1 color=\"blue\"><b>%1</b> : </font><br><br><br>"; struct utsname u; uname(&u); QFile file; QString name_lin, path_pix; QString path; // = qApp->applicationDirPath(); setAplDir(path); path += "/pixmaps/"; if(file.exists("/etc/redhat-release")) { file.setName("/etc/redhat-release"); name_lin = "Fedora Core family"; path_pix = path+"p_fedora_new.png"; if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); line = stream.readLine(); // line of text excluding '\n' file.close(); } } if(file.exists("/etc/SuSE-release")) { file.setName("/etc/SuSE-release"); name_lin = "SuSE family"; path_pix = path+"p_suse.png"; if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); line = stream.readLine(); // line of text excluding '\n' file.close(); } } if(file.exists("/etc/debian_version")) { file.setName("/etc/debian_version"); name_lin = "Debian family"; path_pix = path+"p_debian.png"; if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); line = stream.readLine(); // line of text excluding '\n' file.close(); } } if(file.exists("/etc/mandrake-release")) { file.setName("/etc/mandrake-release"); name_lin = "Mandrake family"; path_pix = path+"p_mandrake.png"; if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); line = stream.readLine(); // line of text excluding '\n' file.close(); } } if(file.exists("/etc/mandriva-release")) { file.setName("/etc/mandriva-release"); name_lin = "Mandriva family"; path_pix = path+"p_mandriva.png"; if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); line = stream.readLine(); // line of text excluding '\n' file.close(); } } if(name_lin.isEmpty()) name_lin = "Other linux family"; if(path_pix.isEmpty()) path_pix = path+"p_linux_new.png"; if(line.isEmpty()) line = "linux"; QString s_msg = font.arg(QObject::tr("System")); s_msg += "<table border=0 width=100%>"; s_msg += QString("<tr bgcolor=\"lightGray\"><th colspan=2>%1</th></tr>").arg(QObject::tr("Operation system")); s_msg += QString("<tr bgcolor=\"#EEF6FF\"><td><img src=\"%1\"></td><td><font color=\"blue\">%2</font></td>").arg(path_pix).arg(name_lin); s_msg += QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"blue\">%1</td><td>%2</font></td>").arg(QObject::tr("Name")).arg(line); s_msg += "</table>"; s_msg += "<br>"; s_msg += "<br>"; s_msg += "<table border=0 width=100%>"; s_msg += QString("<tr bgcolor=\"lightGray\"><th colspan=2>%1</th></tr>").arg(QObject::tr("Kernel")); s_msg += QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"blue\">%1 :</td><td>%2</font></td>").arg(QObject::tr("version")).arg(u.release); s_msg += QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"blue\">%1</td><td>%2</font></td>").arg(QObject::tr("architecture")).arg(u.machine); s_msg += "</table>"; s_msg += "<br>"; s_msg += "<br>"; s_msg += get_info_from_file("/etc/passwd","Users","blue"); s_msg += "<br>"; s_msg += "<br>"; s_msg += "<table border=0 width=100%>"; s_msg += QString("<tr bgcolor=\"lightGray\"><th>%1</th></tr>").arg(QObject::tr("Environments")); extern char** environ; char** var; for(var = environ; *var != NULL; ++var) s_msg += QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"#0F990F\">%1</font></td></tr>").arg(*var); s_msg += "</table>"; return s_msg; }
QString LogError::insertArgs(const QString &rMessage) const { QString result; /* // Don't use a loop to be able to handle arguments that conatin strings // like %1. // Using this method only 9 arguments can be handled as the %1 // in %11 gets also replaced with the first argument. switch (mArgs.count()) { case 0: break; case 1: result = rMessage.arg(mArgs.at(0)); break; case 2: result = rMessage.arg(mArgs.at(0), mArgs.at(1)); break; case 3: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2)); break; case 4: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3)); break; case 5: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4)); break; case 6: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5)); break; case 7: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5), mArgs.at(6)); break; case 8: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5), mArgs.at(6), mArgs.at(7)); break; default: result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5), mArgs.at(6), mArgs.at(7), mArgs.at(8)); break; } if (mArgs.count() > 9) { int i = 9; while(i < mArgs.count()) { result = result.arg(mArgs.at(i)); i++; } } */ result = rMessage; QVariant arg; Q_FOREACH(arg, mArgs) result = result.arg(arg.toString()); return result; }
void DPushButton::setTextColor(const QString &colorStr){ QString style = sStyleTemplate.arg(colorStr); setStyleSheet(style); }
void SendCoinsDialog::on_sendButton_clicked() { if(!model || !model->getOptionsModel()) return; QList<SendCoinsRecipient> recipients; bool valid = true; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getValue()); } else { valid = false; } } } if(!valid || recipients.isEmpty()) { return; } fNewRecipientAllowed = false; WalletModel::UnlockContext ctx(model->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet was cancelled fNewRecipientAllowed = true; return; } // prepare transaction for getting txFee earlier WalletModelTransaction currentTransaction(recipients); WalletModel::SendCoinsReturn prepareStatus; if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl); else prepareStatus = model->prepareTransaction(currentTransaction); // process prepareStatus and on error generate message shown to user processSendCoinsReturn(prepareStatus, BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee())); if(prepareStatus.status != WalletModel::OK) { fNewRecipientAllowed = true; return; } CAmount txFee = currentTransaction.getTransactionFee(); // Format confirmation message QStringList formatted; foreach(const SendCoinsRecipient &rcp, currentTransaction.getRecipients()) { // generate bold amount string QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount); amount.append("</b>"); // generate monospace address string QString address = "<span style='font-family: monospace;'>" + rcp.address; address.append("</span>"); QString recipientElement; if (!rcp.paymentRequest.IsInitialized()) // normal payment { if(rcp.label.length() > 0) // label with address { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label)); recipientElement.append(QString(" (%1)").arg(address)); } else // just address { recipientElement = tr("%1 to %2").arg(amount, address); } } else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)); } else // unauthenticated payment request { recipientElement = tr("%1 to %2").arg(amount, address); } formatted.append(recipientElement); } QString questionString = tr("Are you sure you want to send?"); questionString.append("<br /><br />%1"); if(txFee > 0) { // append fee string if a fee is required questionString.append("<hr /><span style='color:#aa0000;'>"); questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee)); questionString.append("</span> "); questionString.append(tr("added as transaction fee")); // append transaction size questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)"); } // add total amount in all subdivision units questionString.append("<hr />"); CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee; QStringList alternativeUnits; foreach(BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) { if(u != model->getOptionsModel()->getDisplayUnit()) alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount)); } questionString.append(tr("Total Amount %1 (= %2)") .arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)) .arg(alternativeUnits.join(" " + tr("or") + " "))); QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), questionString.arg(formatted.join("<br />")), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; return; } // now send the prepared transaction WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction); // process sendStatus and on error generate message shown to user processSendCoinsReturn(sendStatus); if (sendStatus.status == WalletModel::OK) { accept(); CoinControlDialog::coinControl->UnSelectAll(); coinControlUpdateLabels(); } fNewRecipientAllowed = true; }
bool Installer::associateFiles() { bool success = true; #ifdef _WIN32 //QSettings registry_hkcr("HKEY_CLASSES_ROOT", QSettings::NativeFormat); QSettings registry_hkcu("HKEY_CURRENT_USER", QSettings::NativeFormat); // add template //WriteToLog(QtDebugMsg, registry_hkcu.value("Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Templates").toString().replace("\\","/")+QString("/sample.lvl")); //WriteToLog(QtDebugMsg, registry_hkcu.value("Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Templates").toString().replace("\\","/")+QString("/sample.wld")); //registry_hkcr //QFile l(QProcessEnvironment::systemEnvironment().value("windir","C:\\Windows").replace("\\","/")+QString("/ShellNew/sample.lvl")); //QFile w(QProcessEnvironment::systemEnvironment().value("windir","C:\\Windows").replace("\\","/")+QString("/ShellNew/sample.wld")); QFile l(registry_hkcu.value("Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Templates").toString().replace("\\", "/") + QString("/sample.lvl")); QFile w(registry_hkcu.value("Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Templates").toString().replace("\\", "/") + QString("/sample.wld")); QFile lx(registry_hkcu.value("Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Templates").toString().replace("\\", "/") + QString("/sample.lvlx")); QFile wx(registry_hkcu.value("Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Templates").toString().replace("\\", "/") + QString("/sample.wldx")); success = l.open(QIODevice::WriteOnly); QString raw; if(success) { LevelData indata; FileFormats::CreateLevelData(indata); FileFormats::WriteSMBX64LvlFileRaw(indata, raw, 64); l.write(QByteArray(raw.toStdString().c_str())); l.close(); } success = w.open(QIODevice::WriteOnly); if(success) { WorldData indata; FileFormats::CreateWorldData(indata); FileFormats::WriteSMBX64WldFileRaw(indata, raw, 64); w.write(QByteArray(raw.toStdString().c_str())); w.close(); } success = lx.open(QIODevice::WriteOnly); if(success) { LevelData indata; FileFormats::CreateLevelData(indata); FileFormats::WriteExtendedLvlFileRaw(indata, raw); l.write(QByteArray(raw.toStdString().c_str())); l.close(); } success = wx.open(QIODevice::WriteOnly); if(success) { WorldData indata; FileFormats::CreateWorldData(indata); FileFormats::WriteExtendedWldFileRaw(indata, raw); w.write(QByteArray(raw.toStdString().c_str())); w.close(); } // file extension(s) registry_hkcu.setValue("Software/Classes/.lvlx/Default", "PGEWohlstand.Level"); //Reserved registry_hkcu.setValue("Software/Classes/.wldx/Default", "PGEWohlstand.World"); //Reserved registry_hkcu.setValue("Software/Classes/.lvl/Default", "SMBX64.Level"); registry_hkcu.setValue("Software/Classes/.wld/Default", "SMBX64.World"); registry_hkcu.setValue("Software/Classes/.lvlx/ShellNew/FileName", "sample.lvlx"); registry_hkcu.setValue("Software/Classes/.wldx/ShellNew/FileName", "sample.wldx"); registry_hkcu.setValue("Software/Classes/.lvl/ShellNew/FileName", "sample.lvl"); registry_hkcu.setValue("Software/Classes/.wld/ShellNew/FileName", "sample.wld"); //registry_hkcr.setValue(".lvlx/Default", "PGWWohlstand.Level"); //registry_hkcr.setValue(".wldx/Default", "PGWWohlstand.World"); registry_hkcu.setValue("Software/Classes/PGEWohlstand.Level/Default", tr("PGE Level file", "File Types")); registry_hkcu.setValue("Software/Classes/PGEWohlstand.Level/DefaultIcon/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\",1"); registry_hkcu.setValue("Software/Classes/PGEWohlstand.Level/Shell/Open/Command/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\" \"%1\""); registry_hkcu.setValue("Software/Classes/PGEWohlstand.Level/Shell/Play level/Command/Default", "\"" + QApplication::applicationDirPath().replace("/", "\\") + "\\pge_engine.exe\" \"%1\""); registry_hkcu.setValue("Software/Classes/PGEWohlstand.World/Default", tr("PGE World Map", "File Types")); registry_hkcu.setValue("Software/Classes/PGEWohlstand.World/DefaultIcon/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\",2"); registry_hkcu.setValue("Software/Classes/PGEWohlstand.World/Shell/Open/Command/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\" \"%1\""); registry_hkcu.setValue("Software/Classes/PGEWohlstand.World/Shell/Play episode/Command/Default", "\"" + QApplication::applicationDirPath().replace("/", "\\") + "\\pge_engine.exe\" \"%1\""); registry_hkcu.setValue("Software/Classes/SMBX64.Level/Default", tr("SMBX Level file", "File Types")); registry_hkcu.setValue("Software/Classes/SMBX64.Level/DefaultIcon/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\",3"); registry_hkcu.setValue("Software/Classes/SMBX64.Level/Shell/Open/Command/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\" \"%1\""); registry_hkcu.setValue("Software/Classes/SMBX64.Level/Shell/Play level/Command/Default", "\"" + QApplication::applicationDirPath().replace("/", "\\") + "\\pge_engine.exe\" \"%1\""); registry_hkcu.setValue("Software/Classes/SMBX64.World/Default", tr("SMBX World Map", "File Types")); registry_hkcu.setValue("Software/Classes/SMBX64.World/DefaultIcon/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\",4"); registry_hkcu.setValue("Software/Classes/SMBX64.World/Shell/Open/Command/Default", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\" \"%1\""); registry_hkcu.setValue("Software/Classes/SMBX64.World/Shell/Play episode/Command/Default", "\"" + QApplication::applicationDirPath().replace("/", "\\") + "\\pge_engine.exe\" \"%1\""); // User variable(s) registry_hkcu.setValue("Environment/QT_PLUGIN_PATH", "\"" + QString(ApplicationPath).replace("/", "\\") + "\""); #elif defined __APPLE__ // only useful when other apps have taken precedence over our file extensions and you want to reset it //Need write correct strings for allow associations for Mac OS: /* defaults write com.apple.LaunchServices LSHandlers -array-add '{ LSHandlerContentType = "com.apple.property-list"; LSHandlerRoleAll = "com.apple.dt.xcode"; }' */ QString x = QString("defaults write com.apple.LaunchServices LSHandlers -array-add '" "<dict>" "<key>LSHandlerContentTag</key>" "<string>%1</string>" "<key>LSHandlerContentTagClass</key>" "<string>public.filename-extension</string>" "<key>LSHandlerRoleAll</key>" "<string>ru.wohlsoft.pge-editor</string>" "</dict>" "'"); int ret = system(x.arg("lvl").toStdString().c_str()); ret += system(x.arg("lvlx").toStdString().c_str()); ret += system(x.arg("wld").toStdString().c_str()); ret += system(x.arg("wldx").toStdString().c_str()); ret += system("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -domain local -domain system -domain user"); success = (ret == 0); // remove this when associator was created #elif defined Q_OS_ANDROID //Is not supported yet :P success = false; #else // Here need correctly associate too if(success) success = QDir().mkpath(QDir::home().absolutePath() + "/.local/share/mime/packages"); if(success) success = QDir().mkpath(QDir::home().absolutePath() + "/.local/share/applications"); if(success) success = QDir().mkpath(QDir::home().absolutePath() + "/.local/share/icons"); QFile tmp; Q_UNUSED(tmp); #define XcopyFile(src, target) tmp.setFileName(target); if(tmp.exists()) tmp.remove();\ QFile::copy(src, target); XcopyFile(":/_files/_files/pge-project-mimeinfo.xml", QDir::home().absolutePath() + "/.local/share/mime/packages/pge-project-mimeinfo.xml"); #define IconSize(Size) \ XcopyFile(":/_files/_files/file_lvl/file_lvl_" Size ".png", QDir::home().absolutePath()+"/.local/share/icons/smbx64-level-" Size ".png");\ XcopyFile(":/_files/_files/file_lvlx/file_lvlx_" Size ".png", QDir::home().absolutePath()+"/.local/share/icons/pgex-level-" Size ".png");\ XcopyFile(":/_files/_files/file_wld/file_wld_" Size ".png", QDir::home().absolutePath()+"/.local/share/icons/smbx64-world-" Size ".png");\ XcopyFile(":/_files/_files/file_wldx/file_wldx_" Size ".png", QDir::home().absolutePath()+"/.local/share/icons/pgex-world-" Size ".png");\ XcopyFile(":/images/cat_builder/cat_builder_" Size ".png", QDir::home().absolutePath()+"/.local/share/icons/PgeEditor-" Size ".png");\ if (success) success = system( QString("xdg-icon-resource install --context mimetypes --size " Size " "+QDir::home().absolutePath()+"/.local/share/icons/smbx64-level-" Size ".png x-application-smbx64-level").toLocal8Bit().constData())==0;\ if (success) success = system( QString("xdg-icon-resource install --context mimetypes --size " Size " "+QDir::home().absolutePath()+"/.local/share/icons/smbx64-world-" Size ".png x-application-smbx64-world").toLocal8Bit().constData())==0;\ if (success) success = system( QString("xdg-icon-resource install --context mimetypes --size " Size " "+QDir::home().absolutePath()+"/.local/share/icons/pgex-level-" Size ".png x-application-pgex-level").toLocal8Bit().constData())==0;\ if (success) success = system( QString("xdg-icon-resource install --context mimetypes --size " Size " "+QDir::home().absolutePath()+"/.local/share/icons/pgex-world-" Size ".png x-application-pgex-world").toLocal8Bit().constData())==0;\ if (success) success = system( QString("xdg-icon-resource install --context apps --novendor --size " Size " "+QDir::home().absolutePath()+"/.local/share/icons/PgeEditor-" Size ".png PgeEditor").toLocal8Bit().constData())==0; IconSize("16"); IconSize("32"); IconSize("48"); IconSize("256"); QFile shortcut(":/_files/_files/pge_editor.desktop"); if(success) success = shortcut.open(QFile::ReadOnly | QFile::Text); if(success) { QTextStream shtct(&shortcut); QString shortcut_text = shtct.readAll(); QFile saveAs(QDir::home().absolutePath() + "/.local/share/applications/pge_editor.desktop"); if(success) success = saveAs.open(QFile::WriteOnly | QFile::Text); if(success) QTextStream(&saveAs) << shortcut_text.arg(ApplicationPath_x); } if(success) success = system("xdg-mime default pge_editor.desktop application/x-smbx64-level") == 0; if(success) success = system("xdg-mime default pge_editor.desktop application/x-smbx64-world") == 0; if(success) success = system("xdg-mime default pge_editor.desktop application/x-pgex-level") == 0; if(success) success = system("xdg-mime default pge_editor.desktop application/x-pgex-world") == 0; if(success) success = system(QString("update-desktop-database " + QDir::home().absolutePath() + "/.local/share/applications").toLocal8Bit().constData()) == 0; if(success) success = system(QString("update-mime-database " + QDir::home().absolutePath() + "/.local/share/mime").toLocal8Bit().constData()) == 0; #endif return success; }
void ZealDocsetsRegistry::_runQuery(const QString& rawQuery, int queryNum) { if(queryNum != lastQuery) return; // some other queries pending - ignore this one QList<ZealSearchResult> results; ZealSearchQuery query(rawQuery); QString preparedQuery = query.getSanitizedQuery(); bool hasDocsetFilter = query.hasDocsetFilter(); for (const ZealDocsetsRegistry::docsetEntry docset : docsets()) { if(hasDocsetFilter && !query.docsetPrefixMatch(docset.prefix)) { // Filter out this docset as the names don't match the docset prefix continue; } QString qstr; QSqlQuery q; QList<QList<QVariant> > found; bool withSubStrings = false; // %.%1% for long Django docset values like django.utils.http // %::%1% for long C++ docset values like std::set // %/%1% for long Go docset values like archive/tar QString subNames = QString(" or %1 like '%.%2%' escape '\\'"); subNames += QString(" or %1 like '%::%2%' escape '\\'"); subNames += QString(" or %1 like '%/%2%' escape '\\'"); while(found.size() < 100) { auto curQuery = preparedQuery; QString notQuery; // don't return the same result twice QString parentQuery; if(withSubStrings) { // if less than 100 found starting with query, search all substrings curQuery = "%"+preparedQuery; // don't return 'starting with' results twice if(docset.type == ZDASH) { notQuery = QString(" and not (ztokenname like '%1%' escape '\\' %2) ").arg(preparedQuery, subNames.arg("ztokenname", preparedQuery)); } else { if(docset.type == ZEAL) { notQuery = QString(" and not (t.name like '%1%' escape '\\') ").arg(preparedQuery); parentQuery = QString(" or t2.name like '%1%' escape '\\' ").arg(preparedQuery); } else { // DASH notQuery = QString(" and not (t.name like '%1%' escape '\\' %2) ").arg(preparedQuery, subNames.arg("t.name", preparedQuery)); } } } int cols = 3; if(docset.type == ZEAL) { qstr = QString("select t.name, t2.name, t.path from things t left join things t2 on t2.id=t.parent where " "(t.name like '%1%' escape '\\' %3) %2 order by length(t.name), lower(t.name) asc, t.path asc limit 100").arg(curQuery, notQuery, parentQuery); } else if(docset.type == DASH) { qstr = QString("select t.name, null, t.path from searchIndex t where (t.name " "like '%1%' escape '\\' %3) %2 order by length(t.name), lower(t.name) asc, t.path asc limit 100").arg(curQuery, notQuery, subNames.arg("t.name", curQuery)); } else if(docset.type == ZDASH) { cols = 4; qstr = QString("select ztokenname, null, zpath, zanchor from ztoken " "join ztokenmetainformation on ztoken.zmetainformation = ztokenmetainformation.z_pk " "join zfilepath on ztokenmetainformation.zfile = zfilepath.z_pk where (ztokenname " "like '%1%' escape '\\' %3) %2 order by length(ztokenname), lower(ztokenname) asc, zpath asc, " "zanchor asc limit 100").arg(curQuery, notQuery, subNames.arg("ztokenname", curQuery)); } q = db(docset.name).exec(qstr); while(q.next()) { QList<QVariant> values; for(int i = 0; i < cols; ++i) { values.append(q.value(i)); } found.append(values); } if(withSubStrings) break; withSubStrings = true; // try again searching for substrings } for(auto &row : found) { QString parentName; if(!row[1].isNull()) { parentName = row[1].toString(); } auto path = row[2].toString(); // FIXME: refactoring to use common code in ZealListModel and ZealDocsetsRegistry if(docset.type == ZDASH) { path += "#" + row[3].toString(); } auto itemName = row[0].toString(); normalizeName(itemName, parentName, row[1].toString()); results.append(ZealSearchResult(itemName, parentName, path, docset.name, preparedQuery)); } } qSort(results); if(queryNum != lastQuery) return; // some other queries pending - ignore this one queryResults = results; emit queryCompleted(); }
bool SVT_HttpDownload::getHttpFileProcess() { QFile f(mLocalFile); QIODevice::OpenMode mode=(mStartPos>0)?(QIODevice::WriteOnly|QIODevice::Append):QIODevice::WriteOnly; if(!f.open(mode)) { mErrorStr="Can Not Open Local File"; return false; } QByteArray arraybuffer; QUrl url(mUrl); SVT_IpAddress ip = getDNS(url.host()); if(!ip.isValid()) { mErrorStr="DNS Error"; return false; } SVT_TcpSocket tcp_sock; char recv_buff[1024] = {0}; QString request = "GET %1 HTTP/1.1\r\nConnection: Keep-Alive\r\nHost: %2\r\nRange: bytes=%3-\r\n\r\n"; request = request.arg(url.path(), url.host()).arg(mStartPos); const QByteArray reqarray = request.toAscii(); _SpeedCalculater speedCalc(200); bool headOk=false; quint64 total=0; quint64 processed=0; if(DO_AND_CHECKEXIT(tcp_sock.create()) &&DO_AND_CHECKEXIT(tcp_sock.connect(ip,url.port(80))) &&(DO_AND_CHECKEXIT(tcp_sock.waitForWriteReady(1000)) ||DO_AND_CHECKEXIT(tcp_sock.waitForWriteReady(1000)) ||DO_AND_CHECKEXIT(tcp_sock.waitForWriteReady(1000)) ||DO_AND_CHECKEXIT(tcp_sock.waitForWriteReady(1000)) ) &&DO_AND_CHECKEXIT(reqarray.size()==tcp_sock.sendData(reqarray.data(),reqarray.size()) ) ) { QDateTime ti_last_signal=QDateTime::currentDateTime().addYears(-1); while(!CAN_EXIT) { int readedtemp ; if( (readedtemp= tcp_sock.recvData(recv_buff, sizeof(recv_buff)) ) <=0) { break; } if(!headOk) { arraybuffer.append(recv_buff,readedtemp); int bound=getHttpHeaderBound(arraybuffer); if(bound >=0) { total=getRecvFileSize(arraybuffer); arraybuffer.remove(0,bound); f.write(arraybuffer); processed=arraybuffer.count(); // if(total <= 0) // { // mErrorStr="Wrong Total Size"; // return false; // } speedCalc.init(); headOk=true; } } else { processed+=readedtemp; f.write(recv_buff,readedtemp); if(ti_last_signal.addMSecs(200) < QDateTime::currentDateTime()) { speedCalc.addData(processed); ti_last_signal=QDateTime::currentDateTime(); emit progress(mStartPos+processed, total, speedCalc.calculateSpeed()); } } } } f.close(); return (!total ||total==processed); }
QString Fixture::status() const { QString info; QString t; QString title("<TR><TD CLASS='hilite' COLSPAN='3'>%1</TD></TR>"); QString subTitle("<TR><TD CLASS='subhi' COLSPAN='3'>%1</TD></TR>"); QString genInfo("<TR><TD CLASS='emphasis'>%1</TD><TD COLSPAN='2'>%2</TD></TR>"); /******************************************************************** * General info ********************************************************************/ info += "<TABLE COLS='3' WIDTH='100%'>"; // Fixture title info += title.arg(name()); // Manufacturer if (isDimmer() == false) { info += genInfo.arg(tr("Manufacturer")).arg(m_fixtureDef->manufacturer()); info += genInfo.arg(tr("Model")).arg(m_fixtureDef->model()); info += genInfo.arg(tr("Mode")).arg(m_fixtureMode->name()); info += genInfo.arg(tr("Type")).arg(m_fixtureDef->type()); } else { info += genInfo.arg(tr("Type")).arg(tr("Generic Dimmer")); } // Universe info += genInfo.arg(tr("Universe")).arg(universe() + 1); // Address QString range = QString("%1 - %2").arg(address() + 1).arg(address() + channels()); info += genInfo.arg(tr("Address Range")).arg(range); // Channels info += genInfo.arg(tr("Channels")).arg(channels()); // Binary address QString binaryStr = QString("%1").arg(address() + 1, 10, 2, QChar('0')); QString dipTable("<TABLE COLS='33' cellspacing='0'><TR><TD COLSPAN='33'><IMG SRC=\"" ":/ds_top.png\"></TD></TR>"); dipTable += "<TR><TD><IMG SRC=\"" ":/ds_border.png\"></TD><TD><IMG SRC=\"" ":/ds_border.png\"></TD>"; for (int i = 9; i >= 0; i--) { if (binaryStr.at(i) == '0') dipTable += "<TD COLSPAN='3'><IMG SRC=\"" ":/ds_off.png\"></TD>"; else dipTable += "<TD COLSPAN='3'><IMG SRC=\"" ":/ds_on.png\"></TD>"; } dipTable += "<TD><IMG SRC=\"" ":/ds_border.png\"></TD></TR>"; dipTable += "<TR><TD COLSPAN='33'><IMG SRC=\"" ":/ds_bottom.png\"></TD></TR>"; dipTable += "</TABLE>"; info += genInfo.arg(tr("Binary Address (DIP)")) .arg(QString("%1").arg(dipTable)); /******************************************************************** * Channels ********************************************************************/ // Title row info += QString("<TR><TD CLASS='subhi'>%1</TD>").arg(tr("Channel")); info += QString("<TD CLASS='subhi'>%1</TD>").arg(tr("DMX")); info += QString("<TD CLASS='subhi'>%1</TD></TR>").arg(tr("Name")); // Fill table with the fixture's channels for (quint32 ch = 0; ch < channels(); ch++) { QString chInfo("<TR><TD>%1</TD><TD>%2</TD><TD>%3</TD></TR>"); info += chInfo.arg(ch + 1).arg(address() + ch + 1) .arg(channel(ch)->name()); } /******************************************************************** * Extended device information for non-dimmers ********************************************************************/ if (isDimmer() == false) { QLCPhysical physical = m_fixtureMode->physical(); info += title.arg(tr("Physical")); float mmInch = 0.0393700787; float kgLbs = 2.20462262; QString mm("%1mm (%2\")"); QString kg("%1kg (%2 lbs)"); QString W("%1W"); info += genInfo.arg(tr("Width")).arg(mm.arg(physical.width())) .arg(physical.width() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Height")).arg(mm.arg(physical.height())) .arg(physical.height() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Depth")).arg(mm.arg(physical.depth())) .arg(physical.depth() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Weight")).arg(kg.arg(physical.weight())) .arg(physical.weight() * kgLbs, 0, 'g', 4); info += genInfo.arg(tr("Power consumption")).arg(W.arg(physical.powerConsumption())); info += genInfo.arg(tr("DMX Connector")).arg(physical.dmxConnector()); // Bulb QString K("%1K"); QString lm("%1lm"); info += subTitle.arg(tr("Bulb")); info += genInfo.arg(tr("Type")).arg(physical.bulbType()); info += genInfo.arg(tr("Luminous Flux")).arg(lm.arg(physical.bulbLumens())); info += genInfo.arg(tr("Colour Temperature")).arg(K.arg(physical.bulbColourTemperature())); // Lens QString angle1("%1°"); QString angle2("%1° – %2°"); info += subTitle.arg(tr("Lens")); info += genInfo.arg(tr("Name")).arg(physical.lensName()); if (physical.lensDegreesMin() == physical.lensDegreesMax()) { info += genInfo.arg(tr("Beam Angle")) .arg(angle1.arg(physical.lensDegreesMin())); } else { info += genInfo.arg(tr("Beam Angle")) .arg(angle2.arg(physical.lensDegreesMin()) .arg(physical.lensDegreesMax())); } // Focus QString range("%1°"); info += subTitle.arg(tr("Focus")); info += genInfo.arg(tr("Type")).arg(physical.focusType()); info += genInfo.arg(tr("Pan Range")).arg(range.arg(physical.focusPanMax())); info += genInfo.arg(tr("Tilt Range")).arg(range.arg(physical.focusTiltMax())); } // HTML document & table closure info += "</TABLE>"; if (isDimmer() == false) { info += "<HR>"; info += "<DIV CLASS='author' ALIGN='right'>"; info += tr("Fixture definition author: ") + fixtureDef()->author(); info += "</DIV>"; } return info; }
static void mouseEvent(MouseAction action, QWidget *widget, QObject *item, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPointF _pos, int delay=-1) { QTEST_ASSERT(widget); QTEST_ASSERT(item); if (delay == -1 || delay < QTest::defaultMouseDelay()) delay = QTest::defaultMouseDelay(); if (delay > 0) QTest::qWait(delay); if (action == MouseClick) { mouseEvent(MousePress, widget, item, button, stateKey, _pos); mouseEvent(MouseRelease, widget, item, button, stateKey, _pos); return; } QPoint pos; QDeclarativeView *view = qobject_cast<QDeclarativeView *>(widget); QWidget *eventWidget = widget; QDeclarativeItem *ditem = qobject_cast<QDeclarativeItem *>(item); if (!ditem) { qWarning("Mouse event target is not an Item"); return; } pos = view->mapFromScene(ditem->mapToScene(_pos)); eventWidget = view->viewport(); QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask); QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask); stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask); QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey); switch (action) { case MousePress: me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey); break; case MouseRelease: me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey); break; case MouseDoubleClick: me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey); break; case MouseMove: if (button == Qt::NoButton) { // If we send a mouse move event with no button pressed, it will be // rejected (unless mouseTracking is set to true); simulate instead QCursor::setPos(widget->mapToGlobal(pos)); qApp->processEvents(); } else { me = QMouseEvent(QEvent::MouseMove, pos, widget->mapToGlobal(pos), button, button, stateKey); } break; default: QTEST_ASSERT(false); } QSpontaneKeyEvent::setSpontaneous(&me); if (!qApp->notify(eventWidget, &me)) { static const char *mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" }; QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget"); QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data()); } }