ICS

QicsTable Documentation Set

custom_grid.cpp

/****************************************************************************
** $RCSfile: cg_cpp.html,v $ $Date: 2008/06/23 16:31:51 $
**
** Copyright ( C ) 2002-2006 Integrated Computer Solutions, Inc.
** All rights reserved.
**
** This file is part of an example program for QicsTable.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#include "custom_grid.h"
#include <QMouseEvent>
#include <QMenu>


// This is an example of a custom table grid.  This grid acts like
// the default QicsTableGrid, except that it posts a popup menu
// when the user presses the right mouse button.


CustomGrid::CustomGrid(QWidget *w, QicsGridInfo &info,
               int top_row, int left_column) :
    QicsTableGrid(w, info, top_row, left_column)
{
    _menu = new QMenu(this);
    _menu->addAction(QString("Cut"), w, SLOT(cut()));
    _menu->addAction(QString("Copy"), w, SLOT(copy()));
    _menu->addAction(QString("Paste"), w, SLOT(paste()));
}

QicsTableGrid *
CustomGrid::createGrid(QWidget *w, QicsGridInfo &info,
               int top_row, int left_column)
{
    return (new CustomGrid(w, info, top_row, left_column));
}

void
CustomGrid::handleMousePressEvent(const QicsICell &cell, QMouseEvent *m)
{
    if (m->button() == Qt::RightButton)
    _menu->popup(m->globalPos());
    else
    QicsTableGrid::handleMousePressEvent(cell, m);
}

All trademarks and copyrights on this page are properties of their respective owners.
The rest is copyright 1999-2006 Integrated Computer Solutions, Inc.