Commit 109284d3 authored by Matthias Möller's avatar Matthias Möller

- replaced deprecated qt4 functions

- removed some unnecessary qt headers

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17078 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a65e48fd
......@@ -520,7 +520,7 @@ Core::init() {
it.next();
/// Skip all signals for function calls
if ( checkSignal( this, it.name().toAscii() ) )
if ( checkSignal( this, it.name().toLatin1() ) )
continue;
scriptingFunctions_.push_back( "core." + it.name() );
......
......@@ -93,7 +93,7 @@ Core::
slotLog(Logtype _type, QString _message) {
emit externalLog( _type , _message );
if ( OpenFlipper::Options::logToConsole() ) {
std::string output( _message.toAscii() ) ;
std::string output( _message.toLatin1() ) ;
switch (_type) {
case LOGINFO:
......
......@@ -2089,7 +2089,7 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic
it.next();
/// Skip all signals for function calls
if ( checkSignal( plugin, it.name().toAscii() ) )
if ( checkSignal( plugin, it.name().toLatin1() ) )
continue;
info.rpcFunctions.push_back( it.name() );
......
......@@ -53,7 +53,7 @@
// -------------------- mview
#include "Core.hh"
#include <QtUiTools/QUiLoader>
#include <QUiLoader>
//== IMPLEMENTATION ==========================================================
......
......@@ -752,7 +752,7 @@ void BaseObject::dumpTree() {
std::cerr << " ";
std::cerr << "Node ";
std::cerr << std::string(name().toAscii());
std::cerr << std::string(name().toLatin1());
std::cerr << " with id : ";
std::cerr << id();
......
......@@ -160,7 +160,7 @@ void QtGLViewerLayout::reLayout ()
if (item->size() != item->preferredSize ())
item->resize (item->preferredSize ());
item->resetTransform();
item->scale (scale, scale);
item->setScale (scale);
}
wheelX_->setPos (r.left(),
......
......@@ -117,7 +117,7 @@ QtSlideWindow::QtSlideWindow(QString _name, QGraphicsItem *_parent) :
// Hide widget
hide();
setAcceptsHoverEvents(true);
setAcceptHoverEvents(true);
updateParentGeometry();
}
......
......@@ -298,12 +298,12 @@ void LoadWidget::saveFile(){
//get filename
if (!filename.contains(".",Qt::CaseSensitive)){ //check for extension
int s = selectedFilter().indexOf("*")+1;
int e = selectedFilter().indexOf(" ", s);
int e2 = selectedFilter().indexOf(")", s);
int s = selectedNameFilter().indexOf("*")+1;
int e = selectedNameFilter().indexOf(" ", s);
int e2 = selectedNameFilter().indexOf(")", s);
if (e == -1 || e2 < e) e = e2;
QString ext = selectedFilter().mid(s,e-s);
QString ext = selectedNameFilter().mid(s,e-s);
filename += ext;
}
......
......@@ -50,14 +50,6 @@
void OptionsWidget::startDownload( QString _url ) {
QUrl url(_url);
// If username or passowrd are supplied, use them
if ( ! updateUser->text().isEmpty() )
url.setUserName(updateUser->text());
if ( ! updatePass->text().isEmpty() )
url.setPassword(updatePass->text());
QFileInfo urlInfo(_url);
// Download the file to the Home Directory
......@@ -77,11 +69,8 @@ void OptionsWidget::startDownload( QString _url ) {
file = 0;
checkUpdateButton->setEnabled(true);
} else {
QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
if (!url.userName().isEmpty())
http->setUser(url.userName(), url.password());
QNetworkRequest req;
req.setUrl(url);
httpRequestAborted = false;
QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
......@@ -94,96 +83,95 @@ void OptionsWidget::startDownload( QString _url ) {
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
progressDialog->show();
httpGetId = http->get(path, file);
downloadRep_ = networkMan_->get(req);
connect(downloadRep_, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(showError(QNetworkReply::NetworkError)));
connect(downloadRep_,SIGNAL(downloadProgress(qint64 , qint64 )),
this,SLOT(updateDataReadProgress(qint64 , qint64 )));
checkUpdateButton->setEnabled(false);
}
}
void OptionsWidget::httpRequestFinished(int requestId, bool error)
void OptionsWidget::authentication ( QNetworkReply* _reply, QAuthenticator* _authenticator )
{
if (requestId != httpGetId)
return;
if (httpRequestAborted) {
if (file) {
file->close();
file->remove();
delete file;
file = 0;
}
progressDialog->hide();
checkUpdateButton->setEnabled(true);
return;
}
if ( ! updateUser->text().isEmpty() )
_authenticator->setUser(updateUser->text());
if (requestId != httpGetId)
return;
if ( ! updatePass->text().isEmpty() )
_authenticator->setPassword(updatePass->text());
}
progressDialog->hide();
file->close();
if (error) {
file->remove();
statusLabel->setText(tr("Download failed: %1.").arg(http->errorString()));
QMessageBox::information(this, tr("HTTP"),
tr("Download failed: %1.")
.arg(http->errorString()) + file->fileName() );
} else {
QString fileName = QFileInfo(QUrl(updateURL->text()).path()).fileName();
statusLabel->setText(tr("Downloaded %1").arg(file->fileName() ));
}
void OptionsWidget::httpRequestFinished(QNetworkReply* _qnr)
{
if (_qnr != downloadRep_)
return;
checkUpdateButton->setEnabled(true);
delete file;
file = 0;
QNetworkReply::NetworkError error = _qnr->error();
if ( !error ) {
if ( downloadType == VERSIONS_FILE )
compareVersions();
if ( downloadType == PLUGIN )
updateComponent();
if (httpRequestAborted) {
if (file) {
file->close();
file->remove();
delete file;
file = 0;
}
}
void OptionsWidget::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
switch (responseHeader.statusCode()) {
case 200: // Ok
case 301: // Moved Permanently
case 302: // Found
case 303: // See Other
case 307: // Temporary Redirect
// these are not error conditions
break;
default:
QMessageBox::information(this, tr("HTTP"),
tr("Download failed: %1.")
.arg(responseHeader.reasonPhrase()));
statusLabel->setText(tr("Download failed: ") + responseHeader.reasonPhrase());
httpRequestAborted = true;
progressDialog->hide();
http->abort();
checkUpdateButton->setEnabled(true);
return;
}
progressDialog->hide();
file->close();
if (error != QNetworkReply::NoError) {
file->remove();
} else {
QString fileName = QFileInfo(QUrl(updateURL->text()).path()).fileName();
statusLabel->setText(tr("Downloaded %1").arg(file->fileName() ));
}
}
checkUpdateButton->setEnabled(true);
delete file;
file = 0;
if ( error == QNetworkReply::NoError ) {
if ( downloadType == VERSIONS_FILE )
compareVersions();
if ( downloadType == PLUGIN )
updateComponent();
}
}
void OptionsWidget::cancelDownload()
{
statusLabel->setText(tr("download canceled."));
httpRequestAborted = true;
http->abort();
if (downloadRep_)
downloadRep_->abort();
checkUpdateButton->setEnabled(true);
}
void OptionsWidget::updateDataReadProgress(int bytesRead, int totalBytes)
void OptionsWidget::updateDataReadProgress(qint64 _bytesReceived, qint64 _bytesTotal)
{
if (httpRequestAborted)
return;
progressDialog->setMaximum(totalBytes);
progressDialog->setValue(bytesRead);
progressDialog->setMaximum(_bytesTotal);
progressDialog->setValue(_bytesReceived);
}
void OptionsWidget::showError(QNetworkReply::NetworkError _error)
{
if (_error == QNetworkReply::NoError)
return;
statusLabel->setText(tr("Download failed: %1.").arg(downloadRep_->errorString()));
QMessageBox::information(this, tr("HTTP Error"),
tr("Download failed: %1.")
.arg(downloadRep_->errorString()) + file->fileName() );
}
......
......@@ -121,15 +121,13 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
pluginOptionsLayout = new QVBoxLayout;
pluginOptions->setLayout( pluginOptionsLayout );
http = new QHttp(this);
networkMan_ = new QNetworkAccessManager(this);
// http specific connections
connect(http, SIGNAL(requestFinished(int, bool)),
this, SLOT(httpRequestFinished(int, bool)));
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(http, SIGNAL(dataReadProgress(int, int)),
this, SLOT(updateDataReadProgress(int, int)));
connect(networkMan_, SIGNAL(finished(QNetworkReply *)),
this, SLOT(httpRequestFinished(QNetworkReply *)));
connect(networkMan_,SIGNAL(authenticationRequired(QNetworkReply* , QAuthenticator *)),
this,SLOT(authentication(QNetworkReply *, QAuthenticator*)));
progressDialog = new QProgressDialog(this);
......
......@@ -49,6 +49,7 @@
#include "ui_optionsWidget.hh"
#include <QtGui>
#include <QStringList>
#include <QProgressDialog>
#include <QtNetwork>
#include <OpenFlipper/Core/PluginInfo.hh>
......@@ -149,11 +150,11 @@ private:
// flag indicating if something went wrong and the request has to be aborted
bool httpRequestAborted;
// Id of the current request
int httpGetId;
// Request variable
QHttp *http;
QNetworkAccessManager *networkMan_;
// current request
QNetworkReply* downloadRep_;
// File for http downloads
QFile *file;
......@@ -196,13 +197,13 @@ private:
private slots:
// This slot is called when a http request has been finished
void httpRequestFinished(int requestId, bool error);
// Parses the response and gives feedback
void readResponseHeader(const QHttpResponseHeader &responseHeader);
void httpRequestFinished(QNetworkReply *_qnr);
// Updates the progress Dialog while downloading
void updateDataReadProgress(int bytesRead, int totalBytes);
void updateDataReadProgress(qint64 _bytesReceived, qint64 _bytesTotal);
/// error occured while downloading
void showError(QNetworkReply::NetworkError _error);
// Progress dialog callback for cancel
void cancelDownload();
......@@ -213,6 +214,9 @@ private slots:
// Tracks whether another language has been selected
void slotTranslationIndexChanged(int);
/// authentication
void authentication ( QNetworkReply* _reply, QAuthenticator* _authenticator );
private:
/** After checking for updates this variable will contain a list of filenames for which updates are available
*/
......
......@@ -41,7 +41,6 @@
\*===========================================================================*/
#include "postProcessorWidget.hh"
#include <QtGui>
#include <QMessageBox>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
......
......@@ -46,6 +46,8 @@
#include <QHash>
#include <QTextCharFormat>
#include <QTextEdit>
#include <QTextDocument>
class QTextDocument;
......
......@@ -41,7 +41,7 @@
\*===========================================================================*/
#include "ui_rendererObjectWidget.hh"
#include <QtGui>
#include <QDialog>
#include <OpenFlipper/common/RendererInfo.hh>
#include "renderObjectHighLighter.hh"
......
......@@ -41,7 +41,10 @@
\*===========================================================================*/
#include "ui_rendererWidget.hh"
#include <QtGui>
#include <QDialog>
#include <QVector>
#include <QLabel>
#include <QFrame>
#include <OpenFlipper/common/RendererInfo.hh>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment