Back to index

fet  5.18.0
teachersstatisticsform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           teacherstatisticform.cpp  -  description
00003                              -------------------
00004     begin                : March 25, 2006
00005     copyright            : (C) 2006 by Lalescu Liviu
00006     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "teachersstatisticsform.h"
00019 
00020 #include "timetable_defs.h"
00021 #include "timetable.h"
00022 
00023 #include "fet.h"
00024 
00025 #include <QString>
00026 #include <QStringList>
00027 
00028 #include <QTableWidget>
00029 #include <QHeaderView>
00030 
00031 TeachersStatisticsForm::TeachersStatisticsForm(QWidget* parent): QDialog(parent)
00032 {
00033        setupUi(this);
00034        
00035        closeButton->setDefault(true);
00036 
00037        connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
00038        
00039        tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
00040        tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
00041 
00042        centerWidgetOnScreen(this);
00043        restoreFETDialogGeometry(this);
00044               
00045        tableWidget->clear();
00046        tableWidget->setColumnCount(3);
00047        tableWidget->setRowCount(gt.rules.teachersList.size());
00048        
00049        QStringList columns;
00050        columns<<tr("Teacher");
00051        columns<<tr("No. of activities");
00052        columns<<tr("Duration");
00053        
00054        tableWidget->setHorizontalHeaderLabels(columns);
00055        
00056        for(int i=0; i<gt.rules.teachersList.size(); i++){
00057               Teacher* t=gt.rules.teachersList[i];
00058               
00059               QTableWidgetItem* newItem=new QTableWidgetItem(t->name);
00060               newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
00061               tableWidget->setItem(i, 0, newItem);
00062 
00063               int    nSubActivities=0;
00064               int nHours=0;
00065               
00066               foreach(Activity* act, gt.rules.activitiesList)
00067                      if(act->active)
00068                             if(act->teachersNames.contains(t->name)){
00069                                    nSubActivities++;
00070                                    nHours+=act->duration;
00071                             }
00072 
00073               newItem=new QTableWidgetItem(CustomFETString::number(nSubActivities));
00074               newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
00075               tableWidget->setItem(i, 1, newItem);
00076 
00077               newItem=new QTableWidgetItem(CustomFETString::number(nHours));
00078               newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
00079               tableWidget->setItem(i, 2, newItem);
00080        }
00081 
00082        tableWidget->resizeColumnsToContents();
00083        tableWidget->resizeRowsToContents();
00084 }
00085 
00086 TeachersStatisticsForm::~TeachersStatisticsForm()
00087 {
00088        saveFETDialogGeometry(this);
00089 }