(*** This bug was imported into bugs.kde.org ***) Package: kspread Version: 1.1.1 (using KDE 2.2.2 ) Severity: normal Installed from: ALT Linux Compiler: gcc version 2.96 20000731 (ALT Linux build 2.96-ipl14mdk) OS: Linux (i586) release 2.4.16 OS/Compiler notes: Now you can select only columns (by pressing ABC... buttons) or rows (by pressing 123 etc. buttons) Its needed for many cases to select all data in table (for example when you set the basic borders). So it's need special button that do it. The bect place for this button - top-left cornet of screen between button "A" (for column A) and button "1" (for row 1). This place is now empty and doesn't used. (Submitted via bugs.kde.org) (Called from KBugReport dialog)
Thank you for your bug report. This bug/feature request has already been reported and this report will be marked as a duplicate.
As far as I can tell, this is the first reference of request of "Select All" feature (a wishlist). I'll mark other similar bugs as reference of this bug.
*** Bug 38497 has been marked as a duplicate of this bug. ***
*** Bug 42399 has been marked as a duplicate of this bug. ***
*** Bug 65505 has been marked as a duplicate of this bug. ***
*** Bug 111806 has been marked as a duplicate of this bug. ***
*** Bug 136450 has been marked as a duplicate of this bug. ***
SVN commit 606408 by nikolaus: Selection Select All FEATURE: 36485 M +82 -0 Border.cpp M +26 -0 Border.h M +8 -0 Region.cpp M +10 -2 Region.h M +3 -2 TODO M +14 -1 View.cpp M +2 -1 View.h M +3 -1 kspread.rc --- trunk/koffice/kspread/Border.cpp #606407:606408 @@ -1440,4 +1440,86 @@ m_bMousePressed = false; } + +/**************************************************************** + * + * HBorder + * + ****************************************************************/ + +SelectAllButton::SelectAllButton( View* view ) + : QWidget( view ) + , m_view( view ) + , m_oldSelection() + , m_mousePressed( false ) +{ +} + +SelectAllButton::~SelectAllButton() +{ +} + +QSize SelectAllButton::sizeHint() const +{ + return QSize( 40, 10 ); +} + +void SelectAllButton::paintEvent( QPaintEvent* event ) +{ + // painting rectangle + const QRectF paintRect = m_view->doc()->viewToDocument( event->rect() ); + + // the painter + QPainter painter( this ); + painter.scale( m_view->doc()->zoomedResolutionX(), m_view->doc()->zoomedResolutionY() ); + + painter.setClipRect( paintRect ); + + // if all cells are selected + if ( m_view->selectionInfo()->isAllSelected() ) + { + // selection brush/color + QColor selectionColor( palette().highlight().color() ); + selectionColor.setAlpha( 127 ); + const QBrush selectionBrush( selectionColor ); + + painter.setPen( selectionColor.dark(150) ); + painter.setBrush( selectionBrush ); + } + else + { + // background brush/color + const QBrush backgroundBrush( palette().window() ); + const QColor backgroundColor( backgroundBrush.color() ); + + painter.setPen( backgroundColor.dark(150) ); + painter.setBrush( backgroundBrush ); + } + painter.drawRect( QRectF( 0, 0, width(), height() ) ); +} + +void SelectAllButton::mousePressEvent( QMouseEvent* event ) +{ + if ( event->button() == Qt::LeftButton ) + m_mousePressed = true; +} + +void SelectAllButton::mouseReleaseEvent( QMouseEvent* event ) +{ + Q_UNUSED(event); + if ( !m_mousePressed ) + return; + m_mousePressed = false; + if ( m_oldSelection.isEmpty() ) + { + m_oldSelection = *m_view->selectionInfo(); + m_view->selectionInfo()->initialize( QRect( 1, 1, KS_colMax, KS_rowMax ) ); + } + else + { + m_view->selectionInfo()->initialize( m_oldSelection ); + m_oldSelection.clear(); + } +} + #include "Border.moc" --- trunk/koffice/kspread/Border.h #606407:606408 @@ -170,5 +170,31 @@ QRubberBand* m_rubberband; }; + + +/** + * The widget in the top left corner of the canvas, + * responsible for selecting all cells in a sheet. + */ +class SelectAllButton : public QWidget +{ + Q_OBJECT +public: + SelectAllButton( View* view ); + virtual ~SelectAllButton(); + + QSize sizeHint() const; + +protected: + virtual void paintEvent( QPaintEvent* event ); + virtual void mousePressEvent( QMouseEvent* event ); + virtual void mouseReleaseEvent( QMouseEvent* event ); + +private: + View* m_view; + Region m_oldSelection; + bool m_mousePressed; +}; + } // namespace KSpread #endif --- trunk/koffice/kspread/Region.cpp #606407:606408 @@ -650,6 +650,14 @@ return false; } +bool Region::isAllSelected() const +{ + if (d->cells.count() != 1) + return false; + Q_ASSERT( d->cells.first() ); + return d->cells.first()->isAll(); +} + bool Region::contains(const QPoint& point, Sheet* sheet) const { if (d->cells.isEmpty()) --- trunk/koffice/kspread/Region.h #606407:606408 @@ -165,7 +165,7 @@ /** * @param row the row to check * - * @return @c true, if the row @p row is selected. If row @p row + * @return @c true , if the row @p row is selected. If row @p row * is not given, it returns true, if at least one row is selected * * \note If you want to check more than one row for selection, use @@ -174,11 +174,16 @@ bool isRowSelected(uint row = 0) const; /** - * @return @c true,if at least one column or one row is selected + * @return @c true , if at least one column or one row is selected */ bool isColumnOrRowSelected() const; /** + * @return @c true , if all cells in the sheet are selected + */ + bool isAllSelected() const; + + /** * @return a set of column numbers, for those columns, that are selected */ QSet<int> columnsSelected() const; @@ -389,6 +394,7 @@ virtual bool isValid() const { return false; } virtual bool isColumn() const { return false; } virtual bool isRow() const { return false; } + virtual bool isAll() const { return false; } virtual bool contains(const QPoint&) const { return false; } virtual bool contains(const QRect&) const { return false; } @@ -435,6 +441,7 @@ virtual bool isValid() const { return (!m_point.isNull() && Region::isValid(m_point)); } virtual bool isColumn() const { return false; } virtual bool isRow() const { return false; } + virtual bool isAll() const { return false; } virtual bool contains(const QPoint&) const; virtual bool contains(const QRect&) const; @@ -489,6 +496,7 @@ virtual bool isValid() const { return !m_range.isNull() && Region::isValid(m_range); } virtual bool isColumn() const { return (m_range.top() == 1 && m_range.bottom() == KS_rowMax); } virtual bool isRow() const { return (m_range.left() == 1 && m_range.right() == KS_colMax); } + virtual bool isAll() const { return (m_range == QRect( 1, 1, KS_colMax, KS_rowMax )); } virtual bool contains(const QPoint&) const; virtual bool contains(const QRect&) const; --- trunk/koffice/kspread/TODO #606407:606408 @@ -125,9 +125,10 @@ attributes set for column/rows. - Fix Style::isDefault(). Use the StyleManager's default style. ---- - Port the filters. done - - Decouple validity and conditions from cells. ---- - (think of the select all feature) + - Decouple validity and conditions from cells. done - Fix named styles. ---- + - Extend the Storage template to the StyleStorage level. ---- + Garbage collection, book-keeping, ... + Speed up selection. 1 ---- (probably improved with Format Storage?) --- trunk/koffice/kspread/View.cpp #606407:606408 @@ -194,6 +194,7 @@ Canvas *canvas; VBorder *vBorderWidget; HBorder *hBorderWidget; + SelectAllButton* selectAllButton; QScrollBar *horzScrollBar; QScrollBar *vertScrollBar; KoTabBar *tabBar; @@ -432,6 +433,7 @@ KAction* paste; KAction* specialPaste; KAction* insertCellCopy; + KAction* selectAll; KAction* find; KAction* replace; @@ -1022,9 +1024,11 @@ actions->insertCellCopy = new KAction( KIcon( "insertcellcopy" ), i18n("Paste with Insertion"), ac, "insertCellCopy" ); connect(actions->insertCellCopy, SIGNAL(triggered(bool)), view, SLOT( slotInsertCellCopy() )); - actions->insertCellCopy->setToolTip(i18n("Inserts a cell from the clipboard into the spreadsheet")); + actions->selectAll = KStdAction::selectAll( view, SLOT( selectAll() ), ac, "selectAll" ); + actions->selectAll->setToolTip(i18n("Selects all cells in the current sheet")); + actions->find = KStdAction::find( view, SLOT(find()), ac ); /*actions->findNext =*/ KStdAction::findNext( view, SLOT( findNext() ), ac ); /*actions->findPrevious =*/ KStdAction::findPrev( view, SLOT( findPrevious() ), ac ); @@ -1246,6 +1250,7 @@ actions->paste->setEnabled( mode ); actions->cut->setEnabled( mode ); actions->specialPaste->setEnabled( mode ); + actions->selectAll->setEnabled( mode ); actions->deleteCell->setEnabled( mode ); actions->clearText->setEnabled( mode ); actions->clearComment->setEnabled( mode ); @@ -1716,6 +1721,8 @@ d->vBorderWidget = new VBorder( this, d->canvas ,this ); d->hBorderWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); d->vBorderWidget->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ); + d->selectAllButton = new SelectAllButton( this ); + d->selectAllButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); d->canvas->setFocusPolicy( Qt::StrongFocus ); QWidget::setFocusPolicy( Qt::StrongFocus ); @@ -1749,6 +1756,7 @@ d->viewLayout->setColumnStretch( 1, 10 ); d->viewLayout->setRowStretch( 2, 10 ); d->viewLayout->addWidget( d->toolWidget, 0, 0, 1, 3 ); + d->viewLayout->addWidget( d->selectAllButton, 1, 0 ); d->viewLayout->addWidget( d->hBorderWidget, 1, 1, 1, 2 ); d->viewLayout->addWidget( d->vBorderWidget, 2, 0 ); d->viewLayout->addWidget( d->canvas, 2, 1 ); @@ -4003,6 +4011,11 @@ } } +void View::selectAll() +{ + selectionInfo()->initialize( QRect( 1, 1, KS_colMax, KS_rowMax ) ); +} + void View::changeAngle() { AngleDialog dlg( this, "Angle", selectionInfo()->marker() ); --- trunk/koffice/kspread/View.h #606407:606408 @@ -258,7 +258,7 @@ void deleteSelectedObjects(); -public slots: +public Q_SLOTS: /** * refresh view when you hide/show vertical scrollbar */ @@ -267,6 +267,7 @@ /** * Actions */ + void selectAll(); void createTemplate(); void transformPart(); void copySelection(); --- trunk/koffice/kspread/kspread.rc #606407:606408 @@ -1,4 +1,4 @@ -<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="KSpread" version="31"> +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="KSpread" version="32"> <MenuBar> <Menu name="file"><text>&File</text> <Separator/> @@ -20,6 +20,8 @@ <Action name="fillLeft"/> </Menu> <Separator/> + <Action name="selectAll"/> + <Separator/> <Action name="edit_find"/> <Action name="edit_find_next"/> <Action name="edit_find_last"/>
Great! :) Lot of thank you's ...