[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/kwordquiz/src
From: Peter Hedlund <peter () peterandlinda ! com>
Date: 2010-03-17 18:17:07
Message-ID: 1268849827.628639.26180.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1104444 by hedlund:
Cleaner code for handling column properties.
M +10 -16 documentsettings.kcfg
M +14 -40 kwqtablemodel.cpp
--- trunk/KDE/kdeedu/kwordquiz/src/documentsettings.kcfg #1104443:1104444
@@ -7,23 +7,17 @@
<parameter name="fileurl" />
</kcfgfile>
<group name="Document $(fileurl)">
- <entry name="SizeHintColumn1" type="Int">
- <label>The width for the first table column.</label>
- <whatsthis>The width for the first table column.</whatsthis>
- <default>200</default>
+ <entry name="SizeHintColumn$(Section)" type="Int" \
key="SizeHintColumn$(Section)"> + <parameter name="Section" type="Int" min="0" \
max="1"/> + <label>Column widths</label>
+ <default param="0">200</default>
+ <default param="1">200</default>
</entry>
- <entry name="SizeHintColumn2" type="Int">
- <label>The width for the second table column.</label>
- <whatsthis>The width for the second table column.</whatsthis>
- <default>200</default>
+ <entry name="KeyboardLayoutColumn$(Section)" type="String" \
key="KeyboardLayoutColumn$(Section)"> + <parameter name="Section" type="Int" \
min="0" max="1"/> + <label>Column widths</label>
+ <default param="0"></default>
+ <default param="1"></default>
</entry>
- <entry name="KeyboardLayoutColumn1" type="String">
- <label>Keyboard layout for column 1</label>
- <default></default>
- </entry>
- <entry name="KeyboardLayoutColumn2" type="String">
- <label>Keyboard layout for column 2</label>
- <default></default>
- </entry>
</group>
</kcfg>
--- trunk/KDE/kdeedu/kwordquiz/src/kwqtablemodel.cpp #1104443:1104444
@@ -110,33 +110,23 @@
{
if (orientation == Qt::Horizontal)
{
+ if (section < 0 || section > 1)
+ return QVariant();
+
if (role == Qt::DisplayRole) {
- if (section == 0)
- return m_doc->identifier(0).name();
- else
- return m_doc->identifier(1).name();
+ return m_doc->identifier(section).name();
}
if (role == Qt::SizeHintRole) {
DocumentSettings documentSettings(m_doc->url().url());
documentSettings.readConfig();
- switch (section) {
- case 0:
- return QSize(documentSettings.sizeHintColumn1(), 25);
- case 1:
- return QSize(documentSettings.sizeHintColumn2(), 25);
- }
+ return QSize(documentSettings.sizeHintColumn(section), 25);
}
if (role == KWQTableModel::KeyboardLayoutRole) {
DocumentSettings documentSettings(m_doc->url().url());
documentSettings.readConfig();
- switch (section) {
- case 0:
- return documentSettings.keyboardLayoutColumn1();
- case 1:
- return documentSettings.keyboardLayoutColumn2();
- }
+ return documentSettings.keyboardLayoutColumn(section);
}
return QVariant();
@@ -179,39 +169,23 @@
bool KWQTableModel::setHeaderData(int section, Qt::Orientation orientation, const \
QVariant & value, int role) {
if (orientation == Qt::Horizontal) {
+ if (section < 0 || section > 1)
+ return false;
+
if (role == Qt::EditRole) {
- if (section == 0)
- m_doc->identifier(0).setName(value.toString());
- if (section == 1)
- m_doc->identifier(1).setName(value.toString());
+ m_doc->identifier(section).setName(value.toString());
}
if (role == Qt::SizeHintRole) {
DocumentSettings documentSettings(m_doc->url().url());
- switch (section) {
- case 0:
- documentSettings.setSizeHintColumn1(qvariant_cast<QSize>(value).width());
- documentSettings.writeConfig();
- break;
- case 1:
- documentSettings.setSizeHintColumn2(qvariant_cast<QSize>(value).width());
- documentSettings.writeConfig();
- break;
- }
+ documentSettings.setSizeHintColumn(section, \
qvariant_cast<QSize>(value).width()); + documentSettings.writeConfig();
}
if (role == KWQTableModel::KeyboardLayoutRole) {
DocumentSettings documentSettings(m_doc->url().url());
- switch (section) {
- case 0:
- documentSettings.setKeyboardLayoutColumn1(value.toString());
- documentSettings.writeConfig();
- break;
- case 1:
- documentSettings.setKeyboardLayoutColumn2(value.toString());
- documentSettings.writeConfig();
- break;
- }
+ documentSettings.setKeyboardLayoutColumn(section, value.toString());
+ documentSettings.writeConfig();
}
emit headerDataChanged(orientation, section, section);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic