博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
My Graduation’s project:StudentClassMaintain module
阅读量:5901 次
发布时间:2019-06-19

本文共 7640 字,大约阅读时间需要 25 分钟。

#include "studentclassinfomaintain.h"#include "ui_studentclassinfomaintain.h"#include "serverstyle.h"StudentClassInfoMaintain::StudentClassInfoMaintain(QWidget *parent) :    QMainWindow(parent),    ui(new Ui::StudentClassInfoMaintain){    ui->setupUi(this);    init();    createActions();}StudentClassInfoMaintain::~StudentClassInfoMaintain(){    delete ui;    studentItemList.clear();    classItemList.clear();}void StudentClassInfoMaintain::setClassMaintainItem(TeachingRoomClass *trClass){    QString trClassName = trClass->getClassName();//get class Name    QString trClassStudentsCount = trClass->getClassStudentsCount();    QTreeWidgetItem *currentClass = new QTreeWidgetItem(ui->classList,CLASS_ITEM);    //set text    QString classInfo = trClassName +"   "+trClassStudentsCount+CLASSCOUNTUNIT;    currentClass->setText(0,classInfo);    classItemList.insert(classInfo,trClass);}//set root itemQTreeWidgetItem* StudentClassInfoMaintain::setStudentRootItem(TeachingRoomClass *trClass){    QString trClassName = trClass->getClassName();//get class Name    QTreeWidgetItem *currentClass = new QTreeWidgetItem(ui->studentsList,CLASS_ITEM);    //set text    currentClass->setText(0,trClassName);    currentClass->setExpanded(true);    return currentClass;}//set root's childvoid StudentClassInfoMaintain::setStudentMaintainItem(QTreeWidgetItem *root,TeachingRoomStudents *trStudent){    QString trStudentName = trStudent->getStudentName();//get student Name    QTreeWidgetItem *currentStudent = new QTreeWidgetItem(root,STUDENT_ITEM);    //set text    currentStudent->setText(0,trStudentName);    //add student to studentitemlist    studentItemList.insert(trStudentName,trStudent);}//conn the signal and slotvoid StudentClassInfoMaintain::createActions(){    //change the maintain theme    connect(ui->chooseMaintain,SIGNAL(currentChanged(int)),            this,SLOT(setCurrentIndex(int)));    // reget the data from database    connect(ui->refreshBtn,SIGNAL(clicked()),            this,SIGNAL(refreshData()));    //set current class in class maintain    connect(ui->classList,SIGNAL(itemClicked(QTreeWidgetItem*,int)),            this,SLOT(setCurrentClassInClassMaintain(QTreeWidgetItem*,int)));    //set current class in student maintain    connect(ui->studentsList,SIGNAL(itemClicked(QTreeWidgetItem*,int)),            this,SLOT(setCurrentClassInStudentMaintain(QTreeWidgetItem*,int)));    //edit class    connect(ui->editBtn,SIGNAL(clicked()),            this,SLOT(editClassInfoSlot()));    //add new class    connect(ui->newBtn,SIGNAL(clicked()),            this,SLOT(addClassInfoSlot()));}//clear the listvoid StudentClassInfoMaintain::clearList(){    ui->classList->clear();    ui->studentsList->clear();    studentItemList.clear();    classItemList.clear();    ui->className->clear();}//init datavoid StudentClassInfoMaintain::init(){    //unused    currentIndex = 0;    tempIndex = 0;    studentItemList.clear();    classItemList.clear();    //set style    ServerStyle *style = new ServerStyle();    style->styleNoWork(this);    //set column width    setColumnWidth();}void StudentClassInfoMaintain::setColumnWidth(){    ui->studentInfoWidget->setColumnWidth(TABLEWIDGETITEMROW,TABLEWIDGETITEMWIDTH);}//set student list rowsvoid StudentClassInfoMaintain::setStudentRows(int rows){    ui->studentInfoWidget->setRowCount(rows);}//add student to the student table widgetvoid StudentClassInfoMaintain::addStudentItem(int row, TeachingRoomStudents *student){    QTableWidgetItem *studentIDItem = new QTableWidgetItem(student->getStudentID());    studentIDItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom    ui->studentInfoWidget->setItem(row,0,studentIDItem);    QTableWidgetItem *studentNameItem = new QTableWidgetItem(student->getStudentName());    studentNameItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom    ui->studentInfoWidget->setItem(row,1,studentNameItem);    QTableWidgetItem *studentClassItem = new QTableWidgetItem(student->getClassMajor());    studentClassItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom    ui->studentInfoWidget->setItem(row,2,studentClassItem);    QTableWidgetItem *studentClassCountItem = new QTableWidgetItem(student->getClassCount());    studentClassCountItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom    ui->studentInfoWidget->setItem(row,3,studentClassCountItem);    QTableWidgetItem *studentGradeItem = new QTableWidgetItem(student->getStudentScore());    studentGradeItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom    ui->studentInfoWidget->setItem(row,4,studentGradeItem);}//init class itemvoid StudentClassInfoMaintain::initClassItemList(){    QList
classList = classItemList.values(); int classCount = classList.size(); for(int index=0; index
getClassName(); ui->className_2->addItem(className); }}//change the toolbox indexvoid StudentClassInfoMaintain::setCurrentIndex(int index){ if(tempIndex==1 && currentIndex==0){ currentIndex=1; tempIndex=0; } if(index==1 && currentIndex==0){ currentIndex = 0; } if(index==1 && currentIndex==1){ currentIndex = 1; } if(index==0 && currentIndex==0){ currentIndex=0; } if(index==0 && currentIndex==1){ tempIndex = 1; currentIndex=0; } ui->stackedWidget->setCurrentIndex(index+currentIndex);}//set current classvoid StudentClassInfoMaintain::setCurrentClassInClassMaintain(QTreeWidgetItem *item,int column){ ui->className->setReadOnly(true); ui->studentCount->setReadOnly(true); ui->submitBtn->setEnabled(false); TeachingRoomClass *currentClass = classItemList.value(item->text(column)); ui->className->setText(currentClass->getClassName()); ui->studentCount->setValue(currentClass->getClassStudentsCount().toInt());}void StudentClassInfoMaintain::setCurrentClassInStudentMaintain(QTreeWidgetItem *item, int column){ if(item->type() == CLASS_ITEM){//current click item txt :class name ui->stackedWidget->setCurrentIndex(1); currentIndex = 0; emit clickRootItem(item->text(column)); } else{//show maintain student ui->stackedWidget->setCurrentIndex(2); currentIndex = 1; //set current item edit icon item->setIcon(0,QIcon(":/server/theme/edit")); studentMaintain(item->text(column)); }}//edit current class infovoid StudentClassInfoMaintain::editClassInfoSlot(){ ui->className->setReadOnly(false); ui->studentCount->setReadOnly(false); ui->submitBtn->setEnabled(true);}//add new class infovoid StudentClassInfoMaintain::addClassInfoSlot(){ //setting title ui->title->setText(ADDCLASSINFOTITLE); //setting class name ui->className->setText(NEWCLASSNAME); ui->className->setFocus(); ui->className->setReadOnly(false); //setting class count ui->studentCount->setValue(NEWCLASSCOUNT); ui->studentCount->setReadOnly(false); ui->submitBtn->setEnabled(true);}void StudentClassInfoMaintain::studentMaintain(QString currentStudent){ ui->studentName->setText(currentStudent); TeachingRoomStudents *currentstudent = studentItemList.value(currentStudent); ui->studentID->setText(currentstudent->getStudentID()); QString className = currentstudent->getClassMajor(); ui->className_2->setCurrentIndex(ui->className_2->findText(className)); ui->classCount->setValue(currentstudent->getClassCount().toInt()); ui->studentGrade->setValue(currentstudent->getStudentScore().toInt());}

转载于:https://www.cnblogs.com/Podevor/archive/2012/04/22/2787987.html

你可能感兴趣的文章
javascript继承方式详解
查看>>
lnmp环境搭建
查看>>
自定义session扫描器精确控制session销毁时间--学习笔记
查看>>
PHP队列的实现
查看>>
单点登录加验证码例子
查看>>
[T-SQL]从变量与数据类型说起
查看>>
occActiveX - ActiveX with OpenCASCADE
查看>>
BeanUtils\DBUtils
查看>>
python模块--os模块
查看>>
Java 数组在内存中的结构
查看>>
《关爱码农成长计划》第一期报告
查看>>
学习进度表 04
查看>>
谈谈javascript中的prototype与继承
查看>>
时序约束优先级_Vivado工程经验与各种时序约束技巧分享
查看>>
minio 并发数_MinIO 参数解析与限制
查看>>
flash back mysql_mysqlbinlog flashback 使用最佳实践
查看>>
mysql存储引擎模式_MySQL存储引擎
查看>>
java 重写system.out_重写System.out.println(String x)方法
查看>>
配置ORACLE 11g绿色版客户端和PLSQL远程连接环境
查看>>
ASP.NET中 DataList(数据列表)的使用前台绑定
查看>>