OSDN Git Service

ark: deal with TODO
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 29 Nov 2019 01:35:13 +0000 (01:35 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 29 Nov 2019 01:35:13 +0000 (01:35 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
ark/kerfuffle/cliinterface.cpp
ark/part/arkviewer.cpp
ark/plugins/libarchive/libarchivehandler.cpp

index 1bef9e8..d09be7f 100644 (file)
@@ -453,16 +453,13 @@ void CliInterface::readStdout(bool handleAll)
     //queries (such as file exists, wrong password) on a new line, but
     //freeze waiting for input. So we check for errors on the last line in
     //all cases.
-    // TODO: QLatin1String() might not be the best choice here.
-    //       The call to handleLine() at the end of the method uses
-    //       QString::fromLocal8Bit(), for example.
     // TODO: The same check methods are called in handleLine(), this
     //       is suboptimal.
     bool foundErrorMessage =
-        (checkForErrorMessage(QLatin1String( lines.last() ), WrongPasswordPatterns) ||
-         checkForErrorMessage(QLatin1String( lines.last() ), ExtractionFailedPatterns) ||
-         checkForPasswordPromptMessage(QLatin1String(lines.last())) ||
-         checkForFileExistsMessage(QLatin1String( lines.last() )));
+        (checkForErrorMessage(QString::fromLocal8Bit( lines.last() ), WrongPasswordPatterns) ||
+         checkForErrorMessage(QString::fromLocal8Bit( lines.last() ), ExtractionFailedPatterns) ||
+         checkForPasswordPromptMessage(QString::fromLocal8Bit(lines.last())) ||
+         checkForFileExistsMessage(QString::fromLocal8Bit( lines.last() )));
 
     if (foundErrorMessage) {
         handleAll = true;
index 156b4c4..33ca915 100644 (file)
@@ -120,7 +120,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
                 i18nc("@title:window", "Cannot Preview File"),
                 KGuiItem(i18nc("@action:button", "Preview as Text"), KIcon(QLatin1String("text-plain"))),
                 KStandardGuiItem::cancel(),
-                QString(QLatin1String("PreviewAsText_%1")).arg(mimeType->name()));
+                QString::fromLatin1("PreviewAsText_%1").arg(mimeType->name()));
         }
         else {
             // No defined MIME type, or the default application/octet-stream.
@@ -203,7 +203,7 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const KMimeType::P
 
     KVBox *headerRight = new KVBox(header);
     headerLayout->addWidget(headerRight);
-    new QLabel(QString(QLatin1String( "<qt><b>%1</b></qt>" ))
+    new QLabel(QString::fromLatin1( "<qt><b>%1</b></qt>" )
                .arg(fileUrl.fileName()), headerRight
               );
     new QLabel(mimeType->comment(), headerRight);
@@ -248,11 +248,11 @@ KService::Ptr ArkViewer::getViewer(const KMimeType::Ptr &mimeType)
     }
 
     // Try to get a read-only kpart for the internal viewer
-    KService::List offers = KMimeTypeTrader::self()->query(mimeType->name(), QString::fromLatin1("KParts/ReadOnlyPart"));
+    KService::List offers = KMimeTypeTrader::self()->query(mimeType->name(), QLatin1String("KParts/ReadOnlyPart"));
 
     // If we can't find a kpart, try to get an external application
     if (offers.size() == 0) {
-        offers = KMimeTypeTrader::self()->query(mimeType->name(), QString::fromLatin1("Application"));
+        offers = KMimeTypeTrader::self()->query(mimeType->name(), QLatin1String("Application"));
     }
 
     if (offers.size() > 0) {
index 3c972e6..204ae81 100644 (file)
@@ -123,7 +123,7 @@ bool LibArchiveInterface::list()
 
     if (result != ARCHIVE_EOF) {
         emit error(i18nc("@info", "The archive reading failed with the following error: <message>%1</message>",
-                   QLatin1String( archive_error_string(arch_reader.data()))));
+                   QString::fromAscii( archive_error_string(arch_reader.data()))));
         return false;
     }
 
@@ -404,7 +404,7 @@ bool LibArchiveInterface::addFiles(const QStringList& files, const CompressionOp
 
         if (ret != ARCHIVE_OK) {
             emit error(i18nc("@info", "Setting the compression method failed with the following error: <message>%1</message>",
-                       QLatin1String(archive_error_string(arch_writer.data()))));
+                       QString::fromAscii(archive_error_string(arch_writer.data()))));
 
             return false;
         }
@@ -432,19 +432,19 @@ bool LibArchiveInterface::addFiles(const QStringList& files, const CompressionOp
             }
             break;
         default:
-            emit error(i18n("The compression type '%1' is not supported by Ark.", QLatin1String(archive_filter_name(arch_reader.data(), 0))));
+            emit error(i18n("The compression type '%1' is not supported by Ark.", QString::fromAscii(archive_filter_name(arch_reader.data(), 0))));
             return false;
         }
 
         if (ret != ARCHIVE_OK) {
-            emit error(i18nc("@info", "Setting the compression method failed with the following error: <message>%1</message>", QLatin1String(archive_error_string(arch_writer.data()))));
+            emit error(i18nc("@info", "Setting the compression method failed with the following error: <message>%1</message>", QString::fromAscii(archive_error_string(arch_writer.data()))));
             return false;
         }
     }
 
     ret = archive_write_open_filename(arch_writer.data(), QFile::encodeName(tempFilename));
     if (ret != ARCHIVE_OK) {
-        emit error(i18nc("@info", "Opening the archive for writing failed with the following error: <message>%1</message>", QLatin1String(archive_error_string(arch_writer.data()))));
+        emit error(i18nc("@info", "Opening the archive for writing failed with the following error: <message>%1</message>", QString::fromAscii(archive_error_string(arch_writer.data()))));
         return false;
     }
 
@@ -579,18 +579,18 @@ bool LibArchiveInterface::deleteFiles(const QVariantList& files)
         }
         break;
     default:
-        emit error(i18n("The compression type '%1' is not supported by Ark.", QLatin1String(archive_filter_name(arch_reader.data(), 0))));
+        emit error(i18n("The compression type '%1' is not supported by Ark.", QString::fromAscii(archive_filter_name(arch_reader.data(), 0))));
         return false;
     }
 
     if (ret != ARCHIVE_OK) {
-        emit error(i18nc("@info", "Setting the compression method failed with the following error: <message>%1</message>", QLatin1String(archive_error_string(arch_writer.data()))));
+        emit error(i18nc("@info", "Setting the compression method failed with the following error: <message>%1</message>", QString::fromAscii(archive_error_string(arch_writer.data()))));
         return false;
     }
 
     ret = archive_write_open_filename(arch_writer.data(), QFile::encodeName(tempFilename));
     if (ret != ARCHIVE_OK) {
-        emit error(i18nc("@info", "Opening the archive for writing failed with the following error: <message>%1</message>", QLatin1String(archive_error_string(arch_writer.data()))));
+        emit error(i18nc("@info", "Opening the archive for writing failed with the following error: <message>%1</message>", QString::fromAscii(archive_error_string(arch_writer.data()))));
         return false;
     }
 
@@ -648,7 +648,7 @@ void LibArchiveInterface::emitEntryFromArchiveEntry(struct archive_entry *aentry
     e[IsDirectory] = S_ISDIR(archive_entry_mode(aentry));
 
     if (archive_entry_symlink(aentry)) {
-        e[Link] = QLatin1String( archive_entry_symlink(aentry) );
+        e[Link] = QString::fromAscii( archive_entry_symlink(aentry) );
     }
 
     e[Timestamp] = QDateTime::fromTime_t(archive_entry_mtime(aentry));