Permalink
Browse files

added: comparison operator to CFileOperationJob

  • Loading branch information...
1 parent 1557712 commit 75f78a94c07d12cb5b1b824283852f0f5b240661 spiff committed Oct 4, 2012
Showing with 27 additions and 1 deletion.
  1. +24 −0 xbmc/utils/FileOperationJob.cpp
  2. +3 −1 xbmc/utils/FileOperationJob.h
View
24 xbmc/utils/FileOperationJob.cpp
@@ -304,3 +304,27 @@ bool CFileOperationJob::CFileOperation::OnFileCallback(void* pContext, int iperc
return !data->base->ShouldCancel((unsigned)current, 100);
}
+
+bool CFileOperationJob::operator==(const CJob* job) const
+{
+ if (strcmp(job->GetType(),GetType()) == 0)
+ {
+ const CFileOperationJob* rjob = dynamic_cast<const CFileOperationJob*>(job);
+ if (rjob)
+ {
+ if (GetAction() == rjob->GetAction() &&
+ m_strDestFile == rjob->m_strDestFile &&
+ m_items.Size() == rjob->m_items.Size())
+ {
+ for (int i=0;i<m_items.Size();++i)
+ {
+ if (m_items[i]->GetPath() != rjob->m_items[i]->GetPath() ||
+ m_items[i]->IsSelected() != rjob->m_items[i]->IsSelected())
+ return false;
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+}
View
4 xbmc/utils/FileOperationJob.h
@@ -42,12 +42,14 @@ class CFileOperationJob : public CJob
void SetFileOperation(FileAction action, CFileItemList &items, const CStdString &strDestFile);
+ virtual bool operator==(const CJob *job) const;
+
virtual bool DoWork();
const CStdString &GetAverageSpeed() { return m_avgSpeed; }
const CStdString &GetCurrentOperation() { return m_currentOperation; }
const CStdString &GetCurrentFile() { return m_currentFile; }
const CFileItemList &GetItems() { return m_items; }
- FileAction GetAction() { return m_action; }
+ FileAction GetAction() const { return m_action; }
private:
class CFileOperation : public XFILE::IFileCallback
{

0 comments on commit 75f78a9

Please sign in to comment.