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.

rankuser.cpp 1.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "rankuser.h"
  2. #define PLUGIN_NAME "rank_user"
  3. REGISTER_PLUGIN(PLUGIN_NAME, RankUser)
  4. RankUser::RankUser()
  5. {
  6. }
  7. void RankUser::init()
  8. {
  9. IPlugin::init();
  10. connect(mFeiq->fellowListWidget(), SIGNAL(select(const Fellow*)), this, SLOT(onTalkTo(const Fellow*)));
  11. mFeiq->fellowListWidget()->setRankPredict(std::bind(&RankUser::compare, this, placeholders::_1, placeholders::_2));
  12. }
  13. void RankUser::unInit()
  14. {
  15. IPlugin::unInit();
  16. mFeiq->settings()->sync();
  17. }
  18. void RankUser::onTalkTo(const Fellow *fellow)
  19. {
  20. mFeiq->settings()->setValue(fellowKey(*fellow), weightOfFellow(*fellow)+1);
  21. }
  22. int RankUser::compare(const Fellow &f1, const Fellow &f2)
  23. {
  24. return weightOfFellow(f1)-weightOfFellow(f2);
  25. }
  26. QString RankUser::fellowId(const Fellow &f)
  27. {
  28. QString ip(f.getIp().c_str());
  29. return ip;
  30. }
  31. QString RankUser::fellowKey(const Fellow &f)
  32. {
  33. return QString(PLUGIN_NAME)+"/"+fellowId(f);
  34. }
  35. int RankUser::weightOfFellow(const Fellow &f)
  36. {
  37. return mFeiq->settings()->value(fellowKey(f), "0", false).toInt();
  38. }

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

Contributors (1)