TableWidget::TableWidget(QWidget *parent) : QTableWidget(parent){ originCols_ <<0<<1<<2<<5; resultCols_ <<3<<4; resizeColumnAction = new QAction(tr("Auto resize columns"), this); resizeColumnAction->setCheckable(true); resizeRowAction = new QAction(tr("Auto resize rows"), this); resizeRowAction->setCheckable(true); matchByTrackAction = new QAction(tr("Match by track"), this); matchByTrackAction->setData( MATCH_BY_TRACK ); matchByTrackAction->setCheckable(true); matchByTitleAction = new QAction(tr("Match by title"), this); matchByTitleAction->setData( MATCH_BY_TITLE ); matchByTitleAction->setCheckable(true); dontMatchAction = new QAction(tr("Do not match"), this); dontMatchAction->setData( DONT_MATCH ); dontMatchAction->setCheckable(true); matchByTrackTitleAction = new QAction(tr("Match by track, then title, then title to filename"), this); matchByTrackTitleAction->setData( MATCH_BY_TRACK_TITLE ); matchByTrackTitleAction->setCheckable(true); matchByTitleTrackAction = new QAction(tr("Match by title, then track, then title to filename"), this); matchByTitleTrackAction->setData( MATCH_BY_TITLE_TRACK ); matchByTitleTrackAction->setCheckable(true); matchByFileNameAction = new QAction(tr("Match title to filename"), this); matchByFileNameAction->setData( MATCH_BY_FILE_NAME ); matchByFileNameAction->setCheckable(true); //context menu setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); contextMenu(QPoint(), true ); //initialize actions //verticla header context menu this->verticalHeader()->setContextMenuPolicy(Qt::CustomContextMenu); connect(this->verticalHeader(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(verticalContextMenu(const QPoint &))); verticalContextMenu(QPoint(), true ); //initialize actions connect( this, SIGNAL( cellChanged( int, int ) ), this, SLOT( updateCell(int, int) ) ); settings = Global::guiSettings(); resizeColumns( settings->value("SearchDialog/autoResizeColumns",true).toBool() ); resizeColumnAction->setChecked( settings->value("SearchDialog/autoResizeColumns",true).toBool() ); resizeRows( settings->value("SearchDialog/autoResizeRows",false).toBool() ); resizeRowAction->setChecked( settings->value("SearchDialog/autoResizeRows",false).toBool() ); setSortingEnabled( settings->value("SearchDialog/sortingEnabled",true).toBool() ); if( isSortingEnabled() ){ int sortColumn = settings->value("SearchDialog/sortColumn",CURRENT_TRACK).toInt(); Qt::SortOrder sortOrder = (Qt::SortOrder)settings->value("SearchDialog/sortOrder", Qt::AscendingOrder ).toInt(); sortByColumn( sortColumn, sortOrder ); horizontalHeader()->setSortIndicator(sortColumn, sortOrder); horizontalHeader()->setSortIndicatorShown(true); horizontalHeader()->setClickable(true); } matchByTrackAction->setChecked( settings->value("SearchDialog/matchByTrack",false).toBool() ); matchByTitleAction->setChecked( settings->value("SearchDialog/matchByTitle",false).toBool() ); dontMatchAction->setChecked( settings->value("SearchDialog/dontMacth",true).toBool() ); matchByTrackTitleAction->setChecked( settings->value("SearchDialog/matchByTrackTitle",true).toBool() ); matchByTitleTrackAction->setChecked( settings->value("SearchDialog/matchByTitleTrack",false).toBool() ); matchByFileNameAction->setChecked( settings->value("SearchDialog/matchByFileName",false).toBool() ); this->horizontalHeader()->setStretchLastSection(true); this->verticalHeader()->setStretchLastSection(true); }
TableStatistics::TableStatistics(ScriptingEnv *env, QWidget *parent, Table *base, Type t, QValueList<int> targets) : Table(env, 0, 0, "", parent, ""), d_base(base), d_type(t), d_targets(targets) { worksheet->setReadOnly(true); setCaptionPolicy(myWidget::Both); if (d_type == row) { setName(QString(d_base->name())+"-"+tr("RowStats")); setWindowLabel(tr("Row Statistics of %1").arg(base->name())); resizeRows(d_targets.size()); resizeCols(9); setColName(0, tr("Row")); setColName(1, tr("Cols")); setColName(2, tr("Mean")); setColName(3, tr("StandardDev")); setColName(4, tr("Variance")); setColName(5, tr("Sum")); setColName(6, tr("Max")); setColName(7, tr("Min")); setColName(8, "N"); for (unsigned i=0; i < d_targets.size(); i++) setText(i, 0, QString::number(d_targets[i]+1)); update(d_base, QString::null); } else if (d_type == column) { setName(QString(d_base->name())+"-"+tr("ColStats")); setWindowLabel(tr("Column Statistics of %1").arg(base->name())); resizeRows(d_targets.size()); resizeCols(11); setColName(0, tr("Col")); setColName(1, tr("Rows")); setColName(2, tr("Mean")); setColName(3, tr("StandardDev")); setColName(4, tr("Variance")); setColName(5, tr("Sum")); setColName(6, tr("iMax")); setColName(7, tr("Max")); setColName(8, tr("iMin")); setColName(9, tr("Min")); setColName(10, "N"); for (unsigned i=0; i < d_targets.size(); i++) { setText(i, 0, d_base->colLabel(d_targets[i])); update(d_base, d_base->colName(d_targets[i])); } } int w=9*(worksheet->horizontalHeader())->sectionSize(0); int h; if (tableRows()>11) h=11*(worksheet->verticalHeader())->sectionSize(0); else h=(tableRows()+1)*(worksheet->verticalHeader())->sectionSize(0); setGeometry(50,50,w + 45, h + 45); setColPlotDesignation(0, Table::X); setHeaderColType(); }