[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/ktouch/src
From:       Anne-Marie Mahfouf <annma () kde ! org>
Date:       2010-01-07 18:43:49
Message-ID: 1262889829.232763.28268.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1071220 by annma:

clearer coding style

 M  +60 -33    ktouchcoloreditordialog.cpp  


--- trunk/KDE/kdeedu/ktouch/src/ktouchcoloreditordialog.cpp #1071219:1071220
@@ -43,17 +43,21 @@
     m_currentItem = qMax(0, active);
     updateListWidget();
 
-    if (active >= 0)	m_currentItem = active;
-    else				m_currentItem = -1;
-
+    if (active >= 0) {
+        m_currentItem = active;
+    }
+    else {
+        m_currentItem = -1;
+    }
+    
     exec();
 
     if (m_saveChanges) {
-            selected = m_currentItem;
-            schemes = m_schemes;
+        selected = m_currentItem;
+        schemes = m_schemes;
     }
     else {
-            selected = active;
+        selected = active;
     }
 }
 // ----------------------------------------------------------------------------
@@ -61,12 +65,17 @@
 void KTouchColorEditorDialog::colorSchemeChanged(QListWidgetItem *) {
     //kdDebug() << "[KTouchColorEditor::colorSchemeChanged]" << endl;
     int num = schemeListWidget->currentRow();
+    
     if (num < 0 || num >= static_cast<int>(m_schemes.count())) {
-            updateControls(NULL);
-            return;
+        updateControls(NULL);
+        return;
     }
     QList<KTouchColorScheme>::const_iterator it = m_schemes.constBegin();
-    while (--num >= 0) ++it;
+    
+    while (--num >= 0) {
+        ++it;
+    }
+    
     updateControls(&(*it));
 }
 // ----------------------------------------------------------------------------
@@ -75,15 +84,22 @@
     // first check that we have a valid color scheme selected
     int num = schemeListWidget->currentRow();
     int old_num = num;
+    
     if (num < 0 || num >= static_cast<int>(m_schemes.count())) {
-            updateListWidget();
-            return;
+        updateListWidget();
+        return;
     }
+    
     QList<KTouchColorScheme>::iterator it = m_schemes.begin();
-    while (--num >= 0) ++it;
+    
+    while (--num >= 0) {
+        ++it;
+    }
     (*it).m_name = nameEdit->text();
-    if ((*it).m_name.isEmpty())
-            (*it).m_name = i18n("New color scheme");
+    
+    if ((*it).m_name.isEmpty()) {
+        (*it).m_name = i18n("New color scheme");
+    }
     // slide line colors
     (*it).m_teacherTextColor = teacherTextBtn->color();
     (*it).m_teacherBackground = teacherBackBtn->color();
@@ -119,11 +135,13 @@
 void KTouchColorEditorDialog::removeBtnClicked() {
     int num = schemeListWidget->currentRow();
     int old_num = num;
+    
     if (num >=0 && num < static_cast<int>(m_schemes.count())) {
-            QList<KTouchColorScheme>::iterator it = m_schemes.begin();
-            while (--num >= 0) ++it;
-            m_schemes.erase(it);
+        QList<KTouchColorScheme>::iterator it = m_schemes.begin();
+        while (--num >= 0) ++it;
+        m_schemes.erase(it);
     }
+    
     updateListWidget();
     schemeListWidget->setCurrentRow( qMin(old_num, static_cast<int>(m_schemes.count())-1) );
     colorSchemeChanged(NULL);
@@ -143,14 +161,22 @@
 void KTouchColorEditorDialog::closeEvent( QCloseEvent* ce ) {
     int result = KMessageBox::questionYesNoCancel(this,
             i18n("Save modified color schemes?"));
+            
     switch (result) {
-        case KMessageBox::Cancel : m_saveChanges = false; ce->ignore(); return;
-        case KMessageBox::Yes :
-            m_currentItem = schemeListWidget->currentRow();
-            updateClicked();
-            m_saveChanges = true; break;
-        default : m_saveChanges = false; break;
+    case KMessageBox::Cancel : 
+        m_saveChanges = false; 
+        ce->ignore(); 
+        return;
+    case KMessageBox::Yes :
+        m_currentItem = schemeListWidget->currentRow();
+        updateClicked();
+        m_saveChanges = true; 
+        break;
+    default : 
+        m_saveChanges = false; 
+        break;
     }
+    
     ce->accept();
 }
 // ----------------------------------------------------------------------------
@@ -158,19 +184,20 @@
 void KTouchColorEditorDialog::updateListWidget() {
 //	kdDebug() << "[KTouchColorEditor::updateListBox]" << endl;
     schemeListWidget->clear();
+    
     for (QList<KTouchColorScheme>::const_iterator it = m_schemes.constBegin();
-            it != m_schemes.constEnd(); ++it)
-    {
+            it != m_schemes.constEnd(); ++it) {
             schemeListWidget->addItem( (*it).m_name );
     }
+    
     if (m_schemes.isEmpty()) {
-            editGroupBox->setEnabled(false);
-            removeBtn->setEnabled(false);
+        editGroupBox->setEnabled(false);
+        removeBtn->setEnabled(false);
     }
     else {
-            editGroupBox->setEnabled(true);
-            removeBtn->setEnabled(true);
-            // select the first one by default
+        editGroupBox->setEnabled(true);
+        removeBtn->setEnabled(true);
+        // select the first one by default
     }
 }
 // ----------------------------------------------------------------------------
@@ -178,9 +205,9 @@
 void KTouchColorEditorDialog::updateControls(const KTouchColorScheme * cs) {
 //	kdDebug() << "[KTouchColorEditor::updateControls]" << endl;
     if (cs==NULL) {
-            // TODO : also set all colors back to defaults
-            editGroupBox->setEnabled(false);
-            return;
+        // TODO : also set all colors back to defaults
+        editGroupBox->setEnabled(false);
+        return;
     }
     editGroupBox->setEnabled(true);
     nameEdit->setText(cs->m_name);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic