summaryrefslogtreecommitdiff
path: root/plugins/Themes/Oxygen/TransferModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Themes/Oxygen/TransferModel.cpp')
-rw-r--r--plugins/Themes/Oxygen/TransferModel.cpp155
1 files changed, 96 insertions, 59 deletions
diff --git a/plugins/Themes/Oxygen/TransferModel.cpp b/plugins/Themes/Oxygen/TransferModel.cpp
index d63c4f2..42d2315 100644
--- a/plugins/Themes/Oxygen/TransferModel.cpp
+++ b/plugins/Themes/Oxygen/TransferModel.cpp
@@ -81,16 +81,24 @@ int TransferModel::rowCount( const QModelIndex& parent ) const
return parent == QModelIndex() ? transfertItemList.count() : 0;
}
+quint64 TransferModel::firstId()
+{
+ if(transfertItemList.count()>0)
+ return transfertItemList[0].id;
+ else
+ return 0;
+}
+
QVariant TransferModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
if ( role == Qt::DisplayRole && orientation == Qt::Horizontal && section >= 0 && section < COLUMN_COUNT ) {
switch ( section ) {
case 0:
- return tr( "Source" );
+ return facilityEngine->translateText("Source");
case 1:
- return tr( "Size" );
+ return facilityEngine->translateText("Size");
case 2:
- return tr( "Target" );
+ return facilityEngine->translateText("Destination");
}
}
@@ -164,11 +172,32 @@ QList<quint64> TransferModel::synchronizeItems(const QList<returnActionOnCopyLis
transfertItemList<<newItem;
totalFile++;
totalSize+=action.addAction.size;
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, size: %2, name: %3").arg(action.addAction.id).arg(action.addAction.size).arg(action.addAction.sourceFullPath));
}
break;
case MoveItem:
{
//bool current_entry=
+ if(action.userAction.position<0)
+ {
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.position>(transfertItemList.size()-1))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.moveAt<0)
+ {
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.moveAt>(transfertItemList.size()-1))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
transfertItemList.move(action.userAction.position,action.userAction.moveAt);
}
break;
@@ -176,10 +205,20 @@ QList<quint64> TransferModel::synchronizeItems(const QList<returnActionOnCopyLis
{
if(currentIndexSearch>0 && action.userAction.position<=currentIndexSearch)
currentIndexSearch--;
+ if(action.userAction.position<0)
+ {
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.position>(transfertItemList.size()-1))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
transfertItemList.removeAt(action.userAction.position);
currentFile++;
- startId.removeOne(action.addAction.id);
- stopId.removeOne(action.addAction.id);
+ startId.remove(action.addAction.id);
+ stopId.remove(action.addAction.id);
}
break;
case PreOperation:
@@ -187,43 +226,29 @@ QList<quint64> TransferModel::synchronizeItems(const QList<returnActionOnCopyLis
ItemOfCopyListWithMoreInformations tempItem;
tempItem.currentProgression=0;
tempItem.generalData=action.addAction;
- InternalRunningOperation << tempItem;
+ tempItem.actionType=action.type;
+ internalRunningOperation[action.addAction.id]=tempItem;
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("set for file %1: actionType: PreOperation").arg(action.addAction.id));
}
break;
case Transfer:
{
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("found entry for file %1: actionType: Transfer").arg(action.addAction.id));
if(!startId.contains(action.addAction.id))
startId << action.addAction.id;
- stopId.removeOne(action.addAction.id);
- sub_index_for_loop=0;
- sub_loop_size=InternalRunningOperation.size();
- while(sub_index_for_loop<sub_loop_size)
- {
- if(InternalRunningOperation.at(sub_index_for_loop).generalData.id==action.addAction.id)
- {
- InternalRunningOperation[sub_index_for_loop].actionType=action.type;
- break;
- }
- sub_index_for_loop++;
- }
+ stopId.remove(action.addAction.id);
+ if(internalRunningOperation.contains(action.addAction.id))
+ internalRunningOperation[action.addAction.id].actionType=action.type;
+ else
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("unable to found entry for file %1: actionType: Transfer").arg(action.addAction.id));
}
break;
case PostOperation:
{
if(!stopId.contains(action.addAction.id))
stopId << action.addAction.id;
- startId.removeOne(action.addAction.id);
- sub_index_for_loop=0;
- sub_loop_size=InternalRunningOperation.size();
- while(sub_index_for_loop<sub_loop_size)
- {
- if(InternalRunningOperation.at(sub_index_for_loop).generalData.id==action.addAction.id)
- {
- InternalRunningOperation.removeAt(sub_index_for_loop);
- break;
- }
- sub_index_for_loop++;
- }
+ startId.remove(action.addAction.id);
+ internalRunningOperation.remove(action.addAction.id);
}
break;
case CustomOperation:
@@ -232,29 +257,25 @@ QList<quint64> TransferModel::synchronizeItems(const QList<returnActionOnCopyLis
//without progression
if(custom_with_progression)
{
- if(startId.removeOne(action.addAction.id))
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("switch the file: %1 to custom operation with progression").arg(action.addAction.id));
+ if(startId.remove(action.addAction.id))
if(!stopId.contains(action.addAction.id))
stopId << action.addAction.id;
}
//with progression
else
{
- stopId.removeOne(action.addAction.id);
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("switch the file: %1 to custom operation without progression").arg(action.addAction.id));
+ stopId.remove(action.addAction.id);
if(!startId.contains(action.addAction.id))
startId << action.addAction.id;
}
- sub_index_for_loop=0;
- sub_loop_size=InternalRunningOperation.size();
- while(sub_index_for_loop<sub_loop_size)
+ if(internalRunningOperation.contains(action.addAction.id))
{
- if(InternalRunningOperation.at(sub_index_for_loop).generalData.id==action.addAction.id)
- {
- InternalRunningOperation[sub_index_for_loop].actionType=action.type;
- InternalRunningOperation[sub_index_for_loop].custom_with_progression=custom_with_progression;
- InternalRunningOperation[sub_index_for_loop].currentProgression=0;
- break;
- }
- sub_index_for_loop++;
+ ItemOfCopyListWithMoreInformations &item=internalRunningOperation[action.addAction.id];
+ item.actionType=action.type;
+ item.custom_with_progression=custom_with_progression;
+ item.currentProgression=0;
}
}
break;
@@ -340,35 +361,40 @@ int TransferModel::searchPrev(const QString &text)
return -1;
}
-void TransferModel::setFileProgression(const QList<ProgressionItem> &progressionList)
+void TransferModel::setFileProgression(QList<ProgressionItem> &progressionList)
{
- loop_size=InternalRunningOperation.size();
- sub_loop_size=progressionList.size();
+ loop_size=progressionList.size();
index_for_loop=0;
while(index_for_loop<loop_size)
{
- sub_index_for_loop=0;
- while(sub_index_for_loop<sub_loop_size)
+ if(internalRunningOperation.contains(progressionList.at(index_for_loop).id))
{
- if(progressionList.at(sub_index_for_loop).id==InternalRunningOperation.at(index_for_loop).generalData.id)
- {
- InternalRunningOperation[index_for_loop].generalData.size=progressionList.at(sub_index_for_loop).total;
- InternalRunningOperation[index_for_loop].currentProgression=progressionList.at(sub_index_for_loop).current;
- break;
- }
- sub_index_for_loop++;
+ internalRunningOperation[progressionList.at(index_for_loop).id].generalData.size=progressionList.at(index_for_loop).total;
+ internalRunningOperation[progressionList.at(index_for_loop).id].currentProgression=progressionList.at(index_for_loop).current;
+ #ifdef ULTRACOPIER_PLUGIN_DEBUG
+ progressionList.removeAt(index_for_loop);
+ #endif
}
index_for_loop++;
}
+ #ifdef ULTRACOPIER_PLUGIN_DEBUG
+ if(progressionList.size()>0)
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"progression remaning items");
+ #endif
}
TransferModel::currentTransfertItem TransferModel::getCurrentTransfertItem()
{
currentTransfertItem returnItem;
- returnItem.haveItem=InternalRunningOperation.size()>0;
+ returnItem.haveItem=startId.size()>0;
if(returnItem.haveItem)
{
- const ItemOfCopyListWithMoreInformations &itemTransfer=InternalRunningOperation.first();
+ if(!internalRunningOperation.contains(*startId.constBegin()))
+ {
+ returnItem.haveItem=false;
+ return returnItem;
+ }
+ const ItemOfCopyListWithMoreInformations &itemTransfer=internalRunningOperation[*startId.constBegin()];
returnItem.from=itemTransfer.generalData.sourceFullPath;
returnItem.to=itemTransfer.generalData.destinationFullPath;
returnItem.current_file=itemTransfer.generalData.destinationFileName+", "+facilityEngine->sizeToString(itemTransfer.generalData.size);
@@ -376,13 +402,13 @@ TransferModel::currentTransfertItem TransferModel::getCurrentTransfertItem()
{
case CustomOperation:
if(!itemTransfer.custom_with_progression)
- returnItem.progressBar_file=0;
+ returnItem.progressBar_file=-1;
else
{
if(itemTransfer.generalData.size>0)
returnItem.progressBar_file=((double)itemTransfer.currentProgression/itemTransfer.generalData.size)*65535;
else
- returnItem.progressBar_file=0;
+ returnItem.progressBar_file=-1;
}
break;
case Transfer:
@@ -391,12 +417,23 @@ TransferModel::currentTransfertItem TransferModel::getCurrentTransfertItem()
else
returnItem.progressBar_file=0;
break;
+ //should never pass here
case PostOperation:
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
returnItem.progressBar_file=65535;
break;
+ //should never pass here
+ case PreOperation:
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ returnItem.progressBar_file=0;
+ break;
default:
returnItem.progressBar_file=0;
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("unknow action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ break;
}
}
+/* else
+ ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("No have running item"));*/
return returnItem;
}