OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [java/] [src/] [edu/] [byu/] [cc/] [plieber/] [fpgaenet/] [examples/] [NetListModel.java] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
/**
2
 *
3
 */
4
package edu.byu.cc.plieber.fpgaenet.examples;
5
 
6
import java.util.ArrayList;
7
import java.util.Map;
8
 
9
import com.trolltech.qt.core.QModelIndex;
10
import com.trolltech.qt.core.Qt.ItemDataRole;
11
import com.trolltech.qt.core.Qt.Orientation;
12
import com.trolltech.qt.gui.QAbstractTableModel;
13
 
14
import edu.byu.cc.plieber.fpgaenet.debug.LogicalMapping;
15
import edu.byu.cc.plieber.fpgaenet.debug.llparse.LatchRBEntry;
16
 
17
/**
18
 * @author Peter Lieber
19
 *
20
 */
21
public class NetListModel extends QAbstractTableModel {
22
 
23
        LogicalMapping mapping;
24
        ArrayList<LatchRBEntry> netList;
25
        ArrayList<String> netTileList;
26
 
27
        public NetListModel(LogicalMapping mapping) {
28
                this.mapping = mapping;
29
                netList = new ArrayList<LatchRBEntry>();
30
                netTileList = new ArrayList<String>();
31
                for ( Map.Entry<String, LatchRBEntry> entry: mapping.getAllNetMapEntries()) {
32
                        netList.add(entry.getValue());
33
                        netTileList.add(entry.getKey());
34
                }
35
        }
36
 
37
        /* (non-Javadoc)
38
         * @see com.trolltech.qt.core.QAbstractItemModel#columnCount(com.trolltech.qt.core.QModelIndex)
39
         */
40
        @Override
41
        public int columnCount(QModelIndex parent) {
42
                return 5;
43
        }
44
 
45
        /* (non-Javadoc)
46
         * @see com.trolltech.qt.core.QAbstractItemModel#data(com.trolltech.qt.core.QModelIndex, int)
47
         */
48
        @Override
49
        public Object data(QModelIndex index, int role) {
50
                if (role != ItemDataRole.DisplayRole)
51
                        return null;
52
                switch (index.column()) {
53
                case 0:
54
                        return netList.get(index.row()).getFullName();
55
                case 1:
56
                        return String.format("%8h", netList.get(index.row()).getFrame());
57
                case 2:
58
                        return netList.get(index.row()).getFrameOffset();
59
                case 3:
60
                        return netList.get(index.row()).getType();
61
                case 4:
62
                        return netTileList.get(index.row());
63
                default:
64
                        break;
65
                }
66
                return null;
67
        }
68
 
69
        /* (non-Javadoc)
70
         * @see com.trolltech.qt.core.QAbstractItemModel#rowCount(com.trolltech.qt.core.QModelIndex)
71
         */
72
        @Override
73
        public int rowCount(QModelIndex parent) {
74
                return netList.size();
75
        }
76
 
77
        @Override
78
        public Object headerData(int section, Orientation orientation, int role) {
79
                if (role != ItemDataRole.DisplayRole)
80
                        return null;
81
                else if (orientation == Orientation.Vertical) return "";
82
                switch (section) {
83
                case 0:
84
                        return "Name";
85
                case 1:
86
                        return "FAR";
87
                case 2:
88
                        return "Offset";
89
                case 3:
90
                        return "Type";
91
                case 4:
92
                        return "Tile";
93
                default:
94
                        break;
95
                }
96
                return null;
97
        }
98
 
99
        public LatchRBEntry getEntry(QModelIndex index) {
100
                return netList.get(index.row());
101
        }
102
 
103
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.