コード例 #1
0
        public CoverageView(QWidget parent, String fileName) : base(parent)
        {
            SetRootIsDecorated(true);
            AddColumn("Classes");
            AddColumn("Lines Hit");
            AddColumn("Lines Missed");
            AddColumn("Coverage");

            sourceViews = new Hashtable();

            // TODO: Why the cast ?
            SetColumnAlignment(1, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment(2, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment(3, (int)Qt.AlignmentFlags.AlignCenter);

            QObject.Connect(this, SIGNAL("doubleClicked(QListViewItem)"),
                            this, SLOT("OnDoubleClick(QListViewItem)"));

            QObject.Connect(this,SIGNAL("expanded(QListViewItem)"),
                            this,SLOT("OnExpanded(QListViewItem)"));

            // TODO: This is not supported by current Qt#
            try {
                QObject.Connect(this,SIGNAL("contextMenuRequested(QListViewItem,QPoint,int)"),
                                this,SLOT("OnContextMenu(QListViewItem, QPoint, Int32)"));
            }
            catch (Exception) {
            }

            QPixmap namespaceOpenPixmap   = new QPixmap(namespace_open_xpm);
            QPixmap namespaceClosedPixmap = new QPixmap(namespace_closed_xpm);
            QPixmap classPixmap           = new QPixmap(class_xpm);

            model = new CoverageModel();
            foreach (string filter in DEFAULT_FILTERS)
            {
                model.AddFilter(filter);
            }
            model.ReadFromFile(fileName);

            QListViewItem rootItem = new TreeItem(this,"PROJECT",model);

            rootItem.SetOpen(true);

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable();

            foreach (string name in classes2.Keys)
            {
                ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

                if (klass.filtered)
                {
                    continue;
                }

                string        namespace2 = klass.name_space;
                NamespaceItem nsItem     = (NamespaceItem)namespaces [namespace2];
                if (nsItem == null)
                {
                    // Create namespaces
                    String        nsPrefix   = "";
                    QListViewItem parentItem = rootItem;
                    foreach (String nsPart in namespace2.Split('.'))
                    {
                        if (nsPrefix == "")
                        {
                            nsPrefix = nsPart;
                        }
                        else
                        {
                            nsPrefix = nsPrefix + "." + nsPart;
                        }

                        NamespaceCoverageItem nsModel = (NamespaceCoverageItem)model.Namespaces [nsPrefix];
                        if (nsModel.filtered)
                        {
                            break;
                        }

                        nsItem = (NamespaceItem)namespaces [nsPrefix];
                        if (nsItem == null)
                        {
                            nsItem = new NamespaceItem(parentItem,nsPrefix,
                                                       nsModel);
                            nsItem.SetOpen(true);
                            nsItem.SetPixmap(0,namespaceOpenPixmap);
                            namespaces [nsPrefix] = nsItem;
                        }
                        parentItem = nsItem;
                    }
                }

                if (nsItem != null)
                {
                    ClassItem classItem = new ClassItem(nsItem,klass.name,klass);
                    classItem.SetPixmap(0,classPixmap);
                    if (klass.ChildCount > 0)
                    {
                        classItem.SetExpandable(true);
                    }
                }
            }
        }
コード例 #2
0
ファイル: CoverageView.cs プロジェクト: bennidhamma/monocov
        public CoverageView(QWidget parent, String fileName)
            : base(parent)
        {
            SetRootIsDecorated (true);
            AddColumn ("Classes");
            AddColumn ("Lines Hit");
            AddColumn ("Lines Missed");
            AddColumn ("Coverage");

            sourceViews = new Hashtable ();

            // TODO: Why the cast ?
            SetColumnAlignment (1, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment (2, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment (3, (int)Qt.AlignmentFlags.AlignCenter);

            QObject.Connect (this, SIGNAL ("doubleClicked(QListViewItem)"),
                         this, SLOT ("OnDoubleClick(QListViewItem)"));

            QObject.Connect (this, SIGNAL ("expanded(QListViewItem)"),
                         this, SLOT ("OnExpanded(QListViewItem)"));

            // TODO: This is not supported by current Qt#
            try {
            QObject.Connect (this, SIGNAL ("contextMenuRequested(QListViewItem,QPoint,int)"),
                             this, SLOT ("OnContextMenu(QListViewItem, QPoint, Int32)"));
            }
            catch (Exception) {
            }

            QPixmap namespaceOpenPixmap = new QPixmap (namespace_open_xpm);
            QPixmap namespaceClosedPixmap = new QPixmap (namespace_closed_xpm);
            QPixmap classPixmap = new QPixmap (class_xpm);

            model = new CoverageModel ();
            foreach (string filter in DEFAULT_FILTERS) {
            model.AddFilter (filter);
            }
            model.ReadFromFile (fileName);

            QListViewItem rootItem = new TreeItem (this, "PROJECT", model);
            rootItem.SetOpen (true);

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable ();

            foreach (string name in classes2.Keys) {
            ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

            if (klass.filtered)
                continue;

            string namespace2 = klass.name_space;
            NamespaceItem nsItem = (NamespaceItem)namespaces [namespace2];
            if (nsItem == null) {
                // Create namespaces
                String nsPrefix = "";
                QListViewItem parentItem = rootItem;
                foreach (String nsPart in namespace2.Split ('.')) {
                    if (nsPrefix == "")
                        nsPrefix = nsPart;
                    else
                        nsPrefix = nsPrefix + "." + nsPart;

                    NamespaceCoverageItem nsModel = (NamespaceCoverageItem)model.Namespaces [nsPrefix];
                    if (nsModel.filtered)
                        break;

                    nsItem = (NamespaceItem)namespaces [nsPrefix];
                    if (nsItem == null) {
                        nsItem = new NamespaceItem (parentItem, nsPrefix,
                                                    nsModel);
                        nsItem.SetOpen (true);
                        nsItem.SetPixmap (0, namespaceOpenPixmap);
                        namespaces [nsPrefix] = nsItem;
                    }
                    parentItem = nsItem;
                }
            }

            if (nsItem != null) {
                ClassItem classItem = new ClassItem (nsItem, klass.name, klass);
                classItem.SetPixmap (0, classPixmap);
                if (klass.ChildCount > 0)
                    classItem.SetExpandable (true);
            }
            }
        }