Разработка программы на языке C/С++, страница 7

    }

}

void MainForm::editdeleterecord()

{

    if (trainTimeTable->currentRow()>=nelem) return;

    int i;

    delete base[trainTimeTable->currentRow()];

    nelem--;

    for (i=trainTimeTable->currentRow(); i<nelem; i++)

base[i]=base[i+1];

    redrawtable();

}

void MainForm::editchnum()

{

    ChNumForm *chnumform = new ChNumForm(this,"chnumform",TRUE);

    chnumform->TrainnumspinBox->setValue(header[0]->trnum);

    QChar lett1((ushort)header[0]->lett),lett2((ushort)header[1]->lett);

    chnumform->TrainCodeLineEdit->setText(QString(lett1)+QString(lett2));

    if (chnumform->exec())

    {

                                                                                                                                                                                                                                        int i;

if (trainTimeTable->currentRow()<nelem)

{

for (i=nelem;i>trainTimeTable->currentRow(); i--)

base[i]=base[i-1];

i=trainTimeTable->currentRow();

}

else i=nelem;

base[i]=new datastr00;

base[i]->id=2;

chnum=(datastr10*)base[i];

chnum->trnum=chnumform->TrainnumspinBox->value();

QString trnlett = chnumform->TrainCodeLineEdit->text();

QChar lett;

lett=trnlett.at(0);

chnum->lett1=lett.unicode();

lett=trnlett.at(1);

chnum->lett2=lett.unicode();

nelem++;  

redrawtable();

    }

   delete chnumform;

}

void MainForm::filechangetrainproperties()

{

    NewTrainForm  *newtrainForm = new NewTrainForm( this, "new train", TRUE );

    newtrainForm->TrainnumspinBox->setValue(header[0]->trnum);

    QString trnfrom;

    trnfrom.setNum(header[0]->stcode);

    newtrainForm->StartStatEdit->setText(trnfrom);

    trnfrom.setNum(header[1]->stcode);

    newtrainForm->EndStatEdit->setText(trnfrom);

    newtrainForm->TrainnumspinBox->setValue(header[0]->trnum);

    QChar lett1((ushort)header[0]->lett),lett2((ushort)header[1]->lett);

    newtrainForm->TrainCodeLineEdit->setText(QString(lett1)+QString(lett2));

    if (newtrainForm->exec())

    {

header[0]->trnum=newtrainForm->TrainnumspinBox->value();

header[1]->trnum=newtrainForm->TrainnumspinBox->value();

QString trnlett = newtrainForm->TrainCodeLineEdit->text();

QChar lett;

lett=trnlett.at(0);

header[0]->lett=lett.unicode();

lett=trnlett.at(1);

header[1]->lett=lett.unicode();

trnfrom = newtrainForm->StartStatEdit->text();

header[0]->stcode=trnfrom.toInt();

QString trnto = newtrainForm->EndStatEdit->text();

header[1]->stcode=trnto.toInt();

QString trnum;

trnum.setNum(header[0]->trnum);

TrainNametextLabel->setText(trnum+trnlett+" "+trnfrom.fromLocal8Bit(resolvestat(header[0]->stcode))+" - "+trnto.fromLocal8Bit(resolvestat(header[1]->stcode)));

isChanged=TRUE;

    }

}

getcodeform.h

int openresolvefile(const char *fname);

char *resolvestat(unsigned long int stcode);

unsigned long int resolvestcode(const char *stname);

int freeresolvedata(void);

unsigned long stcode=0;

QString stnam;

void GetCodeForm::getstats()

{

    //unsigned long int resolvestcode(const char *stname)

    stnam=stnamelineEdit->text();   

    while ((stcode==0)&&(stnam.length()>1))

    {

    stcode=resolvestcode(stnam.local8Bit());

    stnam.remove((uint)stnam.length()-1,1);

   }

  stcodespinBox->setValue(stcode);  

  stnamelineEdit->setText(QString::fromLocal8Bit(resolvestat(stcode)));

  }

chroadform.h

struct roadresrec

{

  unsigned int rcode;

  char roadnam[60];

  struct roadresrec *next;

};

extern struct roadresrec *rresinfo,*rcurr;

void chroadForm::init()

{

    rcurr=rresinfo;

    while (rcurr!=NULL)

    {

    chrcomboBox->insertItem(QString::fromLocal8Bit(rcurr->roadnam));

    rcurr=rcurr->next;

   }

}

editstationform.h

void EditStationForm::getstatcode()

{

GetCodeForm  *codeform = new GetCodeForm( this, "codeform", TRUE );

if (codeform->exec())

{

stcodespinBox->setValue(codeform->stcodespinBox->value());