コード例 #1
0
ファイル: mytable.cpp プロジェクト: XRay3D/MT4080D
MyTable::MyTable(QWidget* parent)
    : QTableView(/*7, 13,*/ parent)
    , m_model(new MyModel(this))
{
    setModel(m_model);

    //    QPushButton* cornerButton = reinterpret_cast<QPushButton*>(findChild<QAbstractButton*>());
    //    if (cornerButton) {
    //        cornerButton->disconnect();
    //        cornerButton->setText("123");
    //        cornerButton->setCheckable(true);
    //        //cornerButton->setEnabled(false);
    //        //connect(cornerButton, SIGNAL(clicked()), ..., ...);
    //        QCheckBox* c = new QCheckBox("№", cornerButton);
    //        c->setGeometry(cornerButton->rect() + QMargins(-5, 0, 0, 0));
    //    }

    setHorizontalHeader(new MyHeader(Qt::Horizontal, this));
    setVerticalHeader(new MyHeader(Qt::Vertical, this));

    connect(reinterpret_cast<MyHeader*>(horizontalHeader()), &MyHeader::stateChanged, m_model, &MyModel::stateChanged);
    connect(reinterpret_cast<MyHeader*>(horizontalHeader()), &MyHeader::stateChanged, [&](const QMap<int, bool>& enabled, int /*orientation*/) {
        for (int i = 0; i < enabled.size(); ++i)
            if (enabled[i])
                m_currentColumn = i;
    });
    connect(reinterpret_cast<MyHeader*>(verticalHeader()), &MyHeader::stateChanged, m_model, &MyModel::stateChanged);

    readSettings();
}
コード例 #2
0
ファイル: dbview.cpp プロジェクト: Aurthem/WeatherDB
DBView::DBView(QWidget * parent) : QTableView(parent) {
	QTableView::setItemDelegate(new DBDelegate(this));
	setWordWrap(true);
	setTextElideMode(Qt::ElideRight);
	CheckboxHeader* header = new CheckboxHeader(Qt::Vertical, this);
	setVerticalHeader(header);

	horizontalHeader()->setMinimumSectionSize(fontInfo().pixelSize()+2);	//13=11+2 for margins
	horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
	setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
	setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
}
コード例 #3
0
ファイル: schedulertable.cpp プロジェクト: gil9red/combustion
SchedulerTable::SchedulerTable()
    : QTableView()
{
    setModel(&model);
    setItemDelegate(new SchedulerCellDelegate());

    // Заголовок будет в lineDaysTable
    horizontalHeader()->hide();
    setVerticalHeader(new VerticalSchedulerHeaderView());

    setSelectionBehavior(QAbstractItemView::SelectItems);
    setSelectionMode(QAbstractItemView::SingleSelection);
}
コード例 #4
0
/**
* Constructs a QFilterView with the given @p parent.
*/
QFilterView::QFilterView( QWidget* parent )
    : QTableView(parent), d(new QFilterViewPrivate(this))
{
    setItemDelegate(new QFilterViewItemDelegate(this));

    setHorizontalHeader(new QAdvancedHeaderView(Qt::Horizontal, this));
    setVerticalHeader(new QAdvancedHeaderView(Qt::Vertical, this));

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    QAbstractButton* cb = findChild<QAbstractButton*>();
    if (cb){
        cb->disconnect();
        connect(cb, SIGNAL(clicked()), this, SIGNAL(cornerButtonClicked()));
    }
    updateGeometry();

}
コード例 #5
0
QCustomTableWidget::QCustomTableWidget(QWidget *parent): QTableWidget(parent), menu(new QMenu(this)), hMenu(new QMenu(this)), vMenu(new QMenu(this)), pChangePropertyDial(new ChangePropertyDialog(this)), pChangeCharacterDial(new ChangeCharacterDialog(this)), pProperties(0), pCharacters(0), bEditing(false), bUpdate(false), iCreatedCells(0)
{
    // property menu
    actionAddColumn = new QAction(this);
    actionAddColumn->setIcon(QIcon(":/data/images/add.svg"));
    actionRemoveColumn = new QAction(this);
    actionRemoveColumn->setIcon(QIcon(":/data/images/remove.svg"));
    actionEditColumn = new QAction(this);
    actionEditColumn->setIcon(QIcon(":/data/images/pencil.svg"));
    hMenu->addAction(actionAddColumn);
    hMenu->addAction(actionRemoveColumn);
    hMenu->addAction(actionEditColumn);
    // character menu
    actionAddRow = new QAction(this);
    actionAddRow->setIcon(QIcon(":/data/images/add.svg"));
    actionRemoveRow = new QAction(this);
    actionRemoveRow->setIcon(QIcon(":/data/images/remove.svg"));
    actionEditRow = new QAction(this);
    actionEditRow->setIcon(QIcon(":/data/images/pencil.svg"));
    vMenu->addAction(actionAddRow);
    vMenu->addAction(actionRemoveRow);
    vMenu->addAction(actionEditRow);
    // main menu
    menu->addMenu(hMenu);
    menu->addMenu(vMenu);
    // sets the text of the menus
    retranslate();

    // headers
    setHorizontalHeader(new QCustomHeaderView(Qt::Horizontal,this));
    setVerticalHeader(new QCustomHeaderView(Qt::Vertical,this));

    // connection of signals
    QCustomHeaderView *header = dynamic_cast<QCustomHeaderView*>(horizontalHeader());
    connect(header, SIGNAL(rightClicked(int, const QPoint&)), this, SLOT(onHHeaderClicked(int, const QPoint&)));
    connect(header, SIGNAL(sectionMoved(int, int, int)), this, SLOT(onHHeaderMoved(int, int, int)));
    header = dynamic_cast<QCustomHeaderView*>(verticalHeader());
    connect(header, SIGNAL(rightClicked(int, const QPoint&)), this, SLOT(onVHeaderClicked(int, const QPoint&)));
    connect(header, SIGNAL(sectionMoved(int, int, int)), this, SLOT(onVHeaderMoved(int, int, int)));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(on_itemSelectionChanged()));
    connect(this, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
}
コード例 #6
0
MyTable::MyTable(QWidget* parent)
    : QTableView(/*RowCount, ColumnCount, */ parent)
    , m_header(new MyHeader(Qt::Vertical, this))
    , m_model(new MyTableModel(this))
#ifdef EXCEL
    , excel(new Excel::Application(this))
#endif
{
    setModel(m_model);
    setVerticalHeader(m_header);

    connect(m_model, &MyTableModel::dataChanged, [=](const QModelIndex& topLeft, const QModelIndex& /*bottomRight*/, const QVector<int>& /*roles*/) {
        updatePlot(topLeft.row());
        resizeRowToContents(topLeft.row());
    });

    QAbstractButton* cornerButton = findChild<QAbstractButton*>();
    if (cornerButton) {
        c = new QCheckBox("№", cornerButton);
        c->setGeometry(cornerButton->rect() + QMargins(-5, 0, 100, 0));
        connect(c, &QCheckBox::toggled, [this](bool checked) { m_header->setChecked(checked); });
    }

    connect(m_header, &MyHeader::checkedChanged, m_model, &MyTableModel::setRowsEnabled);

    setColumnHidden(MeasureDeltaCh0, true);
    setColumnHidden(MeasureDeltaCh1, true);

    horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    horizontalHeader()->setSectionResizeMode(MeasureCh0, QHeaderView::Stretch);
    horizontalHeader()->setSectionResizeMode(MeasureCh1, QHeaderView::Stretch);

    setIconSize(QSize(24, 24));
#ifdef EXCEL
    excel->SetVisible(true);
#endif
}
コード例 #7
0
QCustomTableWidget::QCustomTableWidget(QWidget *parent): QTableWidget(parent), menu(new QMenu(this)), hMenu(new QMenu(this)), vMenu(new QMenu(this)), pChangeSkillDial(new ChangeSkillDialog(this)), pChangeCharacterDial(new ChangeCharacterDialog(this)), pSkills(NULL), pCharacters(NULL)
{
    // popup menu
    // skills
    QMenu *menuColumn = menu->addMenu(QApplication::translate("customTable","&Skill",0));
    actionAddColumn = new QAction(QIcon(":/data/images/add.svg"),QApplication::translate("customTable","&Add",0),this);
    actionAddColumn->setIconVisibleInMenu(true);
    actionAddColumn->setStatusTip(QApplication::translate("customTable","Add a new skill",0));
    actionRemoveColumn = new QAction(QIcon(":/data/images/remove.svg"),QApplication::translate("customTable","&Remove",0),this);
    actionRemoveColumn->setIconVisibleInMenu(true);
    actionRemoveColumn->setStatusTip(QApplication::translate("customTable","Remove the skill",0));
    actionEditColumn = new QAction(QIcon(":/data/images/son.svg"),QApplication::translate("customTable","&Edit",0),this);
    actionEditColumn->setIconVisibleInMenu(true);
    actionEditColumn->setStatusTip(QApplication::translate("customTable","Edit the skill",0));
    menuColumn->addAction(actionAddColumn);
    menuColumn->addAction(actionRemoveColumn);
    menuColumn->addAction(actionEditColumn);
    // characters
    QMenu *menuRow = menu->addMenu(QApplication::translate("customTable","&Character",0));
    actionAddRow = new QAction(QIcon(":/data/images/add.svg"),QApplication::translate("customTable","&Add",0),this);
    actionAddRow->setIconVisibleInMenu(true);
    actionAddRow->setStatusTip(QApplication::translate("customTable","Add a new character",0));
    actionRemoveRow = new QAction(QIcon(":/data/images/remove.svg"),QApplication::translate("customTable","&Remove",0),this);
    actionRemoveRow->setIconVisibleInMenu(true);
    actionRemoveRow->setStatusTip(QApplication::translate("customTable","Remove the character",0));
    actionEditRow = new QAction(QIcon(":/data/images/son.svg"),QApplication::translate("customTable","&Edit",0),this);
    actionEditRow->setIconVisibleInMenu(true);
    actionEditRow->setStatusTip(QApplication::translate("customTable","Edit the character",0));
    menuRow->addAction(actionAddRow);
    menuRow->addAction(actionRemoveRow);
    menuRow->addAction(actionEditRow);

    // popup menu for vertical header
    actionVAdd = new QAction(QIcon(":/data/images/add.svg"),QApplication::translate("customTable","&Add",0),this);
    actionVAdd->setIconVisibleInMenu(true);
    actionVAdd->setStatusTip(QApplication::translate("customTable","Add a new character",0));
    actionVRemove = new QAction(QIcon(":/data/images/remove.svg"),QApplication::translate("customTable","&Remove",0),this);
    actionVRemove->setIconVisibleInMenu(true);
    actionVRemove->setStatusTip(QApplication::translate("customTable","Remove the character",0));
    actionVEdit = new QAction(QIcon(":/data/images/son.svg"),QApplication::translate("customTable","&Edit",0),this);
    actionVEdit->setIconVisibleInMenu(true);
    actionVEdit->setStatusTip(QApplication::translate("customTable","Edit the character",0));
    vMenu->addAction(actionVAdd);
    vMenu->addAction(actionVRemove);
    vMenu->addAction(actionVEdit);

    // popup menu for horizontal header
    actionHAdd = new QAction(QIcon(":/data/images/add.svg"),QApplication::translate("customTable","&Add",0),this);
    actionHAdd->setIconVisibleInMenu(true);
    actionHAdd->setStatusTip(QApplication::translate("customTable","Add a new skill",0));
    actionHRemove = new QAction(QIcon(":/data/images/remove.svg"),QApplication::translate("customTable","&Remove",0),this);
    actionHRemove->setIconVisibleInMenu(true);
    actionHRemove->setStatusTip(QApplication::translate("customTable","Remove the skill",0));
    actionHEdit = new QAction(QIcon(":/data/images/son.svg"),QApplication::translate("customTable","&Edit",0),this);
    actionHEdit->setIconVisibleInMenu(true);
    actionHEdit->setStatusTip(QApplication::translate("customTable","Edit the skill",0));
    hMenu->addAction(actionHAdd);
    hMenu->addAction(actionHRemove);
    hMenu->addAction(actionHEdit);

    // headers
    setHorizontalHeader(new QCustomHeaderView(Qt::Horizontal,this));
    setVerticalHeader(new QCustomHeaderView(Qt::Vertical,this));

    // connection of signals
    connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(onCellChanged(int,int)));
    connect(dynamic_cast<QCustomHeaderView*>(horizontalHeader()),SIGNAL(rightClicked(int, const QPoint&)),this,SLOT(onHHeaderClicked(int, const QPoint&)));
    connect(dynamic_cast<QCustomHeaderView*>(verticalHeader()),SIGNAL(rightClicked(int, const QPoint&)),this,SLOT(onVHeaderClicked(int, const QPoint&)));
}