1 /* This file is part of the KDE project
2 Copyright 2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 */
19
20 #include "AutoFilterCommand.h"
21
22 #include <KLocalizedString>
23
24 #include "CellStorage.h"
25 #include "Damages.h"
26 #include "Map.h"
27 #include "Sheet.h"
28
29 #include "database/Database.h"
30 #include "database/DatabaseManager.h"
31
32 using namespace Calligra::Sheets;
33
AutoFilterCommand()34 AutoFilterCommand::AutoFilterCommand()
35 : AbstractRegionCommand()
36 {
37 setText(kundo2_i18n("Auto-Filter"));
38 }
39
~AutoFilterCommand()40 AutoFilterCommand::~AutoFilterCommand()
41 {
42 }
43
redo()44 void AutoFilterCommand::redo()
45 {
46 Database database(m_sheet->map()->databaseManager()->createUniqueName());
47 database.setDisplayFilterButtons(true);
48 database.setRange(*this);
49 m_sheet->cellStorage()->setDatabase(*this, database);
50 m_sheet->map()->addDamage(new CellDamage(m_sheet, *this, CellDamage::Appearance));
51 }
52
undo()53 void AutoFilterCommand::undo()
54 {
55 m_sheet->cellStorage()->setDatabase(*this, Database());
56 m_sheet->map()->addDamage(new CellDamage(m_sheet, *this, CellDamage::Appearance));
57 }
58