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/] [modmod/] [AvailableModule.java] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
package edu.byu.cc.plieber.fpgaenet.modmod;
2
 
3
import java.util.ArrayList;
4
 
5
import com.trolltech.qt.core.QByteArray;
6
import com.trolltech.qt.core.QMimeData;
7
import com.trolltech.qt.core.QPoint;
8
import com.trolltech.qt.core.Qt;
9
import com.trolltech.qt.gui.*;
10
 
11
public class AvailableModule extends QLabel {
12
 
13
        private ModuleContainer parentContainer;
14
 
15
        public AvailableModule() {
16
                super();
17
                this.setup(null, null);
18
        }
19
 
20
        public AvailableModule(String text, QWidget parent) {
21
                super(text, parent);
22
                this.setup(null, null);
23
        }
24
 
25
        public AvailableModule(String text) {
26
                super(text);
27
                this.setup(null, null);
28
        }
29
 
30
        public AvailableModule(String text, QWidget parent, ModuleControlWidget controlWidget) {
31
                super(text, parent);
32
                this.setup(controlWidget, null);
33
        }
34
 
35
        public AvailableModule(String text, QWidget parent, ModuleControlWidget controlWidget, ArrayList<String> bitstreams) {
36
                super(text, parent);
37
                this.setup(controlWidget, bitstreams);
38
        }
39
 
40
        public AvailableModule(AvailableModule am, QWidget parent) {
41
                super(am.text(), parent);
42
                this.setup(am.getControlWidget(), am.getBitStreams());
43
                this.controlWidget = am.controlWidget;
44
        }
45
 
46
        public AvailableModule(AvailableModule am) {
47
                super(am.text());
48
                this.setup(am.getControlWidget(), am.getBitStreams());
49
                this.controlWidget = am.controlWidget;
50
        }
51
 
52
        private void setup(ModuleControlWidget controlWidget, ArrayList<String> bitstreams) {
53
                this.setFrameShape(QFrame.Shape.Panel);
54
                this.setMinimumSize(80, 80);
55
                this.setMaximumSize(80, 80);
56
                this.setAlignment(Qt.AlignmentFlag.AlignCenter);
57
                this.controlWidget = controlWidget;
58
                this.bitStreams = bitstreams;
59
                this.available = true;
60
        }
61
 
62
        private boolean grabbed = false;
63
        private QPoint grabbedPoint;
64
 
65
        @Override
66
        protected void mouseMoveEvent(QMouseEvent ev) {
67
                if (available && grabbed) {
68
                        QPoint dp = grabbedPoint.subtract(ev.pos());
69
                        if (dp.x() * dp.x() + dp.y() * dp.y() > 16) {
70
                                QDrag drag = new QDrag(this);
71
                                QMimeData mimeData = new QMimeData();
72
                                mimeData.setData("application/x-availablemodule", new QByteArray());
73
                                drag.setMimeData(mimeData);
74
                                QPixmap pixmap = new QPixmap(this.size());
75
                                this.render(pixmap);
76
                                drag.setPixmap(pixmap);
77
                                drag.setObjectName(this.text());
78
                                drag.setHotSpot(ev.pos());
79
                                drag.exec(Qt.DropAction.MoveAction);
80
                                grabbed = false;
81
                        }
82
                }
83
        }
84
 
85
        @Override
86
        protected void mousePressEvent(QMouseEvent ev) {
87
                if (available) {
88
                        grabbed = true;
89
                        grabbedPoint = ev.pos();
90
                }
91
        }
92
 
93
        @Override
94
        protected void mouseReleaseEvent(QMouseEvent ev) {
95
                grabbed = false;
96
                ev.setAccepted(false);
97
        }
98
 
99
        private ModuleControlWidget controlWidget;
100
 
101
        public ModuleControlWidget getControlWidget() {
102
                return controlWidget;
103
        }
104
 
105
        public void setControlWidget(ModuleControlWidget cw) {
106
                controlWidget = cw;
107
        }
108
 
109
        public void setParentContainer(ModuleContainer parent) {
110
                this.parentContainer = parent;
111
        }
112
 
113
        public ModuleContainer getParentContainer() {
114
                return parentContainer;
115
        }
116
 
117
        private boolean available = true;
118
 
119
        public boolean isAvailable() {
120
                return available;
121
        }
122
 
123
        public void setAvailable(boolean available) {
124
                this.available = available;
125
        }
126
 
127
        private ArrayList<String> bitStreams;
128
 
129
        public ArrayList<String> getBitStreams() {
130
                return bitStreams;
131
        }
132
 
133
        public void setBitStreams(ArrayList<String> bitStreams) {
134
                this.bitStreams = bitStreams;
135
        }
136
 
137
}

powered by: WebSVN 2.1.0

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