[Tux4kids-commits] r1389 - in tux4kids-admin/trunk: libtux4kidsadmin tux4kids-admin/src

Michał Świtakowski swistakers-guest at alioth.debian.org
Fri Aug 7 19:04:09 UTC 2009


Author: swistakers-guest
Date: 2009-08-07 19:04:09 +0000 (Fri, 07 Aug 2009)
New Revision: 1389

Added:
   tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h
   tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.ui
Modified:
   tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.ui
   tux4kids-admin/trunk/tux4kids-admin/src/src.pro
Log:
+SelectClassWidget, no seg fault on start :)

Modified: tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp	2009-08-07 19:04:09 UTC (rev 1389)
@@ -798,7 +798,7 @@
 		return result;
 	}
 
-	result = studentList();
+	result = studentListNoJoin();
 
 	return result;
 }

Modified: tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt	2009-08-07 19:04:09 UTC (rev 1389)
@@ -22,7 +22,8 @@
 	editClassDialog.cpp 
 	editTeacherDialog.cpp
 	selectStudentWidget.cpp
-	selectTeacherWidget.cpp )
+	selectTeacherWidget.cpp
+	selectClassWidget.cpp )
 
 SET(TUX4KIDS-ADMIN_MOC_HEADERS 
 	mainWindow.h
@@ -42,7 +43,8 @@
 	editClassDialog.h 
 	editTeacherDialog.h
 	selectStudentWidget.h
-	selectTeacherWidget.h )
+	selectTeacherWidget.h
+	selectClassWidget.h )
 
 SET(TUX4KIDS-ADMIN_UIS 
 	mainWindow.ui 
@@ -54,7 +56,8 @@
 	editClassDialog.ui 
 	editTeacherDialog.ui
 	selectStudentWidget.ui
-	selectTeacherWidget.ui )
+	selectTeacherWidget.ui
+	selectClassWidget.ui )
 
 # enable warnings
 ADD_DEFINITIONS( -Wall )

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-08-07 19:04:09 UTC (rev 1389)
@@ -161,3 +161,8 @@
 	emit dataChanged(index(0, ClassSelected), index(rowCount() - 1, ClassSelected));
 }
 
+const Class &ClassTableModel::at(int i)
+{
+	return m_classes.at(i);
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-08-07 19:04:09 UTC (rev 1389)
@@ -22,6 +22,7 @@
 	QList<Class> selectedClasses() const;
 	void setSelectedClasses(const QList<Class> &selectedClasses);
 	void clearSelection();
+	const Class &at(int i);
 
 	void setSchoolDatabase(SchoolDatabase *schoolDatabase);
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-08-07 19:04:09 UTC (rev 1389)
@@ -4,8 +4,10 @@
 #include "mainController.h"
 #include "schoolData.h"
 #include "schoolDatabase.h"
+#include "selectClassWidget.h"
 
 #include <QDebug>
+#include <QTableView>
 
 ManageClassesWidget::ManageClassesWidget(MainController *mainController, QWidget *parent) :
 		QWidget(parent),
@@ -15,12 +17,15 @@
 {
 	m_ui->setupUi(this);
 
-	m_classTableProxyModel.setSourceModel(m_mainController->classTableModel());
-	m_ui->classesTable->setModel(&m_classTableProxyModel);
+	m_selectClassWidget = new SelectClassWidget(this);
+	m_ui->verticalLayout->insertWidget(0, m_selectClassWidget);
+	m_selectClassWidget->classTableModel()->setSchoolDatabase(m_schoolDatabase);
 
 	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()));
+	connect(m_selectClassWidget->classTable()->selectionModel(),
+		SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+		this, SLOT(setEditButtons()));
 
 	setEditButtons();
 }
@@ -47,6 +52,7 @@
 		connect(m_editClassDialog, SIGNAL(accepted()), this, SLOT(editAccepted()));
 		connect(m_editClassDialog, SIGNAL(rejected()), this, SLOT(editRejected()));
 	}
+	//m_editClassDialog->setClass(editedClass);
 	m_editClassDialog->showNormal();
 }
 
@@ -82,7 +88,8 @@
 
 void ManageClassesWidget::setEditButtons()
 {
-	if (m_ui->classesTable->selectionModel()->selectedIndexes().isEmpty()) {
+	if (m_selectClassWidget->classTable()->selectionModel()
+		->selectedIndexes().isEmpty()) {
 		setEditButtonsEnabled(false);
 	} else {
 		setEditButtonsEnabled(true);

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.h	2009-08-07 19:04:09 UTC (rev 1389)
@@ -13,6 +13,7 @@
 class MainController;
 class EditClassDialog;
 class SchoolDatabase;
+class SelectClassWidget;
 
 class ManageClassesWidget : public QWidget
 {
@@ -28,7 +29,7 @@
 	QPointer<SchoolDatabase> m_schoolDatabase;
 	QPointer<EditClassDialog> m_addClassDialog;
 	QPointer<EditClassDialog> m_editClassDialog;
-	ClassTableProxyModel m_classTableProxyModel;
+	QPointer<SelectClassWidget> m_selectClassWidget;
 
 	void setEditButtonsEnabled(bool enable);
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.ui	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.ui	2009-08-07 19:04:09 UTC (rev 1389)
@@ -13,62 +13,47 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
-    <widget class="QTableView" name="classesTable">
-     <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="sortingEnabled">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
+    <layout class="QVBoxLayout" name="verticalLayout">
      <item>
-      <widget class="QPushButton" name="deleteClassButton">
-       <property name="text">
-        <string>Delete</string>
-       </property>
-      </widget>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QPushButton" name="deleteClassButton">
+         <property name="text">
+          <string>Delete</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QPushButton" name="addClassButton">
+         <property name="text">
+          <string>Add</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="editClassButton">
+         <property name="text">
+          <string>Edit</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
      </item>
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="addClassButton">
-       <property name="text">
-        <string>Add</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="editClassButton">
-       <property name="text">
-        <string>Edit</string>
-       </property>
-      </widget>
-     </item>
     </layout>
    </item>
   </layout>

Added: tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp	2009-08-07 19:04:09 UTC (rev 1389)
@@ -0,0 +1,41 @@
+#include "selectClassWidget.h"
+#include "ui_selectClassWidget.h"
+
+SelectClassWidget::SelectClassWidget(QWidget *parent)
+		: QWidget(parent),
+		m_ui(new Ui::SelectClassWidget)
+{
+	m_ui->setupUi(this);
+
+	m_classTableProxyModel.setSourceModel(&m_classTableModel);
+	m_ui->classTable->setModel(&m_classTableProxyModel);
+	connect(m_ui->clearButton, SIGNAL(clicked()), m_ui->searchEdit, SLOT(clear()));
+	connect(m_ui->searchEdit, SIGNAL(textEdited(QString)), this, SLOT(searchEdited()));
+	connect(&m_searchTimer, SIGNAL(timeout()), this, SLOT(updateFilter()));
+}
+
+SelectClassWidget::~SelectClassWidget()
+{
+	delete m_ui;
+}
+
+ClassTableModel *SelectClassWidget::classTableModel()
+{
+	return &m_classTableModel;
+}
+
+QTableView *SelectClassWidget::classTable()
+{
+	return m_ui->classTable;
+}
+
+void SelectClassWidget::searchEdited()
+{
+	m_searchTimer.start(250);
+}
+
+void SelectClassWidget::updateFilter()
+{
+	m_classTableProxyModel.setFilterRegExp(m_ui->searchEdit->text());
+}
+

Added: tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h	2009-08-07 19:04:09 UTC (rev 1389)
@@ -0,0 +1,38 @@
+#ifndef SELECTCLASSWIDGET_H
+#define SELECTCLASSWIDGET_H
+
+#include <QtGui/QWidget>
+#include <QTimer>
+
+#include "classTableModel.h"
+#include "classTableProxyModel.h"
+
+namespace Ui {
+	class SelectClassWidget;
+}
+
+class QTableView;
+
+class SelectClassWidget : public QWidget
+{
+	Q_OBJECT
+public:
+	SelectClassWidget(QWidget *parent = 0);
+	~SelectClassWidget();
+
+	ClassTableModel *classTableModel();
+	QTableView *classTable();
+
+private:
+	Ui::SelectClassWidget *m_ui;
+
+	ClassTableModel m_classTableModel;
+	ClassTableProxyModel m_classTableProxyModel;
+	QTimer m_searchTimer;
+
+private slots:
+	void searchEdited();
+	void updateFilter();
+};
+
+#endif // SELECTCLASSWIDGET_H

Added: tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.ui	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.ui	2009-08-07 19:04:09 UTC (rev 1389)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SelectClassWidget</class>
+ <widget class="QWidget" name="SelectClassWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QPushButton" name="clearButton">
+         <property name="text">
+          <string>Clear</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="searchEdit"/>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QTableView" name="classTable">
+       <property name="alternatingRowColors">
+        <bool>true</bool>
+       </property>
+       <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="sortingEnabled">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Modified: tux4kids-admin/trunk/tux4kids-admin/src/src.pro
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-08-07 10:53:10 UTC (rev 1388)
+++ tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-08-07 19:04:09 UTC (rev 1389)
@@ -23,7 +23,8 @@
     editTeacherDialog.cpp \
     editClassDialog.cpp \
     selectStudentWidget.cpp \
-    selectTeacherWidget.cpp
+    selectTeacherWidget.cpp \
+    selectClassWidget.cpp
 HEADERS += mainWindow.h \
     mainController.h \
     pluginManager.h \
@@ -43,7 +44,8 @@
     editTeacherDialog.h \
     editClassDialog.h \
     selectStudentWidget.h \
-    selectTeacherWidget.h
+    selectTeacherWidget.h \
+    selectClassWidget.h
 FORMS += mainWindow.ui \
     pluginManagerDialog.ui \
     manageStudentsWidget.ui \
@@ -53,6 +55,7 @@
     editTeacherDialog.ui \
     editClassDialog.ui \
     selectStudentWidget.ui \
-    selectTeacherWidget.ui
+    selectTeacherWidget.ui \
+    selectClassWidget.ui
 LIBS += -ltux4kidsadmin \
     -L../../libtux4kidsadmin




More information about the Tux4kids-commits mailing list