Port utils.cpp away from deprecated Qt API
This commit is contained in:
		
					parent
					
						
							
								d20f3e02b1
							
						
					
				
			
			
				commit
				
					
						959d7c89a9
					
				
			
		
					 1 changed files with 13 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
 | 
			
		||||
#include <QJsonDocument>
 | 
			
		||||
#include <QXmlStreamReader>
 | 
			
		||||
#include <QUrlQuery>
 | 
			
		||||
 | 
			
		||||
// KDE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,10 +46,12 @@ QUrl requestUrl(QUrl &url, const QString &path,
 | 
			
		|||
 | 
			
		||||
    // If we have parameters, add them
 | 
			
		||||
 | 
			
		||||
    QUrlQuery query;
 | 
			
		||||
 | 
			
		||||
    if (!parameters.isEmpty()) {
 | 
			
		||||
 | 
			
		||||
        for (auto key : parameters.keys()) {
 | 
			
		||||
            danbooruUrl.addQueryItem(key, parameters.value(key));
 | 
			
		||||
            query.addQueryItem(key, parameters.value(key));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -56,15 +59,17 @@ QUrl requestUrl(QUrl &url, const QString &path,
 | 
			
		|||
    // Now, let's add tags should we have them
 | 
			
		||||
 | 
			
		||||
    if (!tags.isEmpty()) {
 | 
			
		||||
        QByteArray encoded_tags = QUrl::toPercentEncoding(tags.join(" "));
 | 
			
		||||
        danbooruUrl.addEncodedQueryItem("tags", encoded_tags);
 | 
			
		||||
        query.addQueryItem("tags", tags.join(" "));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    danbooruUrl.setQuery(query);
 | 
			
		||||
 | 
			
		||||
    if (!username.isEmpty() && !password.isEmpty()) {
 | 
			
		||||
        danbooruUrl.setUserName(username);
 | 
			
		||||
        danbooruUrl.setPassword(password);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return danbooruUrl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -78,14 +83,18 @@ QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
			
		|||
 | 
			
		||||
    // If we have parameters, add them
 | 
			
		||||
 | 
			
		||||
    QUrlQuery query;
 | 
			
		||||
 | 
			
		||||
    if (!parameters.isEmpty()) {
 | 
			
		||||
 | 
			
		||||
        for (auto key : parameters.keys()) {
 | 
			
		||||
            danbooruUrl.addQueryItem(key, parameters.value(key));
 | 
			
		||||
            query.addQueryItem(key, parameters.value(key));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    danbooruUrl.setQuery(query);
 | 
			
		||||
 | 
			
		||||
    if (!username.isEmpty() && !password.isEmpty()) {
 | 
			
		||||
        danbooruUrl.setUserName(username);
 | 
			
		||||
        danbooruUrl.setPassword(password);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue