本文整理汇总了C++中QProgressBar::setTextVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ QProgressBar::setTextVisible方法的具体用法?C++ QProgressBar::setTextVisible怎么用?C++ QProgressBar::setTextVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProgressBar
的用法示例。
在下文中一共展示了QProgressBar::setTextVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setValue
/**
* Sets a new value to the progress bar.
* If the new value is non-zero, the progress bar is advanced. Otherwise, the
* idle timer is initiated to display a busy indicator.
* @param nValue The new value to set.
*/
void ProgressDlg::setValue(int nValue)
{
QProgressBar* pProgress;
pProgress = progressBar();
if (nValue != 0) {
// Do nothing if the value hasn't changed
if (nValue == pProgress->value())
return;
// Handle first non-zero value
if (m_nIdleValue >= 0) {
m_pIdleTimer->stop();
m_nIdleValue = -1;
pProgress->setTextVisible(true);
}
// Set the new value
pProgress->setValue(nValue);
}
else if (m_nIdleValue == -1) {
// Handle first 0 value
pProgress->setValue(0);
pProgress->setTextVisible(false);
m_nIdleValue = 0;
m_pIdleTimer->start(200);
}
}
示例2: slotUpdateProgressAndStatus
void RenderWindow::slotUpdateProgressAndStatus(const QString &text, const QString &progressText,
double progress, cProgressText::enumProgressType progressType)
{
ui->statusbar->showMessage(text, 0);
QProgressBar *progressBar = NULL;
bool isQueue = this->sender() && this->sender()->objectName() == "Queue";
switch (progressType)
{
case cProgressText::progress_IMAGE:
if (isQueue) progressBar = gMainInterface->progressBarQueueImage;
else progressBar = gMainInterface->progressBar;
break;
case cProgressText::progress_ANIMATION:
if (isQueue) progressBar = gMainInterface->progressBarQueueAnimation;
else progressBar = gMainInterface->progressBarAnimation;
break;
case cProgressText::progress_QUEUE:
// nothing to be done, no progress bar for queue in GUI
break;
}
if (progressBar)
{
if (!progressBar->isVisible())
{
progressBar->setVisible(true);
}
progressBar->setValue(progress * 1000.0);
progressBar->setTextVisible(true);
progressBar->setFormat(progressText);
}
}
示例3: backup
void BackupDialog::backup()
{
QDir dir;
// Compute a default file name & path (eg. "Baskets_2007-01-31.tar.gz"):
KConfig *config = KGlobal::config().data();
KConfigGroup configGroup(config, "Backups");
QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/";
QString fileName = i18np("Backup filename (without extension), %1 is the date", "Baskets_%1", QDate::currentDate().toString(Qt::ISODate));
QString url = folder + fileName;
// Ask a file name & path to the user:
QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files");
QString destination = url;
for (bool askAgain = true; askAgain;) {
// Ask:
destination = KFileDialog::getSaveFileName(destination, filter, 0, i18n("Backup Baskets"));
// User canceled?
if (destination.isEmpty())
return;
// File already existing? Ask for overriding:
if (dir.exists(destination)) {
int result = KMessageBox::questionYesNoCancel(
0,
"<qt>" + i18n("The file <b>%1</b> already exists. Do you really want to override it?",
KUrl(destination).fileName()),
i18n("Override File?"),
KGuiItem(i18n("&Override"), "document-save")
);
if (result == KMessageBox::Cancel)
return;
else if (result == KMessageBox::Yes)
askAgain = false;
} else
askAgain = false;
}
KProgressDialog dialog(0, i18n("Backup Baskets"), i18n("Backing up baskets. Please wait..."));
dialog.setModal(true);
dialog.setAllowCancel(false);
dialog.setAutoClose(true);
dialog.show();
QProgressBar *progress = dialog.progressBar();
progress->setRange(0, 0/*Busy/Undefined*/);
progress->setValue(0);
progress->setTextVisible(false);
BackupThread thread(destination, Global::savesFolder());
thread.start();
while (thread.isRunning()) {
progress->setValue(progress->value() + 1); // Or else, the animation is not played!
kapp->processEvents();
usleep(300); // Not too long because if the backup process is finished, we wait for nothing
}
Settings::setLastBackup(QDate::currentDate());
Settings::saveConfig();
populateLastBackup();
}
示例4: onRunnableStarted
void Ide::onRunnableStarted()
{
onRunnableStopped();
QProgressBar *bar;
_progressDialog = new QProgressDialog(this, Qt::CustomizeWindowHint);
_progressDialog->setBar(bar = new QProgressBar(_progressDialog));
_progressDialog->setCancelButton(nullptr);
_progressDialog->setLabelText(Qrc::text("dialog.waiting.message"));
_progressDialog->setRange(0, 0);
_progressDialog->setWindowModality(Qt::WindowModal);
_progressDialog->show();
bar->setTextVisible(false);
}
示例5: QProgressDialog
QResourceEditorProgressDialog::QResourceEditorProgressDialog( QWidget * parent, Qt::WindowFlags f, bool _isCycled) : QProgressDialog(parent, f)
{
isCycled = _isCycled;
timeIntervalForPercent = TIME_INTERVAL_FOR_1_PERCENT;
connect(&timer, SIGNAL(timeout()), this, SLOT(UpdateProgress()), Qt::QueuedConnection);
if(isCycled)
{
//add custom bar to avoid parcents displaying
QProgressBar *bar = new QProgressBar(this);
bar->setTextVisible(false);
this->setBar(bar);
}
}
示例6: downloadTracksFromOSM
bool downloadTracksFromOSM(QWidget* Main, const QString& aWeb, const QString& aUser, const QString& aPassword, const CoordBox& aBox , Document* theDocument)
{
Downloader theDownloader(aUser, aPassword);
QList<TrackLayer*> theTracklayers;
//TrackMapLayer* trackLayer = new TrackMapLayer(QApplication::translate("Downloader","Downloaded tracks"));
//theDocument->add(trackLayer);
IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main);
if (!aProgressWindow)
return false;
QProgressDialog* dlg = aProgressWindow->getProgressDialog();
dlg->setWindowTitle(QApplication::translate("Downloader","Parsing..."));
QProgressBar* Bar = aProgressWindow->getProgressBar();
Bar->setTextVisible(false);
Bar->setMaximum(11);
QLabel* Lbl = aProgressWindow->getProgressLabel();
Lbl->setText(QApplication::translate("Downloader","Parsing XML"));
if (dlg)
dlg->show();
theDownloader.setAnimator(dlg,Lbl,Bar,true);
for (int Page=0; ;++Page)
{
Lbl->setText(QApplication::translate("Downloader","Downloading trackpoints %1-%2").arg(Page*5000+1).arg(Page*5000+5000));
QString URL = theDownloader.getURLToTrackPoints();
URL = URL.arg(aBox.bottomLeft().x()).
arg(aBox.bottomLeft().y()).
arg(aBox.topRight().x()).
arg(aBox.topRight().y()).
arg(Page);
QUrl theUrl(aWeb+URL);
if (!theDownloader.go(theUrl))
return false;
if (theDownloader.resultCode() != 200)
return false;
int Before = theTracklayers.size();
QByteArray Ar(theDownloader.content());
bool OK = importGPX(Main, Ar, theDocument, theTracklayers, true);
if (!OK)
return false;
if (Before == theTracklayers.size())
break;
theTracklayers[theTracklayers.size()-1]->setName(QApplication::translate("Downloader", "Downloaded track - nodes %1-%2").arg(Page*5000+1).arg(Page*5000+5000));
}
return true;
}
示例7: tr
UpdaterDialog::UpdaterDialog() :
QProgressDialog("", tr("Cancel"), 0, 0)
{
setWindowTitle(tr("Updater - Lightscreen"));
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
setAutoClose(false);
QProgressBar *bar = new QProgressBar(this);
bar->setTextVisible(false);
bar->setRange(0, 0);
QLabel *label = new QLabel(tr("Checking for updates"), this);
connect(label, SIGNAL(linkActivated(QString)), this, SLOT(link(QString)));
setLabel(label);
setBar(bar);
}
示例8: QProgressDialog
UpdaterDialog::UpdaterDialog(QWidget *parent) :
QProgressDialog("", tr("Cancel"), 0, 0, parent)
{
setWindowTitle(tr("Updater - Lightscreen"));
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
setAutoClose(false);
QProgressBar *bar = new QProgressBar(this);
bar->setTextVisible(false);
bar->setRange(0, 0);
QLabel *label = new QLabel(tr("Checking for updates..."), this);
connect(label, &QLabel::linkActivated, this, &UpdaterDialog::link);
setLabel(label);
setBar(bar);
}
示例9: slot_showUpdatesTable
void UUpdateWidget::slot_showUpdatesTable(UUpdatesModel *model)
{
if (model->rowCount() == 0) {
qDebug() << "there is no updates";
QMessageBox::information(this, tr("Nanomite updater"),
tr("There is no updates"));
m_stackedWidget->setCurrentIndex(0);
m_toolBarActions.at(eINSTALL_UPDATES_ACTION)->setEnabled(false);
m_toolBarActions.at(eCHECK_UPDATES_ACTION)->setEnabled(true);
return;
}
// create folder for updates
QDir currDir(QDir::currentPath());
QString createdFolder = currDir.currentPath() + "/updates";
currDir.mkdir(createdFolder);
currDir.setCurrent(createdFolder);
// end of creating folder for updates
m_updatesTableView->setModel(model);
m_progressBarList.clear();
QProgressBar *progressBar;
for (int i = 0; i < model->rowCount(); i++) {
progressBar = new QProgressBar(m_updatesTableView);
progressBar->setTextVisible(false);
progressBar->setMinimum(0);
progressBar->setMaximum(0);
m_progressBarList.append(progressBar);
m_updatesTableView->setIndexWidget(model->index(i, UUpdatesModel::eSTATUS), m_progressBarList.last());
}
m_updatesTableView->resizeColumnsToContents();
m_stackedWidget->setCurrentIndex(2);
m_toolBarActions.at(eINSTALL_UPDATES_ACTION)->setEnabled(true);
m_toolBarActions.at(eCHECK_UPDATES_ACTION)->setEnabled(false);
}
示例10: init
void PinDialog::init( PinFlags flags, const QString &title, TokenData::TokenFlags token )
{
setMinimumWidth( 350 );
setWindowModality( Qt::ApplicationModal );
QLabel *label = new QLabel( this );
QVBoxLayout *l = new QVBoxLayout( this );
l->addWidget( label );
QString _title = title;
QString text;
if( token & TokenData::PinFinalTry )
text += "<font color='red'><b>" + tr("PIN will be locked next failed attempt") + "</b></font><br />";
else if( token & TokenData::PinCountLow )
text += "<font color='red'><b>" + tr("PIN has been entered incorrectly one time") + "</b></font><br />";
text += QString( "<b>%1</b><br />" ).arg( title );
if( flags & Pin2Type )
{
_title = tr("Signing") + " - " + title;
text += tr("Selected action requires sign certificate.") + "<br />" +
(flags & PinpadFlag ?
tr("For using sign certificate enter PIN2 with pinpad") :
tr("For using sign certificate enter PIN2") );
regexp.setPattern( "\\d{5,12}" );
}
else
{
_title = tr("Authendicating") + " - " + title;
text += tr("Selected action requires auth certificate.") + "<br />" +
(flags & PinpadFlag ?
tr("For using auth certificate enter PIN1 with pinpad") :
tr("For using auth certificate enter PIN1") );
regexp.setPattern( "\\d{4,12}" );
}
setWindowTitle( _title );
label->setText( text );
if( flags & PinpadFlag )
{
setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowCloseButtonHint );
QProgressBar *progress = new QProgressBar( this );
progress->setRange( 0, 30 );
progress->setValue( progress->maximum() );
progress->setTextVisible( false );
l->addWidget( progress );
QTimeLine *statusTimer = new QTimeLine( progress->maximum() * 1000, this );
statusTimer->setCurveShape( QTimeLine::LinearCurve );
statusTimer->setFrameRange( progress->maximum(), progress->minimum() );
connect( statusTimer, SIGNAL(frameChanged(int)), progress, SLOT(setValue(int)) );
connect( this, SIGNAL(startTimer()), statusTimer, SLOT(start()) );
}
else
{
m_text = new QLineEdit( this );
m_text->setEchoMode( QLineEdit::Password );
m_text->setFocus();
m_text->setValidator( new QRegExpValidator( regexp, m_text ) );
connect( m_text, SIGNAL(textEdited(QString)), SLOT(textEdited(QString)) );
l->addWidget( m_text );
QDialogButtonBox *buttons = new QDialogButtonBox(
QDialogButtonBox::Ok|QDialogButtonBox::Cancel, Qt::Horizontal, this );
ok = buttons->button( QDialogButtonBox::Ok );
ok->setAutoDefault( true );
connect( buttons, SIGNAL(accepted()), SLOT(accept()) );
connect( buttons, SIGNAL(rejected()), SLOT(reject()) );
l->addWidget( buttons );
textEdited( QString() );
}
}
示例11: QByteArray
void
MolTableView::setMol( adchem::SDFile& file, QProgressBar& progressBar )
{
if ( file ) {
adcontrols::ChemicalFormula cformula;
qtwrapper::waitCursor wait;
//RDKit::SDMolSupplier& supplier = file.molSupplier();
model_->setRowCount( file.size() );
progressBar.setRange( 0, file.size() );
progressBar.setVisible( true );
progressBar.setTextVisible( true );
size_t idx = 0;
for ( auto mol: file ) {
progressBar.setValue( idx + 1 );
try {
size_t col = 0;
std::string smiles = RDKit::MolToSmiles( mol );
if ( ! smiles.empty() ) {
model_->setData( model_->index( idx, col++ ), smiles.c_str() );
// SVG
std::string svg = adchem::drawing::toSVG( mol );
model_->setData( model_->index( idx, col ), QByteArray( svg.data(), svg.size() ) );
model_->item( idx, col )->setEditable( false );
}
col = 2;
try {
mol.updatePropertyCache( false );
std::string formula = RDKit::Descriptors::calcMolFormula( mol, true, false );
model_->setData( model_->index( idx, col++ ), QString::fromStdString( formula) );
model_->setData( model_->index( idx, col++), cformula.getMonoIsotopicMass( formula ) );
} catch ( std::exception& ex ) {
ADDEBUG() << ex.what();
}
col = 4;
// associated data
std::map< std::string, std::string > data;
adchem::SDFile::iterator it = file.begin() + idx;
if ( adchem::SDFile::parseItemText( it.itemText(), data ) ) {
for ( auto tag: tags ) {
auto it = data.find( tag );
if ( it != data.end() )
model_->setData( model_->index( idx, col ), it->second.c_str() );
++col;
}
}
if ( idx == 10 )
this->update();
} catch ( std::exception& ex ) {
ADDEBUG() << boost::current_exception_diagnostic_information() << ex.what();
} catch ( ... ) {
ADDEBUG() << boost::current_exception_diagnostic_information();
}
++idx;
}
progressBar.setVisible( false );
}
}
示例12: restore
void BackupDialog::restore()
{
// Get last backup folder:
KConfig *config = KGlobal::config().data();
KConfigGroup configGroup(config, "Backups");
QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/";
// Ask a file name to the user:
QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files");
QString path = KFileDialog::getOpenFileName(folder, filter, this, i18n("Open Basket Archive"));
if (path.isEmpty()) // User has canceled
return;
// Before replacing the basket data folder with the backup content, we safely backup the current baskets to the home folder.
// So if the backup is corrupted or something goes wrong while restoring (power cut...) the user will be able to restore the old working data:
QString safetyPath = Backup::newSafetyFolder();
FormatImporter copier;
copier.moveFolder(Global::savesFolder(), safetyPath);
// Add the README file for user to cancel a bad restoration:
QString readmePath = safetyPath + i18n("README.txt");
QFile file(readmePath);
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
stream << i18n("This is a safety copy of your baskets like they were before you started to restore the backup %1.", KUrl(path).fileName()) + "\n\n"
<< i18n("If the restoration was a success and you restored what you wanted to restore, you can remove this folder.") + "\n\n"
<< i18n("If something went wrong during the restoration process, you can re-use this folder to store your baskets and nothing will be lost.") + "\n\n"
<< i18n("Choose \"Basket\" -> \"Backup & Restore...\" -> \"Use Another Existing Folder...\" and select that folder.") + "\n";
file.close();
}
QString message =
"<p><nobr>" + i18n("Restoring <b>%1</b>. Please wait...", KUrl(path).fileName()) + "</nobr></p><p>" +
i18n("If something goes wrong during the restoration process, read the file <b>%1</b>.", readmePath);
KProgressDialog *dialog = new KProgressDialog(0, i18n("Restore Baskets"), message);
dialog->setModal(/*modal=*/true);
dialog->setAllowCancel(false);
dialog->setAutoClose(true);
dialog->show();
QProgressBar *progress = dialog->progressBar();
progress->setRange(0, 0/*Busy/Undefined*/);
progress->setValue(0);
progress->setTextVisible(false);
// Uncompress:
RestoreThread thread(path, Global::savesFolder());
thread.start();
while (thread.isRunning()) {
progress->setValue(progress->value() + 1); // Or else, the animation is not played!
kapp->processEvents();
usleep(300); // Not too long because if the restore process is finished, we wait for nothing
}
dialog->hide(); // The restore is finished, do not continue to show it while telling the user the application is going to be restarted
delete dialog; // If we only hidden it, it reappeared just after having restored a small backup... Very strange.
dialog = 0; // This was annoying since it is modal and the "BasKet Note Pads is going to be restarted" message was not reachable.
//kapp->processEvents();
// Check for errors:
if (!thread.success()) {
// Restore the old baskets:
QDir dir;
dir.remove(readmePath);
copier.moveFolder(safetyPath, Global::savesFolder());
// Tell the user:
KMessageBox::error(0, i18n("This archive is either not a backup of baskets or is corrupted. It cannot be imported. Your old baskets have been preserved instead."), i18n("Restore Error"));
return;
}
// Note: The safety backup is not removed now because the code can has been wrong, somehow, or the user perhapse restored an older backup by error...
// The restore process will not be called very often (it is possible it will only be called once or twice arround the world during the next years).
// So it is rare enough to force the user to remove the safety folder, but keep him in control and let him safely recover from restoration errors.
Backup::setFolderAndRestart(Global::savesFolder()/*No change*/, i18n("Your backup has been successfuly restored to <b>%1</b>. %2 is going to be restarted to take this change into account."));
}
示例13: downloadOpenstreetbugs
bool downloadOpenstreetbugs(MainWindow* Main, const CoordBox& aBox, Document* theDocument, SpecialLayer* theLayer)
{
QUrl osbUrl;
osbUrl.setUrl(M_PREFS->getOpenStreetBugsUrl());
osbUrl.setPath(osbUrl.path() + "getGPX");
if (Main)
Main->view()->setUpdatesEnabled(false);
Downloader theDownloader("", "");
QList<TrackLayer*> theTracklayers;
SpecialLayer* trackLayer = theLayer;
if (!trackLayer) {
SpecialLayer* trackLayer = new SpecialLayer(QApplication::translate("Downloader","OpenStreetBugs"),Layer::OsmBugsLayer);
trackLayer->setUploadable(false);
theDocument->add(trackLayer);
}
theTracklayers << trackLayer;
IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main);
if (!aProgressWindow)
return false;
QProgressDialog* dlg = aProgressWindow->getProgressDialog();
dlg->setWindowTitle(QApplication::translate("Downloader","Parsing..."));
QProgressBar* Bar = aProgressWindow->getProgressBar();
Bar->setTextVisible(false);
Bar->setMaximum(11);
QLabel* Lbl = aProgressWindow->getProgressLabel();
Lbl->setText(QApplication::translate("Downloader","Parsing XML"));
if (dlg)
dlg->show();
theDownloader.setAnimator(dlg,Lbl,Bar,true);
Lbl->setText(QApplication::translate("Downloader","Downloading points"));
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QUrlQuery theQuery(osbUrl);
#define theQuery theQuery
#else
#define theQuery osbUrl
#endif
theQuery.addQueryItem("t", COORD2STRING(aBox.topRight().y()));
theQuery.addQueryItem("l", COORD2STRING(aBox.bottomLeft().x()));
theQuery.addQueryItem("b", COORD2STRING(aBox.bottomLeft().y()));
theQuery.addQueryItem("r", COORD2STRING(aBox.topRight().x()));
theQuery.addQueryItem("open", "yes");
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
osbUrl.setQuery(theQuery);
#endif
#undef theQuery
if (!theDownloader.go(osbUrl))
return false;
if (theDownloader.resultCode() != 200)
return false;
QByteArray Ar(theDownloader.content());
bool OK = importGPX(Main, Ar, theDocument, theTracklayers, true);
if (Main)
Main->view()->setUpdatesEnabled(true);
if (OK) {
if (Main)
Main->invalidateView();
}
return OK;
}
示例14: downloadMapdust
bool downloadMapdust(MainWindow* Main, const CoordBox& aBox, Document* theDocument, SpecialLayer* theLayer)
{
QUrl url;
url.setUrl(M_PREFS->getMapdustUrl());
if (Main)
Main->view()->setUpdatesEnabled(false);
Downloader theDownloader("", "");
SpecialLayer* trackLayer = theLayer;
if (!trackLayer) {
trackLayer = new SpecialLayer(QApplication::translate("Downloader","MapDust"), Layer::MapDustLayer);
trackLayer->setUploadable(false);
theDocument->add(trackLayer);
}
IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main);
if (!aProgressWindow)
return false;
QProgressDialog* dlg = aProgressWindow->getProgressDialog();
dlg->setWindowTitle(QApplication::translate("Downloader","Parsing..."));
QProgressBar* Bar = aProgressWindow->getProgressBar();
Bar->setTextVisible(false);
Bar->setMaximum(11);
QLabel* Lbl = aProgressWindow->getProgressLabel();
Lbl->setText(QApplication::translate("Downloader","Parsing XML"));
if (dlg)
dlg->show();
theDownloader.setAnimator(dlg,Lbl,Bar,true);
Lbl->setText(QApplication::translate("Downloader","Downloading points"));
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QUrlQuery theQuery(url);
#define theQuery theQuery
#else
#define theQuery url
#endif
theQuery.addQueryItem("t", COORD2STRING(aBox.topRight().y()));
theQuery.addQueryItem("l", COORD2STRING(aBox.bottomLeft().x()));
theQuery.addQueryItem("b", COORD2STRING(aBox.bottomLeft().y()));
theQuery.addQueryItem("r", COORD2STRING(aBox.topRight().x()));
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
url.setQuery(theQuery);
#endif
#undef theQuery
if (!theDownloader.go(url))
return false;
if (theDownloader.resultCode() != 200)
return false;
QByteArray Ar(theDownloader.content());
ImportExportGdal gdal(theDocument);
bool OK = gdal.import(trackLayer, Ar, false);
if (Main)
Main->view()->setUpdatesEnabled(true);
if (OK) {
if (Main)
Main->invalidateView();
}
return OK;
}
示例15: downloadOSM
bool downloadOSM(QWidget* aParent, const QUrl& theUrl, const QString& aUser, const QString& aPassword, Document* theDocument, Layer* theLayer)
{
Downloader Rcv(aUser, aPassword);
IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(aParent);
if (aProgressWindow) {
QProgressDialog* dlg = aProgressWindow->getProgressDialog();
if (dlg) {
dlg->setWindowTitle(QApplication::translate("Downloader","Downloading..."));
dlg->setWindowFlags(dlg->windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlg->setWindowFlags(dlg->windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
}
QProgressBar* Bar = aProgressWindow->getProgressBar();
Bar->setTextVisible(false);
Bar->setMaximum(11);
QLabel* Lbl = aProgressWindow->getProgressLabel();
Lbl->setText(QApplication::translate("Downloader","Downloading from OSM (connecting)"));
if (dlg)
dlg->show();
Rcv.setAnimator(dlg, Lbl, Bar, true);
}
if (!Rcv.go(theUrl))
{
#ifndef _MOBILE
aParent->setCursor(QCursor(Qt::ArrowCursor));
#endif
return false;
}
int x = Rcv.resultCode();
switch (x)
{
case 200:
break;
case 301:
case 302:
case 307: {
QString aWeb = Rcv.locationText();
if (!aWeb.isEmpty()) {
QUrl aURL(aWeb);
return downloadOSM(aParent, aURL, aUser, aPassword, theDocument, theLayer);
} else {
QString msg = QApplication::translate("Downloader","Unexpected http status code (%1)\nServer message is '%2'").arg(x).arg(Rcv.resultText());
if (!Rcv.errorText().isEmpty())
msg += QApplication::translate("Downloader", "\nAPI message is '%1'").arg(Rcv.errorText());
QMessageBox::warning(aParent,QApplication::translate("Downloader","Download failed"), msg);
return false;
}
break;
}
case 401:
QMessageBox::warning(aParent,QApplication::translate("Downloader","Download failed"),QApplication::translate("Downloader","Username/password invalid"));
return false;
default:
QString msg = QApplication::translate("Downloader","Unexpected http status code (%1)\nServer message is '%2'").arg(x).arg(Rcv.resultText());
if (!Rcv.errorText().isEmpty())
msg += QApplication::translate("Downloader", "\nAPI message is '%1'").arg(Rcv.errorText());
QMessageBox::warning(aParent,QApplication::translate("Downloader","Download failed"), msg);
return false;
}
Downloader Down(aUser, aPassword);
bool OK = importOSM(aParent, Rcv.content(), theDocument, theLayer, &Down);
return OK;
}