📄 stlist.cpp
字号:
#include "stlist.h"//#include <QMessageBox>StList::StList( ) { // TODO arraylength = 0; arraycurrent = 0;}void StList::append (const Student& item)//添加学生信息{ if(arraylength == 100) { QMessageBox::warning (this, tr("Student Information"), tr("The maxinum of student information is 100!")); return ; } array[arraylength]= new Student(item.getNo(),item.getName(),item.getClass()); arraylength = arraylength + 1; //添加成功 QMessageBox::information (this, "Information Application", "The student information is added!"); arraycurrent = arraylength-1;}void StList::next (){ //判断数组是否为空 if(arraylength == 0) { QMessageBox::warning (this, tr("Information Application"), tr("There has no student information!")); return ; } //判断当前记录是否是最后的记录 if(arraycurrent == arraylength-1) { QMessageBox::warning (this, tr("Information Application"), tr("This is the last one!")); return ; } setcurrenValue(arraycurrent+1);}/***************************************************************/void StList::prev (){ //判断数组是否为空 if(arraylength == 0) { QMessageBox::warning (this, tr("Information Application"), tr("There has no student information!")); return ; } //判断数组是否是第一个记录 if(arraycurrent == 0) { QMessageBox::warning (this, tr("Information Application"), tr("This is the frist one!")); return ; } setcurrenValue(arraycurrent-1); }//***************************************************************************void StList::first(){ //判断数组是否为空 if(arraylength == 0) { QMessageBox::warning (this, tr("Information Application"),tr("There has no student information!")); return ; } setcurrenValue(0); }//****************************************************************************void StList::last(){ //判断数组是否为空 if(arraylength == 0) { QMessageBox::warning (this, tr("Information Application"), tr("There has no student information!")); return ; } setcurrenValue(arraylength - 1);}bool StList::remove (){ //判断数组是否为空 if(arraylength == 0) { QMessageBox::warning (this, tr("Information Application"), tr("There has no student information!")); return false; } //确认是否要删除 switch( QMessageBox::information( this, "Student Information", "Do you sure delete this record!\n", "Yes", "No", 0, // ok == button 0 1 ) ) { // no == button 1 case 0: // 按Yes则删除这个记录 for(int n=arraylength-1;n>arraycurrent;n--) { array[n-1] = array[n]; } arraylength--; if(arraylength == 0 ) { QMessageBox::warning (this, tr("Information Application"), tr("There has no student information!")); return false; } if(arraycurrent == arraylength) setcurrenValue(arraycurrent - 1); else setcurrenValue(arraycurrent + 1); break; case 1: // 否则不删除退出 return true; } }void StList::setcurrenValue( int value ){ arraycurrent = value; //触发消息 emit noChanged(array[value]->getNo()); emit nameChanged(array[value]->getName()); emit classChanged(array[value]->getClass()); }void StList::setnoVale(int value){ emit noChanged(array[value]->getNo()); }void StList::setnameVale(int value){ emit noChanged(array[value]->getName()); }void StList::setclassVale(int value){ emit noChanged(array[value]->getClass()); }//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -