MediatorFileTree.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "MediatorFileTree.h"
  2. /* 文件夹对比界面的中介者,使用中介者是为了让消息经过中介对象统一调度,避免左右互相依赖导致交互混乱
  3. */
  4. MediatorFileTree::MediatorFileTree() :QObject(nullptr)
  5. {
  6. }
  7. MediatorFileTree::~MediatorFileTree()
  8. {
  9. }
  10. void MediatorFileTree::setLeftScrollValue(int value)
  11. {
  12. m_leftScrollValue = value;
  13. //如果左右不相等,则推动对方去同步
  14. if (m_leftScrollValue != m_rightScrollValue)
  15. {
  16. emit syncCurScrollValue(0);
  17. }
  18. }
  19. void MediatorFileTree::setRightScrollValue(int value)
  20. {
  21. m_rightScrollValue = value;
  22. if (m_leftScrollValue != m_rightScrollValue)
  23. {
  24. emit syncCurScrollValue(1);
  25. }
  26. }
  27. int MediatorFileTree::getLeftScrollValue()
  28. {
  29. return m_leftScrollValue;
  30. }
  31. int MediatorFileTree::getRightScrollValue()
  32. {
  33. return m_rightScrollValue;
  34. }
  35. //设置item。中介本身不保存ITEM,因为太多,发送消息给外面空间
  36. void MediatorFileTree::setLeftItemStatus(QString name, int status)
  37. {
  38. emit syncExpandStatus(name, RC_LEFT, status);
  39. }
  40. void MediatorFileTree::setRightItemStatus(QString name, int status)
  41. {
  42. emit syncExpandStatus(name, RC_RIGHT, status);
  43. }