summaryrefslogtreecommitdiff
path: root/plugins-alternative/Themes/Teracopy/TransferModel.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2017-11-24 23:24:09 +0000
committerThomas Preud'homme <robotux@celest.fr>2017-11-24 23:24:09 +0000
commitb3c8bdcc0d1e4b2ab298847a7902b6d60410a5bc (patch)
tree8fce8a51adfb245db8ab2a76831661780c0c713e /plugins-alternative/Themes/Teracopy/TransferModel.cpp
parente297dbd8052ef4e66f069e2dd1865ae7fa8af28e (diff)
New upstream version 1.2.3.6
Diffstat (limited to 'plugins-alternative/Themes/Teracopy/TransferModel.cpp')
-rw-r--r--plugins-alternative/Themes/Teracopy/TransferModel.cpp841
1 files changed, 464 insertions, 377 deletions
diff --git a/plugins-alternative/Themes/Teracopy/TransferModel.cpp b/plugins-alternative/Themes/Teracopy/TransferModel.cpp
index 569d31c..24812a0 100644
--- a/plugins-alternative/Themes/Teracopy/TransferModel.cpp
+++ b/plugins-alternative/Themes/Teracopy/TransferModel.cpp
@@ -6,145 +6,146 @@
TransferModel::TransferModel()
{
- iconStart=QIcon(":/resources/player_play.png");
- iconPause=QIcon(":/resources/player_pause.png");
- iconStop=QIcon(":/resources/checkbox.png");
- currentIndexSearch=0;
- haveSearchItem=false;
+ iconStart=QIcon(":/Themes/Teracopy/resources/player_play.png");
+ iconPause=QIcon(":/Themes/Teracopy/resources/player_pause.png");
+ iconStop=QIcon(":/Themes/Teracopy/resources/checkbox.png");
+ currentIndexSearch=0;
+ haveSearchItem=false;
+ facilityEngine=NULL;
}
int TransferModel::columnCount( const QModelIndex& parent ) const
{
- return parent == QModelIndex() ? COLUMN_COUNT : 0;
+ return parent == QModelIndex() ? COLUMN_COUNT : 0;
}
QVariant TransferModel::data( const QModelIndex& index, int role ) const
{
- int row,column;
- row=index.row();
- column=index.column();
- if(index.parent()!=QModelIndex() || row < 0 || row >= transfertItemList.count() || column < 0 || column >= COLUMN_COUNT)
- return QVariant();
+ int row,column;
+ row=index.row();
+ column=index.column();
+ if(index.parent()!=QModelIndex() || row < 0 || row >= transfertItemList.count() || column < 0 || column >= COLUMN_COUNT)
+ return QVariant();
- const transfertItem& item = transfertItemList[row];
- if(role==Qt::UserRole)
- return item.id;
- else if(role==Qt::DisplayRole)
- {
- switch(column)
- {
- case 0:
- return item.source;
- break;
- case 1:
- return item.size;
- break;
- case 2:
- return item.destination;
- break;
- default:
- return QVariant();
- }
- }
- else if(role==Qt::DecorationRole)
- {
- switch(column)
- {
- case 0:
- /*if(item.done)
- return iconStop;
- else */if(stopId.contains(item.id))
- return iconPause;
- else if(startId.contains(item.id))
- return iconStart;
- else
- return QVariant();
- break;
- default:
- return QVariant();
- }
- }
- else if(role==Qt::BackgroundRole)
- {
- if(!search_text.isEmpty() && (item.source.indexOf(search_text,0,Qt::CaseInsensitive)!=-1 || item.destination.indexOf(search_text,0,Qt::CaseInsensitive)!=-1))
- {
- if(haveSearchItem && searchId==item.id)
- return QColor(255,150,150,100);
- else
- return QColor(255,255,0,100);
- }
- else
- return QVariant();
- }
- return QVariant();
+ const transfertItem& item = transfertItemList[row];
+ if(role==Qt::UserRole)
+ return item.id;
+ else if(role==Qt::DisplayRole)
+ {
+ switch(column)
+ {
+ case 0:
+ return item.source;
+ break;
+ case 1:
+ return item.size;
+ break;
+ case 2:
+ return item.destination;
+ break;
+ default:
+ return QVariant();
+ }
+ }
+ else if(role==Qt::DecorationRole)
+ {
+ switch(column)
+ {
+ case 0:
+ /*if(item.done)
+ return iconStop;
+ else */if(stopId.contains(item.id))
+ return iconPause;
+ else if(startId.contains(item.id))
+ return iconStart;
+ else
+ return QVariant();
+ break;
+ default:
+ return QVariant();
+ }
+ }
+ else if(role==Qt::BackgroundRole)
+ {
+ if(!search_text.isEmpty() && (item.source.indexOf(search_text,0,Qt::CaseInsensitive)!=-1 || item.destination.indexOf(search_text,0,Qt::CaseInsensitive)!=-1))
+ {
+ if(haveSearchItem && searchId==item.id)
+ return QColor(255,150,150,100);
+ else
+ return QColor(255,255,0,100);
+ }
+ else
+ return QVariant();
+ }
+ return QVariant();
}
int TransferModel::rowCount( const QModelIndex& parent ) const
{
- return parent == QModelIndex() ? transfertItemList.count() : 0;
+ return parent == QModelIndex() ? transfertItemList.count() : 0;
}
quint64 TransferModel::firstId()
{
- if(transfertItemList.count()>0)
- return transfertItemList[0].id;
- else
- return 0;
+ 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 facilityEngine->translateText("Source");
- case 1:
- return facilityEngine->translateText("Size");
- case 2:
- return facilityEngine->translateText("Destination");
- }
- }
+ if ( role == Qt::DisplayRole && orientation == Qt::Horizontal && section >= 0 && section < COLUMN_COUNT ) {
+ switch ( section ) {
+ case 0:
+ return facilityEngine->translateText("Source");
+ case 1:
+ return facilityEngine->translateText("Size");
+ case 2:
+ return facilityEngine->translateText("Destination");
+ }
+ }
- return QAbstractTableModel::headerData( section, orientation, role );
+ return QAbstractTableModel::headerData( section, orientation, role );
}
bool TransferModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
- row=index.row();
- column=index.column();
- if(index.parent()!=QModelIndex() || row < 0 || row >= transfertItemList.count() || column < 0 || column >= COLUMN_COUNT)
- return false;
+ row=index.row();
+ column=index.column();
+ if(index.parent()!=QModelIndex() || row < 0 || row >= transfertItemList.count() || column < 0 || column >= COLUMN_COUNT)
+ return false;
- transfertItem& item = transfertItemList[row];
- if(role==Qt::UserRole)
- {
- item.id=value.toULongLong();
- return true;
- }
- else if(role==Qt::DisplayRole)
- {
- switch(column)
- {
- case 0:
- item.source=value.toString();
- emit dataChanged(index,index);
- return true;
- break;
- case 1:
- item.size=value.toString();
- emit dataChanged(index,index);
- return true;
- break;
- case 2:
- item.destination=value.toString();
- emit dataChanged(index,index);
- return true;
- break;
- default:
- return false;
- }
- }
- return false;
+ transfertItem& item = transfertItemList[row];
+ if(role==Qt::UserRole)
+ {
+ item.id=value.toULongLong();
+ return true;
+ }
+ else if(role==Qt::DisplayRole)
+ {
+ switch(column)
+ {
+ case 0:
+ item.source=value.toString();
+ emit dataChanged(index,index);
+ return true;
+ break;
+ case 1:
+ item.size=value.toString();
+ emit dataChanged(index,index);
+ return true;
+ break;
+ case 2:
+ item.destination=value.toString();
+ emit dataChanged(index,index);
+ return true;
+ break;
+ default:
+ return false;
+ }
+ }
+ return false;
}
/*
@@ -152,290 +153,376 @@ bool TransferModel::setData( const QModelIndex& index, const QVariant& value, in
Return[1]: totalSize
Return[2]: currentFile
*/
-QList<quint64> TransferModel::synchronizeItems(const QList<returnActionOnCopyList>& returnActions)
+QList<quint64> TransferModel::synchronizeItems(const QList<Ultracopier::ReturnActionOnCopyList>& returnActions)
{
- loop_size=returnActions.size();
- index_for_loop=0;
- totalFile=0;
- totalSize=0;
- currentFile=0;
- emit layoutAboutToBeChanged();
- while(index_for_loop<loop_size)
- {
- const returnActionOnCopyList& action=returnActions.at(index_for_loop);
- switch(action.type)
- {
- case AddingItem:
- {
- transfertItem newItem;
- newItem.id=action.addAction.id;
- newItem.source=action.addAction.sourceFullPath;
- newItem.size=facilityEngine->sizeToString(action.addAction.size);
- newItem.destination=action.addAction.destinationFullPath;
+ loop_size=returnActions.size();
+ index_for_loop=0;
+ totalFile=0;
+ totalSize=0;
+ currentFile=0;
+ emit layoutAboutToBeChanged();
+ while(index_for_loop<loop_size)
+ {
+ const Ultracopier::ReturnActionOnCopyList& action=returnActions.at(index_for_loop);
+ switch(action.type)
+ {
+ case Ultracopier::AddingItem:
+ {
+ transfertItem newItem;
+ newItem.id=action.addAction.id;
+ newItem.source=action.addAction.sourceFullPath;
+ newItem.size=facilityEngine->sizeToString(action.addAction.size);
+ newItem.destination=action.addAction.destinationFullPath;
// newItem.done=false;
- 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;
- case RemoveItem:
- {
- 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.remove(action.addAction.id);
- stopId.remove(action.addAction.id);
- }
- break;
- case PreOperation:
- {
- ItemOfCopyListWithMoreInformations tempItem;
- tempItem.currentProgression=0;
- tempItem.generalData=action.addAction;
- 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.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.remove(action.addAction.id);
- internalRunningOperation.remove(action.addAction.id);
- }
- break;
- case CustomOperation:
- {
- bool custom_with_progression=(action.addAction.size==1);
- //without progression
- if(custom_with_progression)
- {
- if(startId.remove(action.addAction.id))
- if(!stopId.contains(action.addAction.id))
- stopId << action.addAction.id;
- }
- //with progression
- else
- {
- stopId.remove(action.addAction.id);
- if(!startId.contains(action.addAction.id))
- startId << action.addAction.id;
- }
- if(internalRunningOperation.contains(action.addAction.id))
- {
- ItemOfCopyListWithMoreInformations &item=internalRunningOperation[action.addAction.id];
- item.actionType=action.type;
- item.custom_with_progression=custom_with_progression;
- item.currentProgression=0;
- }
- }
- break;
- default:
- //unknow code, ignore it
- break;
- }
- index_for_loop++;
- }
- emit layoutChanged();
- return QList<quint64>() << totalFile << totalSize << currentFile;
+ transfertItemList<<newItem;
+ totalFile++;
+ totalSize+=action.addAction.size;
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, size: %2, name: %3").arg(action.addAction.id).arg(action.addAction.size).arg(action.addAction.sourceFullPath));
+ }
+ break;
+ case Ultracopier::MoveItem:
+ {
+ //bool current_entry=
+ if(action.userAction.position<0)
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.position>(transfertItemList.size()-1))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.moveAt<0)
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.moveAt>(transfertItemList.size()-1))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ transfertItemList.move(action.userAction.position,action.userAction.moveAt);
+ }
+ break;
+ case Ultracopier::RemoveItem:
+ {
+ if(currentIndexSearch>0 && action.userAction.position<=currentIndexSearch)
+ currentIndexSearch--;
+ if(action.userAction.position<0)
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ if(action.userAction.position>(transfertItemList.size()-1))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
+ break;
+ }
+ transfertItemList.removeAt(action.userAction.position);
+ currentFile++;
+ startId.remove(action.addAction.id);
+ stopId.remove(action.addAction.id);
+ internalRunningOperation.remove(action.addAction.id);
+ }
+ break;
+ case Ultracopier::PreOperation:
+ {
+ ItemOfCopyListWithMoreInformations tempItem;
+ tempItem.currentReadProgression=0;
+ tempItem.currentWriteProgression=0;
+ tempItem.generalData=action.addAction;
+ tempItem.actionType=action.type;
+ internalRunningOperation[action.addAction.id]=tempItem;
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("set for file %1: actionType: PreOperation").arg(action.addAction.id));
+ }
+ break;
+ case Ultracopier::Transfer:
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("found entry for file %1: actionType: Transfer").arg(action.addAction.id));
+ if(!startId.contains(action.addAction.id))
+ startId << action.addAction.id;
+ stopId.remove(action.addAction.id);
+ if(internalRunningOperation.contains(action.addAction.id))
+ internalRunningOperation[action.addAction.id].actionType=action.type;
+ else
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to found entry for file %1: actionType: Transfer").arg(action.addAction.id));
+ }
+ break;
+ case Ultracopier::PostOperation:
+ {
+ if(!stopId.contains(action.addAction.id))
+ stopId << action.addAction.id;
+ startId.remove(action.addAction.id);
+ }
+ break;
+ case Ultracopier::CustomOperation:
+ {
+ bool custom_with_progression=(action.addAction.size==1);
+ //without progression
+ if(custom_with_progression)
+ {
+ if(startId.remove(action.addAction.id))
+ if(!stopId.contains(action.addAction.id))
+ stopId << action.addAction.id;
+ }
+ //with progression
+ else
+ {
+ stopId.remove(action.addAction.id);
+ if(!startId.contains(action.addAction.id))
+ startId << action.addAction.id;
+ }
+ if(internalRunningOperation.contains(action.addAction.id))
+ {
+ ItemOfCopyListWithMoreInformations &item=internalRunningOperation[action.addAction.id];
+ item.actionType=action.type;
+ item.custom_with_progression=custom_with_progression;
+ item.currentReadProgression=0;
+ item.currentWriteProgression=0;
+ }
+ }
+ break;
+ default:
+ //unknow code, ignore it
+ break;
+ }
+ index_for_loop++;
+ }
+ emit layoutChanged();
+ return QList<quint64>() << totalFile << totalSize << currentFile;
}
void TransferModel::setFacilityEngine(FacilityInterface * facilityEngine)
{
- this->facilityEngine=facilityEngine;
+ this->facilityEngine=facilityEngine;
}
int TransferModel::search(const QString &text,bool searchNext)
{
- emit layoutAboutToBeChanged();
- search_text=text;
- emit layoutChanged();
- if(transfertItemList.size()==0)
- return -1;
- if(text.isEmpty())
- return -1;
- if(searchNext)
- {
- currentIndexSearch++;
- if(currentIndexSearch>=loop_size)
- currentIndexSearch=0;
- }
- index_for_loop=0;
- loop_size=transfertItemList.size();
- while(index_for_loop<loop_size)
- {
- if(transfertItemList.at(currentIndexSearch).source.indexOf(search_text,0,Qt::CaseInsensitive)!=-1 || transfertItemList.at(currentIndexSearch).destination.indexOf(search_text,0,Qt::CaseInsensitive)!=-1)
- {
- haveSearchItem=true;
- searchId=transfertItemList.at(currentIndexSearch).id;
- return currentIndexSearch;
- }
- currentIndexSearch++;
- if(currentIndexSearch>=loop_size)
- currentIndexSearch=0;
- index_for_loop++;
- }
- haveSearchItem=false;
- return -1;
+ emit layoutAboutToBeChanged();
+ search_text=text;
+ emit layoutChanged();
+ if(transfertItemList.size()==0)
+ return -1;
+ if(text.isEmpty())
+ return -1;
+ if(searchNext)
+ {
+ currentIndexSearch++;
+ if(currentIndexSearch>=loop_size)
+ currentIndexSearch=0;
+ }
+ index_for_loop=0;
+ loop_size=transfertItemList.size();
+ while(index_for_loop<loop_size)
+ {
+ if(transfertItemList.at(currentIndexSearch).source.indexOf(search_text,0,Qt::CaseInsensitive)!=-1 || transfertItemList.at(currentIndexSearch).destination.indexOf(search_text,0,Qt::CaseInsensitive)!=-1)
+ {
+ haveSearchItem=true;
+ searchId=transfertItemList.at(currentIndexSearch).id;
+ return currentIndexSearch;
+ }
+ currentIndexSearch++;
+ if(currentIndexSearch>=loop_size)
+ currentIndexSearch=0;
+ index_for_loop++;
+ }
+ haveSearchItem=false;
+ return -1;
}
int TransferModel::searchPrev(const QString &text)
{
- emit layoutAboutToBeChanged();
- search_text=text;
- emit layoutChanged();
- if(transfertItemList.size()==0)
- return -1;
- if(text.isEmpty())
- return -1;
- if(currentIndexSearch==0)
- currentIndexSearch=loop_size-1;
- else
- currentIndexSearch--;
- index_for_loop=0;
- loop_size=transfertItemList.size();
- while(index_for_loop<loop_size)
- {
- if(transfertItemList.at(currentIndexSearch).source.indexOf(search_text,0,Qt::CaseInsensitive)!=-1 || transfertItemList.at(currentIndexSearch).destination.indexOf(search_text,0,Qt::CaseInsensitive)!=-1)
- {
- haveSearchItem=true;
- searchId=transfertItemList.at(currentIndexSearch).id;
- return currentIndexSearch;
- }
- if(currentIndexSearch==0)
- currentIndexSearch=loop_size-1;
- else
- currentIndexSearch--;
- index_for_loop++;
- }
- haveSearchItem=false;
- return -1;
+ emit layoutAboutToBeChanged();
+ search_text=text;
+ emit layoutChanged();
+ if(transfertItemList.size()==0)
+ return -1;
+ if(text.isEmpty())
+ return -1;
+ if(currentIndexSearch==0)
+ currentIndexSearch=loop_size-1;
+ else
+ currentIndexSearch--;
+ index_for_loop=0;
+ loop_size=transfertItemList.size();
+ while(index_for_loop<loop_size)
+ {
+ if(transfertItemList.at(currentIndexSearch).source.indexOf(search_text,0,Qt::CaseInsensitive)!=-1 || transfertItemList.at(currentIndexSearch).destination.indexOf(search_text,0,Qt::CaseInsensitive)!=-1)
+ {
+ haveSearchItem=true;
+ searchId=transfertItemList.at(currentIndexSearch).id;
+ return currentIndexSearch;
+ }
+ if(currentIndexSearch==0)
+ currentIndexSearch=loop_size-1;
+ else
+ currentIndexSearch--;
+ index_for_loop++;
+ }
+ haveSearchItem=false;
+ return -1;
}
-void TransferModel::setFileProgression(QList<ProgressionItem> &progressionList)
+void TransferModel::setFileProgression(QList<Ultracopier::ProgressionItem> &progressionList)
{
- loop_size=progressionList.size();
- index_for_loop=0;
- while(index_for_loop<loop_size)
- {
- if(internalRunningOperation.contains(progressionList.at(index_for_loop).id))
- {
- 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
+ loop_size=progressionList.size();
+ index_for_loop=0;
+ while(index_for_loop<loop_size)
+ {
+ if(internalRunningOperation.contains(progressionList.at(index_for_loop).id))
+ {
+ internalRunningOperation[progressionList.at(index_for_loop).id].generalData.size=progressionList.at(index_for_loop).total;
+ internalRunningOperation[progressionList.at(index_for_loop).id].currentReadProgression=progressionList.at(index_for_loop).currentRead;
+ internalRunningOperation[progressionList.at(index_for_loop).id].currentWriteProgression=progressionList.at(index_for_loop).currentWrite;
+ #ifdef ULTRACOPIER_PLUGIN_DEBUG
+ progressionList.removeAt(index_for_loop);
+ index_for_loop--;
+ loop_size--;
+ #endif
+ }
+ index_for_loop++;
+ }
+ #ifdef ULTRACOPIER_PLUGIN_DEBUG
+ if(progressionList.size()>0)
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"progression remaning items");
+ #endif
}
TransferModel::currentTransfertItem TransferModel::getCurrentTransfertItem()
{
- currentTransfertItem returnItem;
- returnItem.haveItem=startId.size()>0;
- if(returnItem.haveItem)
- {
- 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);
- switch(itemTransfer.actionType)
- {
- case CustomOperation:
- if(!itemTransfer.custom_with_progression)
- returnItem.progressBar_file=-1;
- else
- {
- if(itemTransfer.generalData.size>0)
- returnItem.progressBar_file=((double)itemTransfer.currentProgression/itemTransfer.generalData.size)*65535;
- else
- returnItem.progressBar_file=-1;
- }
- break;
- case Transfer:
- if(itemTransfer.generalData.size>0)
- returnItem.progressBar_file=((double)itemTransfer.currentProgression/itemTransfer.generalData.size)*65535;
- 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;
+ currentTransfertItem returnItem;
+ returnItem.progressBar_read=-1;
+ returnItem.progressBar_write=0;
+ returnItem.haveItem=startId.size()>0;
+ if(returnItem.haveItem)
+ {
+ 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);
+ returnItem.id=itemTransfer.generalData.id;
+ switch(itemTransfer.actionType)
+ {
+ case Ultracopier::CustomOperation:
+ if(!itemTransfer.custom_with_progression)
+ returnItem.progressBar_read=-1;
+ else
+ {
+ if(itemTransfer.generalData.size>0)
+ {
+ returnItem.progressBar_read=((double)itemTransfer.currentReadProgression/itemTransfer.generalData.size)*65535;
+ returnItem.progressBar_write=((double)itemTransfer.currentWriteProgression/itemTransfer.generalData.size)*65535;
+ }
+ else
+ returnItem.progressBar_read=-1;
+ }
+ break;
+ case Ultracopier::Transfer:
+ if(itemTransfer.generalData.size>0)
+ {
+ returnItem.progressBar_read=((double)itemTransfer.currentReadProgression/itemTransfer.generalData.size)*65535;
+ returnItem.progressBar_write=((double)itemTransfer.currentWriteProgression/itemTransfer.generalData.size)*65535;
+ }
+ else
+ {
+ returnItem.progressBar_read=0;
+ returnItem.progressBar_write=0;
+ }
+ break;
+ //should never pass here
+ case Ultracopier::PostOperation:
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ returnItem.progressBar_read=65535;
+ returnItem.progressBar_write=65535;
+ break;
+ //should never pass here
+ case Ultracopier::PreOperation:
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ returnItem.progressBar_read=0;
+ returnItem.progressBar_write=0;
+ break;
+ default:
+ returnItem.progressBar_read=0;
+ returnItem.progressBar_write=0;
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unknow action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ break;
+ }
+ }
+ else
+ {
+ returnItem.haveItem=stopId.size()>0;
+ if(returnItem.haveItem)
+ {
+ if(!internalRunningOperation.contains(*stopId.constBegin()))
+ {
+ returnItem.haveItem=false;
+ return returnItem;
+ }
+ const ItemOfCopyListWithMoreInformations &itemTransfer=internalRunningOperation[*stopId.constBegin()];
+ returnItem.from=itemTransfer.generalData.sourceFullPath;
+ returnItem.to=itemTransfer.generalData.destinationFullPath;
+ returnItem.current_file=itemTransfer.generalData.destinationFileName+", "+facilityEngine->sizeToString(itemTransfer.generalData.size);
+ returnItem.id=itemTransfer.generalData.id;
+ switch(itemTransfer.actionType)
+ {
+ case Ultracopier::CustomOperation:
+ if(!itemTransfer.custom_with_progression)
+ returnItem.progressBar_read=-1;
+ else
+ {
+ if(itemTransfer.generalData.size>0)
+ {
+ returnItem.progressBar_read=((double)itemTransfer.currentReadProgression/itemTransfer.generalData.size)*65535;
+ returnItem.progressBar_write=((double)itemTransfer.currentWriteProgression/itemTransfer.generalData.size)*65535;
+ }
+ else
+ returnItem.progressBar_read=-1;
+ }
+ break;
+ case Ultracopier::Transfer:
+ if(itemTransfer.generalData.size>0)
+ {
+ returnItem.progressBar_read=((double)itemTransfer.currentReadProgression/itemTransfer.generalData.size)*65535;
+ returnItem.progressBar_write=((double)itemTransfer.currentWriteProgression/itemTransfer.generalData.size)*65535;
+ }
+ else
+ {
+ returnItem.progressBar_read=0;
+ returnItem.progressBar_write=0;
+ }
+ break;
+ case Ultracopier::PostOperation:
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ returnItem.progressBar_read=65535;
+ returnItem.progressBar_write=65535;
+ break;
+ //should never pass here
+ case Ultracopier::PreOperation:
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ returnItem.progressBar_read=0;
+ returnItem.progressBar_write=0;
+ break;
+ default:
+ returnItem.progressBar_read=65535;
+ returnItem.progressBar_write=65535;
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unknow action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
+ break;
+ }
+ }
+ }
+ if(returnItem.haveItem && returnItem.progressBar_read!=-1 && returnItem.progressBar_write>returnItem.progressBar_read)
+ {
+ int tempVar=returnItem.progressBar_write;
+ returnItem.progressBar_write=returnItem.progressBar_read;
+ returnItem.progressBar_read=tempVar;
+ }
+ return returnItem;
}