Ejemplo n.º 1
0
QTableWidget* StatusViewer::prepareTable(int rows, int cols) {
    QTableWidget* table = new QTableWidget(this);
    table->setColumnCount(cols);
    table->setRowCount(rows);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAttribute(Qt::WA_MacShowFocusRect, 0);
    table->setShowGrid(false);
    table->setAlternatingRowColors(true);
    table->setSortingEnabled(false);

    for (int c = 0; c < cols; ++c) {
        table->horizontalHeader()->setSectionResizeMode(c, QHeaderView::Stretch);
    }
    
    for(int row=0; row<rows; ++row) {
        for(int col=0; col<cols; ++col){
            QTableWidgetItem* tableItem = new QTableWidgetItem();
            tableItem->setFlags(tableItem->flags() ^ Qt::ItemIsEditable);
            tableItem->setTextAlignment(Qt::AlignRight);
            tableItem->setText("--");
            table->setItem(row, col, tableItem);
        }
    }
    
    return table;
}
Ejemplo n.º 2
0
QTableWidget* AutoImportWindow::setupFilesTable() {
    QTableWidget* filesTable = new QTableWidget(0, 6);
    filesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    filesTable->setAttribute(Qt::WA_MacShowFocusRect, 0);

    QStringList labels;
    labels << "" << tr("Directory") << tr("Search Name") << tr("Averaged") << tr("Aligned") << tr("Raw");
    filesTable->setHorizontalHeaderLabels(labels);
    filesTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
    filesTable->verticalHeader()->hide();
    filesTable->setShowGrid(false);
    filesTable->setAlternatingRowColors(true);
    
    connect(filesTable, &QTableWidget::itemDoubleClicked, [=](QTableWidgetItem *item){
        if(item->row() != -1 && item->row() < rowToImagePaths_.size()) {
            QString path = rowToImagePaths_[item->row()];
            ProjectImage* image = projectData.projectImage(QDir(projectData.projectDir().absoluteFilePath(path)));
            if(image) emit imageToBeOpened(image);
            else QMessageBox::warning(this, "Image Open Error!", "Image: " + path + " was either not imported or not found.");
        }
    });

    return filesTable;
}