Merge pull request #1015 from shun-iwasawa/fix_cell_input_feature
Cell Input Feature Fixes
This commit is contained in:
commit
9356825406
5 changed files with 59 additions and 8 deletions
|
@ -1591,7 +1591,12 @@ void TCellSelection::deleteCells() {
|
|||
new DeleteCellsUndo(new TCellSelection(m_range), data);
|
||||
|
||||
deleteCellsWithoutUndo(r0, c0, r1, c1);
|
||||
selectNone();
|
||||
// emit selectionChanged() signal so that the rename field will update
|
||||
// accordingly
|
||||
if (Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled())
|
||||
TApp::instance()->getCurrentSelection()->notifySelectionChanged();
|
||||
else
|
||||
selectNone();
|
||||
|
||||
TUndoManager::manager()->add(undo);
|
||||
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
||||
|
@ -1616,7 +1621,12 @@ void TCellSelection::cutCells(bool withoutCopy) {
|
|||
cutCellsWithoutUndo(r0, c0, r1, c1);
|
||||
|
||||
TUndoManager::manager()->add(undo);
|
||||
selectNone();
|
||||
// cutCellsWithoutUndo will clear the selection, so select cells again
|
||||
if (Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled()) {
|
||||
selectCells(r0, c0, r1, c1);
|
||||
TApp::instance()->getCurrentSelection()->notifySelectionChanged();
|
||||
} else
|
||||
selectNone();
|
||||
|
||||
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
||||
}
|
||||
|
|
|
@ -1652,7 +1652,7 @@ void MainWindow::defineActions() {
|
|||
tr("Toggle Link to Studio Palette"), "");
|
||||
createRightClickMenuAction(MI_RemoveReferenceToStudioPalette,
|
||||
tr("Remove Reference to Studio Palette"), "");
|
||||
createMenuEditAction(MI_Clear, tr("&Delete"), "Delete");
|
||||
createMenuEditAction(MI_Clear, tr("&Delete"), "Del");
|
||||
createMenuEditAction(MI_Insert, tr("&Insert"), "Ins");
|
||||
createMenuEditAction(MI_Group, tr("&Group"), "Ctrl+G");
|
||||
createMenuEditAction(MI_Ungroup, tr("&Ungroup"), "Ctrl+Shift+G");
|
||||
|
|
|
@ -496,7 +496,6 @@ namespace XsheetGUI {
|
|||
|
||||
RenameCellField::RenameCellField(QWidget *parent, XsheetViewer *viewer)
|
||||
: QLineEdit(parent), m_viewer(viewer), m_row(-1), m_col(-1) {
|
||||
setFixedSize(XsheetGUI::ColumnWidth + 3, XsheetGUI::RowHeight + 4);
|
||||
connect(this, SIGNAL(returnPressed()), SLOT(onReturnPressed()));
|
||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
setObjectName("RenameCellField");
|
||||
|
@ -512,7 +511,6 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {
|
|||
m_row = row;
|
||||
m_col = col;
|
||||
|
||||
move(QPoint(m_viewer->columnToX(col) - 1, m_viewer->rowToY(row) - 2));
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
#else
|
||||
|
@ -546,6 +544,9 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {
|
|||
|
||||
TXshCell cell = xsh->getCell(row, col);
|
||||
if (!cell.isEmpty()) {
|
||||
setFixedSize(XsheetGUI::ColumnWidth - 5, XsheetGUI::RowHeight + 4);
|
||||
move(QPoint(m_viewer->columnToX(col) + 7, m_viewer->rowToY(row) - 2));
|
||||
|
||||
TFrameId fid = cell.getFrameId();
|
||||
std::wstring levelName = cell.m_level->getName();
|
||||
|
||||
|
@ -574,6 +575,9 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {
|
|||
}
|
||||
// clear the field if the empty cell is clicked
|
||||
else {
|
||||
setFixedSize(XsheetGUI::ColumnWidth + 3, XsheetGUI::RowHeight + 4);
|
||||
move(QPoint(m_viewer->columnToX(col) - 1, m_viewer->rowToY(row) - 2));
|
||||
|
||||
setText("");
|
||||
}
|
||||
show();
|
||||
|
@ -733,8 +737,10 @@ bool RenameCellField::eventFilter(QObject *obj, QEvent *e) {
|
|||
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
|
||||
if (!action) return false;
|
||||
|
||||
return TCellSelection::isEnabledCommand(
|
||||
CommandManager::instance()->getIdFromAction(action));
|
||||
std::string actionId = CommandManager::instance()->getIdFromAction(action);
|
||||
|
||||
if (actionId == "MI_Undo" || actionId == "MI_Redo") return true;
|
||||
return TCellSelection::isEnabledCommand(actionId);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -791,6 +797,34 @@ void RenameCellField::keyPressEvent(QKeyEvent *event) {
|
|||
TApp::instance()->getCurrentSelection()->notifySelectionChanged();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RenameCellField::showEvent(QShowEvent *) {
|
||||
bool ret = connect(TApp::instance()->getCurrentXsheet(),
|
||||
SIGNAL(xsheetChanged()), this, SLOT(onXsheetChanged()));
|
||||
assert(ret);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RenameCellField::hideEvent(QHideEvent *) {
|
||||
disconnect(TApp::instance()->getCurrentXsheet(), SIGNAL(xsheetChanged()),
|
||||
this, SLOT(onXsheetChanged()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RenameCellField::onXsheetChanged() {
|
||||
TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
|
||||
TApp::instance()->getCurrentSelection()->getSelection());
|
||||
if (!cellSelection) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
TCellSelection::Range range = cellSelection->getSelectedCells();
|
||||
showInRowCol(m_row, m_col, range.getColCount() > 1);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// CellArea
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -36,10 +36,14 @@ protected:
|
|||
void keyPressEvent(QKeyEvent *event) override;
|
||||
bool eventFilter(QObject *, QEvent *) override;
|
||||
|
||||
void showEvent(QShowEvent *) override;
|
||||
void hideEvent(QHideEvent *) override;
|
||||
|
||||
void renameCell();
|
||||
|
||||
protected slots:
|
||||
void onReturnPressed();
|
||||
void onXsheetChanged();
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -98,6 +102,7 @@ public:
|
|||
void showRenameField(int row, int col, bool multiColumnSelected = false) {
|
||||
m_renameCell->showInRowCol(row, col, multiColumnSelected);
|
||||
}
|
||||
void hideRenameField() { m_renameCell->hide(); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
|
|
@ -1034,7 +1034,9 @@ void XsheetViewer::onSelectionChanged(TSelection *selection) {
|
|||
changeWindowTitle();
|
||||
if (Preferences::instance()->isInputCellsWithoutDoubleClickingEnabled()) {
|
||||
TCellSelection *cellSel = getCellSelection();
|
||||
if (!cellSel->isEmpty())
|
||||
if (cellSel->isEmpty())
|
||||
m_cellArea->hideRenameField();
|
||||
else
|
||||
m_cellArea->showRenameField(
|
||||
cellSel->getSelectedCells().m_r0, cellSel->getSelectedCells().m_c0,
|
||||
cellSel->getSelectedCells().getColCount() > 1);
|
||||
|
|
Loading…
Reference in a new issue