Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
07c10d10
Commit
07c10d10
authored
Jun 18, 2013
by
Michael Carpenter
Browse files
QuickView selection dialog now sorts items by category and lists them in an easier to read format
parent
3a3085ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/ui/uas/UASQuickViewItemSelect.cc
View file @
07c10d10
...
...
@@ -6,26 +6,75 @@ UASQuickViewItemSelect::UASQuickViewItemSelect(QWidget *parent) : QWidget(parent
ui
.
setupUi
(
this
);
currcol
=
0
;
currrow
=
0
;
ui
.
gridLayout
->
setSpacing
(
0
);
ui
.
gridLayout
->
setSpacing
(
5
);
ui
.
gridLayout
->
setMargin
(
0
);
}
void
UASQuickViewItemSelect
::
addItem
(
QString
item
,
bool
enabled
)
{
QString
category
=
"."
;
QString
name
=
item
;
if
(
item
.
indexOf
(
":"
)
!=
-
1
&&
item
.
indexOf
(
"."
)
!=
-
1
)
{
//Item has a subcateogry
category
=
item
.
mid
(
item
.
indexOf
(
":"
)
+
1
,
item
.
indexOf
(
"."
)
-
item
.
indexOf
(
":"
)
-
1
);
name
=
item
.
mid
(
item
.
indexOf
(
"."
)
+
1
);
}
int
col
=
-
1
;
if
(
m_categoryToIndexMap
.
contains
(
category
))
{
col
=
m_categoryToIndexMap
[
category
];
}
else
{
m_categoryToIndexMap
[
category
]
=
currcol
++
;
col
=
m_categoryToIndexMap
[
category
];
//New column.
QLabel
*
titlelabel
=
new
QLabel
(
this
);
titlelabel
->
setText
(
category
);
titlelabel
->
show
();
ui
.
gridLayout
->
addWidget
(
titlelabel
,
0
,
col
);
}
QCheckBox
*
label
=
new
QCheckBox
(
this
);
m_checkBoxList
.
append
(
label
);
if
(
enabled
)
{
label
->
setChecked
(
true
);
}
connect
(
label
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
checkBoxClicked
(
bool
)));
label
->
setText
(
item
);
label
->
setText
(
name
);
label
->
show
();
ui
.
gridLayout
->
addWidget
(
label
,
currrow
,
currcol
++
);
if
(
currcol
>
10
)
//ui.gridLayout->addWidget(label,currrow,currcol++);
bool
breakout
=
false
;
int
row
=
-
1
;
while
(
!
breakout
)
{
currcol
=
0
;
currrow
++
;
if
(
!
ui
.
gridLayout
->
itemAtPosition
(
++
row
,
col
)
||
row
>
100
)
{
breakout
=
true
;
}
}
//Row is the next invalid object, and col is the proper column.
ui
.
gridLayout
->
addWidget
(
label
,
row
,
col
);
}
void
UASQuickViewItemSelect
::
resizeEvent
(
QResizeEvent
*
event
)
{
/*for (int i=0;i<m_checkBoxList.size();i++)
{
ui.gridLayout->removeWidget(m_checkBoxList[i]);
}
int row = 0;
int col = 0;
for (int i=0;i<m_checkBoxList.size();i++)
{
ui.gridLayout->addWidget(m_checkBoxList[i],row,col);
col++;
ui.gridLayout->widget()->width() > this->width();
//need to reduce column number.
}*/
}
void
UASQuickViewItemSelect
::
checkBoxClicked
(
bool
checked
)
{
QCheckBox
*
check
=
qobject_cast
<
QCheckBox
*>
(
sender
());
...
...
src/ui/uas/UASQuickViewItemSelect.h
View file @
07c10d10
...
...
@@ -2,6 +2,7 @@
#define UASQUICKVIEWITEMSELECT_H
#include
<QWidget>
#include
<QCheckBox>
#include
"ui_UASQuickViewItemSelect.h"
class
UASQuickViewItemSelect
:
public
QWidget
...
...
@@ -14,7 +15,11 @@ public:
void
addItem
(
QString
item
,
bool
enabled
=
false
);
int
currrow
;
int
currcol
;
protected:
void
resizeEvent
(
QResizeEvent
*
event
);
private:
QMap
<
QString
,
int
>
m_categoryToIndexMap
;
QList
<
QCheckBox
*>
m_checkBoxList
;
Ui
::
UASQuickViewItemSelect
ui
;
private
slots
:
void
checkBoxClicked
(
bool
checked
);
...
...
src/ui/uas/UASQuickViewItemSelect.ui
View file @
07c10d10
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
5
7
1
</width>
<height>
474
</height>
<width>
8
51
</width>
<height>
192
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -24,14 +24,27 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
55
1
</width>
<height>
454
</height>
<width>
83
1
</width>
<height>
172
</height>
</rect>
</property>
<layout
class=
"Q
H
BoxLayout"
name=
"
horizont
alLayout"
>
<layout
class=
"Q
V
BoxLayout"
name=
"
vertic
alLayout
_2
"
>
<item>
<layout
class=
"QGridLayout"
name=
"gridLayout"
/>
</item>
<item>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
40
</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment