Beispiel #1
0
CostMatrixTableView::CostMatrixTableView(QWidget *parent) :
    QTableView(parent)
{
    setItemDelegate(new CostMatrixDelegate(this));

    // Context menu
    contextMenu = new QMenu;
    copyAction = new QAction(QIcon(":/icons/img/edit-copy.png"), "Copy", this);
    copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
    copyAction->setShortcutContext(Qt::WidgetShortcut);
    addAction(copyAction);
    connect(copyAction, SIGNAL(triggered()), this, SLOT(onCopyAction()));
    contextMenu->addAction(copyAction);
    pasteAction = new QAction(QIcon(":/icons/img/edit-paste.png"), "Paste", this);
    pasteAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
    pasteAction->setShortcutContext(Qt::WidgetShortcut);
    addAction(pasteAction);
    connect(pasteAction, SIGNAL(triggered()), this, SLOT(onPasteAction()));
    contextMenu->addAction(pasteAction);
    contextMenu->addSeparator();
    contextMenu->addAction(
        QIcon(":/icons/img/autofit-width.png"),
        "Resize columns to contents",
        this, SLOT(resizeColumnsToContents()));
}
Beispiel #2
0
void FileTypesView::keyPressEvent( QKeyEvent* event ) {
	// call the base class implementation
	QTableView::keyPressEvent(event);

	QModelIndex selected = currentIndex();

	if (event->matches(QKeySequence::Copy)) {
		onCopyAction();
	}
	if (event->matches(QKeySequence::Paste)) {
		onPasteAction();
	}
	if (event->matches(QKeySequence::Delete)) {

		// if user had selected the file type column
		if (selected.column() == 0) {

			// if the file type is one of the standard ones, it can't be cleared
			QString selectedFileType = selected.model()->data(selected, Qt::DisplayRole).toString();
			if (General::isIpXactFileType(selectedFileType)) {
				return;
			}
		}

		onClearAction();
	}
	if (event->matches(QKeySequence::InsertLineSeparator)) {
		onAddAction();
	}
}
Beispiel #3
0
//-----------------------------------------------------------------------------
// Function: keyPressEvent()
//-----------------------------------------------------------------------------
void CellEditTableView::keyPressEvent( QKeyEvent* event ) {

    // Call the base class implementation.
    QTableView::keyPressEvent(event);

    if (event->matches(QKeySequence::Copy)) {
        onCopyAction();
    }
    if (event->matches(QKeySequence::Paste)) {
        onPasteAction();
    }
    if (event->matches(QKeySequence::Delete)) {
        onClearAction();
    }
}
Beispiel #4
0
//-----------------------------------------------------------------------------
// Function: setupActions()
//-----------------------------------------------------------------------------
void CellEditTableView::setupActions() {

    copyAction_.setToolTip(tr("Copy a value from the table"));
    copyAction_.setStatusTip(tr("Copy a value from the table"));
    connect(&copyAction_, SIGNAL(triggered()),
        this, SLOT(onCopyAction()), Qt::UniqueConnection);
    copyAction_.setShortcut(QKeySequence::Copy);

    pasteAction_.setToolTip(tr("Paste a value to the table"));
    pasteAction_.setStatusTip(tr("Paste a value to the table"));
    connect(&pasteAction_, SIGNAL(triggered()),
        this, SLOT(onPasteAction()), Qt::UniqueConnection);
    pasteAction_.setShortcut(QKeySequence::Paste);

    clearAction_.setToolTip(tr("Clear the contents of a cell"));
    clearAction_.setStatusTip(tr("Clear the contents of a cell"));
    connect(&clearAction_, SIGNAL(triggered()),
        this, SLOT(onClearAction()), Qt::UniqueConnection);
    clearAction_.setShortcut(QKeySequence::Delete);
}