Implement a TaskGroup class to show widgets without extra header

This commit is contained in:
wmayer
2013-04-26 17:16:56 +02:00
parent bbe4aa54cc
commit f03fed87a9
2 changed files with 77 additions and 19 deletions

View File

@@ -61,7 +61,72 @@ TaskWidget::~TaskWidget()
{
}
//**************************************************************************
//**************************************************************************
// TaskGroup
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskGroup::TaskGroup(QWidget *parent)
: iisTaskGroup(parent, false)
{
setScheme(iisFreeCADTaskPanelScheme::defaultScheme());
}
TaskGroup::~TaskGroup()
{
}
namespace Gui { namespace TaskView {
class TaskIconLabel : public iisIconLabel {
public:
TaskIconLabel(const QIcon &icon,
const QString &title,
QWidget *parent = 0)
: iisIconLabel(icon, title, parent) {
// do not allow to get the focus because when hiding the task box
// it could cause to activate another MDI view.
setFocusPolicy(Qt::NoFocus);
}
void setTitle(const QString &text) {
myText = text;
update();
}
};
}
}
void TaskGroup::actionEvent (QActionEvent* e)
{
QAction *action = e->action();
switch (e->type()) {
case QEvent::ActionAdded:
{
TaskIconLabel *label = new TaskIconLabel(
action->icon(), action->text(), this);
this->addIconLabel(label);
connect(label,SIGNAL(clicked()),action,SIGNAL(triggered()));
break;
}
case QEvent::ActionChanged:
{
// update label when action changes
QBoxLayout* bl = this->groupLayout();
int index = this->actions().indexOf(action);
if (index < 0) break;
QWidgetItem* item = static_cast<QWidgetItem*>(bl->itemAt(index));
TaskIconLabel* label = static_cast<TaskIconLabel*>(item->widget());
label->setTitle(action->text());
break;
}
case QEvent::ActionRemoved:
{
// cannot change anything
break;
}
default:
break;
}
}
//**************************************************************************
//**************************************************************************
@@ -125,25 +190,6 @@ void TaskBox::hideGroupBox()
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
namespace Gui { namespace TaskView {
class TaskIconLabel : public iisIconLabel {
public:
TaskIconLabel(const QIcon &icon,
const QString &title,
QWidget *parent = 0)
: iisIconLabel(icon, title, parent) {
// do not allow to get the focus because when hiding the task box
// it could cause to activate another MDI view.
setFocusPolicy(Qt::NoFocus);
}
void setTitle(const QString &text) {
myText = text;
update();
}
};
}
}
void TaskBox::actionEvent (QActionEvent* e)
{
QAction *action = e->action();