Exemple #1
0
void Tabs::setCurrentTab(int index, bool suppressSignals)
{
    QTabWidget *qtabwidget = static_cast<QTabWidget*>(getQWidget());
    bool oldSignalsState = qtabwidget->blockSignals(suppressSignals);
    qtabwidget->setCurrentIndex(index);
    qtabwidget->blockSignals(oldSignalsState);
}
void
QvisPluginWindow::CreateWindowContents()
{
    // Create the tab widget.
    QTabWidget *tabs = new QTabWidget(central);
    
    connect(tabs, SIGNAL(currentChanged(int)),
            this, SLOT(tabSelected(int)));
            
    topLayout->addWidget(tabs,10000);

    //
    // Create the plot page
    //
    pagePlots = new QWidget(central);
    QVBoxLayout *plots_layout= new QVBoxLayout(pagePlots);
    tabs->addTab(pagePlots, tr("Plots"));

    plotView = new QTreeView(pagePlots);
    plotView->setModel(plotDataModel);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    plotView->header()->setResizeMode(0,QHeaderView::ResizeToContents);
    plotView->header()->setResizeMode(1,QHeaderView::ResizeToContents);
#else
    plotView->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
    plotView->header()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
#endif
    plots_layout->addWidget(plotView);

    //
    // Create the operator page
    //
    pageOperators = new QWidget(central);
    QVBoxLayout *ops_layout = new QVBoxLayout(pageOperators);
    tabs->addTab(pageOperators, tr("Operators"));
    operatorView = new QTreeView(pageOperators);
    operatorView->setModel(operatorDataModel);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    operatorView->header()->setResizeMode(0,QHeaderView::ResizeToContents);
    operatorView->header()->setResizeMode(1,QHeaderView::ResizeToContents);
#else
    operatorView->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
    operatorView->header()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
#endif
    ops_layout->addWidget(operatorView);

    QHBoxLayout *opsBLayout = new QHBoxLayout();
    ops_layout->addLayout(opsBLayout);
    opsBLayout->addStretch(5);
    clearOperatorCategoryButton = new QPushButton(
        tr("Clear category for all operators"), pageOperators);
    opsBLayout->addWidget(clearOperatorCategoryButton);
    connect(clearOperatorCategoryButton, SIGNAL(clicked()),
            this, SLOT(clearOperatorCategories()));

    //
    // Create the database page
    //
    pageDatabases = new QWidget(central);
    QHBoxLayout *db_toplayout = new QHBoxLayout(pageDatabases);
    QFrame      *db_lframe = new QFrame(pageDatabases);
    db_toplayout->addWidget(db_lframe);
    QVBoxLayout *db_llayout= new QVBoxLayout(db_lframe);
    
    tabs->addTab(pageDatabases, tr("Databases"));

    listDatabases = new QTreeWidget(pageDatabases);
    listDatabases->setRootIsDecorated(false);

    QStringList dbHeaders;
    dbHeaders << tr("Enabled") << tr("Name") << tr("Options") ;
    listDatabases->setHeaderLabels(dbHeaders);
    listDatabases->headerItem()->setTextAlignment(1, Qt::AlignCenter);
    listDatabases->headerItem()->setTextAlignment(2, Qt::AlignCenter);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    listDatabases->header()->setResizeMode(0,QHeaderView::ResizeToContents);
    listDatabases->header()->setResizeMode(2,QHeaderView::ResizeToContents);
#else
    listDatabases->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
    listDatabases->header()->setSectionResizeMode(2,QHeaderView::ResizeToContents);
#endif
    db_llayout->addWidget(listDatabases);

    QFrame *grpBox = new QFrame(pageDatabases);
    QHBoxLayout *grp_layout = new QHBoxLayout(grpBox);
    grp_layout->setContentsMargins(5,5,5,5);

    // Add select all and unselect all buttons.
    selectAllReadersButton = new QPushButton(tr("Enable all"), grpBox);
    connect(selectAllReadersButton, SIGNAL(clicked()),
            this, SLOT(selectAllReadersButtonClicked()));
    grp_layout->addWidget(selectAllReadersButton);

    unSelectAllReadersButton = new QPushButton(tr("Disable all"), grpBox);
    connect(unSelectAllReadersButton, SIGNAL(clicked()),
            this, SLOT(unSelectAllReadersButtonClicked()));
    grp_layout->addWidget(unSelectAllReadersButton);
    db_llayout->addWidget(grpBox);

    QFrame      *db_rframe = new QFrame(pageDatabases);
    db_toplayout->addWidget(db_rframe);
    QVBoxLayout *db_rlayout= new QVBoxLayout(db_rframe);

    databaseOptionsSetButton = new QPushButton(tr("Set default open options"),
                                               pageDatabases);
    connect(databaseOptionsSetButton, SIGNAL(clicked()),
            this, SLOT(databaseOptionsSetButtonClicked()));
    connect(listDatabases, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), 
            this, SLOT(databaseSelectedItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
    
    db_rlayout->addWidget(databaseOptionsSetButton);
    
    dbAddToPreferedButton = new QPushButton(tr("Add to preferred list"),
                                            pageDatabases);
    connect(dbAddToPreferedButton, SIGNAL(clicked()),
            this, SLOT(dbAddToPreferedButtonClicked()));
    db_rlayout->addWidget(dbAddToPreferedButton);

    QGroupBox *preferredGroup = new QGroupBox("Preferred Database Plugins",
                                              pageDatabases);
    db_rlayout->addWidget(preferredGroup);
    QGridLayout *preferredLayout = new QGridLayout(preferredGroup);

    QLabel *preferredHintLabel = new QLabel(
        "This is an ordered list of plugins which take precedence when "
        "opening files.  When they accept the given file name pattern, these "
        "are tried frst.  And when all attempts to guess based on file "
        "name fail, these are tried before giving up.", preferredGroup);
    preferredHintLabel->setWordWrap(true);
    preferredLayout->addWidget(preferredHintLabel, 0,0, 1,3);

    listPreferredDBs = new QListWidget(preferredGroup);
    preferredLayout->addWidget(listPreferredDBs, 1,0, 1,3);
    connect(listPreferredDBs,
            SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), 
            this,
            SLOT(dbPreferredListItemChanged(QListWidgetItem*,QListWidgetItem*)));
    
    dbPreferredUpButton = new QPushButton(tr("Up"), preferredGroup);
    connect(dbPreferredUpButton, SIGNAL(clicked()),
            this, SLOT(dbPreferredUpButtonClicked()));
    preferredLayout->addWidget(dbPreferredUpButton, 2,0);

    dbPreferredDownButton = new QPushButton(tr("Down"), preferredGroup);
    connect(dbPreferredDownButton, SIGNAL(clicked()),
            this, SLOT(dbPreferredDownButtonClicked()));
    preferredLayout->addWidget(dbPreferredDownButton, 2,1);

    dbPreferredRemoveButton = new QPushButton(tr("Remove"), preferredGroup);
    connect(dbPreferredRemoveButton, SIGNAL(clicked()),
            this, SLOT(dbPreferredRemoveButtonClicked()));
    preferredLayout->addWidget(dbPreferredRemoveButton, 2,2);

    // Show the appropriate page based on the activeTab setting.
    tabs->blockSignals(true);
    tabs->setCurrentIndex(activeTab);
    tabs->blockSignals(false);
}