QlightRead package | ESS final project 1.22-beta

/home/ron/Desktop/Frontend/src/settings_dialog.cpp

Go to the documentation of this file.
00001 
00041 #include <QtGui>
00042 #include <QFile>
00043 #include <QLabel>
00044 #include <QTextStream>
00045 #include <iostream>
00046 #include <QDebug>
00047 
00048 
00049 #include "settings_dialog.h"
00050 #include "mainwindow.h"
00051 #include "dataplot.h"
00052 #include "global_macros.h"
00053 
00064 TSabout::TSabout(QWidget *parent) : QDialog(parent)
00065 {
00066 
00067         QWidget *aboutw = new QWidget(this);
00068         QVBoxLayout *main = new QVBoxLayout(aboutw);
00069 
00070         QVBoxLayout *D = new QVBoxLayout;
00071 
00072 
00073         QLabel *LD = new QLabel(tr("Description"));
00074         QTextBrowser *DTb = new QTextBrowser;
00075         D->setAlignment(Qt::AlignLeft);
00076         DTb->setText(DESCRIPTION);
00077         DTb->setReadOnly(true);
00078         D->addWidget(LD);
00079         D->addWidget(DTb);
00080 
00081 
00082         QVBoxLayout *L = new QVBoxLayout;
00083         QLabel *LL = new QLabel(tr("Libraries"));
00084         QTextBrowser *LTb = new QTextBrowser;
00085         LTb->setText(LIBRARIES);
00086         LTb->setReadOnly(true);
00087         L->setAlignment(Qt::AlignLeft);
00088         L->addWidget(LL);
00089         L->addWidget(LTb);
00090 
00091         QHBoxLayout *P = new QHBoxLayout;
00092         QVBoxLayout *A = new QVBoxLayout;
00093         QVBoxLayout *LO = new QVBoxLayout;
00094         QLabel *Aut = new QLabel(tr("Author:\tRon Ablinger"));
00095         QLabel *Comp = new QLabel(tr("Company:\tTrilog Studios"));
00096         QLabel *V = new QLabel(VERSION);
00097         QLabel *bld = new QLabel(BUILD_V);
00098         QLabel *date = new QLabel(BUILD_D);
00099         QLabel *LLO = new QLabel;
00100         LLO->setBackgroundRole(QPalette::Base);
00101         QImage image("resources/TS_Logo.png");
00102         LLO->setPixmap(QPixmap::fromImage(image));
00103         A->setAlignment(Qt::AlignLeft);
00104         A->addWidget(Aut);
00105         A->addWidget(Comp);
00106         A->addWidget(V);
00107         A->addWidget(bld);
00108         A->addWidget(date);
00109         LO->addWidget(LLO);
00110         P->setAlignment(Qt::AlignRight);
00111         P->addLayout(A);
00112         P->addLayout(LO);
00113 
00114         QHBoxLayout *B = new QHBoxLayout;
00115         QPushButton *ok = new QPushButton(tr("close"));
00116         connect(ok,SIGNAL(clicked()),this,SLOT(close()));
00117         B->setAlignment(Qt::AlignRight);
00118         B->addWidget(ok);
00119 
00120         main->addLayout(D);
00121         main->addLayout(L);
00122         main->addLayout(P);
00123         main->addLayout(B);
00124 
00125 
00126 
00127 
00128 
00129 }
00130 
00141 ProgEditDialog::ProgEditDialog(QWidget *parent) : QDialog(parent)
00142 {
00143 
00144 
00145     QString Title;
00146     QString graphcc;
00147     QString graphca;
00148     QString graphsc;
00149     QString graphsa;
00150     QString Main_width;
00151     QString Main_highth;
00152 
00153 
00154     int leng = 0;
00155 
00156     QFile usb(PROG_SETTINGS_TSS);
00157     usb.open(QIODevice::ReadOnly);
00158 
00159     QTextStream fs(&usb);    // read the data serialized from the file
00160 
00161     str.clear();
00162     while (!fs.atEnd())
00163         {
00164             leng = 0;
00165             str=fs.readLine();
00166 
00167             leng = str.length();
00168             if (str[0] == '#')
00169                 continue;
00170             if ((str[0] =='t') && (str[1] =='i') && (str[3] == 'l')) //title
00171             {
00172                 for (int i = 8;i <=leng;i++)
00173                 {
00174                     if (str[i] == '>')
00175                        Title[i-8]='\0';
00176                     else
00177                         Title[i-8]=str[i];
00178 
00179 
00180                 }
00181 
00182 
00183             }
00184             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 'c') && (str[6] == 'c'))//graphcc
00185             {
00186                 for (int i = 10;i <=leng;i++)
00187                 {
00188                     if(str[i] == '>')
00189                         graphcc[i-10]='\0';
00190                     else
00191                         graphcc[i-10]=str[i];
00192 
00193 
00194                 }
00195 
00196             }
00197             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 'c') && (str[6] == 'a'))//graphca
00198             {
00199                 for (int i = 10;i <=leng;i++)
00200                 {
00201                     if (str[i] == '>')
00202                         graphca[i-10]='\0';
00203                     else
00204                         graphca[i-10]=str[i];
00205 
00206 
00207                 }
00208 
00209             }
00210             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 's') && (str[6] == 'c'))//graphsc
00211             {
00212                 for (int i = 10;i <=leng;i++)
00213                 {
00214                     if (str[i] == '>')
00215                         graphsc[i-10]='\0';
00216                     else
00217                         graphsc[i-10]=str[i];
00218 
00219 
00220                 }
00221 
00222             }
00223             if ((str[0] =='g') && (str[1] =='r') && (str[4] == 'h') && (str[5] == 's') && (str[6] == 'a'))//graphsa
00224             {
00225                 for (int i = 10;i <=leng;i++)
00226                 {
00227                     if (str[i] == '>')
00228                         graphsc[i-10]='\0';
00229                     else
00230                         graphsc[i-10]=str[i];
00231 
00232 
00233                 }
00234 
00235 
00236             }
00237             if ((str[0] =='M') && (str[1] =='a') && (str[4] == '_') && (str[5] == 'w') && (str[7] == 'd'))//Main_W
00238             {
00239                 for (int i = 13;i <=leng;i++)
00240                 {
00241                     if (str[i] == '>')
00242                         Main_width[i-13]='\n';
00243                     else
00244                         Main_width[i-13]=str[i];
00245 
00246 
00247 
00248                 }
00249                 QString test;
00250                 test.append("|");
00251                 test.append(Main_width);
00252                 test.append("|");
00253                 QMessageBox::information(this,"test",test);
00254 
00255             }
00256             if ((str[0] =='M') && (str[1] =='a') && (str[4] == '_') && (str[5] == 'h') && (str[7] == 'g'))//Main_h
00257             {
00258                 for (int i = 16;i <=leng;i++)
00259                 {
00260                     if (str[i] == '>')
00261                         Main_highth[i-16]='\0';
00262                     else
00263                         Main_highth[i-16]=str[i];
00264 
00265 
00266                 }
00267                 QString test;
00268                 test.append("|");
00269                 test.append(Main_highth);
00270                 test.append("|");
00271                 QMessageBox::information(this,"test",test);
00272 
00273             }
00274         }
00275 
00276 
00277 
00278 
00279     Swidget = new QWidget(this);
00280     QVBoxLayout *Main_Layout = new QVBoxLayout(Swidget);
00281 
00282     QHBoxLayout *windows1 = new QHBoxLayout;
00283     QHBoxLayout *windows2 = new QHBoxLayout;
00284     QVBoxLayout *vb = new QVBoxLayout;
00285 
00286     QLabel *LTitle =  new QLabel("Title");
00287     QLineEdit *ETitle = new QLineEdit;
00288     QLabel *LWidth = new QLabel("Window width: ");
00289     QLabel *Lhighth = new QLabel("Window highth: ");
00290     QSpinBox *WWidth = new QSpinBox;
00291     QSpinBox *Whighth = new QSpinBox;
00292     WWidth->setRange(0,1600);
00293     Whighth->setRange(0,1200);
00294     //write_to_file("debug.tsD",Main_highth);
00295     int tempw;
00296     int temph;
00297     bool ok;
00298     QString kk = "1234";
00299     tempw = kk.toInt();
00300     temph = Main_highth.toUInt(&ok,10);
00301 
00302     qDebug() << "Tempw" <<tempw << "and the string" <<Main_width;
00303     qDebug() << "Temph" <<temph << "and the string" <<Main_highth;
00304 
00305     WWidth->setValue(tempw);
00306     Whighth->setValue(temph);
00307     ETitle->setText(Title);
00308     //WWidth->setValue(1000);
00309     //Whighth->setValue(350);
00310     windows1->addWidget(LTitle);
00311     windows1->addWidget(ETitle);
00312     windows2->addWidget(LWidth);
00313     windows2->addWidget(WWidth);
00314     windows2->addWidget(Lhighth);
00315     windows2->addWidget(Whighth);
00316     vb->addLayout(windows1);
00317     vb->addSpacing(5);
00318     vb->addLayout(windows2);
00319 
00320 
00321     QVBoxLayout *gcvb = new QVBoxLayout;
00322     QHBoxLayout *gcwindows1 = new QHBoxLayout;
00323     QHBoxLayout *gcwindows2 = new QHBoxLayout;
00324     QHBoxLayout *gcwindows3 = new QHBoxLayout;
00325 
00326     QLabel *LCGraphBox = new QLabel("Settings for <Current Value> Graph");
00327     QLabel *LCcolour = new QLabel("Colour :");
00328     QLabel *LCStyle = new QLabel("Style: ");
00329     QComboBox *CGcspin = new QComboBox;
00330     QComboBox *CGsspin = new QComboBox;
00331 
00332 
00333     CGcspin->addItem("Red");
00334     CGcspin->addItem("Blue");
00335     CGcspin->addItem("Yellow");
00336     CGcspin->addItem("Green");
00337     CGcspin->addItem("Black");
00338 
00339 
00340 
00341     CGsspin->addItem("Lines");
00342     CGsspin->addItem("Sticks");
00343     CGsspin->addItem("Steps");
00344     CGsspin->addItem("Dots");
00345     CGsspin->addItem("NoCurve");
00346 
00347 
00348     gcwindows1->addWidget(LCcolour);
00349     gcwindows1->addWidget(CGcspin);
00350     gcwindows2->addWidget(LCStyle);
00351     gcwindows2->addWidget(CGsspin);
00352     gcwindows3->addLayout(gcwindows1);
00353     gcwindows3->addLayout(gcwindows2);
00354     gcvb->addWidget(LCGraphBox);
00355     gcvb->addLayout(gcwindows3);
00356 
00357 
00358     QVBoxLayout *gavb = new QVBoxLayout;
00359     QHBoxLayout *gawindows1 = new QHBoxLayout;
00360     QHBoxLayout *gawindows2 = new QHBoxLayout;
00361     QHBoxLayout *gawindows3 = new QHBoxLayout;
00362 
00363     QLabel *LAGraphBox = new QLabel("Settings for <Current Value> Graph");
00364     QLabel *LAcolour = new QLabel("Colour :");
00365     QLabel *LAStyle = new QLabel("Style: ");
00366     QComboBox *AGcspin = new QComboBox;
00367     QComboBox *AGsspin = new QComboBox;
00368 
00369     AGcspin->addItem("Red");
00370     AGcspin->addItem("Blue");
00371     AGcspin->addItem("Yellow");
00372     AGcspin->addItem("Green");
00373     AGcspin->addItem("Black");
00374 
00375     AGsspin->addItem("Lines");
00376     AGsspin->addItem("Sticks");
00377     AGsspin->addItem("Steps");
00378     AGsspin->addItem("Dots");
00379     AGsspin->addItem("NoCurve");
00380 
00381     gawindows1->addWidget(LAcolour);
00382     gawindows1->addWidget(AGcspin);
00383     gawindows2->addWidget(LAStyle);
00384     gawindows2->addWidget(AGsspin);
00385     gawindows3->addLayout(gawindows1);
00386     gawindows3->addLayout(gawindows2);
00387     gavb->addWidget(LAGraphBox);
00388     gavb->addLayout(gawindows3);
00389 
00390 
00391 
00392     QHBoxLayout *bbox = new QHBoxLayout;
00393     QPushButton *bOK = new QPushButton("OK");
00394     QPushButton *bApply = new QPushButton("Apply");
00395     QPushButton *bCancel = new QPushButton("Cancel");
00396     bbox->addWidget(bOK);
00397     bbox->addWidget(bApply);
00398     bbox->addWidget(bCancel);
00399     connect(bCancel,SIGNAL(clicked()),this, SLOT(close()));
00400 
00401     Main_Layout->addLayout(vb);
00402     Main_Layout->addSpacing(5);
00403     Main_Layout->addLayout(gcvb);
00404     Main_Layout->addSpacing(5);
00405     Main_Layout->addLayout(gavb);
00406     Main_Layout->addSpacing(5);
00407     Main_Layout->addLayout(bbox);
00408 
00409 
00410 }
00411 
00423 DeviceEditDialog::DeviceEditDialog(int mode, QWidget *parent) : QDialog (parent)
00424 {
00425     QString dDev;
00426     QString vID;
00427     QString pID;
00428     int leng = 0;
00429 
00430 
00431     if (mode == 1)
00432     {
00433         //USB
00434         QFile usb(USB_SETTINGS_TSS);
00435         usb.open(QIODevice::ReadOnly);
00436 
00437         QTextStream fs(&usb);    // read the data serialized from the file
00438 
00439         str.clear();
00440         while (!fs.atEnd())
00441         {
00442             leng = 0;
00443             str=fs.readLine();
00444             leng = str.length();
00445             if (str[0] == '#')
00446                 continue;
00447 
00448             if ((str[0] =='c') && (str[6] == 'v'))
00449             {
00450                 for (int i = 12;i <=leng;i++)
00451                 {
00452                     if(str[i] == '>')
00453                         vID[i-12]='\0';
00454                     else
00455                         vID[i-12]=str[i];
00456 
00457 
00458                 }
00459 
00460             }
00461             if ((str[0] =='c') && (str[6] == 'p'))
00462             {
00463                 for (int i = 12;i <=leng;i++)
00464                 {
00465                     if (str[i] == '>')
00466                         pID[i-12]='\0';
00467                     else
00468                         pID[i-12]=str[i];
00469 
00470 
00471                 }
00472 
00473             }
00474         }
00475 
00476 
00477     }
00478     else if (mode == 0)
00479     {
00480 
00481     }
00482     else
00483     {
00484         QMessageBox::about(this,tr("Error!"), tr("Error connecting to correct Settings! Please try again"));
00485         return;
00486     }
00487 
00488     QWidget *MainW = new QWidget(this);
00489 
00490     QVBoxLayout *Main_layout= new QVBoxLayout(MainW);
00491 
00492   //  QVBoxLayout *Devb = new QVBoxLayout;
00493   //  QHBoxLayout *devt = new QHBoxLayout;
00494  //   QHBoxLayout *devb = new QHBoxLayout;
00495 
00496     QVBoxLayout *Cb = new QVBoxLayout;
00497     QHBoxLayout *Ctt = new QHBoxLayout;
00498     QHBoxLayout *Ctb = new QHBoxLayout;
00499 
00500 
00501  //   QVBoxLayout *Bb = new QVBoxLayout(newg);
00502     QHBoxLayout *Bbt = new QHBoxLayout;
00503 
00504 
00505    // dev = new QLabel("Device: ");
00506     LVendorID = new QLabel("Vendor ID: ");
00507     LProductID = new QLabel("Product ID :");
00508    // BCustom = new QPushButton("Custom");
00509     BUsave = new QPushButton("Save");
00510     BCancel = new QPushButton("Cancel");
00511     EVendorID = new QLineEdit;
00512     EProductID = new QLineEdit;
00513     Cb_dev = new QComboBox;
00514     EVendorID->setText(vID);
00515     EProductID->setText(pID);
00516 
00517 
00518 
00519 
00520     //LVendorID->setDisabled(true);
00521    // LProductID->setDisabled(true);
00522   //  EVendorID->setDisabled(true);
00523   //  EProductID->setDisabled(true);
00524 
00525 
00526  //   devt->addWidget(dev);
00527   //  devt->addWidget(Cb_dev);
00528  //   devb->addWidget(BCustom);
00529     //Devb->addLayout(devt);
00530    // Devb->addLayout(devb);
00531 
00532 
00533 
00534     Ctt->addWidget(LVendorID);
00535     Ctt->addWidget(EVendorID);
00536     Ctb->addWidget(LProductID);
00537     Ctb->addWidget(EProductID);
00538     Cb->addLayout(Ctt);
00539     Cb->addLayout(Ctb);
00540 
00541 
00542     Bbt->addWidget(BUsave);
00543     Bbt->addWidget(BCancel);
00544 
00545     //Bb->addLayout(Bbt);
00546 
00547    // Main_layout->addLayout(Devb);
00548    // Main_layout->addSpacing(5);
00549     Main_layout->addLayout(Cb);
00550     Main_layout->addSpacing(5);
00551     Main_layout->addLayout(Bbt);
00552     //connect(BCustom,SIGNAL(clicked()),this,SLOT(enable_custome()));
00553     connect(BCancel,SIGNAL(clicked()), this, SLOT(close()));
00554     connect(BUsave,SIGNAL(clicked()), this, SLOT(bsave()));
00555     //connect(BImport,SIGNAL(clicked()), this, SLOT(bImport()));
00556 
00557 
00558 
00559 
00560 }
00561 
00572 SDeviceEditDialog::SDeviceEditDialog(QWidget *parent) : QDialog(parent)
00573 {
00574 
00575     int leng;
00576     QString DataB;
00577     QString parity;
00578     QString StopB;
00579     QString dDev;
00580     QString Brate;
00581 
00582 
00583 
00584     QFile usb(SERIAL_SETTINGS_TSS);
00585     usb.open(QIODevice::ReadOnly);
00586 
00587     QTextStream fs(&usb);    // read the data serialized from the file
00588 
00589     str.clear();
00590     while (!fs.atEnd())
00591     {
00592         leng = 0;
00593         str=fs.readLine();
00594         leng = str.length();
00595         if (str[0] == '#')
00596             continue;
00597         if ((str[0] =='d') && (str[3] == '_') && (str[6] == 'v'))//default devices
00598         {
00599             for (int i = 10;i <=leng;i++)
00600             {
00601                 if (str[i] == '>')
00602                     dDev[i-10]='\0';
00603                 else
00604                     dDev[i-10]=str[i];
00605 
00606 
00607             }
00608 
00609 
00610         }
00611         if ((str[0] =='b') && (str[2] == 'u') && (str[5] == 'a') && (str[6] == 't'))//baudrate
00612         {
00613             for (int i = 11;i <=leng;i++)
00614             {
00615                 if (str[i] == '>')
00616                     Brate[i-11]='\0';
00617                 else
00618                     Brate[i-11]=str[i];
00619 
00620 
00621             }
00622 
00623          }
00624         if ((str[0] =='d') && (str[3] == 'a') && (str[5] == 'i') && (str[6] == 't'))//databits
00625         {
00626             for (int i = 11;i <=leng;i++)
00627             {
00628                 if (str[i] == '>')
00629                     DataB[i-11]='\0';
00630                 else
00631                     DataB[i-11]=str[i];
00632 
00633 
00634             }
00635 
00636 
00637         }
00638         if ((str[0] =='s') && (str[3] == 'p') && (str[5] == 'i') && (str[6] == 't'))//stopbits
00639         {
00640             for (int i = 11;i <=leng;i++)
00641             {
00642                 if(str[i] == '>')
00643                     StopB[i-11]='\0';
00644                 else
00645                     StopB[i-11]=str[i];
00646 
00647 
00648             }
00649 
00650         }
00651         if ((str[0] =='p') && (str[2] == 'r') && (str[3] == 'i') && (str[5] == 'y'))//parity
00652         {
00653             for (int i = 12;i <=leng;i++)
00654             {
00655                 if (str[i] == '>')
00656                     parity[i-9]='\0';
00657                 else
00658                     parity[i-9]=str[i];
00659 
00660 
00661             }
00662 
00663         }
00664     }
00665 
00666 
00667 
00668 
00669     QWidget *MainW = new QWidget(this);
00670 
00671     QVBoxLayout *Main_layout= new QVBoxLayout(MainW);
00672 
00673     QVBoxLayout *Devb = new QVBoxLayout;
00674     QHBoxLayout *devt = new QHBoxLayout;
00675 
00676     QVBoxLayout *Cb = new QVBoxLayout;
00677     QHBoxLayout *Ctt = new QHBoxLayout;
00678     QHBoxLayout *Ctb = new QHBoxLayout;
00679     QHBoxLayout *Cbt = new QHBoxLayout;
00680     QHBoxLayout *Cbb = new QHBoxLayout;
00681 
00682 
00683 
00684  //   QVBoxLayout *Bb = new QVBoxLayout(newg);
00685     QHBoxLayout *Bbt = new QHBoxLayout;
00686 
00687 
00688     dev = new QLabel("Device: ");
00689     Lbaud = new QLabel("Baud Rate: ");
00690     Ldatab = new QLabel("Data bits :");
00691     Lstopb = new QLabel("Stop bits :");
00692     Lparity = new QLabel("Parity: ");
00693 
00694     Bsave = new QPushButton("Save");
00695     BCancel = new QPushButton("Cancel");
00696 
00697     Ebaud = new QLineEdit;
00698     Ebaud->setText(Brate);
00699     Edev = new QLineEdit;
00700     Edev->setText(dDev);
00701     Edatab = new QLineEdit;
00702     Edatab->setText(DataB);
00703 
00704     Cb_stopb = new QComboBox;
00705     Cb_parity = new QComboBox;
00706 
00707     if (StopB[0] == '1')
00708     {
00709 
00710         Cb_stopb->addItem("0");
00711         Cb_stopb->addItem(StopB);
00712         Cb_stopb->addItem("2");
00713     }
00714     else if(StopB[0] == '2')
00715     {
00716 
00717         Cb_stopb->addItem("0");
00718         Cb_stopb->addItem("1");
00719         Cb_stopb->addItem(StopB);
00720 
00721 
00722     }
00723     if (StopB[0] == '0')
00724     {
00725         Cb_stopb->addItem(StopB);
00726         Cb_stopb->addItem("1");
00727         Cb_stopb->addItem("2");
00728 
00729     }
00730 
00731     devt->addWidget(dev);
00732     devt->addWidget(Edev);
00733     Devb->addLayout(devt);
00734 
00735     Ctt->addWidget(Lbaud);
00736     Ctt->addWidget(Ebaud);
00737     Ctb->addWidget(Ldatab);
00738     Ctb->addWidget(Edatab);
00739     Cbt->addWidget(Lstopb);
00740     Cbt->addWidget(Cb_stopb);
00741     Cbb->addWidget(Lparity);
00742     Cbb->addWidget(Cb_parity);
00743 
00744     Cb->addLayout(Ctt);
00745     Cb->addLayout(Ctb);
00746     Cb->addLayout(Cbt);
00747     Cb->addLayout(Cbb);
00748 
00749     Bbt->setAlignment(Qt::AlignRight);
00750     Bbt->addWidget(Bsave);
00751 
00752     Bbt->addWidget(BCancel);
00753 
00754     //Bb->addLayout(Bbt);
00755 
00756     Main_layout->addLayout(Devb);
00757     Main_layout->addSpacing(5);
00758     Main_layout->addLayout(Cb);
00759     Main_layout->addSpacing(5);
00760     Main_layout->addLayout(Bbt);
00761 
00762     connect(BCancel,SIGNAL(clicked()), this, SLOT(close()));
00763     connect(Bsave,SIGNAL(clicked()), this, SLOT(bsave()));
00764 
00765 
00766 
00767 }
00778 BDeviceEditDialog::BDeviceEditDialog(QWidget *parent) : QDialog(parent)
00779 {
00780 
00781     int leng;
00782     QString DataB;
00783     QString parity;
00784     QString StopB;
00785     QString dDev;
00786     QString Brate;
00787 
00788 
00789 
00790     QFile usb(SERIAL_SETTINGS_TSS);
00791     usb.open(QIODevice::ReadOnly);
00792 
00793     QTextStream fs(&usb);    // read the data serialized from the file
00794 
00795     str.clear();
00796     while (!fs.atEnd())
00797     {
00798         leng = 0;
00799         str=fs.readLine();
00800         leng = str.length();
00801         if (str[0] == '#')
00802             continue;
00803         if ((str[0] =='d') && (str[3] == '_') && (str[6] == 'v'))//default devices
00804         {
00805             for (int i = 10;i <=leng;i++)
00806             {
00807                 if (str[i] == '>')
00808                     dDev[i-10]='\0';
00809                 else
00810                     dDev[i-10]=str[i];
00811 
00812 
00813             }
00814 
00815 
00816         }
00817         if ((str[0] =='b') && (str[2] == 'u') && (str[5] == 'a') && (str[6] == 't'))//baudrate
00818         {
00819             for (int i = 11;i <=leng;i++)
00820             {
00821                 if (str[i] == '>')
00822                     Brate[i-11]='\0';
00823                 else
00824                     Brate[i-11]=str[i];
00825 
00826 
00827             }
00828 
00829          }
00830         if ((str[0] =='d') && (str[3] == 'a') && (str[5] == 'i') && (str[6] == 't'))//databits
00831         {
00832             for (int i = 11;i <=leng;i++)
00833             {
00834                 if (str[i] == '>')
00835                     DataB[i-11]='\0';
00836                 else
00837                     DataB[i-11]=str[i];
00838 
00839 
00840             }
00841 
00842 
00843         }
00844         if ((str[0] =='s') && (str[3] == 'p') && (str[5] == 'i') && (str[6] == 't'))//stopbits
00845         {
00846             for (int i = 11;i <=leng;i++)
00847             {
00848                 if(str[i] == '>')
00849                     StopB[i-11]='\0';
00850                 else
00851                     StopB[i-11]=str[i];
00852 
00853 
00854             }
00855 
00856         }
00857         if ((str[0] =='p') && (str[2] == 'r') && (str[3] == 'i') && (str[5] == 'y'))//parity
00858         {
00859             for (int i = 12;i <=leng;i++)
00860             {
00861                 if (str[i] == '>')
00862                     parity[i-9]='\0';
00863                 else
00864                     parity[i-9]=str[i];
00865 
00866 
00867             }
00868 
00869         }
00870     }
00871 
00872 
00873 
00874 
00875     QWidget *MainW = new QWidget(this);
00876 
00877     QVBoxLayout *Main_layout= new QVBoxLayout(MainW);
00878 
00879     QVBoxLayout *Devb = new QVBoxLayout;
00880     QHBoxLayout *devt = new QHBoxLayout;
00881 
00882     QVBoxLayout *Cb = new QVBoxLayout;
00883     QHBoxLayout *Ctt = new QHBoxLayout;
00884     QHBoxLayout *Ctb = new QHBoxLayout;
00885     QHBoxLayout *Cbt = new QHBoxLayout;
00886     QHBoxLayout *Cbb = new QHBoxLayout;
00887 
00888 
00889 
00890  //   QVBoxLayout *Bb = new QVBoxLayout(newg);
00891     QHBoxLayout *Bbt = new QHBoxLayout;
00892 
00893 
00894     dev = new QLabel("Device: ");
00895     Lbaud = new QLabel("Baud Rate: ");
00896     Ldatab = new QLabel("Data bits :");
00897     Lstopb = new QLabel("Stop bits :");
00898     Lparity = new QLabel("Parity: ");
00899 
00900     Bsave = new QPushButton("Save");
00901     BCancel = new QPushButton("Cancel");
00902 
00903     Ebaud = new QLineEdit;
00904     Ebaud->setText(Brate);
00905     Edev = new QLineEdit;
00906     Edev->setText(dDev);
00907     Edatab = new QLineEdit;
00908     Edatab->setText(DataB);
00909 
00910     Cb_stopb = new QComboBox;
00911     Cb_parity = new QComboBox;
00912 
00913     if (StopB[0] == '1')
00914     {
00915 
00916         Cb_stopb->addItem("0");
00917         Cb_stopb->addItem(StopB);
00918         Cb_stopb->addItem("2");
00919     }
00920     else if(StopB[0] == '2')
00921     {
00922 
00923         Cb_stopb->addItem("0");
00924         Cb_stopb->addItem("1");
00925         Cb_stopb->addItem(StopB);
00926 
00927 
00928     }
00929     if (StopB[0] == '0')
00930     {
00931         Cb_stopb->addItem(StopB);
00932         Cb_stopb->addItem("1");
00933         Cb_stopb->addItem("2");
00934 
00935     }
00936 
00937     devt->addWidget(dev);
00938     devt->addWidget(Edev);
00939     Devb->addLayout(devt);
00940 
00941     Ctt->addWidget(Lbaud);
00942     Ctt->addWidget(Ebaud);
00943     Ctb->addWidget(Ldatab);
00944     Ctb->addWidget(Edatab);
00945     Cbt->addWidget(Lstopb);
00946     Cbt->addWidget(Cb_stopb);
00947     Cbb->addWidget(Lparity);
00948     Cbb->addWidget(Cb_parity);
00949 
00950     Cb->addLayout(Ctt);
00951     Cb->addLayout(Ctb);
00952     Cb->addLayout(Cbt);
00953     Cb->addLayout(Cbb);
00954 
00955     Bbt->setAlignment(Qt::AlignRight);
00956     Bbt->addWidget(Bsave);
00957 
00958     Bbt->addWidget(BCancel);
00959 
00960     //Bb->addLayout(Bbt);
00961 
00962     Main_layout->addLayout(Devb);
00963     Main_layout->addSpacing(5);
00964     Main_layout->addLayout(Cb);
00965     Main_layout->addSpacing(5);
00966     Main_layout->addLayout(Bbt);
00967 
00968     connect(BCancel,SIGNAL(clicked()), this, SLOT(close()));
00969     connect(Bsave,SIGNAL(clicked()), this, SLOT(bsave()));
00970 
00971 
00972 
00973 }
00985 void DeviceEditDialog::enable_custome()
00986 {
00987     LVendorID->setEnabled(true);
00988     LProductID->setEnabled(true);
00989     EVendorID->setEnabled(true);
00990     EProductID->setEnabled(true);
00991     Cb_dev->setDisabled(true);
00992 
00993 }
00994 
01006 void DeviceEditDialog::bsave()
01007 {
01008   //  QFile file("c://test.txt");
01009    // file.open(QIODevice::WriteOnly);
01010   //  QDataStream out(&file);   // we will serialize the data into the file
01011   //  out << "welcome to the Qt World";   // serialize a string
01012     //file.close();
01013 
01014 
01015 }
01027 void ProgEditDialog::bpsave()
01028 {
01029 
01030 }
01031 
01043 void SDeviceEditDialog::bsave()
01044 {
01045 
01046 }
01047 
01048 \
01059 DataViewDialog::DataViewDialog(QWidget *parent) : QDialog(parent)
01060 {
01061 
01062     QWidget *widget = new QWidget(this);
01063     QString str;
01064     QString desc_str;
01065     QVBoxLayout *main = new QVBoxLayout(widget);
01066 
01067 
01068     QFile desc(DESCRIPTION_FILE);
01069     desc.open(QIODevice::ReadOnly);
01070 
01071     QTextStream fs(&desc);
01072 
01073     while(!fs.atEnd())
01074     {
01075         str = fs.readLine();
01076         if(str[0] == '#')
01077             continue;
01078         desc_str.append(str);
01079 
01080     }
01081 
01082 
01083 
01084 
01085     QStringList str_list;
01086 
01087     QVBoxLayout *Desc = new QVBoxLayout;
01088     QLabel *Ldesc = new QLabel("Description:");
01089     QTextBrowser *TB = new QTextBrowser;
01090     TB->setText(desc_str);
01091 
01092     QVBoxLayout *lib = new QVBoxLayout;
01093     QLabel *Llib = new QLabel("Libraries");
01094 
01095     QFile datf(QFileDialog::getOpenFileName(this, tr("Open File"), "/home", tr("Captured Data [*.tsd]  (*.tsd);;Plot Data [*.tsp] (*.tsp)")));
01096     datf.open(QIODevice::ReadOnly);
01097 
01098    /* if(!datf.isOpen())
01099     {
01100         QMessageBox::information(this,"Error Opening File","An error has occured when opening file. Do you have permission?");
01101         return;
01102     }*/
01103     QTextStream ts(&datf);
01104 
01105 
01106     int leng = 0;
01107     QString str1;
01108     QString temp;
01109     QString temp2;
01110     QStringList row1;
01111     QStringList row2;
01112     QStringList row3;
01113     int k = 1;
01114     int y = 0;
01115     while(!ts.atEnd())
01116     {
01117 
01118 
01119         qDebug() << str1 << " " << temp;
01120         str1 = ts.readLine();
01121         k=0;
01122         qDebug() << str1;
01123         if (str1[0] == '#')
01124             continue;
01125         while(1)
01126         {
01127             qDebug() << "we r in while(1)";
01128             if (str1[k] == '>')
01129             {
01130                 temp[k-1] = ':';
01131                 //temp[k] = '\0';
01132                 break;
01133             }
01134             else
01135                 temp[k-1] = str1[k];
01136 
01137             k++;
01138 
01139         }
01140         qDebug() << "this is temp: " << temp;
01141         int v = 0;
01142         int z = 0;
01143         int x = 0;
01144         while (1)
01145         {
01146             while(temp[v] != ':')
01147             {
01148                 temp2[x] = temp[v];
01149                 v++;
01150                 x++;
01151                 qDebug() << "in temp2 loop temp2,v,x,z,temp" << temp2 <<" " << v << " " << x << " " << z << " " << temp;
01152             }
01153             qDebug() << temp2 << v << z;
01154             if(temp[v] == ':')
01155                 v++;
01156             if(z == 0)
01157                 row1 << temp2;
01158             if(z == 1)
01159                 row2 << temp2;
01160             if(z == 2)
01161                 row3 << temp2;
01162 
01163             temp2.clear();
01164             x = 0;
01165             if (z == 2)
01166                 break;
01167             z++;
01168 
01169         }
01170 
01171     }
01172 
01173 
01174 
01175   /*  QTableWidget *Tw = new QTableWidget;
01176 
01177     str_list << "test1" << "test2";
01178     Tw->setHorizontalHeaderLabels(str_list);
01179 
01180    // items << tr("T-shirt") << tr("Badge") << tr("Reference book")
01181                //<< tr("Coffee cup");
01182 
01183          itemsTable = new QTableWidget(items.count(), 2);
01184 
01185          for (int row = 0; row < items.count(); ++row) {
01186              QTableWidgetItem *name = new QTableWidgetItem(items[row]);
01187              name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
01188              itemsTable->setItem(row, 0, name);
01189              QTableWidgetItem *quantity = new QTableWidgetItem("1");
01190              itemsTable->setItem(row, 1, quantity);
01191          }
01192 
01193 
01194 
01195 */
01196 
01197 }
 All Classes Files Functions Variables Defines