]> git.sur5r.net Git - minitube/commitdiff
QLatin1String
authorFlavio <flavio@odisseo.local>
Thu, 10 Jan 2013 13:52:43 +0000 (14:52 +0100)
committerFlavio <flavio@odisseo.local>
Thu, 10 Jan 2013 13:52:43 +0000 (14:52 +0100)
src/main.cpp
src/qtsingleapplication/qtlocalpeer.cpp
src/updatechecker.cpp
src/utils.cpp
src/video.cpp
src/video.h
src/videomimedata.cpp
src/ytcategories.cpp
src/ytfeedreader.cpp
src/ytsuggester.cpp

index 380418302db716d4d8b851a727e0a29aa31ef10a..399e6f081a940dc60d929e79ef22c65d1fe49b04 100644 (file)
@@ -65,17 +65,17 @@ int main(int argc, char **argv) {
 #endif
 
     QtSingleApplication app(argc, argv);
-    QString message = app.arguments().size() > 1 ? app.arguments().at(1) : "";
-    if (message == "--help") {
+    QString message = app.arguments().size() > 1 ? app.arguments().at(1) : QString();
+    if (message == QLatin1String("--help")) {
         MainWindow::printHelp();
         return 0;
     }
     if (app.sendMessage(message))
         return 0;
 
-    app.setApplicationName(Constants::NAME);
-    app.setOrganizationName(Constants::ORG_NAME);
-    app.setOrganizationDomain(Constants::ORG_DOMAIN);
+    app.setApplicationName(QLatin1String(Constants::NAME));
+    app.setOrganizationName(QLatin1String(Constants::ORG_NAME));
+    app.setOrganizationDomain(QLatin1String(Constants::ORG_DOMAIN));
     app.setWheelScrollLines(1);
     app.setAttribute(Qt::AA_DontShowIconsInMenus);
 
@@ -149,11 +149,11 @@ int main(int argc, char **argv) {
     app.setActivationWindow(&mainWin, true);
 
     // all string literals are UTF-8
-    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+    // QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
 
     if (app.arguments().size() > 1) {
         QString query = app.arguments().at(1);
-        if (query.startsWith("--")) {
+        if (query.startsWith(QLatin1String("--"))) {
             mainWin.messageReceived(query);
             return 0;
         } else {
index e7db47d9b3e15a9572f2ee6454c112ed8d83cb88..7e968dfa551afbb71e85a18e150552ef6eb97833 100644 (file)
@@ -84,7 +84,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
 #endif
         prefix = id.section(QLatin1Char('/'), -1);
     }
-    prefix.remove(QRegExp("[^a-zA-Z]"));
+    prefix.remove(QRegExp(QLatin1String("[^a-zA-Z]")));
     prefix.truncate(6);
 
     QByteArray idc = id.toUtf8();
index c98a83635ea8842ffe2897f7774349573b801be0..fc794d31d874ea848c8da801216e730d673442d9 100644 (file)
@@ -57,10 +57,10 @@ bool UpdateCheckerStreamReader::read(QByteArray data) {
     while (!atEnd()) {
         readNext();
         if (isStartElement()) {
-            if (name() == "release") {
+            if (name() == QLatin1String("release")) {
                 while (!atEnd()) {
                     readNext();
-                    if (isStartElement() && name() == "version") {
+                    if (isStartElement() && name() == QLatin1String("version")) {
                         QString remoteVersion = readElementText();
                         qDebug() << remoteVersion << QString(Constants::VERSION);
                         m_needUpdate = remoteVersion != QString(Constants::VERSION);
index 3973a6bf5171c1b5c353a296310b3dd566fd6c34..01b03b3d18b3eb05e58ac2f1507dd502d5bf1825 100644 (file)
@@ -14,7 +14,7 @@ QIcon getIcon(const QString &name) {
 QIcon Utils::icon(const QString &name) {
 #ifdef Q_WS_X11
     QString themeName = qApp->property("style").toString();
-    if (themeName == "Ambiance")
+    if (themeName == QLatin1String("Ambiance"))
         return icon(QStringList() << name + "-symbolic" << name);
     else return getIcon(name);
 #else
index 9cb9017d895b50661c42dac19b242f758d26b41b..bedfee93a5ac7de46384ca5dadf04f4b3dfb52e7 100644 (file)
@@ -98,7 +98,7 @@ void  Video::getVideoInfo() {
 
     // Get Video Token
     QUrl videoInfoUrl = QUrl(QString(
-            "http://www.youtube.com/get_video_info?video_id=%1%2&ps=default&eurl=&gl=US&hl=en"
+            "https://www.youtube.com/get_video_info?video_id=%1%2&ps=default&eurl=&gl=US&hl=en"
             ).arg(videoId, elTypes.at(elIndex)));
 
     QObject *reply = The::http()->get(videoInfoUrl);
index 7fd1cb960781cc5acdffc44b533cc0ca59648c8f..f5b75745c3a2106bbb0edaa5a5da6a2dd653dae4 100644 (file)
@@ -52,7 +52,11 @@ public:
     void loadStreamUrl();
     QUrl getStreamUrl() { return m_streamUrl; }
 
-    QString id() { return videoId; }
+    QString id() const { return videoId; }
+
+    bool operator==(const Video &other) const {
+        return videoId == other.id();
+    }
 
 signals:
     void gotThumbnail();
index 38998f2169a5fe7fa74b9788296f1a5f7becad65..619c7d197ab0010f6832be81a6c980767372016e 100644 (file)
@@ -9,5 +9,5 @@ QStringList VideoMimeData::formats() const {
 }
 
 bool VideoMimeData::hasFormat( const QString &mimeType ) const {
-    return mimeType == "application/x-minitube-video";
+    return mimeType == QLatin1String("application/x-minitube-video");
 }
index 2e5bab4742c9fae839b823ad29ae2d3c6720dcfd..92e2dbc5db61933350371c66e43e410cd180fa72 100644 (file)
@@ -25,11 +25,11 @@ void YTCategories::parseCategories(QByteArray bytes) {
     QXmlStreamReader xml(bytes);
     while (!xml.atEnd()) {
         xml.readNext();
-        if (xml.isStartElement() && xml.name() == "category") {
+        if (xml.isStartElement() && xml.name() == QLatin1String("category")) {
             QString term = xml.attributes().value("term").toString();
             QString label = xml.attributes().value("label").toString();
             while(xml.readNextStartElement())
-                if (xml.name() == "assignable") {
+                if (xml.name() == QLatin1String("assignable")) {
                     YTCategory category;
                     category.term = term;
                     category.label = label;
index 342e9ebf672a58b77318888aaf227ffdc47248e8..2551d8426f33656fc53ecb8b4a83f3d45ab00d49 100644 (file)
@@ -4,11 +4,11 @@
 YTFeedReader::YTFeedReader(const QByteArray &bytes) : QXmlStreamReader(bytes) {
     while (!atEnd()) {
         readNext();
-        if (isStartElement() && name() == "entry") {
+        if (isStartElement() && name() == QLatin1String("entry")) {
             readEntry();
-        } else if (name() == "link"
+        } else if (name() == QLatin1String("link")
                    && attributes().value("rel").toString()
-                   == "http://schemas.google.com/g/2006#spellcorrection") {
+                   == QLatin1String("http://schemas.google.com/g/2006#spellcorrection")) {
             suggestions << attributes().value("title").toString();
         }
     }
@@ -27,62 +27,63 @@ void YTFeedReader::readEntry() {
             qDebug() << attribute.name() << ":" << attribute.value();
         */
 
-        if (isEndElement() && name() == "entry") break;
+        if (isEndElement() && name() == QLatin1String("entry")) break;
         if (isStartElement()) {
 
-            if (name() == "link"
-                    && attributes().value("rel").toString() == "alternate"
-                    && attributes().value("type").toString() == "text/html"
+            if (name() == QLatin1String("link")
+                    && attributes().value("rel").toString() == QLatin1String("alternate")
+                    && attributes().value("type").toString() == QLatin1String("text/html")
                     ) {
                 QString webpage = attributes().value("href").toString();
                 webpage.remove("&feature=youtube_gdata");
                 video->setWebpage(QUrl(webpage));
-            } else if (name() == "author") {
+            } else if (name() == QLatin1String("author")) {
                 while(readNextStartElement())
-                    if (name() == "name") {
+                    if (name() == QLatin1String("name")) {
                         QString author = readElementText();
                         video->setAuthor(author);
-                    } else if (name() == "uri") {
+                    } else if (name() == QLatin1String("uri")) {
                         QString uri = readElementText();
                         int i = uri.lastIndexOf('/');
                         if (i != -1) uri = uri.mid(i+1);
                         video->setAuthorUri(uri);
                     } else skipCurrentElement();
-            } else if (name() == "published") {
+            } else if (name() == QLatin1String("published")) {
                 video->setPublished(QDateTime::fromString(readElementText(), Qt::ISODate));
-            } else if (namespaceUri() == "http://gdata.youtube.com/schemas/2007"
-                       && name() == "statistics") {
+            } else if (namespaceUri() == QLatin1String("http://gdata.youtube.com/schemas/2007")
+                       && name() == QLatin1String("statistics")) {
                 QString viewCount = attributes().value("viewCount").toString();
                 video->setViewCount(viewCount.toInt());
             }
-            else if (namespaceUri() == "http://search.yahoo.com/mrss/" && name() == "group") {
+            else if (namespaceUri() == QLatin1String("http://search.yahoo.com/mrss/")
+                     && name() == QLatin1String("group")) {
 
                 // read media group
                 while (!atEnd()) {
                     readNext();
-                    if (isEndElement() && name() == "group") break;
+                    if (isEndElement() && name() == QLatin1String("group")) break;
                     if (isStartElement()) {
-                        if (name() == "thumbnail") {
+                        if (name() == QLatin1String("thumbnail")) {
                             // qDebug() << "Thumb: " << attributes().value("url").toString();
                             QStringRef name = attributes().value("yt:name");
-                            if (name == "default")
+                            if (name == QLatin1String("default"))
                                 video->setThumbnailUrl(
                                             attributes().value("url").toString());
-                            else if (name == "hqdefault")
+                            else if (name == QLatin1String("hqdefault"))
                                 video->setMediumThumbnailUrl(
                                             attributes().value("url").toString());
                         }
-                        else if (name() == "title") {
+                        else if (name() == QLatin1String("title")) {
                             QString title = readElementText();
                             // qDebug() << "Title: " << title;
                             video->setTitle(title);
                         }
-                        else if (name() == "description") {
+                        else if (name() == QLatin1String("description")) {
                             QString desc = readElementText();
                             // qDebug() << "Description: " << desc;
                             video->setDescription(desc);
                         }
-                        else if (name() == "duration") {
+                        else if (name() == QLatin1String("duration")) {
                             QString duration = attributes().value("seconds").toString();
                             // qDebug() << "Duration: " << duration;
                             video->setDuration(duration.toInt());
index 6d1226e295957c978d552fc05d6b78dbe4dff62b..b0693d8221bc186a2d6bb6dc9a9d20247b8d305e 100644 (file)
@@ -39,7 +39,7 @@ void YTSuggester::handleNetworkData(QByteArray response) {
     while (!xml.atEnd()) {
         xml.readNext();
         if (xml.tokenType() == QXmlStreamReader::StartElement) {
-            if (xml.name() == "suggestion") {
+            if (xml.name() == QLatin1String("suggestion")) {
                 QStringRef str = xml.attributes().value("data");
                 choices << str.toString();
             }