You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

filetask.cpp 1.4 kB

9 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include "filetask.h"
  2. FileTask::FileTask()
  3. {
  4. }
  5. FileTask::FileTask(shared_ptr<FileContent> fileContent, FileTaskType type)
  6. :mContent(fileContent), mType(type)
  7. {
  8. mNotifySize = fileContent->size/100;//每1%通知一次
  9. const int minNotifySize = 102400;//至少变化了100k才通知
  10. if (mNotifySize < minNotifySize)
  11. mNotifySize = minNotifySize;
  12. }
  13. void FileTask::setObserver(IFileTaskObserver *observer)
  14. {
  15. mObserver = observer;
  16. }
  17. void FileTask::setProcess(int val)
  18. {
  19. mProcess = val;
  20. if (mProcess - mLastProcess >= mNotifySize)
  21. {
  22. mLastProcess = mProcess;
  23. mObserver->onProgress(this);
  24. }
  25. }
  26. void FileTask::setState(FileTaskState val, const string &msg)
  27. {
  28. mState = val;
  29. mMsg = msg;
  30. mObserver->onStateChanged(this);
  31. }
  32. void FileTask::setFellow(shared_ptr<Fellow> fellow)
  33. {
  34. mFellow = fellow;
  35. }
  36. void FileTask::cancel()
  37. {
  38. mCancelPending=true;
  39. }
  40. bool FileTask::hasCancelPending()
  41. {
  42. return mCancelPending;
  43. }
  44. shared_ptr<Fellow> FileTask::fellow() const
  45. {
  46. return mFellow;
  47. }
  48. int FileTask::getProcess() const
  49. {
  50. return mProcess;
  51. }
  52. FileTaskState FileTask::getState() const
  53. {
  54. return mState;
  55. }
  56. string FileTask::getDetailInfo() const
  57. {
  58. return mMsg;
  59. }
  60. shared_ptr<FileContent> FileTask::getContent() const
  61. {
  62. return mContent;
  63. }
  64. FileTaskType FileTask::type() const
  65. {
  66. return mType;
  67. }

mac下的“飞秋”大多数只是飞鸽传书协议,而且未发现令人满意的开源项目,所以基于c++与qt实现了基础的飞秋协议。

Contributors (1)