/** * @file: PaiModuleToolBar.h * @brief 包括模块树和模块树上方工具条的组合视图 * @date: 2011-9-20 * @author: sinopec */ #include #include #include #include #include #include #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 pToolBar = this->GetToolBars(); for(int i=0; isetContentsMargins(1,0,30,0);//设置左右的空白 //添加查询控件 PaiSearchLineEdit* pSearchModuleLEdit = new PaiSearchLineEdit; styleToolBar->addWidget(pSearchModuleLEdit); m_pComWellSlfFile = new PaiComAction(); styleToolBar->addAction(m_pComWellSlfFile); 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())); connect(m_pComWellSlfFile->GetDefaultWidget(),SIGNAL(currentIndexChanged(int)),this,SLOT(oncurrentIndexChanged(int))); } void CPaiModuleToolBarView::setAllSlfFile(QMap mapAllSlfFile,QString CurrentSLFFileName) { m_mapAllSlfFile = mapAllSlfFile; PaiComboBox* pComboBox = dynamic_cast(m_pComWellSlfFile->GetDefaultWidget()); if (pComboBox) { pComboBox->clear(); QList listShowSlfName = mapAllSlfFile.keys(); int iSel = 0; for (int i = 0; iaddItem(listShowSlfName.at(i)); QString strSLFFileName = mapAllSlfFile[listShowSlfName.at(i)]; if (CurrentSLFFileName == strSLFFileName) iSel = i; } if (iSel>0) pComboBox->setCurrentIndex(iSel); } } QString CPaiModuleToolBarView::getCurrentSLFFileName() { PaiComboBox* pComboBox = dynamic_cast(m_pComWellSlfFile->GetDefaultWidget()); if (pComboBox && m_mapAllSlfFile.size()>0) { return m_mapAllSlfFile[pComboBox->currentText()]; } return ""; } CPaiModuleToolBarView::~CPaiModuleToolBarView() { // TODO Auto-generated destructor stub } void CPaiModuleToolBarView::oncurrentIndexChanged(int index) { }