@@ -0,0 +1,153 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #include "qvpushbutton.h" | |||
|
23 | #include <QStylePainter> | |||
|
24 | #include <QMenu> | |||
|
25 | ||||
|
26 | QVPushButton::QVPushButton(QWidget *parent) : | |||
|
27 | QPushButton(parent) | |||
|
28 | { | |||
|
29 | init(); | |||
|
30 | } | |||
|
31 | ||||
|
32 | QVPushButton::QVPushButton(const QString &text, QWidget *parent) | |||
|
33 | { | |||
|
34 | init(); | |||
|
35 | } | |||
|
36 | ||||
|
37 | QVPushButton::QVPushButton(const QIcon &icon, const QString &text, QWidget *parent): | |||
|
38 | QPushButton(parent) | |||
|
39 | { | |||
|
40 | init(); | |||
|
41 | } | |||
|
42 | ||||
|
43 | QVPushButton::~QVPushButton() | |||
|
44 | { | |||
|
45 | ||||
|
46 | } | |||
|
47 | ||||
|
48 | Qt::Orientation QVPushButton::orientation() const | |||
|
49 | { | |||
|
50 | return orientation_; | |||
|
51 | } | |||
|
52 | ||||
|
53 | void QVPushButton::setOrientation(Qt::Orientation orientation) | |||
|
54 | { | |||
|
55 | orientation_ = orientation; | |||
|
56 | switch (orientation) | |||
|
57 | { | |||
|
58 | case Qt::Horizontal: | |||
|
59 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); | |||
|
60 | break; | |||
|
61 | ||||
|
62 | case Qt::Vertical: | |||
|
63 | setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | |||
|
64 | break; | |||
|
65 | } | |||
|
66 | } | |||
|
67 | ||||
|
68 | bool QVPushButton::mirrored() const | |||
|
69 | { | |||
|
70 | return mirrored_; | |||
|
71 | } | |||
|
72 | ||||
|
73 | void QVPushButton::setMirrored(bool mirrored) | |||
|
74 | { | |||
|
75 | mirrored_ = mirrored; | |||
|
76 | } | |||
|
77 | ||||
|
78 | QSize QVPushButton::sizeHint() const | |||
|
79 | { | |||
|
80 | QSize size = QPushButton::sizeHint(); | |||
|
81 | if (orientation_ == Qt::Vertical) | |||
|
82 | size.transpose(); | |||
|
83 | return size; | |||
|
84 | } | |||
|
85 | ||||
|
86 | void QVPushButton::paintEvent(QPaintEvent *event) | |||
|
87 | { | |||
|
88 | Q_UNUSED(event); | |||
|
89 | QStylePainter p(this); | |||
|
90 | ||||
|
91 | switch (orientation_) | |||
|
92 | { | |||
|
93 | case Qt::Horizontal: | |||
|
94 | if (mirrored_) | |||
|
95 | { | |||
|
96 | p.rotate(180); | |||
|
97 | p.translate(-width(), -height()); | |||
|
98 | } | |||
|
99 | break; | |||
|
100 | ||||
|
101 | case Qt::Vertical: | |||
|
102 | if (mirrored_) | |||
|
103 | { | |||
|
104 | p.rotate(-90); | |||
|
105 | p.translate(-height(), 0); | |||
|
106 | } | |||
|
107 | else | |||
|
108 | { | |||
|
109 | p.rotate(90); | |||
|
110 | p.translate(0, -width()); | |||
|
111 | } | |||
|
112 | break; | |||
|
113 | } | |||
|
114 | ||||
|
115 | p.drawControl(QStyle::CE_PushButton, getStyleOption()); | |||
|
116 | } | |||
|
117 | ||||
|
118 | QStyleOptionButton QVPushButton::getStyleOption() const | |||
|
119 | { | |||
|
120 | QStyleOptionButton opt; | |||
|
121 | opt.initFrom(this); | |||
|
122 | if (orientation_ == Qt::Vertical) | |||
|
123 | { | |||
|
124 | QSize size = opt.rect.size(); | |||
|
125 | size.transpose(); | |||
|
126 | opt.rect.setSize(size); | |||
|
127 | } | |||
|
128 | opt.features = QStyleOptionButton::None; | |||
|
129 | if (isFlat()) | |||
|
130 | opt.features |= QStyleOptionButton::Flat; | |||
|
131 | if (menu()) | |||
|
132 | opt.features |= QStyleOptionButton::HasMenu; | |||
|
133 | if (autoDefault() || isDefault()) | |||
|
134 | opt.features |= QStyleOptionButton::AutoDefaultButton; | |||
|
135 | if (isDefault()) | |||
|
136 | opt.features |= QStyleOptionButton::DefaultButton; | |||
|
137 | if (isDown() || (menu() && menu()->isVisible())) | |||
|
138 | opt.state |= QStyle::State_Sunken; | |||
|
139 | if (isChecked()) | |||
|
140 | opt.state |= QStyle::State_On; | |||
|
141 | if (!isFlat() && !isDown()) | |||
|
142 | opt.state |= QStyle::State_Raised; | |||
|
143 | opt.text = text(); | |||
|
144 | opt.icon = icon(); | |||
|
145 | opt.iconSize = iconSize(); | |||
|
146 | return opt; | |||
|
147 | } | |||
|
148 | ||||
|
149 | void QVPushButton::init() | |||
|
150 | { | |||
|
151 | orientation_ = Qt::Horizontal; | |||
|
152 | mirrored_ = false; | |||
|
153 | } |
@@ -0,0 +1,58 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | -- Copied from example http://www.qtcentre.org/wiki/index.php?title=OrientationButton | |||
|
22 | ----------------------------------------------------------------------------*/ | |||
|
23 | #ifndef QVPUSHBUTTON_H | |||
|
24 | #define QVPUSHBUTTON_H | |||
|
25 | ||||
|
26 | #include <QPushButton> | |||
|
27 | #include <QStyleOptionButton> | |||
|
28 | ||||
|
29 | class QVPushButton : public QPushButton | |||
|
30 | { | |||
|
31 | Q_OBJECT | |||
|
32 | public: | |||
|
33 | explicit QVPushButton(QWidget *parent = 0); | |||
|
34 | QVPushButton(const QString& text, QWidget* parent = 0); | |||
|
35 | QVPushButton(const QIcon& icon, const QString& text, QWidget* parent = 0); | |||
|
36 | ~QVPushButton(); | |||
|
37 | ||||
|
38 | Qt::Orientation orientation() const; | |||
|
39 | void setOrientation(Qt::Orientation orientation); | |||
|
40 | ||||
|
41 | bool mirrored() const; | |||
|
42 | void setMirrored(bool mirrored); | |||
|
43 | ||||
|
44 | QSize sizeHint() const; | |||
|
45 | ||||
|
46 | protected: | |||
|
47 | void paintEvent(QPaintEvent* event); | |||
|
48 | ||||
|
49 | private: | |||
|
50 | QStyleOptionButton getStyleOption() const; | |||
|
51 | void init(); | |||
|
52 | ||||
|
53 | Qt::Orientation orientation_; | |||
|
54 | bool mirrored_; | |||
|
55 | ||||
|
56 | }; | |||
|
57 | ||||
|
58 | #endif // QVPUSHBUTTON_H |
@@ -0,0 +1,258 | |||||
|
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
|
2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |||
|
3 | <svg | |||
|
4 | xmlns:dc="http://purl.org/dc/elements/1.1/" | |||
|
5 | xmlns:cc="http://web.resource.org/cc/" | |||
|
6 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||
|
7 | xmlns:svg="http://www.w3.org/2000/svg" | |||
|
8 | xmlns="http://www.w3.org/2000/svg" | |||
|
9 | xmlns:xlink="http://www.w3.org/1999/xlink" | |||
|
10 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||
|
11 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||
|
12 | inkscape:export-ydpi="90.000000" | |||
|
13 | inkscape:export-xdpi="90.000000" | |||
|
14 | inkscape:export-filename="/home/jimmac/Desktop/wi-fi.png" | |||
|
15 | width="48" | |||
|
16 | height="48" | |||
|
17 | id="svg11300" | |||
|
18 | sodipodi:version="0.32" | |||
|
19 | inkscape:version="0.45" | |||
|
20 | sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/emblems" | |||
|
21 | sodipodi:docname="emblem-unreadable.svg" | |||
|
22 | inkscape:output_extension="org.inkscape.output.svg.inkscape" | |||
|
23 | version="1.0"> | |||
|
24 | <defs | |||
|
25 | id="defs3"> | |||
|
26 | <linearGradient | |||
|
27 | inkscape:collect="always" | |||
|
28 | id="linearGradient7000"> | |||
|
29 | <stop | |||
|
30 | style="stop-color:#ffffff;stop-opacity:1;" | |||
|
31 | offset="0" | |||
|
32 | id="stop7002" /> | |||
|
33 | <stop | |||
|
34 | style="stop-color:#ffffff;stop-opacity:0;" | |||
|
35 | offset="1" | |||
|
36 | id="stop7004" /> | |||
|
37 | </linearGradient> | |||
|
38 | <linearGradient | |||
|
39 | inkscape:collect="always" | |||
|
40 | id="linearGradient6964"> | |||
|
41 | <stop | |||
|
42 | style="stop-color:#000000;stop-opacity:1;" | |||
|
43 | offset="0" | |||
|
44 | id="stop6966" /> | |||
|
45 | <stop | |||
|
46 | style="stop-color:#000000;stop-opacity:0;" | |||
|
47 | offset="1" | |||
|
48 | id="stop6968" /> | |||
|
49 | </linearGradient> | |||
|
50 | <linearGradient | |||
|
51 | id="linearGradient2790"> | |||
|
52 | <stop | |||
|
53 | style="stop-color:white;stop-opacity:1;" | |||
|
54 | offset="0" | |||
|
55 | id="stop2792" /> | |||
|
56 | <stop | |||
|
57 | id="stop2798" | |||
|
58 | offset="0.8108108" | |||
|
59 | style="stop-color:#d3d7cf;stop-opacity:1;" /> | |||
|
60 | <stop | |||
|
61 | style="stop-color:#959e8b;stop-opacity:1;" | |||
|
62 | offset="1" | |||
|
63 | id="stop2794" /> | |||
|
64 | </linearGradient> | |||
|
65 | <linearGradient | |||
|
66 | inkscape:collect="always" | |||
|
67 | xlink:href="#linearGradient2790" | |||
|
68 | id="linearGradient6945" | |||
|
69 | x1="4.3764215" | |||
|
70 | y1="0.068979882" | |||
|
71 | x2="19.255854" | |||
|
72 | y2="30.038462" | |||
|
73 | gradientUnits="userSpaceOnUse" | |||
|
74 | gradientTransform="matrix(1.7588235,0,0,1.7588235,6.032353,6.0323539)" /> | |||
|
75 | <radialGradient | |||
|
76 | inkscape:collect="always" | |||
|
77 | xlink:href="#linearGradient6964" | |||
|
78 | id="radialGradient6970" | |||
|
79 | cx="-2" | |||
|
80 | cy="19.5" | |||
|
81 | fx="-2" | |||
|
82 | fy="19.5" | |||
|
83 | r="3" | |||
|
84 | gradientTransform="matrix(1,0,0,0.5,0,9.75)" | |||
|
85 | gradientUnits="userSpaceOnUse" /> | |||
|
86 | <radialGradient | |||
|
87 | inkscape:collect="always" | |||
|
88 | xlink:href="#linearGradient6964" | |||
|
89 | id="radialGradient6972" | |||
|
90 | cx="-2" | |||
|
91 | cy="19.5" | |||
|
92 | fx="-2" | |||
|
93 | fy="19.5" | |||
|
94 | r="3" | |||
|
95 | gradientTransform="matrix(1,0,0,0.5,0,9.75)" | |||
|
96 | gradientUnits="userSpaceOnUse" /> | |||
|
97 | <radialGradient | |||
|
98 | inkscape:collect="always" | |||
|
99 | xlink:href="#linearGradient6964" | |||
|
100 | id="radialGradient6976" | |||
|
101 | gradientUnits="userSpaceOnUse" | |||
|
102 | gradientTransform="matrix(1,0,0,0.5,0,9.75)" | |||
|
103 | cx="-2" | |||
|
104 | cy="19.5" | |||
|
105 | fx="-2" | |||
|
106 | fy="19.5" | |||
|
107 | r="3" /> | |||
|
108 | <linearGradient | |||
|
109 | inkscape:collect="always" | |||
|
110 | xlink:href="#linearGradient7000" | |||
|
111 | id="linearGradient7006" | |||
|
112 | x1="17.838388" | |||
|
113 | y1="19.939341" | |||
|
114 | x2="39.418972" | |||
|
115 | y2="61.80806" | |||
|
116 | gradientUnits="userSpaceOnUse" /> | |||
|
117 | <linearGradient | |||
|
118 | inkscape:collect="always" | |||
|
119 | xlink:href="#linearGradient7000" | |||
|
120 | id="linearGradient7010" | |||
|
121 | gradientUnits="userSpaceOnUse" | |||
|
122 | x1="17.838388" | |||
|
123 | y1="19.939341" | |||
|
124 | x2="27.044603" | |||
|
125 | y2="40.064526" /> | |||
|
126 | </defs> | |||
|
127 | <sodipodi:namedview | |||
|
128 | stroke="#ef2929" | |||
|
129 | fill="#888a85" | |||
|
130 | id="base" | |||
|
131 | pagecolor="#ffffff" | |||
|
132 | bordercolor="#666666" | |||
|
133 | borderopacity="0.25490196" | |||
|
134 | inkscape:pageopacity="0.0" | |||
|
135 | inkscape:pageshadow="2" | |||
|
136 | inkscape:zoom="1" | |||
|
137 | inkscape:cx="118.89613" | |||
|
138 | inkscape:cy="30.767475" | |||
|
139 | inkscape:current-layer="layer1" | |||
|
140 | showgrid="false" | |||
|
141 | inkscape:grid-bbox="false" | |||
|
142 | inkscape:document-units="px" | |||
|
143 | inkscape:showpageshadow="false" | |||
|
144 | inkscape:window-width="908" | |||
|
145 | inkscape:window-height="924" | |||
|
146 | inkscape:window-x="573" | |||
|
147 | inkscape:window-y="126" | |||
|
148 | showborder="false" | |||
|
149 | width="48px" | |||
|
150 | height="48px" | |||
|
151 | borderlayer="true" | |||
|
152 | inkscape:grid-points="false" | |||
|
153 | inkscape:guide-bbox="true" /> | |||
|
154 | <metadata | |||
|
155 | id="metadata4"> | |||
|
156 | <rdf:RDF> | |||
|
157 | <cc:Work | |||
|
158 | rdf:about=""> | |||
|
159 | <dc:format>image/svg+xml</dc:format> | |||
|
160 | <dc:type | |||
|
161 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||
|
162 | <dc:creator> | |||
|
163 | <cc:Agent> | |||
|
164 | <dc:title>Lapo Calamandrei</dc:title> | |||
|
165 | </cc:Agent> | |||
|
166 | </dc:creator> | |||
|
167 | <dc:source /> | |||
|
168 | <cc:license | |||
|
169 | rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" /> | |||
|
170 | <dc:title>Read-only</dc:title> | |||
|
171 | <dc:subject> | |||
|
172 | <rdf:Bag> | |||
|
173 | <rdf:li>emblem</rdf:li> | |||
|
174 | <rdf:li>read-only</rdf:li> | |||
|
175 | <rdf:li>no-read</rdf:li> | |||
|
176 | <rdf:li>locked</rdf:li> | |||
|
177 | <rdf:li>lock</rdf:li> | |||
|
178 | </rdf:Bag> | |||
|
179 | </dc:subject> | |||
|
180 | </cc:Work> | |||
|
181 | <cc:License | |||
|
182 | rdf:about="http://creativecommons.org/licenses/GPL/2.0/"> | |||
|
183 | <cc:permits | |||
|
184 | rdf:resource="http://web.resource.org/cc/Reproduction" /> | |||
|
185 | <cc:permits | |||
|
186 | rdf:resource="http://web.resource.org/cc/Distribution" /> | |||
|
187 | <cc:requires | |||
|
188 | rdf:resource="http://web.resource.org/cc/Notice" /> | |||
|
189 | <cc:permits | |||
|
190 | rdf:resource="http://web.resource.org/cc/DerivativeWorks" /> | |||
|
191 | <cc:requires | |||
|
192 | rdf:resource="http://web.resource.org/cc/ShareAlike" /> | |||
|
193 | <cc:requires | |||
|
194 | rdf:resource="http://web.resource.org/cc/SourceCode" /> | |||
|
195 | </cc:License> | |||
|
196 | </rdf:RDF> | |||
|
197 | </metadata> | |||
|
198 | <g | |||
|
199 | id="layer1" | |||
|
200 | inkscape:label="Layer 1" | |||
|
201 | inkscape:groupmode="layer"> | |||
|
202 | <g | |||
|
203 | id="g6978" | |||
|
204 | style="opacity:0.7238806" | |||
|
205 | transform="matrix(1.8719362,0,0,1.5205944,5.0000002,10.484903)"> | |||
|
206 | <path | |||
|
207 | transform="matrix(2.0312501,0,0,1.2946278,14.455805,-7.7591062)" | |||
|
208 | d="M 1 19.5 A 3 1.5 0 1 1 -5,19.5 A 3 1.5 0 1 1 1 19.5 z" | |||
|
209 | sodipodi:ry="1.5" | |||
|
210 | sodipodi:rx="3" | |||
|
211 | sodipodi:cy="19.5" | |||
|
212 | sodipodi:cx="-2" | |||
|
213 | id="path6974" | |||
|
214 | style="opacity:0.14179107;fill:url(#radialGradient6976);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" | |||
|
215 | sodipodi:type="arc" /> | |||
|
216 | <path | |||
|
217 | transform="matrix(1.6666667,0,0,1.2946278,8.3333333,-6.6568542)" | |||
|
218 | d="M 1 19.5 A 3 1.5 0 1 1 -5,19.5 A 3 1.5 0 1 1 1 19.5 z" | |||
|
219 | sodipodi:ry="1.5" | |||
|
220 | sodipodi:rx="3" | |||
|
221 | sodipodi:cy="19.5" | |||
|
222 | sodipodi:cx="-2" | |||
|
223 | id="path6960" | |||
|
224 | style="opacity:0.2;fill:url(#radialGradient6970);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" | |||
|
225 | sodipodi:type="arc" /> | |||
|
226 | <path | |||
|
227 | transform="matrix(1.6666667,0,0,1.2946278,19.333333,-6.6568542)" | |||
|
228 | d="M 1 19.5 A 3 1.5 0 1 1 -5,19.5 A 3 1.5 0 1 1 1 19.5 z" | |||
|
229 | sodipodi:ry="1.5" | |||
|
230 | sodipodi:rx="3" | |||
|
231 | sodipodi:cy="19.5" | |||
|
232 | sodipodi:cx="-2" | |||
|
233 | id="path6962" | |||
|
234 | style="opacity:0.2;fill:url(#radialGradient6972);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" | |||
|
235 | sodipodi:type="arc" /> | |||
|
236 | </g> | |||
|
237 | <path | |||
|
238 | style="fill:url(#linearGradient6945);fill-opacity:1;fill-rule:evenodd;stroke:#6f716b;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" | |||
|
239 | d="M 14.82647,9.5500008 L 9.55,14.826471 L 19.22353,24.5 L 9.55,34.17353 L 14.82647,39.45 L 24.500002,29.776471 L 34.17352,39.45 L 39.45,34.17353 L 29.77647,24.5 L 39.45,14.826471 L 34.17352,9.5500008 L 24.500002,19.22353 L 14.82647,9.5500008 z " | |||
|
240 | id="path6930" /> | |||
|
241 | <path | |||
|
242 | sodipodi:type="inkscape:offset" | |||
|
243 | inkscape:radius="-1.0514843" | |||
|
244 | inkscape:original="M 14.8125 8.5625 L 9.5625 13.8125 L 19.21875 23.5 L 9.5625 33.1875 L 14.8125 38.4375 L 24.5 28.78125 L 34.1875 38.4375 L 39.4375 33.1875 L 29.78125 23.5 L 39.4375 13.8125 L 34.1875 8.5625 L 24.5 18.21875 L 14.8125 8.5625 z " | |||
|
245 | style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient7006);stroke-width:1.10000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" | |||
|
246 | id="path6996" | |||
|
247 | d="M 14.8125,10.0625 L 11.0625,13.8125 L 19.96875,22.75 C 20.169915,22.947709 20.283223,23.217943 20.283223,23.5 C 20.283223,23.782057 20.169915,24.052291 19.96875,24.25 L 11.0625,33.1875 L 14.8125,36.9375 L 23.75,28.03125 C 23.947709,27.830085 24.217943,27.716777 24.5,27.716777 C 24.782057,27.716777 25.052291,27.830085 25.25,28.03125 L 34.1875,36.9375 L 37.9375,33.1875 L 29.03125,24.25 C 28.830085,24.052291 28.716777,23.782057 28.716777,23.5 C 28.716777,23.217943 28.830085,22.947709 29.03125,22.75 L 37.9375,13.8125 L 34.1875,10.0625 L 25.25,18.96875 C 25.052291,19.169915 24.782057,19.283223 24.5,19.283223 C 24.217943,19.283223 23.947709,19.169915 23.75,18.96875 L 14.8125,10.0625 z " | |||
|
248 | transform="translate(0,1)" /> | |||
|
249 | <path | |||
|
250 | sodipodi:type="inkscape:offset" | |||
|
251 | inkscape:radius="-1.0514843" | |||
|
252 | inkscape:original="M 14.8125 8.5625 L 9.5625 13.8125 L 19.21875 23.5 L 9.5625 33.1875 L 14.8125 38.4375 L 24.5 28.78125 L 34.1875 38.4375 L 39.4375 33.1875 L 29.78125 23.5 L 39.4375 13.8125 L 34.1875 8.5625 L 24.5 18.21875 L 14.8125 8.5625 z " | |||
|
253 | style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient7010);stroke-width:1.10000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" | |||
|
254 | id="path7008" | |||
|
255 | d="M 14.8125,10.0625 L 11.0625,13.8125 L 19.96875,22.75 C 20.169915,22.947709 20.283223,23.217943 20.283223,23.5 C 20.283223,23.782057 20.169915,24.052291 19.96875,24.25 L 11.0625,33.1875 L 14.8125,36.9375 L 23.75,28.03125 C 23.947709,27.830085 24.217943,27.716777 24.5,27.716777 C 24.782057,27.716777 25.052291,27.830085 25.25,28.03125 L 34.1875,36.9375 L 37.9375,33.1875 L 29.03125,24.25 C 28.830085,24.052291 28.716777,23.782057 28.716777,23.5 C 28.716777,23.217943 28.830085,22.947709 29.03125,22.75 L 37.9375,13.8125 L 34.1875,10.0625 L 25.25,18.96875 C 25.052291,19.169915 24.782057,19.283223 24.5,19.283223 C 24.217943,19.283223 23.947709,19.169915 23.75,18.96875 L 14.8125,10.0625 z " | |||
|
256 | transform="translate(0,1)" /> | |||
|
257 | </g> | |||
|
258 | </svg> |
@@ -1,38 +1,59 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
1 | #include "filelist.h" |
|
22 | #include "filelist.h" | |
2 | #include <QMimeData> |
|
23 | #include <QMimeData> | |
3 | #include <QUrl> |
|
24 | #include <QUrl> | |
4 |
|
25 | |||
5 | FileList::FileList(QWidget *parent) : |
|
26 | FileList::FileList(QWidget *parent) : | |
6 | QTableWidget(parent) |
|
27 | QTableWidget(parent) | |
7 | { |
|
28 | { | |
8 | setHorizontalHeaderLabels(QStringList()<<"File"<<"Type"); |
|
29 | setHorizontalHeaderLabels(QStringList()<<"File"<<"Type"); | |
9 | this->setAcceptDrops(true); |
|
30 | this->setAcceptDrops(true); | |
10 | } |
|
31 | } | |
11 |
|
32 | |||
12 | void FileList::dragEnterEvent(QDragEnterEvent *event) |
|
33 | void FileList::dragEnterEvent(QDragEnterEvent *event) | |
13 | { |
|
34 | { | |
14 | event->acceptProposedAction(); |
|
35 | event->acceptProposedAction(); | |
15 | } |
|
36 | } | |
16 |
|
37 | |||
17 | void FileList::dragMoveEvent(QDragMoveEvent *event) |
|
38 | void FileList::dragMoveEvent(QDragMoveEvent *event) | |
18 | { |
|
39 | { | |
19 | event->acceptProposedAction(); |
|
40 | event->acceptProposedAction(); | |
20 | } |
|
41 | } | |
21 |
|
42 | |||
22 | void FileList::dropEvent(QDropEvent *event) |
|
43 | void FileList::dropEvent(QDropEvent *event) | |
23 | { |
|
44 | { | |
24 | const QMimeData* mimeData = event->mimeData(); |
|
45 | const QMimeData* mimeData = event->mimeData(); | |
25 |
|
46 | |||
26 | if (mimeData->hasUrls()) |
|
47 | if (mimeData->hasUrls()) | |
27 | { |
|
48 | { | |
28 | QStringList pathList; |
|
49 | QStringList pathList; | |
29 | QList<QUrl> urlList = mimeData->urls(); |
|
50 | QList<QUrl> urlList = mimeData->urls(); | |
30 |
|
51 | |||
31 | for (int i = 0; i < urlList.size() && i < 32; ++i) |
|
52 | for (int i = 0; i < urlList.size() && i < 32; ++i) | |
32 | { |
|
53 | { | |
33 | pathList.append(urlList.at(i).toLocalFile()); |
|
54 | pathList.append(urlList.at(i).toLocalFile()); | |
34 | } |
|
55 | } | |
35 | emit openFiles(pathList); |
|
56 | emit openFiles(pathList); | |
36 | event->acceptProposedAction(); |
|
57 | event->acceptProposedAction(); | |
37 | } |
|
58 | } | |
38 | } |
|
59 | } |
@@ -1,26 +1,47 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
1 | #ifndef FILELIST_H |
|
22 | #ifndef FILELIST_H | |
2 | #define FILELIST_H |
|
23 | #define FILELIST_H | |
3 |
|
24 | |||
4 | #include <QTableWidget> |
|
25 | #include <QTableWidget> | |
5 | #include <QDropEvent> |
|
26 | #include <QDropEvent> | |
6 | #include <QDragEnterEvent> |
|
27 | #include <QDragEnterEvent> | |
7 | #include <QDragMoveEvent> |
|
28 | #include <QDragMoveEvent> | |
8 | #include <QString> |
|
29 | #include <QString> | |
9 | #include <QStringList> |
|
30 | #include <QStringList> | |
10 |
|
31 | |||
11 | class FileList : public QTableWidget |
|
32 | class FileList : public QTableWidget | |
12 | { |
|
33 | { | |
13 | Q_OBJECT |
|
34 | Q_OBJECT | |
14 | public: |
|
35 | public: | |
15 | explicit FileList(QWidget *parent = 0); |
|
36 | explicit FileList(QWidget *parent = 0); | |
16 | void dragEnterEvent(QDragEnterEvent *event); |
|
37 | void dragEnterEvent(QDragEnterEvent *event); | |
17 | void dragMoveEvent(QDragMoveEvent *event); |
|
38 | void dragMoveEvent(QDragMoveEvent *event); | |
18 | void dropEvent(QDropEvent *event); |
|
39 | void dropEvent(QDropEvent *event); | |
19 |
|
40 | |||
20 | signals: |
|
41 | signals: | |
21 | void openFiles(const QStringList& files); |
|
42 | void openFiles(const QStringList& files); | |
22 | public slots: |
|
43 | public slots: | |
23 |
|
44 | |||
24 | }; |
|
45 | }; | |
25 |
|
46 | |||
26 | #endif // FILELIST_H |
|
47 | #endif // FILELIST_H |
@@ -1,6 +1,7 | |||||
1 | <RCC> |
|
1 | <RCC> | |
2 | <qresource prefix="/img"> |
|
2 | <qresource prefix="/img"> | |
3 | <file>ressources/Gnome-list-add.svg</file> |
|
3 | <file>ressources/Gnome-list-add.svg</file> | |
4 | <file>ressources/Gnome-user-trash.svg</file> |
|
4 | <file>ressources/Gnome-user-trash.svg</file> | |
|
5 | <file>ressources/Gnome-emblem-unreadable.svg</file> | |||
5 | </qresource> |
|
6 | </qresource> | |
6 | </RCC> |
|
7 | </RCC> |
@@ -1,190 +1,228 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
1 | #include "genericbinaryfilewidget.h" |
|
22 | #include "genericbinaryfilewidget.h" | |
2 | #include "ui_genericbinaryfilewidget.h" |
|
23 | #include "ui_genericbinaryfilewidget.h" | |
3 | #include <QFileDialog> |
|
24 | #include <QFileDialog> | |
4 | #include <QFile> |
|
25 | #include <QFile> | |
5 | #include "srec/srecfile.h" |
|
26 | #include "srec/srecfile.h" | |
6 | #include "srec/srecfilewidget.h" |
|
27 | #include "srec/srecfilewidget.h" | |
7 | #include "BinFile/binaryfile.h" |
|
28 | #include "BinFile/binaryfile.h" | |
8 | #include "BinFile/binaryfilewidget.h" |
|
29 | #include "BinFile/binaryfilewidget.h" | |
9 | #include "elf/elffile.h" |
|
30 | #include "elf/elffile.h" | |
10 | #include "elf/elffilewidget.h" |
|
31 | #include "elf/elffilewidget.h" | |
11 |
|
32 | |||
12 |
|
33 | |||
13 | genericBinaryFileWidget::genericBinaryFileWidget(QWidget *parent) : |
|
34 | genericBinaryFileWidget::genericBinaryFileWidget(QWidget *parent) : | |
14 | QWidget(parent), |
|
35 | QWidget(parent), | |
15 | ui(new Ui::genericBinaryFileWidget) |
|
36 | ui(new Ui::genericBinaryFileWidget) | |
16 | { |
|
37 | { | |
17 | ui->setupUi(this); |
|
38 | ui->setupUi(this); | |
|
39 | ui->showFileListQpb->setOrientation(Qt::Vertical); | |||
|
40 | ui->showFileListWdgt->setHidden(true); | |||
18 | connect(this->ui->openFileQpb,SIGNAL(clicked()),this,SLOT(openFile())); |
|
41 | connect(this->ui->openFileQpb,SIGNAL(clicked()),this,SLOT(openFile())); | |
19 | connect(this->ui->removeFileQpb,SIGNAL(clicked()),this,SLOT(removeFiles())); |
|
42 | connect(this->ui->removeFileQpb,SIGNAL(clicked()),this,SLOT(removeFiles())); | |
20 | connect(this->ui->fileList,SIGNAL(cellActivated(int,int)),this,SLOT(fileCellActivated(int,int))); |
|
43 | connect(this->ui->fileList,SIGNAL(cellActivated(int,int)),this,SLOT(fileCellActivated(int,int))); | |
21 | connect(this->ui->fileList,SIGNAL(openFiles(QStringList)),this,SLOT(openFile(QStringList))); |
|
44 | connect(this->ui->fileList,SIGNAL(openFiles(QStringList)),this,SLOT(openFile(QStringList))); | |
|
45 | connect(this->ui->hideFileListQpb,SIGNAL(clicked()),this,SLOT(hideFileList())); | |||
|
46 | connect(this->ui->showFileListQpb,SIGNAL(clicked()),this,SLOT(showFileList())); | |||
|
47 | ||||
22 | } |
|
48 | } | |
23 |
|
49 | |||
24 | genericBinaryFileWidget::~genericBinaryFileWidget() |
|
50 | genericBinaryFileWidget::~genericBinaryFileWidget() | |
25 | { |
|
51 | { | |
26 | delete ui; |
|
52 | delete ui; | |
27 | } |
|
53 | } | |
28 |
|
54 | |||
29 | void genericBinaryFileWidget::openFile() |
|
55 | void genericBinaryFileWidget::openFile() | |
30 | { |
|
56 | { | |
31 | QStringList filesNames = QFileDialog::getOpenFileNames( |
|
57 | QStringList filesNames = QFileDialog::getOpenFileNames( | |
32 | this, |
|
58 | this, | |
33 | "Select one or more files to open", |
|
59 | "Select one or more files to open", | |
34 | NULL, |
|
60 | NULL, | |
35 | "Binary Files (*.bin);;SREC Files (*.srec);;Elf Files (*)"); |
|
61 | "Binary Files (*.bin);;SREC Files (*.srec);;Elf Files (*)"); | |
36 |
|
62 | |||
37 | openFile(filesNames); |
|
63 | openFile(filesNames); | |
38 | } |
|
64 | } | |
39 |
|
65 | |||
40 | void genericBinaryFileWidget::openFile(const QStringList &FileList) |
|
66 | void genericBinaryFileWidget::openFile(const QStringList &FileList) | |
41 | { |
|
67 | { | |
42 | for(int i=0;i<FileList.count();i++) |
|
68 | for(int i=0;i<FileList.count();i++) | |
43 | { |
|
69 | { | |
44 | bool fileOpened = false; |
|
70 | bool fileOpened = false; | |
45 | for(int l=0;l<files.count();l++) |
|
71 | for(int l=0;l<files.count();l++) | |
46 | { |
|
72 | { | |
47 | if(FileList.at(i)==files.at(l)->fileName) |
|
73 | if(FileList.at(i)==files.at(l)->fileName) | |
48 | { |
|
74 | { | |
49 | fileOpened = true; |
|
75 | fileOpened = true; | |
50 | } |
|
76 | } | |
51 | } |
|
77 | } | |
52 | QFile file(FileList.at(i)); |
|
78 | QFile file(FileList.at(i)); | |
53 | if(!fileOpened && file.open(QIODevice::ReadOnly)) |
|
79 | if(!fileOpened && file.open(QIODevice::ReadOnly)) | |
54 | { |
|
80 | { | |
55 | char magic[4]; |
|
81 | char magic[4]; | |
56 | file.read(magic,4); |
|
82 | file.read(magic,4); | |
57 | QString line; |
|
83 | QString line; | |
58 | switch((int)magic[0]) |
|
84 | switch((int)magic[0]) | |
59 | { |
|
85 | { | |
60 | case 0x7F: |
|
86 | case 0x7F: | |
61 | if((magic[1]=='E') && (magic[2]=='L') && (magic[3]=='F')) |
|
87 | if((magic[1]=='E') && (magic[2]=='L') && (magic[3]=='F')) | |
62 | { |
|
88 | { | |
63 | files.append(new FileListElement(FileList.at(i),false,Type_Elf,NULL,NULL)); |
|
89 | files.append(new FileListElement(FileList.at(i),false,Type_Elf,NULL,NULL)); | |
64 | } |
|
90 | } | |
65 | break; |
|
91 | break; | |
66 | case 'S': |
|
92 | case 'S': | |
67 | file.seek(0); |
|
93 | file.seek(0); | |
68 | line = file.readLine(); |
|
94 | line = file.readLine(); | |
69 | if(srecFile::checkSum(line)) |
|
95 | if(srecFile::checkSum(line)) | |
70 | { |
|
96 | { | |
71 | files.append(new FileListElement(FileList.at(i),false,Type_SREC,NULL,NULL)); |
|
97 | files.append(new FileListElement(FileList.at(i),false,Type_SREC,NULL,NULL)); | |
72 | } |
|
98 | } | |
73 | break; |
|
99 | break; | |
74 | default: |
|
100 | default: | |
75 | files.append(new FileListElement(FileList.at(i),false,Type_Bin,NULL,NULL)); |
|
101 | files.append(new FileListElement(FileList.at(i),false,Type_Bin,NULL,NULL)); | |
76 | break; |
|
102 | break; | |
77 | } |
|
103 | } | |
78 | } |
|
104 | } | |
79 | } |
|
105 | } | |
80 | updateFileList(); |
|
106 | updateFileList(); | |
81 | } |
|
107 | } | |
82 |
|
108 | |||
83 | void genericBinaryFileWidget::updateFileList() |
|
109 | void genericBinaryFileWidget::updateFileList() | |
84 | { |
|
110 | { | |
85 | this->ui->fileList->clear(); |
|
111 | this->ui->fileList->clear(); | |
86 | this->ui->fileList->setRowCount(files.count()); |
|
112 | this->ui->fileList->setRowCount(files.count()); | |
87 | this->ui->fileList->setHorizontalHeaderLabels(QStringList()<<"File"<<"Type"); |
|
113 | this->ui->fileList->setHorizontalHeaderLabels(QStringList()<<"File"<<"Type"); | |
88 | for(int i=0;i<files.count();i++) |
|
114 | for(int i=0;i<files.count();i++) | |
89 | { |
|
115 | { | |
90 | QTableWidgetItem *newItem = new QTableWidgetItem(files.at(i)->fileName); |
|
116 | QTableWidgetItem *newItem = new QTableWidgetItem(files.at(i)->fileName); | |
91 | newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable); |
|
117 | newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable); | |
92 | this->ui->fileList->setItem(i, 0, newItem); |
|
118 | this->ui->fileList->setItem(i, 0, newItem); | |
93 |
|
119 | |||
94 | newItem = new QTableWidgetItem(files.at(i)->type()); |
|
120 | newItem = new QTableWidgetItem(files.at(i)->type()); | |
95 | newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable); |
|
121 | newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable); | |
96 | this->ui->fileList->setItem(i, 1, newItem); |
|
122 | this->ui->fileList->setItem(i, 1, newItem); | |
97 | } |
|
123 | } | |
98 | this->ui->fileList->resizeColumnsToContents(); |
|
124 | this->ui->fileList->resizeColumnsToContents(); | |
99 | } |
|
125 | } | |
100 |
|
126 | |||
101 | void genericBinaryFileWidget::removeFiles() |
|
127 | void genericBinaryFileWidget::removeFiles() | |
102 | { |
|
128 | { | |
103 | QList<QTableWidgetItem*> items = this->ui->fileList->selectedItems(); |
|
129 | QList<QTableWidgetItem*> items = this->ui->fileList->selectedItems(); | |
104 | for(int i=0;i<items.count();i++) |
|
130 | for(int i=0;i<items.count();i++) | |
105 | { |
|
131 | { | |
106 | QString filename = this->ui->fileList->item(items.at(i)->row(),0)->text(); |
|
132 | QString filename = this->ui->fileList->item(items.at(i)->row(),0)->text(); | |
107 | for(int l=0;l<files.count();l++) |
|
133 | for(int l=0;l<files.count();l++) | |
108 | { |
|
134 | { | |
109 | if(files.at(l)->fileName==filename) |
|
135 | if(files.at(l)->fileName==filename) | |
110 | { |
|
136 | { | |
111 | if(files.at(l)->isOpened) |
|
137 | if(files.at(l)->isOpened) | |
112 | { |
|
138 | { | |
113 | for(int m=0;m<this->ui->fileViewerTab->count();m++) |
|
139 | for(int m=0;m<this->ui->fileViewerTab->count();m++) | |
114 | { |
|
140 | { | |
115 | if(this->ui->fileViewerTab->widget(m)==this->files.at(l)->viewer) |
|
141 | if(this->ui->fileViewerTab->widget(m)==this->files.at(l)->viewer) | |
116 | { |
|
142 | { | |
117 | this->ui->fileViewerTab->removeTab(m); |
|
143 | this->ui->fileViewerTab->removeTab(m); | |
118 | } |
|
144 | } | |
119 | } |
|
145 | } | |
120 | delete this->files.at(l)->viewer; |
|
146 | delete this->files.at(l)->viewer; | |
121 | delete this->files.at(l)->parser; |
|
147 | delete this->files.at(l)->parser; | |
122 | } |
|
148 | } | |
123 | delete files.at(l); |
|
149 | delete files.at(l); | |
124 | files.removeAt(l); |
|
150 | files.removeAt(l); | |
125 | } |
|
151 | } | |
126 | } |
|
152 | } | |
127 | } |
|
153 | } | |
128 | updateFileList(); |
|
154 | updateFileList(); | |
129 | } |
|
155 | } | |
130 |
|
156 | |||
131 | void genericBinaryFileWidget::fileCellActivated(int row, int column) |
|
157 | void genericBinaryFileWidget::fileCellActivated(int row, int column) | |
132 | { |
|
158 | { | |
133 | Q_UNUSED(column) |
|
159 | Q_UNUSED(column) | |
134 | QString fileName = this->ui->fileList->item(row,0)->text(); |
|
160 | QString fileName = this->ui->fileList->item(row,0)->text(); | |
135 | if(fileName!="") |
|
161 | if(fileName!="") | |
136 | { |
|
162 | { | |
137 | for(int l=0;l<files.count();l++) |
|
163 | for(int l=0;l<files.count();l++) | |
138 | { |
|
164 | { | |
139 | FileListElement* file = files.at(l); |
|
165 | FileListElement* file = files.at(l); | |
140 | if(file->fileName==fileName) |
|
166 | if(file->fileName==fileName) | |
141 | { |
|
167 | { | |
142 | if(!file->isOpened) |
|
168 | if(!file->isOpened) | |
143 | { |
|
169 | { | |
144 | if(file->parser==NULL) |
|
170 | if(file->parser==NULL) | |
145 | { |
|
171 | { | |
146 | switch (file->FileType) |
|
172 | switch (file->FileType) | |
147 | { |
|
173 | { | |
148 | case Type_Bin: |
|
174 | case Type_Bin: | |
149 | file->parser = new binaryFile(file->fileName); |
|
175 | file->parser = new binaryFile(file->fileName); | |
150 | if(file->viewer==NULL) |
|
176 | if(file->viewer==NULL) | |
151 | { |
|
177 | { | |
152 | file->viewer = new binaryFileWidget(); |
|
178 | file->viewer = new binaryFileWidget(); | |
153 | file->viewer->setFile(file->parser); |
|
179 | file->viewer->setFile(file->parser); | |
154 | this->ui->fileViewerTab->addTab(file->viewer,file->fileName); |
|
180 | this->ui->fileViewerTab->addTab(file->viewer,file->fileName); | |
155 | } |
|
181 | } | |
156 | file->isOpened = true; |
|
182 | file->isOpened = true; | |
157 | break; |
|
183 | break; | |
158 | case Type_Elf: |
|
184 | case Type_Elf: | |
159 | file->parser = new ElfFile(file->fileName); |
|
185 | file->parser = new ElfFile(file->fileName); | |
160 | if(file->viewer==NULL) |
|
186 | if(file->viewer==NULL) | |
161 | { |
|
187 | { | |
162 | file->viewer = new elfFileWidget(); |
|
188 | file->viewer = new elfFileWidget(); | |
163 | file->viewer->setFile(file->parser); |
|
189 | file->viewer->setFile(file->parser); | |
164 | this->ui->fileViewerTab->addTab(file->viewer,file->fileName); |
|
190 | this->ui->fileViewerTab->addTab(file->viewer,file->fileName); | |
165 | } |
|
191 | } | |
166 | file->isOpened = true; |
|
192 | file->isOpened = true; | |
167 | break; |
|
193 | break; | |
168 | case Type_SREC: |
|
194 | case Type_SREC: | |
169 | file->parser = new srecFile(file->fileName); |
|
195 | file->parser = new srecFile(file->fileName); | |
170 | if(file->viewer==NULL) |
|
196 | if(file->viewer==NULL) | |
171 | { |
|
197 | { | |
172 | file->viewer = new srecFileWidget(); |
|
198 | file->viewer = new srecFileWidget(); | |
173 | file->viewer->setFile(file->parser); |
|
199 | file->viewer->setFile(file->parser); | |
174 | this->ui->fileViewerTab->addTab(file->viewer,file->fileName); |
|
200 | this->ui->fileViewerTab->addTab(file->viewer,file->fileName); | |
175 | } |
|
201 | } | |
176 | file->isOpened = true; |
|
202 | file->isOpened = true; | |
177 | break; |
|
203 | break; | |
178 | default: |
|
204 | default: | |
179 | break; |
|
205 | break; | |
180 | } |
|
206 | } | |
181 | } |
|
207 | } | |
182 | } |
|
208 | } | |
183 | } |
|
209 | } | |
184 | } |
|
210 | } | |
185 | } |
|
211 | } | |
186 | } |
|
212 | } | |
187 |
|
213 | |||
|
214 | void genericBinaryFileWidget::hideFileList() | |||
|
215 | { | |||
|
216 | this->ui->fileListGBox->setHidden(true); | |||
|
217 | this->ui->showFileListWdgt->setVisible(true); | |||
|
218 | } | |||
|
219 | ||||
|
220 | void genericBinaryFileWidget::showFileList() | |||
|
221 | { | |||
|
222 | this->ui->fileListGBox->setVisible(true); | |||
|
223 | this->ui->showFileListWdgt->setHidden(true); | |||
|
224 | } | |||
188 |
|
225 | |||
189 |
|
226 | |||
190 |
|
227 | |||
|
228 |
@@ -1,64 +1,87 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
1 | #ifndef GENERICBINARYFILEWIDGET_H |
|
22 | #ifndef GENERICBINARYFILEWIDGET_H | |
2 | #define GENERICBINARYFILEWIDGET_H |
|
23 | #define GENERICBINARYFILEWIDGET_H | |
3 |
|
24 | |||
4 | #include <QWidget> |
|
25 | #include <QWidget> | |
5 | #include <QString> |
|
26 | #include <QString> | |
6 | #include <QStringList> |
|
27 | #include <QStringList> | |
7 | #include <abstractbinfile.h> |
|
28 | #include <abstractbinfile.h> | |
8 |
|
29 | |||
9 | namespace Ui { |
|
30 | namespace Ui { | |
10 | class genericBinaryFileWidget; |
|
31 | class genericBinaryFileWidget; | |
11 | } |
|
32 | } | |
12 |
|
33 | |||
13 | typedef enum {Type_SREC,Type_Bin,Type_Elf}FileTypeEnum; |
|
34 | typedef enum {Type_SREC,Type_Bin,Type_Elf}FileTypeEnum; | |
14 | class FileListElement |
|
35 | class FileListElement | |
15 | { |
|
36 | { | |
16 | public: |
|
37 | public: | |
17 | FileListElement() {} |
|
38 | FileListElement() {} | |
18 | FileListElement(QString fileName,bool isOpened,FileTypeEnum FileType,abstractBinFileWidget* viewer=0,abstractBinFile* parser=0) |
|
39 | FileListElement(QString fileName,bool isOpened,FileTypeEnum FileType,abstractBinFileWidget* viewer=0,abstractBinFile* parser=0) | |
19 | :fileName(fileName),isOpened(isOpened),FileType(FileType),viewer(viewer),parser(parser){} |
|
40 | :fileName(fileName),isOpened(isOpened),FileType(FileType),viewer(viewer),parser(parser){} | |
20 | QString type() |
|
41 | QString type() | |
21 | { |
|
42 | { | |
22 | switch (this->FileType) { |
|
43 | switch (this->FileType) { | |
23 | case Type_SREC: |
|
44 | case Type_SREC: | |
24 | return "Srec"; |
|
45 | return "Srec"; | |
25 | break; |
|
46 | break; | |
26 | case Type_Bin: |
|
47 | case Type_Bin: | |
27 | return "Binary"; |
|
48 | return "Binary"; | |
28 | break; |
|
49 | break; | |
29 | case Type_Elf: |
|
50 | case Type_Elf: | |
30 | return "Elf"; |
|
51 | return "Elf"; | |
31 | break; |
|
52 | break; | |
32 | default: |
|
53 | default: | |
33 | return "Unknow"; |
|
54 | return "Unknow"; | |
34 | break; |
|
55 | break; | |
35 | } |
|
56 | } | |
36 | } |
|
57 | } | |
37 | QString fileName; |
|
58 | QString fileName; | |
38 | bool isOpened; |
|
59 | bool isOpened; | |
39 | FileTypeEnum FileType; |
|
60 | FileTypeEnum FileType; | |
40 | abstractBinFileWidget* viewer; |
|
61 | abstractBinFileWidget* viewer; | |
41 | abstractBinFile* parser; |
|
62 | abstractBinFile* parser; | |
42 | }; |
|
63 | }; | |
43 |
|
64 | |||
44 | class genericBinaryFileWidget : public QWidget |
|
65 | class genericBinaryFileWidget : public QWidget | |
45 | { |
|
66 | { | |
46 | Q_OBJECT |
|
67 | Q_OBJECT | |
47 |
|
68 | |||
48 | public: |
|
69 | public: | |
49 | explicit genericBinaryFileWidget(QWidget *parent = 0); |
|
70 | explicit genericBinaryFileWidget(QWidget *parent = 0); | |
50 | ~genericBinaryFileWidget(); |
|
71 | ~genericBinaryFileWidget(); | |
51 |
|
72 | |||
52 | public slots: |
|
73 | public slots: | |
53 | void openFile(); |
|
74 | void openFile(); | |
54 | void openFile(const QStringList& FileList); |
|
75 | void openFile(const QStringList& FileList); | |
55 | void updateFileList(); |
|
76 | void updateFileList(); | |
56 | void removeFiles(); |
|
77 | void removeFiles(); | |
57 | void fileCellActivated(int row, int column); |
|
78 | void fileCellActivated(int row, int column); | |
|
79 | void hideFileList(); | |||
|
80 | void showFileList(); | |||
58 |
|
81 | |||
59 | private: |
|
82 | private: | |
60 | Ui::genericBinaryFileWidget *ui; |
|
83 | Ui::genericBinaryFileWidget *ui; | |
61 | QList<FileListElement*> files; |
|
84 | QList<FileListElement*> files; | |
62 | }; |
|
85 | }; | |
63 |
|
86 | |||
64 | #endif // GENERICBINARYFILEWIDGET_H |
|
87 | #endif // GENERICBINARYFILEWIDGET_H |
@@ -1,119 +1,249 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>genericBinaryFileWidget</class> |
|
3 | <class>genericBinaryFileWidget</class> | |
4 | <widget class="QWidget" name="genericBinaryFileWidget"> |
|
4 | <widget class="QWidget" name="genericBinaryFileWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>878</width> |
|
9 | <width>878</width> | |
10 | <height>360</height> |
|
10 | <height>360</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="acceptDrops"> |
|
13 | <property name="acceptDrops"> | |
14 | <bool>false</bool> |
|
14 | <bool>false</bool> | |
15 | </property> |
|
15 | </property> | |
16 | <property name="windowTitle"> |
|
16 | <property name="windowTitle"> | |
17 | <string>Form</string> |
|
17 | <string>Form</string> | |
18 | </property> |
|
18 | </property> | |
19 |
<layout class="Q |
|
19 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
20 | <item row="0" column="0"> |
|
20 | <property name="spacing"> | |
|
21 | <number>0</number> | |||
|
22 | </property> | |||
|
23 | <property name="leftMargin"> | |||
|
24 | <number>0</number> | |||
|
25 | </property> | |||
|
26 | <property name="topMargin"> | |||
|
27 | <number>2</number> | |||
|
28 | </property> | |||
|
29 | <property name="rightMargin"> | |||
|
30 | <number>2</number> | |||
|
31 | </property> | |||
|
32 | <property name="bottomMargin"> | |||
|
33 | <number>2</number> | |||
|
34 | </property> | |||
|
35 | <item> | |||
|
36 | <widget class="QWidget" name="showFileListWdgt" native="true"> | |||
|
37 | <layout class="QVBoxLayout" name="verticalLayout"> | |||
|
38 | <property name="margin"> | |||
|
39 | <number>0</number> | |||
|
40 | </property> | |||
|
41 | <item> | |||
|
42 | <widget class="QVPushButton" name="showFileListQpb"> | |||
|
43 | <property name="text"> | |||
|
44 | <string>File list</string> | |||
|
45 | </property> | |||
|
46 | </widget> | |||
|
47 | </item> | |||
|
48 | <item> | |||
|
49 | <spacer name="showFileListVSpacer"> | |||
|
50 | <property name="orientation"> | |||
|
51 | <enum>Qt::Vertical</enum> | |||
|
52 | </property> | |||
|
53 | <property name="sizeHint" stdset="0"> | |||
|
54 | <size> | |||
|
55 | <width>20</width> | |||
|
56 | <height>40</height> | |||
|
57 | </size> | |||
|
58 | </property> | |||
|
59 | </spacer> | |||
|
60 | </item> | |||
|
61 | </layout> | |||
|
62 | </widget> | |||
|
63 | </item> | |||
|
64 | <item> | |||
21 | <widget class="QSplitter" name="splitter"> |
|
65 | <widget class="QSplitter" name="splitter"> | |
22 | <property name="orientation"> |
|
66 | <property name="orientation"> | |
23 | <enum>Qt::Horizontal</enum> |
|
67 | <enum>Qt::Horizontal</enum> | |
24 | </property> |
|
68 | </property> | |
25 |
<widget class="Q |
|
69 | <widget class="QGroupBox" name="fileListGBox"> | |
|
70 | <property name="title"> | |||
|
71 | <string>File list</string> | |||
|
72 | </property> | |||
|
73 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |||
|
74 | <property name="spacing"> | |||
|
75 | <number>2</number> | |||
|
76 | </property> | |||
|
77 | <property name="margin"> | |||
|
78 | <number>2</number> | |||
|
79 | </property> | |||
|
80 | <item> | |||
|
81 | <widget class="QWidget" name="fileListWdgt" native="true"> | |||
26 | <layout class="QGridLayout" name="gridLayout"> |
|
82 | <layout class="QGridLayout" name="gridLayout"> | |
27 | <item row="1" column="0"> |
|
83 | <property name="margin"> | |
|
84 | <number>2</number> | |||
|
85 | </property> | |||
|
86 | <property name="spacing"> | |||
|
87 | <number>2</number> | |||
|
88 | </property> | |||
|
89 | <item row="1" column="3"> | |||
|
90 | <widget class="QPushButton" name="hideFileListQpb"> | |||
|
91 | <property name="minimumSize"> | |||
|
92 | <size> | |||
|
93 | <width>16</width> | |||
|
94 | <height>16</height> | |||
|
95 | </size> | |||
|
96 | </property> | |||
|
97 | <property name="maximumSize"> | |||
|
98 | <size> | |||
|
99 | <width>16</width> | |||
|
100 | <height>16</height> | |||
|
101 | </size> | |||
|
102 | </property> | |||
|
103 | <property name="text"> | |||
|
104 | <string/> | |||
|
105 | </property> | |||
|
106 | <property name="icon"> | |||
|
107 | <iconset resource="genericBinaryFiles.qrc"> | |||
|
108 | <normaloff>:/img/ressources/Gnome-emblem-unreadable.svg</normaloff>:/img/ressources/Gnome-emblem-unreadable.svg</iconset> | |||
|
109 | </property> | |||
|
110 | </widget> | |||
|
111 | </item> | |||
|
112 | <item row="2" column="0" colspan="4"> | |||
|
113 | <widget class="FileList" name="fileList"> | |||
|
114 | <property name="dragEnabled"> | |||
|
115 | <bool>false</bool> | |||
|
116 | </property> | |||
|
117 | <column> | |||
|
118 | <property name="text"> | |||
|
119 | <string>File</string> | |||
|
120 | </property> | |||
|
121 | </column> | |||
|
122 | <column> | |||
|
123 | <property name="text"> | |||
|
124 | <string>Type</string> | |||
|
125 | </property> | |||
|
126 | </column> | |||
|
127 | </widget> | |||
|
128 | </item> | |||
|
129 | <item row="1" column="0" colspan="3"> | |||
|
130 | <spacer name="horizontalSpacer_2"> | |||
|
131 | <property name="orientation"> | |||
|
132 | <enum>Qt::Horizontal</enum> | |||
|
133 | </property> | |||
|
134 | <property name="sizeHint" stdset="0"> | |||
|
135 | <size> | |||
|
136 | <width>40</width> | |||
|
137 | <height>20</height> | |||
|
138 | </size> | |||
|
139 | </property> | |||
|
140 | </spacer> | |||
|
141 | </item> | |||
|
142 | <item row="3" column="1"> | |||
|
143 | <widget class="QPushButton" name="removeFileQpb"> | |||
|
144 | <property name="minimumSize"> | |||
|
145 | <size> | |||
|
146 | <width>32</width> | |||
|
147 | <height>32</height> | |||
|
148 | </size> | |||
|
149 | </property> | |||
|
150 | <property name="maximumSize"> | |||
|
151 | <size> | |||
|
152 | <width>32</width> | |||
|
153 | <height>32</height> | |||
|
154 | </size> | |||
|
155 | </property> | |||
|
156 | <property name="text"> | |||
|
157 | <string/> | |||
|
158 | </property> | |||
|
159 | <property name="icon"> | |||
|
160 | <iconset resource="genericBinaryFiles.qrc"> | |||
|
161 | <normaloff>:/img/ressources/Gnome-user-trash.svg</normaloff>:/img/ressources/Gnome-user-trash.svg</iconset> | |||
|
162 | </property> | |||
|
163 | <property name="iconSize"> | |||
|
164 | <size> | |||
|
165 | <width>24</width> | |||
|
166 | <height>24</height> | |||
|
167 | </size> | |||
|
168 | </property> | |||
|
169 | </widget> | |||
|
170 | </item> | |||
|
171 | <item row="3" column="0"> | |||
28 | <widget class="QPushButton" name="openFileQpb"> |
|
172 | <widget class="QPushButton" name="openFileQpb"> | |
|
173 | <property name="minimumSize"> | |||
|
174 | <size> | |||
|
175 | <width>32</width> | |||
|
176 | <height>32</height> | |||
|
177 | </size> | |||
|
178 | </property> | |||
|
179 | <property name="maximumSize"> | |||
|
180 | <size> | |||
|
181 | <width>32</width> | |||
|
182 | <height>32</height> | |||
|
183 | </size> | |||
|
184 | </property> | |||
29 | <property name="text"> |
|
185 | <property name="text"> | |
30 | <string/> |
|
186 | <string/> | |
31 | </property> |
|
187 | </property> | |
32 | <property name="icon"> |
|
188 | <property name="icon"> | |
33 | <iconset resource="genericBinaryFiles.qrc"> |
|
189 | <iconset resource="genericBinaryFiles.qrc"> | |
34 | <normaloff>:/img/ressources/Gnome-list-add.svg</normaloff>:/img/ressources/Gnome-list-add.svg</iconset> |
|
190 | <normaloff>:/img/ressources/Gnome-list-add.svg</normaloff>:/img/ressources/Gnome-list-add.svg</iconset> | |
35 | </property> |
|
191 | </property> | |
36 | <property name="iconSize"> |
|
192 | <property name="iconSize"> | |
37 | <size> |
|
193 | <size> | |
38 | <width>24</width> |
|
194 | <width>24</width> | |
39 | <height>24</height> |
|
195 | <height>24</height> | |
40 | </size> |
|
196 | </size> | |
41 | </property> |
|
197 | </property> | |
42 | </widget> |
|
198 | </widget> | |
43 | </item> |
|
199 | </item> | |
44 |
<item row=" |
|
200 | <item row="3" column="2" colspan="2"> | |
45 | <widget class="QPushButton" name="removeFileQpb"> |
|
|||
46 | <property name="text"> |
|
|||
47 | <string/> |
|
|||
48 | </property> |
|
|||
49 | <property name="icon"> |
|
|||
50 | <iconset resource="genericBinaryFiles.qrc"> |
|
|||
51 | <normaloff>:/img/ressources/Gnome-user-trash.svg</normaloff>:/img/ressources/Gnome-user-trash.svg</iconset> |
|
|||
52 | </property> |
|
|||
53 | <property name="iconSize"> |
|
|||
54 | <size> |
|
|||
55 | <width>24</width> |
|
|||
56 | <height>24</height> |
|
|||
57 | </size> |
|
|||
58 | </property> |
|
|||
59 | </widget> |
|
|||
60 | </item> |
|
|||
61 | <item row="1" column="2"> |
|
|||
62 | <spacer name="horizontalSpacer"> |
|
201 | <spacer name="horizontalSpacer"> | |
63 | <property name="orientation"> |
|
202 | <property name="orientation"> | |
64 | <enum>Qt::Horizontal</enum> |
|
203 | <enum>Qt::Horizontal</enum> | |
65 | </property> |
|
204 | </property> | |
66 | <property name="sizeHint" stdset="0"> |
|
205 | <property name="sizeHint" stdset="0"> | |
67 | <size> |
|
206 | <size> | |
68 | <width>40</width> |
|
207 | <width>40</width> | |
69 | <height>20</height> |
|
208 | <height>20</height> | |
70 | </size> |
|
209 | </size> | |
71 | </property> |
|
210 | </property> | |
72 | </spacer> |
|
211 | </spacer> | |
73 | </item> |
|
212 | </item> | |
74 | <item row="0" column="0" colspan="3"> |
|
213 | </layout> | |
75 | <widget class="FileList" name="fileList"> |
|
|||
76 | <property name="dragEnabled"> |
|
|||
77 | <bool>false</bool> |
|
|||
78 | </property> |
|
|||
79 | <column> |
|
|||
80 | <property name="text"> |
|
|||
81 | <string>File</string> |
|
|||
82 | </property> |
|
|||
83 | </column> |
|
|||
84 | <column> |
|
|||
85 | <property name="text"> |
|
|||
86 | <string>Type</string> |
|
|||
87 | </property> |
|
|||
88 | </column> |
|
|||
89 | </widget> |
|
214 | </widget> | |
90 | </item> |
|
215 | </item> | |
91 | </layout> |
|
216 | </layout> | |
92 | </widget> |
|
217 | </widget> | |
93 | <widget class="QTabWidget" name="fileViewerTab"> |
|
218 | <widget class="QTabWidget" name="fileViewerTab"> | |
94 | <property name="minimumSize"> |
|
219 | <property name="minimumSize"> | |
95 | <size> |
|
220 | <size> | |
96 | <width>300</width> |
|
221 | <width>300</width> | |
97 | <height>0</height> |
|
222 | <height>0</height> | |
98 | </size> |
|
223 | </size> | |
99 | </property> |
|
224 | </property> | |
100 | <property name="currentIndex"> |
|
225 | <property name="currentIndex"> | |
101 | <number>-1</number> |
|
226 | <number>-1</number> | |
102 | </property> |
|
227 | </property> | |
103 | </widget> |
|
228 | </widget> | |
104 | </widget> |
|
229 | </widget> | |
105 | </item> |
|
230 | </item> | |
106 | </layout> |
|
231 | </layout> | |
107 | </widget> |
|
232 | </widget> | |
108 | <customwidgets> |
|
233 | <customwidgets> | |
109 | <customwidget> |
|
234 | <customwidget> | |
110 | <class>FileList</class> |
|
235 | <class>FileList</class> | |
111 | <extends>QTableWidget</extends> |
|
236 | <extends>QTableWidget</extends> | |
112 | <header>filelist.h</header> |
|
237 | <header>filelist.h</header> | |
113 | </customwidget> |
|
238 | </customwidget> | |
|
239 | <customwidget> | |||
|
240 | <class>QVPushButton</class> | |||
|
241 | <extends>QPushButton</extends> | |||
|
242 | <header>qvpushbutton.h</header> | |||
|
243 | </customwidget> | |||
114 | </customwidgets> |
|
244 | </customwidgets> | |
115 | <resources> |
|
245 | <resources> | |
116 | <include location="genericBinaryFiles.qrc"/> |
|
246 | <include location="genericBinaryFiles.qrc"/> | |
117 | </resources> |
|
247 | </resources> | |
118 | <connections/> |
|
248 | <connections/> | |
119 | </ui> |
|
249 | </ui> |
@@ -1,51 +1,72 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
1 | #include "qtablewidgetintitem.h" |
|
22 | #include "qtablewidgetintitem.h" | |
2 |
|
23 | |||
3 | QTableWidgetIntItem::QTableWidgetIntItem(const QString &text,int Type) |
|
24 | QTableWidgetIntItem::QTableWidgetIntItem(const QString &text,int Type) | |
4 | :QTableWidgetItem(text,Type) |
|
25 | :QTableWidgetItem(text,Type) | |
5 | { |
|
26 | { | |
6 | } |
|
27 | } | |
7 |
|
28 | |||
8 | bool QTableWidgetIntItem::operator <(const QTableWidgetItem& other) const |
|
29 | bool QTableWidgetIntItem::operator <(const QTableWidgetItem& other) const | |
9 | { |
|
30 | { | |
10 | return toInt() < toInt(other); |
|
31 | return toInt() < toInt(other); | |
11 | } |
|
32 | } | |
12 |
|
33 | |||
13 | bool QTableWidgetIntItem::operator >(const QTableWidgetItem &other) const |
|
34 | bool QTableWidgetIntItem::operator >(const QTableWidgetItem &other) const | |
14 | { |
|
35 | { | |
15 | return toInt() > toInt(other); |
|
36 | return toInt() > toInt(other); | |
16 | } |
|
37 | } | |
17 |
|
38 | |||
18 | bool QTableWidgetIntItem::operator ==(const QTableWidgetItem &other) const |
|
39 | bool QTableWidgetIntItem::operator ==(const QTableWidgetItem &other) const | |
19 | { |
|
40 | { | |
20 | return toInt() == toInt(other); |
|
41 | return toInt() == toInt(other); | |
21 | } |
|
42 | } | |
22 |
|
43 | |||
23 | int QTableWidgetIntItem::toInt() const |
|
44 | int QTableWidgetIntItem::toInt() const | |
24 | { |
|
45 | { | |
25 | bool ok=true; |
|
46 | bool ok=true; | |
26 | if(type()==DecimalItem) |
|
47 | if(type()==DecimalItem) | |
27 | { |
|
48 | { | |
28 | return text().toInt(); |
|
49 | return text().toInt(); | |
29 | } |
|
50 | } | |
30 | else if(type()==HexaDecimalItem) |
|
51 | else if(type()==HexaDecimalItem) | |
31 | { |
|
52 | { | |
32 | return text().replace("0x","").toInt(&ok,16); |
|
53 | return text().replace("0x","").toInt(&ok,16); | |
33 | } |
|
54 | } | |
34 | return 0; |
|
55 | return 0; | |
35 | } |
|
56 | } | |
36 |
|
57 | |||
37 | int QTableWidgetIntItem::toInt(const QTableWidgetItem &item) const |
|
58 | int QTableWidgetIntItem::toInt(const QTableWidgetItem &item) const | |
38 | { |
|
59 | { | |
39 | bool ok=true; |
|
60 | bool ok=true; | |
40 | if(item.type()==DecimalItem) |
|
61 | if(item.type()==DecimalItem) | |
41 | { |
|
62 | { | |
42 | return item.text().toInt(); |
|
63 | return item.text().toInt(); | |
43 | } |
|
64 | } | |
44 | else if(item.type()==HexaDecimalItem) |
|
65 | else if(item.type()==HexaDecimalItem) | |
45 | { |
|
66 | { | |
46 | return item.text().replace("0x","").toInt(&ok,16); |
|
67 | return item.text().replace("0x","").toInt(&ok,16); | |
47 | } |
|
68 | } | |
48 | return 0; |
|
69 | return 0; | |
49 | } |
|
70 | } | |
50 |
|
71 | |||
51 |
|
72 |
@@ -1,22 +1,43 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
1 | #ifndef QTABLEWIDGETINTITEM_H |
|
22 | #ifndef QTABLEWIDGETINTITEM_H | |
2 | #define QTABLEWIDGETINTITEM_H |
|
23 | #define QTABLEWIDGETINTITEM_H | |
3 |
|
24 | |||
4 | #include <QTableWidgetItem> |
|
25 | #include <QTableWidgetItem> | |
5 |
|
26 | |||
6 | #define DecimalItem 0 |
|
27 | #define DecimalItem 0 | |
7 | #define HexaDecimalItem 1 |
|
28 | #define HexaDecimalItem 1 | |
8 |
|
29 | |||
9 | class QTableWidgetIntItem : public QTableWidgetItem |
|
30 | class QTableWidgetIntItem : public QTableWidgetItem | |
10 | { |
|
31 | { | |
11 |
|
32 | |||
12 | public: |
|
33 | public: | |
13 | explicit QTableWidgetIntItem(const QString& text, int Type); |
|
34 | explicit QTableWidgetIntItem(const QString& text, int Type); | |
14 | bool operator <(const QTableWidgetItem &other)const; |
|
35 | bool operator <(const QTableWidgetItem &other)const; | |
15 | bool operator >(const QTableWidgetItem &other)const; |
|
36 | bool operator >(const QTableWidgetItem &other)const; | |
16 | bool operator ==(const QTableWidgetItem &other)const; |
|
37 | bool operator ==(const QTableWidgetItem &other)const; | |
17 | int toInt() const; |
|
38 | int toInt() const; | |
18 | int toInt(const QTableWidgetItem &item) const; |
|
39 | int toInt(const QTableWidgetItem &item) const; | |
19 |
|
40 | |||
20 | }; |
|
41 | }; | |
21 |
|
42 | |||
22 | #endif // QTABLEWIDGETINTITEM_H |
|
43 | #endif // QTABLEWIDGETINTITEM_H |
General Comments 0
You need to be logged in to leave comments.
Login now