accountsitemmodel.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #include "accountsitemmodel.h"
  2. AccountsItemModel::AccountsItemModel( const QString &_accountJid,
  3. const QString &_accountPasswd,
  4. const QString &_accountIcon,
  5. const QString &_accountType,
  6. const QString &_accountResource,
  7. const QString &_accountHost,
  8. const int _accountPort,
  9. const bool _accountDefault,
  10. const bool _manuallyHostPort,
  11. QObject *parent ) :
  12. ListItem(parent),
  13. m_jid(_accountJid),
  14. m_passwd(_accountPasswd),
  15. m_icon(_accountIcon),
  16. m_type(_accountType),
  17. m_resource(_accountResource),
  18. m_host(_accountHost),
  19. m_port(_accountPort),
  20. m_default(_accountDefault),
  21. m_manual_host_port(_manuallyHostPort)
  22. {
  23. }
  24. void AccountsItemModel::setJid(QString &_accountJid)
  25. {
  26. if(m_jid != _accountJid) {
  27. m_jid = _accountJid;
  28. emit dataChanged();
  29. }
  30. }
  31. void AccountsItemModel::setPasswd(QString &_accountPasswd)
  32. {
  33. if(m_passwd != _accountPasswd) {
  34. m_passwd = _accountPasswd;
  35. emit dataChanged();
  36. }
  37. }
  38. void AccountsItemModel::setIcon(QString &_accountIcon)
  39. {
  40. if(m_icon != _accountIcon) {
  41. m_icon = _accountIcon;
  42. emit dataChanged();
  43. }
  44. }
  45. void AccountsItemModel::setDefault(bool &_accountDefault)
  46. {
  47. if(m_default != _accountDefault) {
  48. m_default = _accountDefault;
  49. emit dataChanged();
  50. }
  51. }
  52. void AccountsItemModel::setType(QString &_accountType)
  53. {
  54. if(m_type!= _accountType) {
  55. m_type = _accountType;
  56. emit dataChanged();
  57. }
  58. }
  59. void AccountsItemModel::setResource(QString &_accountResource)
  60. {
  61. if(m_type!= _accountResource) {
  62. m_type = _accountResource;
  63. emit dataChanged();
  64. }
  65. }
  66. void AccountsItemModel::setHost(QString &_accountHost)
  67. {
  68. if(m_host!= _accountHost) {
  69. m_host = _accountHost;
  70. emit dataChanged();
  71. }
  72. }
  73. void AccountsItemModel::setPort(int _accountPort)
  74. {
  75. if(m_port!= _accountPort) {
  76. m_port = _accountPort;
  77. emit dataChanged();
  78. }
  79. }
  80. void AccountsItemModel::setManuallyHostPort(bool _manuallyHostPort)
  81. {
  82. if(m_manual_host_port != _manuallyHostPort) {
  83. m_manual_host_port = _manuallyHostPort;
  84. emit dataChanged();
  85. }
  86. }
  87. QHash<int, QByteArray> AccountsItemModel::roleNames() const
  88. {
  89. QHash<int, QByteArray> names;
  90. names[accJid] = "accJid";
  91. names[accPasswd] = "accPasswd";
  92. names[accIcon] = "accIcon";
  93. names[accDefault] = "accDefault";
  94. names[accType] = "accType";
  95. names[accResource] = "accResource";
  96. names[accHost] = "accHost";
  97. names[accPort] = "accPort";
  98. names[accManualHostPort] = "accManualHostPort";
  99. return names;
  100. }
  101. QVariant AccountsItemModel::data(int role) const
  102. {
  103. switch(role) {
  104. case accJid:
  105. return jid();
  106. case accPasswd:
  107. return passwd();
  108. case accIcon:
  109. return icon();
  110. case accDefault:
  111. return isDefault();
  112. case accType:
  113. return type();
  114. case accResource:
  115. return resource();
  116. case accHost:
  117. return host();
  118. case accPort:
  119. return port();
  120. case accManualHostPort:
  121. return isManuallyHostPort();
  122. default:
  123. return QVariant();
  124. }
  125. }