Example #1
0
        public SourceWindow(QWidget parent, ClassItem klass)
            : base(parent, "", WidgetFlags.WType_TopLevel)
        {
            SetCaption (klass.Model.sourceFile.sourceFile);
            Resize (640, 480);

            QBoxLayout layout =
            new QBoxLayout (this, 0);

            editor = new QTextEdit (this);
            editor.SetTextFormat (TextFormat.PlainText);
            editor.SetReadOnly (true);
            editor.SetFamily ("misc-fixed");
            editor.SetPointSize (13);
            editor.SetWordWrap (QTextEdit.WordWrap.NoWrap);
            layout.AddWidget (editor);

            int[] coverage = klass.Model.sourceFile.Coverage;

            StreamReader infile = new StreamReader (klass.Model.sourceFile.sourceFile);
            int pos = 1;
            QColor deadColor = editor.Color ();
            QColor hitColor = new QColor ("blue");
            QColor missedColor = new QColor ("red");
            while (infile.Peek () > -1) {
            if (pos < coverage.Length) {
                int count = coverage [pos];
                if (count > 0)
                    editor.SetColor (hitColor);
                else if (count == 0)
                    editor.SetColor (missedColor);
                else
                    editor.SetColor (deadColor);
            }
            else
                editor.SetColor (deadColor);
            editor.Append (String.Format ("{0, 6}", pos) + "  " + infile.ReadLine ());
            pos ++;
            }
            editor.SetCursorPosition (0, 0);
        }
Example #2
0
        private void OnExpanded(QListViewItem item)
        {
            if (item is ClassItem)
            {
                // Create children on-demand
                ClassItem         classItem = (ClassItem)item;
                ClassCoverageItem klass     = classItem.Model;

                if (item.ChildCount() == 0)
                {
                    foreach (MethodCoverageItem method in klass.Methods)
                    {
                        string title = method.name;
                        if (title.Length > 64)
                        {
                            title = title.Substring(0,63) + "...)";
                        }

                        MethodItem methodItem = new MethodItem(classItem,title,method);
                    }
                }
            }
        }
Example #3
0
 private SourceWindow ShowSourceFor(ClassItem item)
 {
     SourceWindow sourceView = (SourceWindow)sourceViews [item.Model.sourceFile];
     if (sourceView != null) {
         sourceView.ShowNormal ();
         sourceView.Raise ();
     }
     else {
         sourceView = new SourceWindow (this, item);
         sourceViews [item.Model.sourceFile] = sourceView;
         sourceView.Show ();
     }
     return sourceView;
 }
Example #4
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);
                    }
                }
            }
        }
Example #5
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);
            }
            }
        }