• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

gui/roctabswidget.cpp (r4864/r1008)

Go to the documentation of this file.
00001 #include "roctabswidget.h"
00002 
00003 #include "subwidget.h"
00004 
00005 #include <iostream>
00006 #include <QFileDialog>
00007 
00008 RocTabsWidget::RocTabsWidget(QWidget* parent, roc::Board* brd) :
00009    QTabWidget(parent),
00010    fBoard(brd),
00011    fStatus(0),
00012    fCmdFileName("name.cmd")
00013 {
00014 }
00015 
00016 void RocTabsWidget::getFullConfig()
00017 {
00018    for (int n=0; n<count(); n++) {
00019       SubWidget* w = dynamic_cast<SubWidget*>(widget(n));
00020       if (w==0) continue;
00021 
00022       // subwidget should produce error message itself
00023       if (!w->getSubConfig()) return;
00024       w->setSubChanged(false);
00025    }
00026 
00027    showMessage("Get done");
00028 }
00029 
00030 void RocTabsWidget::setFullConfig()
00031 {
00032    for (int n=0; n<count(); n++) {
00033       SubWidget* w = dynamic_cast<SubWidget*>(widget(n));
00034       if (w==0) continue;
00035 
00036       // subwidget should produce error message itself
00037       if (!w->setSubConfig()) return;
00038       w->setSubChanged(false);
00039    }
00040 
00041    showMessage("Set full done");
00042 }
00043 
00044 void RocTabsWidget::saveFullConfig()
00045 {
00046    QFileDialog fd(this, "Create command file",
00047                   fCmdFileName, "Command file (*.cmd);;Any file (*)");
00048    fd.setFileMode( QFileDialog::AnyFile);
00049    fd.setAcceptMode(QFileDialog::AcceptSave);
00050 
00051    if (fd.exec() != QDialog::Accepted) return;
00052    QStringList flst = fd.selectedFiles();
00053    if (flst.isEmpty()) return;
00054 
00055    fCmdFileName = flst[0];
00056 
00057    FILE* f = fopen(fCmdFileName.toAscii(), "w");
00058 
00059    if (f==0) return;
00060 
00061    if (produceCmdFile(f))
00062       showMessage(QString("%1 produced").arg(fCmdFileName));
00063 
00064    fclose(f);
00065 }
00066 
00067 
00068 void RocTabsWidget::showSubChanged(SubWidget* sub)
00069 {
00070    if (sub==0) return;
00071 
00072    int indx = indexOf(sub);
00073    if (indx<0) return;
00074 
00075    QString txt = tabText(indx);
00076 
00077    if (sub->isSubChanged()) {
00078       if (txt[0] != QChar('*'))
00079          txt = QString("*") + txt;
00080    } else {
00081       if (txt[0] == QChar('*'))
00082          txt.remove(0,1);
00083    }
00084 
00085    setTabText(indx, txt);
00086 }
00087 
00088 
00089 void RocTabsWidget::showMessage(const QString& msg, int tmout)
00090 {
00091    if (fStatus!=0)
00092       fStatus->showMessage(msg, tmout);
00093 }
00094 
00095 void RocTabsWidget::getCurrConfig()
00096 {
00097    SubWidget* w = dynamic_cast<SubWidget*>(currentWidget());
00098    if (w!=0) {
00099       w->getSubConfig();
00100       w->setSubChanged(false);
00101    }
00102 }
00103 
00104 void RocTabsWidget::setCurrConfig()
00105 {
00106    SubWidget* w = dynamic_cast<SubWidget*>(currentWidget());
00107    if (w!=0) {
00108       w->setSubConfig();
00109       w->setSubChanged(false);
00110    }
00111 }
00112 
00113 void RocTabsWidget::setCurrDefault()
00114 {
00115    SubWidget* w = dynamic_cast<SubWidget*>(currentWidget());
00116    if (w==0) return;
00117 
00118    showMessage("");
00119 
00120    if (!w->setSubToDefault())
00121       showMessage("Set default not implemented");
00122 }
00123 
00124 bool RocTabsWidget::produceCmdFile(FILE* f)
00125 {
00126    if (f==0) return false;
00127    fprintf(f,"// this is generated file \n");
00128 
00129    for (int n=0; n<count(); n++) {
00130       SubWidget* w = dynamic_cast<SubWidget*>(widget(n));
00131       if (w==0) continue;
00132 
00133       // subwidget should produce error message itself
00134       if (!w->fillCmdFile(f)) return false;
00135    }
00136 
00137    return true;
00138 }

Generated on Tue Dec 10 2013 04:52:22 for ROCsoft by  doxygen 1.7.1