1515#include " gui/fromiconid.h"
1616#include " item/serialize.h"
1717
18- #ifdef HAS_TESTS
19- # include " tests/itemencryptedtests.h"
20- #endif
21-
2218#include < QAbstractItemModel>
2319#include < QDebug>
2420#include < QDir>
@@ -406,7 +402,7 @@ bool ItemEncryptedScriptable::isEncrypted()
406402 bool ok;
407403 const int row = arg.toInt (&ok);
408404 if (ok) {
409- const auto result = call (" read" , QVariantList () << " ?" << row);
405+ const auto result = call (" read" , { QStringLiteral ( " ?" ), row} );
410406 if ( result.toByteArray ().contains (mimeEncryptedData.data ()) )
411407 return true ;
412408 }
@@ -432,43 +428,43 @@ QByteArray ItemEncryptedScriptable::decrypt()
432428void ItemEncryptedScriptable::encryptItem ()
433429{
434430 QVariantMap dataMap;
435- const auto formats = call (" dataFormats" ).toList ();
431+ const auto formats = call (" dataFormats" , {} ).toList ();
436432 for (const auto &formatValue : formats) {
437433 const auto format = formatValue.toString ();
438434 if ( !format.startsWith (COPYQ_MIME_PREFIX) ) {
439- const auto data = call (" data" , QVariantList () << format).toByteArray ();
435+ const auto data = call (" data" , { format} ).toByteArray ();
440436 dataMap.insert (format, data);
441437 }
442438 }
443439
444- const auto bytes = call (" pack" , QVariantList () << dataMap).toByteArray ();
440+ const auto bytes = call (" pack" , { dataMap} ).toByteArray ();
445441 const auto encryptedBytes = encrypt (bytes);
446442 if (encryptedBytes.isEmpty ())
447443 return ;
448444
449- call (" setData" , QVariantList () << mimeEncryptedData << encryptedBytes);
445+ call (" setData" , { mimeEncryptedData, encryptedBytes} );
450446
451447 for (auto it = dataMap.constBegin (); it != dataMap.constEnd (); ++it)
452- call (" removeData" , QVariantList () << it.key ());
448+ call (" removeData" , { it.key ()} );
453449}
454450
455451void ItemEncryptedScriptable::decryptItem ()
456452{
457- const auto encryptedBytes = call (" data" , QVariantList () << mimeEncryptedData).toByteArray ();
453+ const auto encryptedBytes = call (" data" , { mimeEncryptedData} ).toByteArray ();
458454 const auto itemData = decrypt (encryptedBytes);
459455 if (itemData.isEmpty ())
460456 return ;
461457
462- const auto dataMap = call (" unpack" , QVariantList () << itemData).toMap ();
458+ const auto dataMap = call (" unpack" , { itemData} ).toMap ();
463459 for (auto it = dataMap.constBegin (); it != dataMap.constEnd (); ++it) {
464460 const auto &format = it.key ();
465- call (" setData" , QVariantList () << format << dataMap[format]);
461+ call (" setData" , { format, dataMap[format]} );
466462 }
467463}
468464
469465void ItemEncryptedScriptable::encryptItems ()
470466{
471- const auto dataValueList = call (" selectedItemsData" ).toList ();
467+ const auto dataValueList = call (" selectedItemsData" , {} ).toList ();
472468
473469 QVariantList dataList;
474470 for (const auto &itemDataValue : dataValueList) {
@@ -483,7 +479,7 @@ void ItemEncryptedScriptable::encryptItems()
483479 }
484480 }
485481
486- const auto bytes = call (" pack" , QVariantList () << itemDataToEncrypt).toByteArray ();
482+ const auto bytes = call (" pack" , { itemDataToEncrypt} ).toByteArray ();
487483 const auto encryptedBytes = encrypt (bytes);
488484 if (encryptedBytes.isEmpty ())
489485 return ;
@@ -492,12 +488,12 @@ void ItemEncryptedScriptable::encryptItems()
492488 dataList.append (itemData);
493489 }
494490
495- call ( " setSelectedItemsData" , QVariantList () << QVariant (dataList) );
491+ call ( " setSelectedItemsData" , { QVariant (dataList)} );
496492}
497493
498494void ItemEncryptedScriptable::decryptItems ()
499495{
500- const auto dataValueList = call (" selectedItemsData" ).toList ();
496+ const auto dataValueList = call (" selectedItemsData" , {} ).toList ();
501497
502498 QVariantList dataList;
503499 for (const auto &itemDataValue : dataValueList) {
@@ -511,20 +507,20 @@ void ItemEncryptedScriptable::decryptItems()
511507 if (decryptedBytes.isEmpty ())
512508 return ;
513509
514- const auto decryptedItemData = call (" unpack" , QVariantList () << decryptedBytes).toMap ();
510+ const auto decryptedItemData = call (" unpack" , { decryptedBytes} ).toMap ();
515511 for (auto it = decryptedItemData.constBegin (); it != decryptedItemData.constEnd (); ++it)
516512 itemData.insert (it.key (), it.value ());
517513 }
518514
519515 dataList.append (itemData);
520516 }
521517
522- call ( " setSelectedItemsData" , QVariantList () << QVariant (dataList) );
518+ call ( " setSelectedItemsData" , { QVariant (dataList)} );
523519}
524520
525521void ItemEncryptedScriptable::copyEncryptedItems ()
526522{
527- const auto dataValueList = call (" selectedItemsData" ).toList ();
523+ const auto dataValueList = call (" selectedItemsData" , {} ).toList ();
528524 QString text;
529525 for (const auto &dataValue : dataValueList) {
530526 if ( !text.isEmpty () )
@@ -540,15 +536,13 @@ void ItemEncryptedScriptable::copyEncryptedItems()
540536 const auto itemData = decrypt (encryptedBytes);
541537 if (itemData.isEmpty ())
542538 return ;
543- const auto dataMap = call (" unpack" , QVariantList () << itemData).toMap ();
539+ const auto dataMap = call (" unpack" , { itemData} ).toMap ();
544540 text.append ( getTextData (dataMap) );
545541 }
546542 }
547543 }
548544
549- const auto args = QVariantList ()
550- << mimeText << text
551- << mimeHidden << " 1" ;
545+ const QVariantList args{mimeText, text, mimeHidden, " 1" };
552546 call (" copy" , args);
553547 call (" copySelection" , args);
554548}
@@ -567,7 +561,7 @@ void ItemEncryptedScriptable::pasteEncryptedItems()
567561 copy('');
568562 copySelection('');
569563 )" ;
570- call (" eval" , QVariantList () << script);
564+ call (" eval" , { script} );
571565}
572566
573567QString ItemEncryptedScriptable::generateTestKeys ()
@@ -829,17 +823,6 @@ ItemSaverPtr ItemEncryptedLoader::initializeTab(const QString &, QAbstractItemMo
829823 return createSaver ();
830824}
831825
832- QObject *ItemEncryptedLoader::tests (const TestInterfacePtr &test) const
833- {
834- #ifdef HAS_TESTS
835- QObject *tests = new ItemEncryptedTests (test);
836- return tests;
837- #else
838- Q_UNUSED (test)
839- return nullptr ;
840- #endif
841- }
842-
843826ItemScriptable *ItemEncryptedLoader::scriptableObject ()
844827{
845828 return new ItemEncryptedScriptable ();
0 commit comments