1 /* This file is part of the KDE project
2    Copyright (C) 2004 Ariya Hidayat <ariya@kde.org>
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 // Local
21 #include "SheetPropertiesDialog.h"
22 
23 #include <kcombobox.h>
24 #include <KLocalizedString>
25 
26 #include <KoVBox.h>
27 
28 #include "Sheet.h"
29 
30 using namespace Calligra::Sheets;
31 
SheetPropertiesDialog(QWidget * parent)32 SheetPropertiesDialog::SheetPropertiesDialog(QWidget* parent):
33         KoDialog(parent)
34 {
35     setCaption(i18n("Sheet Properties"));
36     setObjectName(QLatin1String("sheetPropertiesDialog"));
37     setModal(true);
38     setButtons(Ok | Cancel | Default);
39 
40     KoVBox* mainWidget = new KoVBox();//makeVBoxMainWidget();
41     setMainWidget(mainWidget);
42     m_widget = new SheetPropertiesWidget(mainWidget);
43     QWidget* spacer = new QWidget(mainWidget);
44     spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
45     showButtonSeparator(true);
46     connect(this, SIGNAL(defaultClicked()), this, SLOT(slotDefault()));
47 }
48 
~SheetPropertiesDialog()49 SheetPropertiesDialog::~SheetPropertiesDialog()
50 {
51     delete m_widget;
52 }
53 
slotDefault()54 void SheetPropertiesDialog::slotDefault()
55 {
56     setLayoutDirection(Qt::LeftToRight);
57     setAutoCalculationEnabled(true);
58     setShowGrid(true);
59     setShowFormula(false);
60     setHideZero(false);
61     setShowFormulaIndicator(true);
62     setShowCommentIndicator(true);
63     setShowPageOutline(false);
64     setColumnAsNumber(false);
65     setLcMode(false);
66     setCapitalizeFirstLetter(false);
67 }
68 
layoutDirection() const69 Qt::LayoutDirection SheetPropertiesDialog::layoutDirection() const
70 {
71     if (m_widget->directionComboBox->currentText() == i18n("Left to Right"))
72         return Qt::LeftToRight;
73 
74     if (m_widget->directionComboBox->currentText() == i18n("Right to Left"))
75         return Qt::RightToLeft;
76 
77     // fallback
78     return Qt::LeftToRight;
79 }
80 
setLayoutDirection(Qt::LayoutDirection dir)81 void SheetPropertiesDialog::setLayoutDirection(Qt::LayoutDirection dir)
82 {
83     switch (dir) {
84     case Qt::LeftToRight:
85         m_widget->directionComboBox->setCurrentIndex(0);
86         break;
87     case Qt::RightToLeft:
88         m_widget->directionComboBox->setCurrentIndex(1);
89         break;
90     default: break;
91     };
92 }
93 
autoCalc() const94 bool SheetPropertiesDialog::autoCalc() const
95 {
96     return m_widget->autoCalcCheckBox->isChecked();
97 }
98 
setAutoCalculationEnabled(bool b)99 void SheetPropertiesDialog::setAutoCalculationEnabled(bool b)
100 {
101     m_widget->autoCalcCheckBox->setChecked(b);
102 }
103 
showGrid() const104 bool SheetPropertiesDialog::showGrid() const
105 {
106     return m_widget->showGridCheckBox->isChecked();
107 }
108 
setShowGrid(bool b)109 void SheetPropertiesDialog::setShowGrid(bool b)
110 {
111     m_widget->showGridCheckBox->setChecked(b);
112 }
113 
showPageOutline() const114 bool SheetPropertiesDialog::showPageOutline() const
115 {
116     return m_widget->showPageOutlineCheckBox->isChecked();
117 }
118 
setShowPageOutline(bool b)119 void SheetPropertiesDialog::setShowPageOutline(bool b)
120 {
121     m_widget->showPageOutlineCheckBox->setChecked(b);
122 }
123 
showFormula() const124 bool SheetPropertiesDialog::showFormula() const
125 {
126     return m_widget->showFormulaCheckBox->isChecked();
127 }
128 
setShowFormula(bool b)129 void SheetPropertiesDialog::setShowFormula(bool b)
130 {
131     m_widget->showFormulaCheckBox->setChecked(b);
132 }
133 
hideZero() const134 bool SheetPropertiesDialog::hideZero() const
135 {
136     return m_widget->hideZeroCheckBox->isChecked();
137 }
138 
setHideZero(bool b)139 void SheetPropertiesDialog::setHideZero(bool b)
140 {
141     m_widget->hideZeroCheckBox->setChecked(b);
142 }
143 
showFormulaIndicator() const144 bool SheetPropertiesDialog::showFormulaIndicator() const
145 {
146     return m_widget->showFormulaIndicatorCheckBox->isChecked();
147 }
148 
setShowFormulaIndicator(bool b)149 void SheetPropertiesDialog::setShowFormulaIndicator(bool b)
150 {
151     m_widget->showFormulaIndicatorCheckBox->setChecked(b);
152 }
153 
showCommentIndicator() const154 bool SheetPropertiesDialog::showCommentIndicator() const
155 {
156     return m_widget->showCommentIndicatorCheckBox->isChecked();
157 }
158 
setShowCommentIndicator(bool b)159 void SheetPropertiesDialog::setShowCommentIndicator(bool b)
160 {
161     m_widget->showCommentIndicatorCheckBox->setChecked(b);
162 }
163 
columnAsNumber() const164 bool SheetPropertiesDialog::columnAsNumber() const
165 {
166     return m_widget->showColumnAsNumbersCheckBox->isChecked();
167 }
168 
setColumnAsNumber(bool b)169 void SheetPropertiesDialog::setColumnAsNumber(bool b)
170 {
171     m_widget->showColumnAsNumbersCheckBox->setChecked(b);
172 }
173 
lcMode() const174 bool SheetPropertiesDialog::lcMode() const
175 {
176     return m_widget->useLCModeCheckBox->isChecked();
177 }
178 
setLcMode(bool b)179 void SheetPropertiesDialog::setLcMode(bool b)
180 {
181     m_widget->useLCModeCheckBox->setChecked(b);
182 }
183 
capitalizeFirstLetter() const184 bool SheetPropertiesDialog::capitalizeFirstLetter() const
185 {
186     return m_widget->capitalizeFirstLetterCheckBox->isChecked();
187 }
188 
setCapitalizeFirstLetter(bool b)189 void SheetPropertiesDialog::setCapitalizeFirstLetter(bool b)
190 {
191     m_widget->capitalizeFirstLetterCheckBox->setChecked(b);
192 }
193