coptions.cpp coptions.h ui_coptions.h coptionsplugins.h QTreeWidgetItem #include"coptions.h" #include"ui_coptions.h" #include"coptionsplugins.h" #include<QTreeWidgetItem> cOptions::cOptions(QWidget*parent): QDialog(parent), ui(newUi::cOptions) { init(); m_lpMainWindow=(cMainWindow*)parent; m_pluginList=m_lpMainWindow->pluginList(); QStandardItem*lpPluginRoot=newQStandardItem("Plugins"); m_lpOptionsTreeModel->appendRow(lpPluginRoot); for(intz=0;z<m_pluginList.count();z++) { QStandardItem*lpItemNew=newQStandardItem(m_pluginList.at(z)->pluginName()); lpPluginRoot->appendRow(lpItemNew); } ui->m_lpOptionsTree->expandAll(); } cOptions::~cOptions() { deleteui; } voidcOptions::init() { ui->setupUi(this); m_lpOptionsTreeModel=newQStandardItemModel(0,1); ui->m_lpOptionsTree->setModel(m_lpOptionsTreeModel); ui->m_lpSplitter->setStretchFactor(0,0); ui->m_lpSplitter->setStretchFactor(1,1); connect(ui->m_lpOptionsTree->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)),SLOT(onOptionsTreeSelectionChanged(QItemSelection,QItemSelection))); } voidcOptions::onOptionsTreeSelectionChanged(constQItemSelection&selected,constQItemSelection&/*deselected*/) { QStandardItem*lpSelected; if(selected.indexes().count()) lpSelected=m_lpOptionsTreeModel->itemFromIndex(selected.indexes().at(0)); else return; if(!lpSelected->text().compare("plugins",Qt::CaseInsensitive)) { cOptionsPlugins*lpOptionsPlugins=newcOptionsPlugins(this); lpOptionsPlugins->setPlugins(m_pluginList); ui->m_lpOptionsScrollArea->setWidget(lpOptionsPlugins); } else ui->m_lpOptionsScrollArea->setWidget(newQWidget); }