mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Cut/Copy/Paste menu entries are now enabled/disabled according to the current state of editor, selection and clipboard.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1563 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -452,6 +452,7 @@ void QETTitleBlockTemplateEditor::initWidgets() {
|
|||||||
SLOT(savePreviewWidthToApplicationSettings(int, int))
|
SLOT(savePreviewWidthToApplicationSettings(int, int))
|
||||||
);
|
);
|
||||||
connect(undo_stack_, SIGNAL(cleanChanged(bool)), this, SLOT(updateEditorTitle()));
|
connect(undo_stack_, SIGNAL(cleanChanged(bool)), this, SLOT(updateEditorTitle()));
|
||||||
|
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(updateActions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -578,9 +579,13 @@ void QETTitleBlockTemplateEditor::updateActions() {
|
|||||||
|
|
||||||
bool can_merge;
|
bool can_merge;
|
||||||
bool can_split;
|
bool can_split;
|
||||||
|
int count;
|
||||||
if (!read_only_) {
|
if (!read_only_) {
|
||||||
template_edition_area_view_ -> analyzeSelectedCells(&can_merge, &can_split);
|
template_edition_area_view_ -> analyzeSelectedCells(&can_merge, &can_split, &count);
|
||||||
}
|
}
|
||||||
|
cut_ -> setEnabled(!read_only_ && count);
|
||||||
|
copy_ -> setEnabled(count);
|
||||||
|
paste_ -> setEnabled(!read_only_ && count && template_edition_area_view_ -> mayPaste());
|
||||||
merge_cells_ -> setEnabled(!read_only_ && can_merge);
|
merge_cells_ -> setEnabled(!read_only_ && can_merge);
|
||||||
split_cell_ -> setEnabled(!read_only_ && can_split);
|
split_cell_ -> setEnabled(!read_only_ && can_split);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,15 @@ QList<TitleBlockCell *> TitleBlockTemplateView::copy() {
|
|||||||
return(copied_cells);
|
return(copied_cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true if the content of the clipboard looks interesting
|
||||||
|
*/
|
||||||
|
bool TitleBlockTemplateView::mayPaste() {
|
||||||
|
// retrieve the clipboard content
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
return(clipboard -> text().contains("<titleblocktemplate-partial"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Import the cells described in the clipboard.
|
Import the cells described in the clipboard.
|
||||||
*/
|
*/
|
||||||
@@ -385,8 +394,9 @@ TitleBlockTemplateCellsSet TitleBlockTemplateView::cells(const QRectF &rect) con
|
|||||||
/**
|
/**
|
||||||
@param can_merge If non-zero, will be changed to reflect whether selected cells may be merged
|
@param can_merge If non-zero, will be changed to reflect whether selected cells may be merged
|
||||||
@param can_merge If non-zero, will be changed to reflect whether selected cells may be splitted
|
@param can_merge If non-zero, will be changed to reflect whether selected cells may be splitted
|
||||||
|
@param count If non-zero, will be changed to reflect the number of selected cells
|
||||||
*/
|
*/
|
||||||
void TitleBlockTemplateView::analyzeSelectedCells(bool *can_merge, bool *can_split) {
|
void TitleBlockTemplateView::analyzeSelectedCells(bool *can_merge, bool *can_split, int *count) {
|
||||||
if (!can_merge && !can_split) return;
|
if (!can_merge && !can_split) return;
|
||||||
|
|
||||||
if (!tbtemplate_) {
|
if (!tbtemplate_) {
|
||||||
@@ -404,6 +414,9 @@ void TitleBlockTemplateView::analyzeSelectedCells(bool *can_merge, bool *can_spl
|
|||||||
if (can_split) {
|
if (can_split) {
|
||||||
*can_split = SplitCellsCommand::canSplit(selected_cells, tbtemplate_);
|
*can_split = SplitCellsCommand::canSplit(selected_cells, tbtemplate_);
|
||||||
}
|
}
|
||||||
|
if (count) {
|
||||||
|
*count = selectedCellsSet().count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class TitleBlockTemplateView : public QGraphicsView {
|
|||||||
virtual QList<TitleBlockCell *> selectedCells() const;
|
virtual QList<TitleBlockCell *> selectedCells() const;
|
||||||
virtual TitleBlockTemplateCellsSet selectedCellsSet() const;
|
virtual TitleBlockTemplateCellsSet selectedCellsSet() const;
|
||||||
virtual TitleBlockTemplateCellsSet cells(const QRectF &) const;
|
virtual TitleBlockTemplateCellsSet cells(const QRectF &) const;
|
||||||
virtual void analyzeSelectedCells(bool *, bool *);
|
virtual void analyzeSelectedCells(bool *, bool *, int *);
|
||||||
virtual QSizeF templateSize() const;
|
virtual QSizeF templateSize() const;
|
||||||
virtual qreal templateWidth() const;
|
virtual qreal templateWidth() const;
|
||||||
virtual qreal templateHeight() const;
|
virtual qreal templateHeight() const;
|
||||||
@@ -60,6 +60,7 @@ class TitleBlockTemplateView : public QGraphicsView {
|
|||||||
void zoomReset();
|
void zoomReset();
|
||||||
QList<TitleBlockCell *> cut();
|
QList<TitleBlockCell *> cut();
|
||||||
QList<TitleBlockCell *> copy();
|
QList<TitleBlockCell *> copy();
|
||||||
|
bool mayPaste();
|
||||||
void paste();
|
void paste();
|
||||||
void addColumnBefore();
|
void addColumnBefore();
|
||||||
void addRowBefore();
|
void addRowBefore();
|
||||||
|
|||||||
Reference in New Issue
Block a user