logplus/ModuleConsole/src/PaiModuleToolBarView.cpp
2026-01-16 17:18:41 +08:00

89 lines
2.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file: PaiModuleToolBar.h
* @brief 包括模块树和模块树上方工具条的组合视图
* @date: 2011-9-20
* @author: sinopec
*/
#include <QApplication>
#include <QIcon>
#include <QBoxLayout>
#include <QAction>
#include <QtDebug>
#include "PaiWidgetAction.h"
#include "PaiModuleToolBarView.h"
#include "PaiModuleTree.h"
#include "PaiToolBar.h"
#include "PaiSearchLineEdit.h"
#include "PaiComboBox.h"
using namespace pai;
using namespace pai::gui;
/**
* @class PaiComAction
* @brief 为PaiComboBox实现的 WidgetAction类
*/
class PaiComAction : public PaiWidgetAction
{
public:
/**
* @brief 构造函数
* @param[in] pParent 父指针
*/
PaiComAction(QObject *parent=0);
/**
* @brief 创建控件
*/
virtual QWidget *NewWidget(QWidget *parent);
};
PaiComAction::PaiComAction(QObject *parent)
:PaiWidgetAction(parent)
{
}
QWidget *PaiComAction::NewWidget(QWidget *parent)
{
PaiComboBox* comBox = new PaiComboBox(parent);
comBox->addItem(/*tr*/("Alphabetical Order"));
comBox->setMinimumWidth(150);
return comBox;
}
///////////////////////////////////////////////////////////////////////////////////////
CPaiModuleToolBarView::CPaiModuleToolBarView(QWidget *parent):PaiToolBarView(parent)
{
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));
}
PaiToolBar* styleToolBar = new PaiToolBar("", NULL);
styleToolBar->setContentsMargins(1,0,30,0);//设置左右的空白
//添加查询控件
PaiSearchLineEdit* pSearchModuleLEdit = new PaiSearchLineEdit;
styleToolBar->addWidget(pSearchModuleLEdit);
styleToolBar->addAction(new PaiComAction());
this->AddToolBar(styleToolBar, PaiToolBarView::SMALL_TOOLBAR);
// 因需等待搜索结果再响应returnPressed信号把搜索的结果放入工作流视图
// 所以需要将该值设置为50ms原因请看函数体注释
pSearchModuleLEdit->SetEditStopDuration(50);
m_pModuleTree = new CPaiModuleTree(NULL);
m_pModuleTree->expandAll();
this->SetViewport(m_pModuleTree);
connect(pSearchModuleLEdit,SIGNAL(EditingStoped(const QString&)),m_pModuleTree,SLOT(Filter(const QString&)));
connect(pSearchModuleLEdit,SIGNAL(returnPressed()), m_pModuleTree, SLOT(RequireDeliverSelectedModules()));
}
CPaiModuleToolBarView::~CPaiModuleToolBarView()
{
// TODO Auto-generated destructor stub
}