diff --git a/src/ui/uas/UASQuickViewItemSelect.cc b/src/ui/uas/UASQuickViewItemSelect.cc index ebe47a7144f09a5124a7bb4bf437fb3166f30e0a..bf3832333cffa5017396bbc548c60ceb93b565bb 100644 --- a/src/ui/uas/UASQuickViewItemSelect.cc +++ b/src/ui/uas/UASQuickViewItemSelect.cc @@ -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;iremoveWidget(m_checkBoxList[i]); + } + int row = 0; + int col = 0; + for (int i=0;iaddWidget(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(sender()); diff --git a/src/ui/uas/UASQuickViewItemSelect.h b/src/ui/uas/UASQuickViewItemSelect.h index 4be402c5e1530f342594a0671cfd6393a234d93f..04174b4b7ef87313b352ff07b2eaa9aae70c7d7a 100644 --- a/src/ui/uas/UASQuickViewItemSelect.h +++ b/src/ui/uas/UASQuickViewItemSelect.h @@ -2,6 +2,7 @@ #define UASQUICKVIEWITEMSELECT_H #include +#include #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 m_categoryToIndexMap; + QList m_checkBoxList; Ui::UASQuickViewItemSelect ui; private slots: void checkBoxClicked(bool checked); diff --git a/src/ui/uas/UASQuickViewItemSelect.ui b/src/ui/uas/UASQuickViewItemSelect.ui index 9a35660c0e1beab619198e580ca1ff78dc059e7b..60cc4102c8c0b2fa55da8d03394de88c0d7d9ff4 100644 --- a/src/ui/uas/UASQuickViewItemSelect.ui +++ b/src/ui/uas/UASQuickViewItemSelect.ui @@ -6,8 +6,8 @@ 0 0 - 571 - 474 + 851 + 192 @@ -24,14 +24,27 @@ 0 0 - 551 - 454 + 831 + 172 - + + + + + Qt::Vertical + + + + 20 + 40 + + + +