[Tux4kids-commits] r1345 - tux4kids-admin/trunk/tux4kids-admin/src

Michał Świtakowski swistakers-guest at alioth.debian.org
Mon Aug 3 21:03:20 UTC 2009


Author: swistakers-guest
Date: 2009-08-03 21:03:20 +0000 (Mon, 03 Aug 2009)
New Revision: 1345

Modified:
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h
   tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.h
   tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.ui
   tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h
Log:
gray out buttons when not needed 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-08-03 21:03:20 UTC (rev 1345)
@@ -17,6 +17,9 @@
 
 	connect(m_ui->addClassButton, SIGNAL(clicked()), this, SLOT(addClicked()));
 	connect(m_ui->editClassButton, SIGNAL(clicked()), this, SLOT(editClicked()));
+	connect(m_ui->classesTable->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(setEditButtons()));
+
+	setEditButtons();
 }
 
 ManageClassesWidget::~ManageClassesWidget()
@@ -69,3 +72,18 @@
 	qDebug() << "edit rejected";
 }
 
+void ManageClassesWidget::setEditButtons()
+{
+	if (m_ui->classesTable->selectionModel()->selectedIndexes().isEmpty()) {
+		setEditButtonsEnabled(false);
+	} else {
+		setEditButtonsEnabled(true);
+	}
+}
+
+void ManageClassesWidget::setEditButtonsEnabled(bool enable)
+{
+	m_ui->editClassButton->setEnabled(enable);
+	m_ui->deleteClassButton->setEnabled(enable);
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h	2009-08-03 21:03:20 UTC (rev 1345)
@@ -28,6 +28,8 @@
 	QPointer<EditClassDialog> m_editClassDialog;
 	ClassTableProxyModel m_classTableProxyModel;
 
+	void setEditButtonsEnabled(bool enable);
+
 private slots:
 	void addClicked();
 	void editClicked();
@@ -36,6 +38,7 @@
 	void addRejected();
 	void editAccepted();
 	void editRejected();
+	void setEditButtons();
 };
 
 #endif // MANAGECLASSESWIDGET_H

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp	2009-08-03 21:03:20 UTC (rev 1345)
@@ -19,6 +19,9 @@
 
 	m_mainController = mainController;
 	connect(m_ui->addStudentButton, SIGNAL(clicked()), this, SLOT(addStudentClicked()));
+	connect(m_ui->studentsTable->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(setEditButtons()));
+
+	setEditButtons();
 }
 
 ManageStudentsWidget::~ManageStudentsWidget()
@@ -45,3 +48,19 @@
 
 }
 
+void ManageStudentsWidget::setEditButtons()
+{
+	if (m_ui->studentsTable->selectionModel()->selectedIndexes().isEmpty()) {
+		setEditButtonsEnabled(false);
+	} else {
+		setEditButtonsEnabled(true);
+	}
+}
+
+void ManageStudentsWidget::setEditButtonsEnabled(bool enable)
+{
+	m_ui->editStudentButton->setEnabled(enable);
+	m_ui->deleteStudentButton->setEnabled(enable);
+}
+
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.h	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.h	2009-08-03 21:03:20 UTC (rev 1345)
@@ -27,10 +27,13 @@
 	QPointer<MainController> m_mainController;
 	StudentTableProxyModel m_studentTableProxyModel;
 
+	void setEditButtonsEnabled(bool enable);
+
 private slots:
 
 	void addStudentClicked();
 	void addStudent();
+	void setEditButtons();
 };
 
 #endif // MANAGESTUDENTSWIDGET_H

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.ui	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.ui	2009-08-03 21:03:20 UTC (rev 1345)
@@ -13,30 +13,50 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <layout class="QVBoxLayout" name="verticalLayout">
+    <widget class="QTableView" name="studentsTable">
+     <property name="selectionMode">
+      <enum>QAbstractItemView::SingleSelection</enum>
+     </property>
+     <property name="selectionBehavior">
+      <enum>QAbstractItemView::SelectRows</enum>
+     </property>
+     <property name="verticalScrollMode">
+      <enum>QAbstractItemView::ScrollPerPixel</enum>
+     </property>
+     <property name="horizontalScrollMode">
+      <enum>QAbstractItemView::ScrollPerPixel</enum>
+     </property>
+     <property name="gridStyle">
+      <enum>Qt::DashLine</enum>
+     </property>
+     <property name="sortingEnabled">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
-      <widget class="QTableView" name="studentsTable">
-       <property name="selectionMode">
-        <enum>QAbstractItemView::SingleSelection</enum>
+      <widget class="QPushButton" name="deleteStudentButton">
+       <property name="text">
+        <string>Delete</string>
        </property>
-       <property name="selectionBehavior">
-        <enum>QAbstractItemView::SelectRows</enum>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
        </property>
-       <property name="verticalScrollMode">
-        <enum>QAbstractItemView::ScrollPerPixel</enum>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
        </property>
-       <property name="horizontalScrollMode">
-        <enum>QAbstractItemView::ScrollPerPixel</enum>
-       </property>
-       <property name="gridStyle">
-        <enum>Qt::DashLine</enum>
-       </property>
-       <property name="sortingEnabled">
-        <bool>true</bool>
-       </property>
-      </widget>
+      </spacer>
      </item>
      <item>
       <widget class="QPushButton" name="addStudentButton">
@@ -45,6 +65,13 @@
        </property>
       </widget>
      </item>
+     <item>
+      <widget class="QPushButton" name="editStudentButton">
+       <property name="text">
+        <string>Edit</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
   </layout>

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp	2009-08-03 21:03:20 UTC (rev 1345)
@@ -19,6 +19,9 @@
 	connect(m_ui->addTeacherButton, SIGNAL(clicked()), this, SLOT(addClicked()));
 	connect(m_ui->editTeacherButton, SIGNAL(clicked()), this, SLOT(editClicked()));
 	connect(m_ui->deleteTeacherButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
+	connect(m_ui->teachersTable->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(setEditButtons()));
+
+	setEditButtons();
 }
 
 ManageTeachersWidget::~ManageTeachersWidget()
@@ -43,7 +46,7 @@
 		connect(m_editTeacherDialog, SIGNAL(accepted()), this, SLOT(editAccepted()));
 		connect(m_editTeacherDialog, SIGNAL(rejected()), this, SLOT(editRejected()));
 	}
-	m_editTeacherDialog->showNormal();;
+	m_editTeacherDialog->showNormal();
 }
 
 void ManageTeachersWidget::deleteClicked()
@@ -71,3 +74,18 @@
 	qDebug() << "edit rejected";
 }
 
+void ManageTeachersWidget::setEditButtons()
+{
+	if (m_ui->teachersTable->selectionModel()->selectedIndexes().isEmpty()) {
+		setEditButtonsEnabled(false);
+	} else {
+		setEditButtonsEnabled(true);
+	}
+}
+
+void ManageTeachersWidget::setEditButtonsEnabled(bool enable)
+{
+	m_ui->editTeacherButton->setEnabled(enable);
+	m_ui->deleteTeacherButton->setEnabled(enable);
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h	2009-08-03 20:25:50 UTC (rev 1344)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h	2009-08-03 21:03:20 UTC (rev 1345)
@@ -26,6 +26,7 @@
 	TeacherTableProxyModel m_teacherTableProxyModel;
 	QPointer<EditTeacherDialog> m_addTeacherDialog;
 	QPointer<EditTeacherDialog> m_editTeacherDialog;
+	void setEditButtonsEnabled(bool enable);
 
 private slots:
 	void addClicked();
@@ -35,6 +36,7 @@
 	void addRejected();
 	void editAccepted();
 	void editRejected();
+	void setEditButtons();
 
 };
 




More information about the Tux4kids-commits mailing list