colorhandler.cpp 960 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "colorhandler.h"
  2. #include <gitbranch.h>
  3. #include <gitrepository.h>
  4. #include <QDateTime>
  5. ColorHandler::ColorHandler()
  6. {
  7. qsrand(QDateTime::currentMSecsSinceEpoch());
  8. for(int i = 0; i < m_colors.size(); i++) {
  9. }
  10. }
  11. QString ColorHandler::color(const GitOid& oid)
  12. {
  13. return m_colors.value(oid);
  14. }
  15. void ColorHandler::updateColors(GitRepository* repo)
  16. {
  17. int red = 0;
  18. int green = 0;
  19. int blue = 0;
  20. BranchContainer &branches = repo->branches();
  21. foreach(GitBranch* branch, branches) {
  22. red = qrand() % 205 + 50;
  23. green = qrand() % 205 + 50;
  24. blue = qrand() % 205 + 50;
  25. m_colors[branch->oid()] = QString::number(red, 16) + QString::number(green, 16) + QString::number(blue, 16);
  26. }
  27. red = qrand() % 205 + 50;
  28. green = qrand() % 205 + 50;
  29. blue = qrand() % 205 + 50;
  30. m_colors[repo->head()] = QString::number(red, 16) + QString::number(green, 16) + QString::number(blue, 16);
  31. }