160 lines
4.9 KiB
C++
160 lines
4.9 KiB
C++
|
|
/*
|
|||
|
|
* WorkflowToolBarView.cpp
|
|||
|
|
*
|
|||
|
|
* Created on: 2011-10-8
|
|||
|
|
* Author: dev
|
|||
|
|
*/
|
|||
|
|
#include <cassert>
|
|||
|
|
#include <QApplication>
|
|||
|
|
#include <QIcon>
|
|||
|
|
#include <QAction>
|
|||
|
|
#include <QPainter>
|
|||
|
|
#include <QtDebug>
|
|||
|
|
#include <QStyle>
|
|||
|
|
#include <QMenu>
|
|||
|
|
|
|||
|
|
#include "WorkflowWidget.h"
|
|||
|
|
#include "WorkflowToolBarView.h"
|
|||
|
|
#include "PaiToolBar.h"
|
|||
|
|
#include "PaiLineEdit.h"
|
|||
|
|
#include "PageService.h"
|
|||
|
|
#include "ConsoleGUIService.h"
|
|||
|
|
#include "ToolBarService.h"
|
|||
|
|
#include "WorkflowConst.h"
|
|||
|
|
#include "PaiWorkflowDataModel.h"
|
|||
|
|
#include "PaiTabWidget.h"
|
|||
|
|
#include "PaiAction.h"
|
|||
|
|
|
|||
|
|
using namespace pai;
|
|||
|
|
using namespace pai::gui;
|
|||
|
|
using namespace pai::graphics2d;
|
|||
|
|
|
|||
|
|
namespace pai
|
|||
|
|
{
|
|||
|
|
/**
|
|||
|
|
* P.A.I系统的插件的内容区通常有一个带菜单的工具栏,这个类定制了这种工具栏
|
|||
|
|
*/
|
|||
|
|
class CPaiSubToolBar:public pai::gui::PaiToolBar
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
CPaiSubToolBar(const QString& strTitle,QWidget* pParent):PaiToolBar(strTitle,pParent)
|
|||
|
|
{
|
|||
|
|
setIconSize(QSize(14, 14));
|
|||
|
|
}
|
|||
|
|
virtual ~CPaiSubToolBar()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
virtual void paintEvent ( QPaintEvent * event )
|
|||
|
|
{
|
|||
|
|
PaiToolBar::paintEvent(event);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CWorkflowToolBarView::CWorkflowToolBarView(WorkflowWidget *wfw,const QUuid& pageID,QWidget *parent)
|
|||
|
|
:PaiToolBarView(parent),m_pageID(pageID),m_workflowToolBarName(wfw->GetID().toString()+g_szStyleToolBarName) {
|
|||
|
|
// TODO Auto-generated constructor stub
|
|||
|
|
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_CommandLink);
|
|||
|
|
//删除里面所有的toolBar,其实只有一个默认toolBar
|
|||
|
|
QList<QToolBar*> pToolBar = this->GetToolBars();
|
|||
|
|
for(int i=0; i<pToolBar.size(); i++)
|
|||
|
|
{
|
|||
|
|
RemoveToolBar(pToolBar.at(i));
|
|||
|
|
}
|
|||
|
|
//注意这里给工具栏赋予了唯一的名字
|
|||
|
|
CPaiSubToolBar* styleToolBar = new pai::CPaiSubToolBar(m_workflowToolBarName, NULL);
|
|||
|
|
//为该工具栏添加工具栏服务
|
|||
|
|
PageService* pPageService = ::GetConsoleGUIService()->GetViewTabService()->GetPageService(m_pageID);
|
|||
|
|
assert(pPageService != NULL);
|
|||
|
|
ToolBarService* pStyleToolBarService = new pai::ToolBarService();//该对象的生存期由PageService负责
|
|||
|
|
pStyleToolBarService->SetStringID(m_workflowToolBarName.toStdString());//该ToolBarService的ExtensionID为工作流ID+g_szStyleToolBarName
|
|||
|
|
pPageService->Register(pStyleToolBarService,ILocation());
|
|||
|
|
|
|||
|
|
//添加查询控件
|
|||
|
|
|
|||
|
|
PaiAction* pAddlineAction=new PaiAction(QIcon(":/WAddline.png"),tr(g_szConnect),NULL);
|
|||
|
|
pAddlineAction->SetPermission(pai::gui::PaiAction::UPDATE);
|
|||
|
|
pAddlineAction->setEnabled(false);
|
|||
|
|
pStyleToolBarService->Register(pAddlineAction);
|
|||
|
|
|
|||
|
|
PaiAction* pBreakAction=new PaiAction(QIcon(":/WBreak.png"),tr(g_szBreak),NULL);
|
|||
|
|
pBreakAction->setEnabled(false);
|
|||
|
|
pBreakAction->SetPermission(pai::gui::PaiAction::UPDATE);
|
|||
|
|
pStyleToolBarService->Register(pBreakAction);
|
|||
|
|
|
|||
|
|
PaiAction* pDeleteAction=new PaiAction(QIcon(":/WDelete.png"),tr(g_szDeleteO),NULL);
|
|||
|
|
pDeleteAction->setEnabled(false);
|
|||
|
|
pDeleteAction->SetPermission(pai::gui::PaiAction::UPDATE);
|
|||
|
|
pStyleToolBarService->Register(pDeleteAction);
|
|||
|
|
|
|||
|
|
PaiAction* pLayoutAction=new PaiAction(QIcon(":/WLayout.png"),tr(g_szAutoAlign),NULL);
|
|||
|
|
pLayoutAction->setEnabled(false);
|
|||
|
|
pLayoutAction->SetPermission(pai::gui::PaiAction::UPDATE);
|
|||
|
|
pStyleToolBarService->Register(pLayoutAction);
|
|||
|
|
|
|||
|
|
QAction* pEditAction=new QAction(QIcon(":/WEdit.png"),tr(g_szEditDot),NULL);
|
|||
|
|
pEditAction->setEnabled(false);
|
|||
|
|
pStyleToolBarService->Register(pEditAction);
|
|||
|
|
|
|||
|
|
QMenu *menu = new QMenu();
|
|||
|
|
menu->addAction("item");
|
|||
|
|
QAction* pDemoAction=new QAction(QIcon(":/WDemo.png"),tr(g_szDemo),NULL);
|
|||
|
|
pDemoAction->setMenu(menu);
|
|||
|
|
pDemoAction->setEnabled(false);
|
|||
|
|
pStyleToolBarService->Register(pDemoAction);
|
|||
|
|
|
|||
|
|
QAction* pDeleteDisabledItemAction=new QAction(QIcon(":/DeleteDisable.png"),tr(g_szDeleteDisabledItems),NULL);
|
|||
|
|
pDeleteDisabledItemAction->setEnabled(false);
|
|||
|
|
pStyleToolBarService->Register(pDeleteDisabledItemAction);
|
|||
|
|
|
|||
|
|
styleToolBar->addActions(pStyleToolBarService->GetToolbarActions());
|
|||
|
|
|
|||
|
|
styleToolBar->AddSpacer();
|
|||
|
|
|
|||
|
|
QWidget *widget = new QWidget;
|
|||
|
|
styleToolBar->addWidget(widget);
|
|||
|
|
|
|||
|
|
this->AddToolBar(styleToolBar, PaiToolBarView::SMALL_TOOLBAR);
|
|||
|
|
|
|||
|
|
this->SetViewport(wfw);
|
|||
|
|
installEventFilter(this);
|
|||
|
|
}
|
|||
|
|
bool CWorkflowToolBarView::eventFilter(QObject *pObj, QEvent *pEvent)
|
|||
|
|
{
|
|||
|
|
bool ret = QObject::eventFilter(pObj, pEvent);
|
|||
|
|
switch (pEvent->type())
|
|||
|
|
{
|
|||
|
|
case QEvent::WindowActivate:
|
|||
|
|
{
|
|||
|
|
if (this == pObj && parent() != NULL)
|
|||
|
|
{
|
|||
|
|
PaiTabWidget* pTabWidget = dynamic_cast<PaiTabWidget*>(parent()->parent());
|
|||
|
|
if (pTabWidget != NULL)
|
|||
|
|
{
|
|||
|
|
pTabWidget->OnCurrentChanged(pTabWidget->currentIndex());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
CWorkflowToolBarView::~CWorkflowToolBarView() {
|
|||
|
|
// TODO Auto-generated destructor stub
|
|||
|
|
PageService* pPageService = ::GetConsoleGUIService()->GetViewTabService()->GetPageService(m_pageID);
|
|||
|
|
if (pPageService != NULL)
|
|||
|
|
{
|
|||
|
|
pPageService->CService::Unregister(m_workflowToolBarName.toStdString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|