public override int RowCount(Qyoto.QModelIndex parent) { if (!parent.IsValid()) return ServiceManager.Get<AccountService>().Accounts.Count; else return 0; }
public override QModelIndex Parent(Qyoto.QModelIndex child) { if (!child.IsValid()) return new QModelIndex(); if (child.InternalPointer() is Account) { return new QModelIndex(); } else { BookmarkConference bmark = (BookmarkConference)child.InternalPointer(); Account account = m_AccountService.Accounts.FirstOrDefault(a => a.BookmarkManager.Conferences.Contains(bmark)); if (account != null) return CreateIndex(m_AccountService.Accounts.IndexOf(account), 0, account); else return new QModelIndex(); } }
public override int RowCount(Qyoto.QModelIndex parent) { if (!parent.IsValid()) { return m_AccountService.Accounts.Count; } else { if (parent.InternalPointer() is Account) { Account account = (Account)parent.InternalPointer(); return account.BookmarkManager.Count; } else { return 0; } } }
public override QModelIndex Index(int row, int column, Qyoto.QModelIndex parent) { if (!HasIndex(row, column, parent)) return new QModelIndex(); if (!parent.IsValid()) { Account account = m_AccountService.Accounts[row]; return CreateIndex(row, column, account); } else { Account account = (Account)parent.InternalPointer(); BookmarkConference bmark = account.BookmarkManager.Conferences.ElementAt(row); return CreateIndex(row, column, bmark); } }
public override QVariant Data(Qyoto.QModelIndex index, int role) { if (index.IsValid()) { Account account = (Account)index.InternalPointer(); if (account != null) { if (index.Column() == 0) { if (role == (int)Qt.ItemDataRole.DisplayRole) { return account.Jid.ToString(); } else if (role == (int)Qt.ItemDataRole.CheckStateRole) { return (int)Qt.CheckState.Checked; } } else if (index.Column() == 1) { if (role == (int)Qt.ItemDataRole.DisplayRole) { return account.ConnectionState.ToString(); } } } } return new QVariant(); }