void walkDir(const char*path, char*table) { // find DIR *root = opendir(path); char nextdir[256]; char fullname[256]; struct dirent *entry; if (root == NULL) { fprintf(stderr, "Failed to opendir(%s): %s\n\n", path, strerror(errno)); exit(1); } while((entry = readdir(root)) != NULL) { if (entry->d_type == 4 && entry->d_name[0] != '.') { sprintf(nextdir, "%s/%s", path, entry->d_name); walkDir(nextdir, table); } else if (entry->d_type == 8 && entry->d_name[0] == 'r' && entry->d_name[1] == '.') { sprintf(fullname, "%s/%s", path, entry->d_name); fprintf(stderr, "."); fflush(stderr); readRegion(fullname, table); } } closedir(root); }
void QgsGrassRegion::reloadRegion() { readRegion(); refreshGui(); }
PjModeler::PjModeler(const QDir &dir, QWidget *parent, QSqlDatabase db) : QWidget(parent), dir(dir) { if( ( ! dir.exists("main.cpp")) && ! QFile::copy( ":/file/files/main.cpp", dir.absoluteFilePath("main.cpp")) ) { setEnabled(false); QMessageBox::critical(this,tr("Error"),"Failed to build the <b>main.cpp</b> file!",QMessageBox::Ok,QMessageBox::Ok); } //editor editor = new MainEditor; editor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); regionViewer = new QListView; regionViewer->setObjectName("RegionViewer"); regionModel = new QStandardItemModel(this); mdDebug = new MdDebug; paroutModel = new ParoutModel(dir,editor,db); paroutViewer = new ParoutView; titleLabel = new QLabel; titleLabel->setObjectName("TitleLabel"); titleLabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); titleLabel->setText("Simulation Datas exist! (Read-Only Mode)"); editButton = new QToolButton; editButton->setText(tr("Enable Editing") ); editButton->setToolButtonStyle(Qt::ToolButtonTextOnly); editButton->setObjectName("Switcher"); editButton->setCheckable(true); connect(editButton, SIGNAL(toggled(bool)), this,SLOT(setReadWrite(bool)) ); nextButton = new QToolButton; nextButton->setIcon(QIcon(":/icon/images/next.png") ); nextButton->setText(tr("Next Page")); nextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); nextButton->setToolTip(tr("Next Page")); nextButton->setObjectName("ToolButton"); addchainButton = new QToolButton; addchainButton->setText(tr("Chain")); addchainButton->setIcon(QIcon(":/icon/images/addchain.png") ); addchainButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addchainButton->setToolTip(tr("New Chain")); addchainButton->setObjectName("ToolButton"); addoutputButton = new QToolButton; addoutputButton->setText(tr("Output")); addoutputButton->setIcon(QIcon(":/icon/images/addoutput.png") ); addoutputButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addoutputButton->setToolTip(tr("New Output")); addoutputButton->setObjectName("ToolButton"); titleBar = new QToolBar; titleBar->setObjectName("TitleBar"); editAction = titleBar->addWidget(editButton); titleBar->addWidget(titleLabel); deleteAction = titleBar->addAction(QIcon(":/icon/images/delete.png"),tr("Delete"),this,SLOT(deleteExtraSelections())); deleteAction->setDisabled(true); undoAction = titleBar->addAction(QIcon(":/icon/images/undo.png"),tr("Undo"),editor,SLOT(undo())); undoAction->setDisabled(true); redoAction = titleBar->addAction(QIcon(":/icon/images/redo.png"),tr("Redo"),editor,SLOT(redo())); redoAction->setDisabled(true); saveAction = titleBar->addAction(QIcon(":/icon/images/save.png"),tr("Save"),this,SLOT(save()) ); saveAction->setDisabled(true); titleBar->addSeparator(); titleBar->addWidget(addchainButton); titleBar->addWidget(addoutputButton); titleBar->addSeparator(); titleBar->addWidget(nextButton); //left splitter QSplitter *spl = new QSplitter(Qt::Vertical); spl->addWidget(regionViewer); spl->addWidget(paroutViewer); //rigth splitter QSplitter *spr = new QSplitter(Qt::Vertical); spr->addWidget(editor); spr->addWidget(mdDebug->textOutput); QVBoxLayout *lr = new QVBoxLayout; lr->addWidget(spr); lr->addWidget(mdDebug); QHBoxLayout *bodyLayout = new QHBoxLayout; bodyLayout->addWidget(spl); bodyLayout->addLayout(lr); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); mainLayout->addWidget(titleBar); mainLayout->addLayout(bodyLayout); QStringList conststrs; conststrs << "//!" << "for(unsigned long istep=0;istep<steps;++istep)"; QFile file( dir.absoluteFilePath("main.cpp")); // file.setPermissions( QFileDevice::WriteOwner); editor->setEnabled( file.open(QIODevice::ReadOnly)); editor->setPlainText( file.readAll()); editor->setConstStrings( conststrs); editor->updateEnv(); editor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); //region widget regionViewer->setModel(regionModel); regionViewer->setSelectionMode(QAbstractItemView::ExtendedSelection); regionViewer->setEditTriggers(QAbstractItemView::NoEditTriggers); readRegion(); //parout viewer. connect(paroutModel,SIGNAL(simulationExistence(bool)),this,SLOT(setReadOnlyMode(bool)) ); paroutModel->initialize(); paroutViewer->setEditTriggers(QAbstractItemView::EditKeyPressed | QAbstractItemView::DoubleClicked); paroutViewer->setSelectionMode(QAbstractItemView::SingleSelection); paroutViewer->setContextMenuPolicy(Qt::ActionsContextMenu); paroutViewer->setIndentation(0); paroutViewer->setAlternatingRowColors(true); paroutViewer->header()->setSectionResizeMode(QHeaderView::ResizeToContents); paroutViewer->header()->setStretchLastSection(false); paroutViewer->header()->setMinimumSectionSize(15); paroutViewer->setModel(paroutModel); paroutDelegate = new ParoutDelegate(paroutViewer); paroutViewer->setItemDelegateForColumn(1,paroutDelegate); paroutViewer->resizeToContent(); connect(undoAction,SIGNAL(triggered()),this,SLOT(readRegion())); connect(redoAction,SIGNAL(triggered()),this,SLOT(readRegion())); connect(addchainButton,SIGNAL(clicked()),this,SLOT(newChain()) ); connect(addoutputButton,SIGNAL(clicked()),this,SLOT(newOutput()) ); connect(regionViewer->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)),this,SLOT(regionViewerSelectionChanged()) ); connect(nextButton,SIGNAL(clicked()),this,SIGNAL(switch2Analyse()) ); connect(editor,SIGNAL(undoAvailable(bool)),undoAction,SLOT(setEnabled(bool)) ); connect(editor,SIGNAL(redoAvailable(bool)),redoAction,SLOT(setEnabled(bool)) ); connect(editor,SIGNAL(blockCountChanged(int)),this,SLOT(highlightCurrentSelection()) ); connect(mdDebug,SIGNAL(runTriggered()),this,SLOT(debug()) ); connect(mdDebug,SIGNAL(exploreDebugFolder()),this,SLOT(exploreDebugFolder()) ); connect(editor,SIGNAL(modificationChanged(bool)),this,SLOT(slotModificationChanged(bool)) ); }