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 <QJsonDocument>
 | 
				
			||||||
#include <QXmlStreamReader>
 | 
					#include <QXmlStreamReader>
 | 
				
			||||||
 | 
					#include <QUrlQuery>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// KDE
 | 
					// KDE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,10 +46,12 @@ QUrl requestUrl(QUrl &url, const QString &path,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // If we have parameters, add them
 | 
					    // If we have parameters, add them
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QUrlQuery query;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!parameters.isEmpty()) {
 | 
					    if (!parameters.isEmpty()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (auto key : parameters.keys()) {
 | 
					        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
 | 
					    // Now, let's add tags should we have them
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!tags.isEmpty()) {
 | 
					    if (!tags.isEmpty()) {
 | 
				
			||||||
        QByteArray encoded_tags = QUrl::toPercentEncoding(tags.join(" "));
 | 
					        query.addQueryItem("tags", tags.join(" "));
 | 
				
			||||||
        danbooruUrl.addEncodedQueryItem("tags", encoded_tags);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    danbooruUrl.setQuery(query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!username.isEmpty() && !password.isEmpty()) {
 | 
					    if (!username.isEmpty() && !password.isEmpty()) {
 | 
				
			||||||
        danbooruUrl.setUserName(username);
 | 
					        danbooruUrl.setUserName(username);
 | 
				
			||||||
        danbooruUrl.setPassword(password);
 | 
					        danbooruUrl.setPassword(password);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return danbooruUrl;
 | 
					    return danbooruUrl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,14 +83,18 @@ QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // If we have parameters, add them
 | 
					    // If we have parameters, add them
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QUrlQuery query;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!parameters.isEmpty()) {
 | 
					    if (!parameters.isEmpty()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (auto key : parameters.keys()) {
 | 
					        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()) {
 | 
					    if (!username.isEmpty() && !password.isEmpty()) {
 | 
				
			||||||
        danbooruUrl.setUserName(username);
 | 
					        danbooruUrl.setUserName(username);
 | 
				
			||||||
        danbooruUrl.setPassword(password);
 | 
					        danbooruUrl.setPassword(password);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue