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());
                }
            }
        }
Beispiel #2
0
 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());
 }
 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 QVariant Data(QModelIndex index, int role)
 {
     object item = index.InternalPointer();
     if (role == (int)Qt.ItemDataRole.DisplayRole) {
         if (item is Account)
             return ((Account)item).Jid.Bare;
         else if (item is BookmarkConference) {
             BookmarkConference conf = (BookmarkConference)item;
             return String.Format("{0} ({1})", conf.ConferenceName, conf.JID);
         }
     }
     return new QVariant();
 }
        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));
            }
        }
Beispiel #6
0
 void on_mucTree_activated(QModelIndex index)
 {
     if (index.IsValid()) {
         if (index.InternalPointer() is BookmarkConference) {
             Account account = (Account)index.Parent().InternalPointer();
             BookmarkConference conf = (BookmarkConference)index.InternalPointer();
             try {
                 account.JoinMuc(conf.JID, conf.Password);
             } catch (UserException e) {
                 QMessageBox.Critical(this.TopLevelWidget(), "Synapse", e.Message);
             }
         }
     }
 }
            public override int RowCount(QModelIndex parent)
            {
                string start = "Row count of " + this.SerializeModelIndex(parent) + " requested";

                SolutionItem parentItem;
                if (parent.Column() > 0)
                {
                    m_Log.Debug(start + " (answer: 0).");
                    return 0;
                }

                if (!parent.IsValid())
                    parentItem = this.m_RootItem;
                else
                    parentItem = parent.InternalPointer() as SolutionItem;

                m_Log.Debug(start + " (answer: " + parentItem.Count + ").");
                return parentItem.Count;
            }
            public override QModelIndex Parent(QModelIndex child)
            {
                string start = "Parent of " + this.SerializeModelIndex(child) + " requested";

                if (!child.IsValid())
                {
                    m_Log.Debug(start + " (answer: empty).");
                    return new QModelIndex();
                }

                SolutionItem childItem = child.InternalPointer() as SolutionItem;
                SolutionItem parentItem = childItem.Parent;

                if (parentItem == this.m_RootItem || parentItem == null)
                {
                    // FIXME: This can cause weirdness with broken trees as the root node
                    // will be placed under folders if the structure is incorrect!
                    m_Log.Debug(start + " (answer: empty).");
                    return new QModelIndex();
                }

                QModelIndex result = this.CreateIndex(parentItem.Index, 0, parentItem);
                m_Log.Debug(start + " (answer: " + this.SerializeModelIndex(result) + ").");
                return result;
            }
            public override QModelIndex Index(int row, int column, QModelIndex parent)
            {
                string start = "Index at " + row + ", " + column + " requested with parent " + this.SerializeModelIndex(parent) + "";

                if (!this.HasIndex(row, column, parent))
                {
                    m_Log.Debug(start + " (answer: empty).");
                    return new QModelIndex();
                }

                SolutionItem parentItem;
                if (!parent.IsValid())
                    parentItem = this.m_RootItem;
                else
                    parentItem = parent.InternalPointer() as SolutionItem;

                SolutionItem childItem = parentItem[row];
                if (childItem != null)
                {
                    QModelIndex model = this.CreateIndex(row, column, childItem);
                    m_Log.Debug(start + " (answer: " + this.SerializeModelIndex(model) + ").");
                    return model;
                }
                else
                {
                    m_Log.Debug(start + " (answer: empty).");
                    return new QModelIndex();
                }
            }
            public override QVariant Data(QModelIndex index, int role)
            {
                string start = "Data of " + this.SerializeModelIndex(index) + " requested with role " + role;

                if (!index.IsValid())
                {
                    m_Log.Debug(start + " (answer: empty).");
                    return new QVariant();
                }

                if (role != (int)ItemDataRole.DisplayRole && role != (int)ItemDataRole.DecorationRole)
                {
                    m_Log.Debug(start + " (answer: empty).");
                    return new QVariant();
                }

                if (index.Column() == 0)
                {
                    if (role == (int)ItemDataRole.DisplayRole)
                    {
                        m_Log.Debug(start + " (answer: \"" + (index.InternalPointer() as SolutionItem).Text + "\").");
                        return (index.InternalPointer() as SolutionItem).Text;
                    }
                    else if (role ==(int)ItemDataRole.DecorationRole)
                    {
                        string key = (index.InternalPointer() as SolutionItem).ImageKey;
                        System.Drawing.Image image = this.m_ExplorerTool.m_LinuxImageList[key];
                        if (image == null)
                            m_Log.Error("No association icon found for image key '" + key + "'.");
                        else
                        {
                            m_Log.Debug(start + " (answer: <qicon>).");
                            return LinuxImageList.ConvertToQIcon(image);
                        }
                    }
                }

                m_Log.Debug(start + " (answer: empty).");
                return new QVariant();
            }