1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
|
/** \file copyEngine.cpp
\brief Define the copy engine
\author alpha_one_x86 */
#include <QFileDialog>
#include <QMessageBox>
#include <cmath>
#ifdef ULTRACOPIER_PLUGIN_DEBUG
#include <sys/stat.h>
#include <regex>
#endif
#include "CopyEngine.h"
#include "FolderExistsDialog.h"
#include "../../../interface/PluginInterface_CopyEngine.h"
// The cmath header from MSVC does not contain round()
#if (defined(_WIN64) || defined(_WIN32)) && defined(_MSC_VER)
inline double round(double d) {
return floor( d + 0.5 );
}
#endif
CopyEngine::CopyEngine(FacilityInterface * facilityEngine) :
listThread(NULL),
tempWidget(NULL),
ui(new Ui::copyEngineOptions()),
uiIsInstalled(false),
uiinterface(NULL),
filters(NULL),
renamingRules(NULL),
facilityEngine(NULL),
doRightTransfer(false),
keepDate(false),
followTheStrictOrder(false),
deletePartiallyTransferredFiles(false),
inodeThreads(0),
renameTheOriginalDestination(false),
moveTheWholeFolder(false),
#ifdef ULTRACOPIER_PLUGIN_RSYNC
rsync(false),
#endif
checkDestinationFolderExists(false),
mkFullPath(false),
checksum(false),
alwaysDoThisActionForFileExists(FileExistsAction::FileExists_NotSet),
alwaysDoThisActionForFileError(FileErrorAction::FileError_NotSet),
alwaysDoThisActionForFolderError(FileErrorAction::FileError_NotSet),
alwaysDoThisActionForFolderExists(FolderExistsAction::FolderExists_NotSet),
dialogIsOpen(false),
stopIt(false),
size_for_speed(0),
mode(Ultracopier::CopyMode::Copy),
forcedMode(false),
checkDiskSpace(false),
osBufferLimit(0),
errorPutAtEnd(0),
putAtBottom(0)
{
listThread=new ListThread(facilityEngine);
this->facilityEngine = facilityEngine;
filters = NULL;
renamingRules = NULL;
uiinterface = NULL;
tempWidget = NULL;
uiIsInstalled = false;
dialogIsOpen = false;
renameTheOriginalDestination = false;
alwaysDoThisActionForFileExists = FileExists_NotSet;
alwaysDoThisActionForFileError = FileError_NotSet;
checkDestinationFolderExists = false;
stopIt = false;
size_for_speed = 0;
putAtBottom = 0;
forcedMode = false;
followTheStrictOrder = false;
deletePartiallyTransferredFiles = true;
inodeThreads = 16;
moveTheWholeFolder = true;
//implement the SingleShot in this class
//timerActionDone.setSingleShot(true);
timerActionDone.setInterval(ULTRACOPIER_PLUGIN_TIME_UPDATE_TRASNFER_LIST);
//timerProgression.setSingleShot(true);
timerProgression.setInterval(ULTRACOPIER_PLUGIN_TIME_UPDATE_PROGRESSION);
timerUpdateMount.setInterval(ULTRACOPIER_PLUGIN_TIME_UPDATE_MOUNT_MS);
}
CopyEngine::~CopyEngine()
{
/*if(filters!=NULL)
delete filters;
if(renamingRules!=NULL)
delete renamingRules;
destroyed by the widget parent, here the interface
*/
stopIt=true;
delete listThread;
delete ui;
}
void CopyEngine::connectTheSignalsSlots()
{
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
debugDialogWindow.show();
debugDialogWindow.copyEngine=this;
#endif
if(!connect(listThread,&ListThread::isInPause, this,&CopyEngine::isInPause, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect isInPause()");
if(!connect(listThread,&ListThread::actionInProgess, this,&CopyEngine::actionInProgess, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect actionInProgess()");
if(!connect(listThread,&ListThread::actionInProgess, this,&CopyEngine::newActionInProgess, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect actionInProgess() to slot");
if(!connect(listThread,&ListThread::newFolderListing, this,&CopyEngine::newFolderListing, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect newFolderListing()");
if(!connect(listThread,&ListThread::error, this,&CopyEngine::error, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect error()");
if(!connect(listThread,&ListThread::rmPath, this,&CopyEngine::rmPath, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect rmPath()");
if(!connect(listThread,&ListThread::mkPath, this,&CopyEngine::mkPath, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect mkPath()");
if(!connect(listThread,&ListThread::newActionOnList, this,&CopyEngine::newActionOnList, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect newActionOnList()");
if(!connect(listThread,&ListThread::doneTime, this,&CopyEngine::doneTime, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect doneTime()");
if(!connect(listThread,&ListThread::pushFileProgression, this,&CopyEngine::pushFileProgression, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect pushFileProgression()");
if(!connect(listThread,&ListThread::pushGeneralProgression, this,&CopyEngine::pushGeneralProgression, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect pushGeneralProgression()");
if(!connect(listThread,&ListThread::syncReady, this,&CopyEngine::syncReady, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect syncReady()");
if(!connect(listThread,&ListThread::canBeDeleted, this,&CopyEngine::canBeDeleted, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect canBeDeleted()");
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
if(!connect(listThread,&ListThread::debugInformation, this,&CopyEngine::debugInformation, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect debugInformation()");
#endif
if(!connect(listThread,&ListThread::send_fileAlreadyExists, this,&CopyEngine::fileAlreadyExistsSlot, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_fileAlreadyExists()");
if(!connect(listThread,&ListThread::send_errorOnFile, this,&CopyEngine::errorOnFileSlot, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_errorOnFile()");
if(!connect(listThread,&ListThread::send_folderAlreadyExists, this,&CopyEngine::folderAlreadyExistsSlot, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_folderAlreadyExists()");
if(!connect(listThread,&ListThread::send_errorOnFolder, this,&CopyEngine::errorOnFolderSlot, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_errorOnFolder()");
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
if(!connect(listThread,&ListThread::updateTheDebugInfo, this,&CopyEngine::updateTheDebugInfo, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect updateTheDebugInfo()");
#endif
if(!connect(listThread,&ListThread::errorTransferList, this,&CopyEngine::errorTransferList, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect errorTransferList()");
if(!connect(listThread,&ListThread::warningTransferList, this,&CopyEngine::warningTransferList, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect warningTransferList()");
if(!connect(listThread,&ListThread::mkPathErrorOnFolder, this,&CopyEngine::mkPathErrorOnFolderSlot, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect mkPathErrorOnFolder()");
if(!connect(listThread,&ListThread::send_realBytesTransfered, this,&CopyEngine::get_realBytesTransfered, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_realBytesTransfered()");
if(!connect(this,&CopyEngine::tryCancel, listThread,&ListThread::cancel, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect tryCancel()");
if(!connect(this,&CopyEngine::getNeedPutAtBottom, listThread,&ListThread::getNeedPutAtBottom, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect getNeedPutAtBottom()");
if(!connect(listThread,&ListThread::haveNeedPutAtBottom, this,&CopyEngine::haveNeedPutAtBottom, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect haveNeedPutAtBottom()");
if(!connect(this,&CopyEngine::signal_pause, listThread,&ListThread::pause, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_pause()");
if(!connect(this,&CopyEngine::signal_setSpeedLimitation, listThread,&ListThread::setSpeedLimitation, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect setSpeedLimitation()");
if(!connect(this,&CopyEngine::signal_exportErrorIntoTransferList,listThread,&ListThread::exportErrorIntoTransferList, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_exportErrorIntoTransferList()");
if(!connect(this,&CopyEngine::signal_resume, listThread,&ListThread::resume, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_resume()");
if(!connect(this,&CopyEngine::signal_skip, listThread,&ListThread::skip, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_skip()");
if(!connect(this,&CopyEngine::signal_setCollisionAction, listThread,&ListThread::setAlwaysFileExistsAction, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_setCollisionAction()");
if(!connect(this,&CopyEngine::signal_setFolderCollision, listThread,&ListThread::setFolderCollision, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_setFolderCollision()");
if(!connect(this,&CopyEngine::signal_removeItems, listThread,&ListThread::removeItems, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_removeItems()");
if(!connect(this,&CopyEngine::signal_moveItemsOnTop, listThread,&ListThread::moveItemsOnTop, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_moveItemsOnTop()");
if(!connect(this,&CopyEngine::signal_moveItemsUp, listThread,&ListThread::moveItemsUp, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_moveItemsUp()");
if(!connect(this,&CopyEngine::signal_moveItemsDown, listThread,&ListThread::moveItemsDown, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_moveItemsDown()");
if(!connect(this,&CopyEngine::signal_moveItemsOnBottom, listThread,&ListThread::moveItemsOnBottom, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_moveItemsOnBottom()");
if(!connect(this,&CopyEngine::signal_exportTransferList, listThread,&ListThread::exportTransferList, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_exportTransferList()");
if(!connect(this,&CopyEngine::signal_importTransferList, listThread,&ListThread::importTransferList, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_importTransferList()");
if(!connect(this,&CopyEngine::signal_forceMode, listThread,&ListThread::forceMode, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect signal_forceMode()");
if(!connect(this,&CopyEngine::send_moveTheWholeFolder, listThread,&ListThread::setMoveTheWholeFolder, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect moveTheWholeFolder()");
if(!connect(this,&CopyEngine::send_deletePartiallyTransferredFiles, listThread,&ListThread::setDeletePartiallyTransferredFiles, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect deletePartiallyTransferredFiles()");
if(!connect(this,&CopyEngine::send_setRenameTheOriginalDestination, listThread,&ListThread::setRenameTheOriginalDestination, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect setRenameTheOriginalDestination()");
if(!connect(this,&CopyEngine::send_setInodeThreads, listThread,&ListThread::setInodeThreads, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect setInodeThreads()");
if(!connect(this,&CopyEngine::send_followTheStrictOrder, listThread,&ListThread::setFollowTheStrictOrder, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect followTheStrictOrder()");
if(!connect(this,&CopyEngine::send_setFilters,listThread,&ListThread::set_setFilters, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_setFilters()");
if(!connect(this,&CopyEngine::send_sendNewRenamingRules,listThread,&ListThread::set_sendNewRenamingRules, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect send_sendNewRenamingRules()");
if(!connect(&timerActionDone,&QTimer::timeout, listThread,&ListThread::sendActionDone))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect timerActionDone");
if(!connect(&timerProgression,&QTimer::timeout, listThread,&ListThread::sendProgression))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect timerProgression");
if(!connect(listThread,&ListThread::missingDiskSpace, this,&CopyEngine::missingDiskSpace,Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect timerProgression");
if(!connect(this,&CopyEngine::queryOneNewDialog,this,&CopyEngine::showOneNewDialog,Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect queryOneNewDialog()");
if(!connect(listThread,&ListThread::errorToRetry,this,&CopyEngine::errorToRetry,Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect errorToRetry()");
if(!connect(&timerUpdateMount,&QTimer::timeout,listThread,&ListThread::set_updateMount, Qt::QueuedConnection))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect set_updateMount()");
}
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
void CopyEngine::updateTheDebugInfo(const std::vector<std::string> &newList, const std::vector<std::string> &newList2, const int &numberOfInodeOperation)
{
debugDialogWindow.setTransferThreadList(newList);
debugDialogWindow.setTransferList(newList2);
debugDialogWindow.setInodeUsage(numberOfInodeOperation);
}
#endif
//to send the options panel
bool CopyEngine::getOptionsEngine(QWidget * tempWidget)
{
this->tempWidget=tempWidget;
ui->setupUi(tempWidget);
ui->toolBox->setCurrentIndex(0);
connect(tempWidget, &QWidget::destroyed, this, &CopyEngine::resetTempWidget);
//here else, the default settings can't be loaded
uiIsInstalled=true;
#ifdef ULTRACOPIER_PLUGIN_RSYNC
setRsync(rsync);
#else
ui->label_rsync->setVisible(false);
ui->rsync->setVisible(false);
#endif
setAutoStart(autoStart);
setCheckDestinationFolderExists(checkDestinationFolderExists);
setMkFullPath(mkFullPath);
setChecksum(checksum);
setRightTransfer(doRightTransfer);
setKeepDate(keepDate);
setOsSpecFlags(os_spec_flags);
setNativeCopy(native_copy);
setFollowTheStrictOrder(followTheStrictOrder);
setDeletePartiallyTransferredFiles(deletePartiallyTransferredFiles);
setInodeThreads(inodeThreads);
setRenameTheOriginalDestination(renameTheOriginalDestination);
setMoveTheWholeFolder(moveTheWholeFolder);
setCheckDiskSpace(checkDiskSpace);
setDefaultDestinationFolder(defaultDestinationFolder);
switch(alwaysDoThisActionForFileExists)
{
case FileExists_NotSet:
ui->comboBoxFileCollision->setCurrentIndex(0);
break;
case FileExists_Skip:
ui->comboBoxFileCollision->setCurrentIndex(1);
break;
case FileExists_Overwrite:
ui->comboBoxFileCollision->setCurrentIndex(2);
break;
case FileExists_OverwriteIfNotSameMdate:
ui->comboBoxFileCollision->setCurrentIndex(3);
break;
case FileExists_OverwriteIfNewer:
ui->comboBoxFileCollision->setCurrentIndex(4);
break;
case FileExists_OverwriteIfOlder:
ui->comboBoxFileCollision->setCurrentIndex(5);
break;
case FileExists_Rename:
ui->comboBoxFileCollision->setCurrentIndex(6);
break;
case FileExists_OverwriteIfNotSameSize:
ui->comboBoxFileCollision->setCurrentIndex(6);
break;
case FileExists_OverwriteIfNotSameSizeAndDate:
ui->comboBoxFileCollision->setCurrentIndex(6);
break;
default:
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored");
ui->comboBoxFileCollision->setCurrentIndex(0);
break;
}
switch(alwaysDoThisActionForFileError)
{
case FileError_NotSet:
ui->comboBoxFileError->setCurrentIndex(0);
break;
case FileError_Skip:
ui->comboBoxFileError->setCurrentIndex(1);
break;
case FileError_PutToEndOfTheList:
ui->comboBoxFileError->setCurrentIndex(2);
break;
default:
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored");
ui->comboBoxFileError->setCurrentIndex(0);
break;
}
switch(alwaysDoThisActionForFolderExists)
{
case FolderExists_NotSet:
ui->comboBoxFolderCollision->setCurrentIndex(0);
break;
case FolderExists_Merge:
ui->comboBoxFolderCollision->setCurrentIndex(1);
break;
case FolderExists_Skip:
ui->comboBoxFolderCollision->setCurrentIndex(2);
break;
case FolderExists_Rename:
ui->comboBoxFolderCollision->setCurrentIndex(3);
break;
default:
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored");
ui->comboBoxFolderCollision->setCurrentIndex(0);
break;
}
switch(alwaysDoThisActionForFolderError)
{
case FileError_NotSet:
ui->comboBoxFolderError->setCurrentIndex(0);
break;
case FileError_Skip:
ui->comboBoxFolderError->setCurrentIndex(1);
break;
default:
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored: "+std::to_string(alwaysDoThisActionForFolderError));
ui->comboBoxFolderError->setCurrentIndex(0);
break;
}
return true;
}
//to have interface widget to do modal dialog
void CopyEngine::setInterfacePointer(QWidget * uiinterface)
{
this->uiinterface=uiinterface;
if(filters==NULL)
filters=new Filters(tempWidget);
if(renamingRules==NULL)
renamingRules=new RenamingRules(tempWidget);
if(uiIsInstalled)
{
connect(ui->autoStart, &QCheckBox::toggled, this,&CopyEngine::setAutoStart);
connect(ui->doRightTransfer, &QCheckBox::toggled, this,&CopyEngine::setRightTransfer);
connect(ui->keepDate, &QCheckBox::toggled, this,&CopyEngine::setKeepDate);
connect(ui->os_spec_flags, &QCheckBox::toggled, this,&CopyEngine::setOsSpecFlags);
connect(ui->native_copy, &QCheckBox::toggled, this,&CopyEngine::setNativeCopy);
connect(ui->moveTheWholeFolder, &QCheckBox::toggled, this,&CopyEngine::setMoveTheWholeFolder);
connect(ui->deletePartiallyTransferredFiles, &QCheckBox::toggled, this,&CopyEngine::setDeletePartiallyTransferredFiles);
connect(ui->followTheStrictOrder, &QCheckBox::toggled, this,&CopyEngine::setFollowTheStrictOrder);
connect(ui->checkBoxDestinationFolderExists, &QCheckBox::toggled, this,&CopyEngine::setCheckDestinationFolderExists);
connect(ui->mkpath, &QCheckBox::toggled, this,&CopyEngine::setMkFullPath);
connect(ui->checksum, &QCheckBox::toggled, this,&CopyEngine::setChecksum);
#ifdef ULTRACOPIER_PLUGIN_RSYNC
connect(ui->rsync, &QCheckBox::toggled, this,&CopyEngine::setRsync);
#endif
connect(ui->renameTheOriginalDestination, &QCheckBox::toggled, this,&CopyEngine::setRenameTheOriginalDestination);
connect(filters, &Filters::haveNewFilters, this,&CopyEngine::sendNewFilters);
connect(ui->filters, &QPushButton::clicked, this,&CopyEngine::showFilterDialog);
connect(ui->inodeThreads, &QSpinBox::editingFinished, this,&CopyEngine::inodeThreadsFinished);
connect(ui->inodeThreads, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,&CopyEngine::setInodeThreads);
connect(ui->defaultDestinationFolderBrowse, &QPushButton::clicked, this,&CopyEngine::defaultDestinationFolderBrowse);
connect(ui->comboBoxFolderError, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,&CopyEngine::setFolderError);
connect(ui->comboBoxFolderCollision, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,&CopyEngine::setFolderCollision);
connect(ui->comboBoxFileError, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,&CopyEngine::setFileError);
connect(ui->comboBoxFileCollision, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,&CopyEngine::setFileCollision);
if(!connect(renamingRules,&RenamingRules::sendNewRenamingRules,this,&CopyEngine::sendNewRenamingRules))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect sendNewRenamingRules()");
if(!connect(ui->renamingRules,&QPushButton::clicked,this,&CopyEngine::showRenamingRules))
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"unable to connect renamingRules.clicked()");
}
if(!filters->setFilters(includeStrings,includeOptions,excludeStrings,excludeOptions))
{
includeStrings.clear();
includeOptions.clear();
excludeStrings.clear();
excludeOptions.clear();
set_setFilters(includeStrings,includeOptions,excludeStrings,excludeOptions);
}
renamingRules->setRenamingRules(firstRenamingRule,otherRenamingRule);
emit send_sendNewRenamingRules(firstRenamingRule,otherRenamingRule);
}
bool CopyEngine::haveSameSource(const std::vector<std::string> &sources)
{
return listThread->haveSameSource(sources);
}
bool CopyEngine::haveSameDestination(const std::string &destination)
{
return listThread->haveSameDestination(destination);
}
std::string CopyEngine::stringimplode(const std::vector<std::string>& elems, const std::string &delim)
{
std::string newString;
for (std::vector<std::string>::const_iterator ii = elems.begin(); ii != elems.cend(); ++ii)
{
newString += (*ii);
if ( ii + 1 != elems.end() ) {
newString += delim;
}
}
return newString;
}
bool CopyEngine::newCopy(const std::vector<std::string> &sources)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,stringimplode(sources,", "));
if(forcedMode && mode!=Ultracopier::Copy)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"The engine is forced to move, you can't copy with it");
QMessageBox::critical(NULL,QString::fromStdString(facilityEngine->translateText("Internal error")),tr("The engine is forced to move, you can't copy with it"));
return false;
}
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
std::string destination;
if(!defaultDestinationFolder.empty() && QDir(QString::fromStdString(defaultDestinationFolder)).exists())
destination = defaultDestinationFolder;
else
destination = askDestination();
if(destination.empty())
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"Canceled by the user");
return false;
}
return listThread->newCopy(sources,destination);
}
bool CopyEngine::newCopy(const std::vector<std::string> &sources,const std::string &destination)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,stringimplode(sources,", ")+" "+destination);
if(forcedMode && mode!=Ultracopier::Copy)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"The engine is forced to move, you can't copy with it");
QMessageBox::critical(NULL,QString::fromStdString(facilityEngine->translateText("Internal error")),tr("The engine is forced to move, you can't copy with it"));
return false;
}
return listThread->newCopy(sources,destination);
}
#ifdef ULTRACOPIER_PLUGIN_DEBUG
bool stringStartWithC(std::string const &fullString, std::string const &starting)
{
if (fullString.length() >= starting.length()) {
return (fullString.substr(0,starting.length())==starting);
} else {
return false;
}
}
#endif
bool CopyEngine::newMove(const std::vector<std::string> &sources)
{
#ifdef ULTRACOPIER_PLUGIN_DEBUG
{
std::regex base_regex("^[a-z][a-z][a-z]*:/.*");
std::smatch base_match;
unsigned int index=0;
while(index<sources.size())
{
std::string source=sources.at(index);
//can be: file://192.168.0.99/share/file.txt
//can be: file:///C:/file.txt
//can be: file:///home/user/fileatrootunderunix
#ifndef Q_OS_WIN
if(stringStartWithC(source,"file:///"))
source.replace(0,7,"");
#else
if(stringStartWithC(source,"file:///"))
source.replace(0,8,"");
else if(stringStartWithC(source,"file://"))
source.replace(0,5,"");
else if(stringStartWithC(source,"file:/"))
source.replace(0,6,"");
#endif
if(index<99)
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,sources.at(index)+" -> "+source);
index++;
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"source is_file: "+std::to_string(TransferThread::is_file(TransferThread::stringToInternalString(source)))+" is_dir: "+std::to_string(TransferThread::is_dir(TransferThread::stringToInternalString(source))));
}
}
#endif
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,stringimplode(sources,", "));
if(forcedMode && mode!=Ultracopier::Move)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"The engine is forced to copy, you can't move with it");
QMessageBox::critical(NULL,QString::fromStdString(facilityEngine->translateText("Internal error")),tr("The engine is forced to copy, you can't move with it"));
return false;
}
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
std::string destination;
if(!ui->defaultDestinationFolder->text().isEmpty() && QDir(ui->defaultDestinationFolder->text()).exists())
destination = ui->defaultDestinationFolder->text().toStdString();
else
destination = askDestination();
if(destination.empty())
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"Canceled by the user");
return false;
}
return listThread->newMove(sources,destination);
}
bool CopyEngine::newMove(const std::vector<std::string> &sources,const std::string &destination)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,stringimplode(sources,", ")+" "+destination);
if(forcedMode && mode!=Ultracopier::Move)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"The engine is forced to copy, you can't move with it");
QMessageBox::critical(NULL,QString::fromStdString(facilityEngine->translateText("Internal error")),tr("The engine is forced to copy, you can't move with it"));
return false;
}
return listThread->newMove(sources,destination);
}
void CopyEngine::defaultDestinationFolderBrowse()
{
std::string destination = askDestination();
if(destination.empty())
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"Canceled by the user");
return;
}
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"the value have changed");
if(uiIsInstalled)
ui->defaultDestinationFolder->setText(QString::fromStdString(destination));
}
std::string CopyEngine::askDestination()
{
std::string destination = listThread->getUniqueDestinationFolder();
if(!destination.empty())
{
QMessageBox::StandardButton button=QMessageBox::question(uiinterface,tr("Destination"),tr("Use the actual destination \"%1\"?")
.arg(QString::fromStdString(destination)),
QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes);
if(button==QMessageBox::Yes)
return destination;
}
destination=QFileDialog::getExistingDirectory(uiinterface,QString::fromStdString(facilityEngine->translateText("Select destination directory")),QStringLiteral(""),QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
return destination;
}
void CopyEngine::newTransferList(const std::string &file)
{
emit signal_importTransferList(file);
}
//because direct access to list thread into the main thread can't be do
uint64_t CopyEngine::realByteTransfered()
{
return size_for_speed;
}
//speed limitation
bool CopyEngine::supportSpeedLimitation() const
{
return true;
}
/** \brief to sync the transfer list
* Used when the interface is changed, useful to minimize the memory size */
void CopyEngine::syncTransferList()
{
listThread->syncTransferList();
}
void CopyEngine::set_setFilters(std::vector<std::string> includeStrings,std::vector<std::string> includeOptions,std::vector<std::string> excludeStrings,std::vector<std::string> excludeOptions)
{
if(filters==NULL)
filters=new Filters();
if(filters!=NULL)
{
if(!filters->setFilters(includeStrings,includeOptions,excludeStrings,excludeOptions))
{
includeStrings.clear();
includeOptions.clear();
excludeStrings.clear();
excludeOptions.clear();
}
emit send_setFilters(filters->getInclude(),filters->getExclude());
listThread->set_setFilters(filters->getInclude(),filters->getExclude());
}
this->includeStrings=includeStrings;
this->includeOptions=includeOptions;
this->excludeStrings=excludeStrings;
this->excludeOptions=excludeOptions;
}
void CopyEngine::setRenamingRules(std::string firstRenamingRule,std::string otherRenamingRule)
{
sendNewRenamingRules(firstRenamingRule,otherRenamingRule);
}
bool CopyEngine::userAddFolder(const Ultracopier::CopyMode &mode)
{
std::string source = QFileDialog::getExistingDirectory(uiinterface,QString::fromStdString(facilityEngine->translateText("Select source directory")),
QStringLiteral(""),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
if(source.empty() || source=="")
return false;
std::vector<std::string> sources;
sources.push_back(source);
if(mode==Ultracopier::Copy)
return newCopy(sources);
else
return newMove(sources);
}
bool CopyEngine::userAddFile(const Ultracopier::CopyMode &mode)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
QStringList sources = QFileDialog::getOpenFileNames(
uiinterface,
QString::fromStdString(facilityEngine->translateText("Select one or more files to open")),
QStringLiteral(""),
QString::fromStdString(facilityEngine->translateText("All files"))+QStringLiteral(" (*)"));
std::vector<std::string> sourcesstd;
unsigned int index=0;
while(index<(unsigned int)sources.size())
{
sourcesstd.push_back(sources.at(index).toStdString());
index++;
}
if(sourcesstd.empty())
return false;
if(mode==Ultracopier::Copy)
return newCopy(sourcesstd);
else
return newMove(sourcesstd);
}
void CopyEngine::pause()
{
emit signal_pause();
}
void CopyEngine::resume()
{
emit signal_resume();
}
void CopyEngine::skip(const uint64_t &id)
{
emit signal_skip(id);
}
void CopyEngine::cancel()
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
stopIt=true;
timerProgression.stop();
timerActionDone.stop();
emit tryCancel();
}
void CopyEngine::removeItems(const std::vector<uint64_t> &ids)
{
emit signal_removeItems(ids);
}
void CopyEngine::moveItemsOnTop(const std::vector<uint64_t> &ids)
{
emit signal_moveItemsOnTop(ids);
}
void CopyEngine::moveItemsUp(const std::vector<uint64_t> &ids)
{
emit signal_moveItemsUp(ids);
}
void CopyEngine::moveItemsDown(const std::vector<uint64_t> &ids)
{
emit signal_moveItemsDown(ids);
}
void CopyEngine::moveItemsOnBottom(const std::vector<uint64_t> &ids)
{
emit signal_moveItemsOnBottom(ids);
}
/** \brief give the forced mode, to export/import transfer list */
void CopyEngine::forceMode(const Ultracopier::CopyMode &mode)
{
#ifdef ULTRACOPIER_PLUGIN_RSYNC
if(mode==Ultracopier::Move)
{
listThread->setRsync(false);
rsync=false;
}
if(uiIsInstalled)
ui->rsync->setEnabled(mode==Ultracopier::Copy);
#endif
if(forcedMode)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Mode forced previously");
QMessageBox::critical(NULL,QString::fromStdString(facilityEngine->translateText("Internal error")),tr("The mode has been forced previously. This is an internal error, please report it"));
return;
}
#ifdef ULTRACOPIER_PLUGIN_RSYNC
if(mode==Ultracopier::Move)
rsync=false;
#endif
if(mode==Ultracopier::Copy)
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Force mode to copy");
else
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Force mode to move");
#ifdef ULTRACOPIER_PLUGIN_RSYNC
if(uiIsInstalled)
ui->rsync->setEnabled(mode==Ultracopier::Copy);
#endif
this->mode=mode;
forcedMode=true;
emit signal_forceMode(mode);
}
void CopyEngine::exportTransferList()
{
std::string fileName = QFileDialog::getSaveFileName(uiinterface,QString::fromStdString(facilityEngine->translateText("Save transfer list")),QStringLiteral("transfer-list.lst"),QString::fromStdString(facilityEngine->translateText("Transfer list"))+QStringLiteral(" (*.lst)")).toStdString();
if(fileName.empty())
return;
emit signal_exportTransferList(fileName);
}
void CopyEngine::importTransferList()
{
std::string fileName = QFileDialog::getOpenFileName(uiinterface,QString::fromStdString(facilityEngine->translateText("Open transfer list")),QStringLiteral("transfer-list.lst"),QString::fromStdString(facilityEngine->translateText("Transfer list"))+QStringLiteral(" (*.lst)")).toStdString();
if(fileName.empty())
return;
emit signal_importTransferList(fileName);
}
void CopyEngine::warningTransferList(const std::string &warning)
{
QMessageBox::warning(uiinterface,QString::fromStdString(facilityEngine->translateText("Error")),QString::fromStdString(warning));
}
void CopyEngine::errorTransferList(const std::string &error)
{
QMessageBox::critical(uiinterface,QString::fromStdString(facilityEngine->translateText("Error")),QString::fromStdString(error));
}
bool CopyEngine::setSpeedLimitation(const int64_t &speedLimitation)
{
//ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"maxSpeed: "+std::to_string(speedLimitation));
emit signal_setSpeedLimitation(speedLimitation);
return false;
}
void CopyEngine::setFileCollision(int index)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"action index: "+std::to_string(index));
if(uiIsInstalled)
if(index!=ui->comboBoxFileCollision->currentIndex())
ui->comboBoxFileCollision->setCurrentIndex(index);
switch(index)
{
case 0:
alwaysDoThisActionForFileExists=FileExists_NotSet;
break;
case 1:
alwaysDoThisActionForFileExists=FileExists_Skip;
break;
case 2:
alwaysDoThisActionForFileExists=FileExists_Overwrite;
break;
case 3:
alwaysDoThisActionForFileExists=FileExists_OverwriteIfNotSameMdate;
break;
case 4:
alwaysDoThisActionForFileExists=FileExists_OverwriteIfNewer;
break;
case 5:
alwaysDoThisActionForFileExists=FileExists_OverwriteIfOlder;
break;
case 6:
alwaysDoThisActionForFileExists=FileExists_Rename;
break;
case 7:
alwaysDoThisActionForFileExists=FileExists_OverwriteIfNotSameSize;
break;
case 8:
alwaysDoThisActionForFileExists=FileExists_OverwriteIfNotSameSizeAndDate;
break;
default:
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored: "+std::to_string(index));
alwaysDoThisActionForFileExists=FileExists_NotSet;
break;
}
emit signal_setCollisionAction(alwaysDoThisActionForFileExists);
}
void CopyEngine::setFileError(int index)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"action index: "+std::to_string(index));
if(uiIsInstalled)
if(index!=ui->comboBoxFileError->currentIndex())
ui->comboBoxFileError->setCurrentIndex(index);
switch(index)
{
case 0:
alwaysDoThisActionForFileError=FileError_NotSet;
break;
case 1:
alwaysDoThisActionForFileError=FileError_Skip;
break;
case 2:
alwaysDoThisActionForFileError=FileError_PutToEndOfTheList;
break;
default:
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored: "+std::to_string(index));
alwaysDoThisActionForFileError=FileError_NotSet;
break;
}
//emit signal_setCollisionAction(alwaysDoThisActionForFileExists);
}
void CopyEngine::setRightTransfer(const bool doRightTransfer)
{
this->doRightTransfer=doRightTransfer;
if(uiIsInstalled)
ui->doRightTransfer->setChecked(doRightTransfer);
listThread->setRightTransfer(doRightTransfer);
}
//set keep date
void CopyEngine::setKeepDate(const bool keepDate)
{
this->keepDate=keepDate;
if(uiIsInstalled)
ui->keepDate->setChecked(keepDate);
listThread->setKeepDate(keepDate);
}
void CopyEngine::setOsSpecFlags(const bool os_spec_flags)
{
this->os_spec_flags=os_spec_flags;
if(uiIsInstalled)
ui->os_spec_flags->setChecked(os_spec_flags);
listThread->setOsSpecFlags(os_spec_flags);
}
void CopyEngine::setNativeCopy(const bool native_copy)
{
this->native_copy=native_copy;
if(uiIsInstalled)
{
ui->native_copy->setChecked(native_copy);
#ifndef Q_OS_WIN32
ui->native_copy->setEnabled(false);
ui->label_native_copy->setEnabled(false);
ui->native_copy->setToolTip(tr("Supported only on Windows"));
#endif
}
listThread->setNativeCopy(native_copy);
}
void CopyEngine::setMoveTheWholeFolder(const bool &moveTheWholeFolder)
{
this->moveTheWholeFolder=moveTheWholeFolder;
if(uiIsInstalled)
ui->moveTheWholeFolder->setChecked(moveTheWholeFolder);
emit send_moveTheWholeFolder(moveTheWholeFolder);
}
void CopyEngine::setFollowTheStrictOrder(const bool &followTheStrictOrder)
{
this->followTheStrictOrder=followTheStrictOrder;
if(uiIsInstalled)
ui->followTheStrictOrder->setChecked(followTheStrictOrder);
listThread->setFollowTheStrictOrder(followTheStrictOrder);
emit send_followTheStrictOrder(followTheStrictOrder);
}
void CopyEngine::setDeletePartiallyTransferredFiles(const bool &deletePartiallyTransferredFiles)
{
this->deletePartiallyTransferredFiles=deletePartiallyTransferredFiles;
if(uiIsInstalled)
ui->deletePartiallyTransferredFiles->setChecked(deletePartiallyTransferredFiles);
emit send_deletePartiallyTransferredFiles(deletePartiallyTransferredFiles);
}
void CopyEngine::setInodeThreads(const int &inodeThreads)
{
this->inodeThreads=inodeThreads;
if(uiIsInstalled)
ui->inodeThreads->setValue(inodeThreads);
emit send_setInodeThreads(inodeThreads);
}
void CopyEngine::setRenameTheOriginalDestination(const bool &renameTheOriginalDestination)
{
this->renameTheOriginalDestination=renameTheOriginalDestination;
if(uiIsInstalled)
ui->renameTheOriginalDestination->setChecked(renameTheOriginalDestination);
emit send_setRenameTheOriginalDestination(renameTheOriginalDestination);
}
void CopyEngine::inodeThreadsFinished()
{
this->inodeThreads=ui->inodeThreads->value();
emit send_setInodeThreads(inodeThreads);
}
#ifdef ULTRACOPIER_PLUGIN_RSYNC
/// \brief set rsync
void CopyEngine::setRsync(const bool rsync)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"set rsync: "+std::to_string(rsync));
this->rsync=rsync;
if(uiIsInstalled)
{
ui->rsync->setChecked(rsync);
ui->rsync->setEnabled(forcedMode && mode==Ultracopier::Copy);
ui->label_rsync->setEnabled(forcedMode && mode==Ultracopier::Copy);
}
listThread->setRsync(rsync);
}
#endif
//set check destination folder
void CopyEngine::setCheckDestinationFolderExists(const bool checkDestinationFolderExists)
{
this->checkDestinationFolderExists=checkDestinationFolderExists;
if(uiIsInstalled)
ui->checkBoxDestinationFolderExists->setChecked(checkDestinationFolderExists);
listThread->setCheckDestinationFolderExists(checkDestinationFolderExists);
}
void CopyEngine::setMkFullPath(const bool mkFullPath)
{
this->mkFullPath=mkFullPath;
if(uiIsInstalled)
ui->mkpath->setChecked(mkFullPath);
listThread->setMkFullPath(mkFullPath);
}
void CopyEngine::setChecksum(const bool checksum)
{
this->checksum=checksum;
if(uiIsInstalled)
ui->checksum->setChecked(checksum);
}
//reset widget
void CopyEngine::resetTempWidget()
{
uiIsInstalled=false;
tempWidget=NULL;
}
void CopyEngine::setFolderCollision(int index)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"action index: "+std::to_string(index));
if(uiIsInstalled)
if(index!=ui->comboBoxFolderCollision->currentIndex())
ui->comboBoxFolderCollision->setCurrentIndex(index);
switch(index)
{
case 0:
setComboBoxFolderCollision(FolderExists_NotSet,false);
break;
case 1:
setComboBoxFolderCollision(FolderExists_Merge,false);
break;
case 2:
setComboBoxFolderCollision(FolderExists_Skip,false);
break;
case 3:
setComboBoxFolderCollision(FolderExists_Rename,false);
break;
}
emit signal_setFolderCollision(alwaysDoThisActionForFolderExists);
}
void CopyEngine::setFolderError(int index)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"action index: "+std::to_string(index));
if(uiIsInstalled)
if(index!=ui->comboBoxFolderError->currentIndex())
ui->comboBoxFolderError->setCurrentIndex(index);
switch(index)
{
case 0:
setComboBoxFolderError(FileError_NotSet,false);
break;
case 1:
setComboBoxFolderError(FileError_Skip,false);
break;
}
emit signal_setCollisionAction(alwaysDoThisActionForFileExists);
}
//set the translate
void CopyEngine::newLanguageLoaded()
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, retranslate the widget options");
if(tempWidget!=NULL)
{
ui->retranslateUi(tempWidget);
ui->comboBoxFolderError->setItemText(0,tr("Ask"));
ui->comboBoxFolderError->setItemText(1,tr("Skip"));
ui->comboBoxFolderCollision->setItemText(0,tr("Ask"));
ui->comboBoxFolderCollision->setItemText(1,tr("Merge"));
ui->comboBoxFolderCollision->setItemText(2,tr("Skip"));
ui->comboBoxFolderCollision->setItemText(3,tr("Rename"));
ui->comboBoxFileError->setItemText(0,tr("Ask"));
ui->comboBoxFileError->setItemText(1,tr("Skip"));
ui->comboBoxFileError->setItemText(2,tr("Put at the end"));
ui->comboBoxFileCollision->setItemText(0,tr("Ask"));
ui->comboBoxFileCollision->setItemText(1,tr("Skip"));
ui->comboBoxFileCollision->setItemText(2,tr("Overwrite"));
ui->comboBoxFileCollision->setItemText(3,tr("Overwrite if different"));
ui->comboBoxFileCollision->setItemText(4,tr("Overwrite if newer"));
ui->comboBoxFileCollision->setItemText(5,tr("Overwrite if older"));
ui->comboBoxFileCollision->setItemText(6,tr("Rename"));
}
else
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"ui not loaded!");
}
void CopyEngine::setComboBoxFolderCollision(FolderExistsAction action,bool changeComboBox)
{
alwaysDoThisActionForFolderExists=action;
emit signal_setFolderCollision(alwaysDoThisActionForFolderExists);
if(!changeComboBox || !uiIsInstalled)
return;
switch(action)
{
case FolderExists_Merge:
ui->comboBoxFolderCollision->setCurrentIndex(1);
break;
case FolderExists_Skip:
ui->comboBoxFolderCollision->setCurrentIndex(2);
break;
case FolderExists_Rename:
ui->comboBoxFolderCollision->setCurrentIndex(3);
break;
default:
ui->comboBoxFolderCollision->setCurrentIndex(0);
break;
}
}
void CopyEngine::setComboBoxFolderError(FileErrorAction action,bool changeComboBox)
{
alwaysDoThisActionForFolderError=action;
if(!changeComboBox || !uiIsInstalled)
return;
switch(action)
{
case FileError_Skip:
ui->comboBoxFolderError->setCurrentIndex(1);
break;
default:
ui->comboBoxFolderError->setCurrentIndex(0);
break;
}
}
void CopyEngine::showFilterDialog()
{
if(filters!=NULL)
filters->exec();
}
void CopyEngine::sendNewFilters()
{
if(filters!=NULL)
emit send_setFilters(filters->getInclude(),filters->getExclude());
}
void CopyEngine::sendNewRenamingRules(std::string firstRenamingRule,std::string otherRenamingRule)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"new filter");
this->firstRenamingRule=firstRenamingRule;
this->otherRenamingRule=otherRenamingRule;
emit send_sendNewRenamingRules(firstRenamingRule,otherRenamingRule);
}
void CopyEngine::showRenamingRules()
{
if(renamingRules==NULL)
{
QMessageBox::critical(NULL,tr("Options error"),tr("Options engine is not loaded. Unable to access the filters"));
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"options not loaded");
return;
}
renamingRules->exec();
}
void CopyEngine::get_realBytesTransfered(quint64 realBytesTransfered)
{
size_for_speed=realBytesTransfered;
}
void CopyEngine::newActionInProgess(Ultracopier::EngineActionInProgress action)
{
if(action==Ultracopier::Idle)
{
timerProgression.stop();
timerActionDone.stop();
}
else
{
timerProgression.start();
timerActionDone.start();
}
}
void CopyEngine::setCheckDiskSpace(const bool &checkDiskSpace)
{
this->checkDiskSpace=checkDiskSpace;
if(uiIsInstalled)
ui->checkDiskSpace->setChecked(checkDiskSpace);
listThread->setCheckDiskSpace(checkDiskSpace);
}
void CopyEngine::setBuffer(const bool &buffer)
{
this->buffer=buffer;
if(uiIsInstalled)
ui->buffer->setChecked(buffer);
listThread->setBuffer(buffer);
}
void CopyEngine::setDefaultDestinationFolder(const std::string &defaultDestinationFolder)
{
this->defaultDestinationFolder=defaultDestinationFolder;
if(uiIsInstalled)
ui->defaultDestinationFolder->setText(QString::fromStdString(defaultDestinationFolder));
}
void CopyEngine::exportErrorIntoTransferList()
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"exportErrorIntoTransferList");
std::string fileName = QFileDialog::getSaveFileName(uiinterface,QString::fromStdString(facilityEngine->translateText("Save transfer list")),QStringLiteral("transfer-list.lst"),QString::fromStdString(facilityEngine->translateText("Transfer list"))+QStringLiteral(" (*.lst)")).toStdString();
if(fileName.empty())
return;
emit signal_exportErrorIntoTransferList(fileName);
}
//set auto start
void CopyEngine::setAutoStart(const bool autoStart)
{
this->autoStart=autoStart;
if(uiIsInstalled)
ui->autoStart->setChecked(autoStart);
listThread->setAutoStart(autoStart);
}
|