Commit 07c10d10 authored by Michael Carpenter's avatar Michael Carpenter

QuickView selection dialog now sorts items by category and lists them in an easier to read format

parent 3a3085ad
......@@ -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());
......
......@@ -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);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>571</width>
<height>474</height>
<width>851</width>
<height>192</height>
</rect>
</property>
<property name="windowTitle">
......@@ -24,14 +24,27 @@
<rect>
<x>0</x>
<y>0</y>
<width>551</width>
<height>454</height>
<width>831</width>
<height>172</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout_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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment