Example #1
0
void TestPage::slotAccel (int id)
{
  switch (id)
  {
    case NewTest:
      newTest();
      break;  
    case DeleteTest:
      deleteTest();
      break;  
    case RenameTest:
      renameTest();
      break;  
    case OpenTest:
      openTest();
      break;  
    case CopyTest:
      copyTest();
      break;  
    case Help:
      slotHelp();
      break;  
    default:
      break;
  }
}
Example #2
0
TestPage::TestPage (QWidget *w, MainMenubar *mb, DBIndex *i) : QWidget (w)
{
  chartIndex = i;
  menubar = mb;
  idir.setFilter(QDir::Dirs);

  QVBoxLayout *vbox = new QVBoxLayout(this);
  vbox->setMargin(0);
  vbox->setSpacing(5);
  
  search = new QLineEdit(this);
  search->setText("*");
  connect(search, SIGNAL(textChanged(const QString &)), this, SLOT(searchChanged(const QString &)));
  QToolTip::add(search, tr("List Filter, e.g. s* or sb*"));
  vbox->addWidget(search);

  list = new QListBox(this);
  connect(list, SIGNAL(contextMenuRequested(QListBoxItem *, const QPoint &)), this,
          SLOT(rightClick(QListBoxItem *)));
  connect(list, SIGNAL(highlighted(const QString &)), this, SLOT(testSelected(const QString &)));
  connect(list, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(doubleClick(QListBoxItem *)));
  vbox->addWidget(list);
  
  menu = new QPopupMenu(this);
  menu->insertItem(QPixmap(newchart), tr("&New Rule		Ctrl+N"), this, SLOT(newTest()));
  menu->insertItem(QPixmap(open), tr("&Open Rule		Ctrl+O"), this, SLOT(openTest()));
  menu->insertItem(QPixmap(deleteitem), tr("&Delete Rule	Ctrl+D"), this, SLOT(deleteTest()));
  menu->insertItem(QPixmap(renam), tr("&Rename Rule		Ctrl+R"), this, SLOT(renameTest()));
  menu->insertItem(QPixmap(copypic), tr("&Copy Rule		Ctrl+Y"), this, SLOT(copyTest()));
  menu->insertSeparator(-1);
  menu->insertItem(QPixmap(help), tr("&Help		Ctrl+H"), this, SLOT(slotHelp()));

  QAccel *a = new QAccel(this);
  connect(a, SIGNAL(activated(int)), this, SLOT(slotAccel(int)));
  a->insertItem(CTRL+Key_N, NewTest);
  a->insertItem(CTRL+Key_O, OpenTest);
  a->insertItem(CTRL+Key_D, DeleteTest);
  a->insertItem(CTRL+Key_R, RenameTest);
  a->insertItem(CTRL+Key_Y, CopyTest);
  a->insertItem(CTRL+Key_H, Help);
  
  updateList();
  testNoSelection();
}
Example #3
0
MainWindow::MainWindow()
{
    setupUi(this);
    if (tr("LTR") == "RTL") {
        qApp->setLayoutDirection(Qt::RightToLeft);
    }

#ifndef Q_OS_WIN32
    testPageSplitter->setPalette(this->palette());
#endif

    remainingTimeLcdNumber->setVisible(false);
    remainingTimeProgressBar->setVisible(false);
    label_minutes->setVisible(false);
    questionTextSvgSplitter->setCollapsible(0, false);
    questionTextSvgSplitter->setCollapsible(1, true);
    tcpSocket = new QTcpSocket(this);
    progress_dialog = NULL;
    current_test_use_groups = false;
    current_connection_local = false;

    QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateTime()));
    QObject::connect(tbtnQuit, SIGNAL(released()), this, SLOT(close()));
    QObject::connect(tbtnAbout, SIGNAL(released()), this, SLOT(about()));
    QObject::connect(tbtnGetReady, SIGNAL(released()), this, SLOT(getReady()));
    QObject::connect(tbtnStart, SIGNAL(released()), this, SLOT(start()));
    QObject::connect(tbtnBrowse_DBPath, SIGNAL(released()), this, SLOT(browse_i()));
    QObject::connect(tbtnBrowse_savePath, SIGNAL(released()), this, SLOT(browse_o()));
    QObject::connect(tbtnLoad, SIGNAL(released()), this, SLOT(loadFile()));
    QObject::connect(useDefaultOutputCheckBox, SIGNAL(toggled(bool)), savePathLineEdit, SLOT(setDisabled(bool)));
    QObject::connect(useDefaultOutputCheckBox, SIGNAL(toggled(bool)), tbtnBrowse_savePath, SLOT(setDisabled(bool)));
    QObject::connect(serverNameLineEdit, SIGNAL(textChanged(const QString &)),
                     this, SLOT(enableConnectButton()));
    QObject::connect(serverPortLineEdit, SIGNAL(textChanged(const QString &)),
                     this, SLOT(enableConnectButton()));
    QObject::connect(DBPathLineEdit, SIGNAL(textChanged(const QString &)),
                     this, SLOT(enableLoadButton()));
    QObject::connect(tbtnConnect, SIGNAL(released()), this, SLOT(connectSocket()));
    QObject::connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readIncomingData()));
    QObject::connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
                     this, SLOT(displayError(QAbstractSocket::SocketError)));
    QObject::connect(LQListWidget, SIGNAL(currentTextChanged(QString)),
                     this, SLOT(setCurrentQuestion()));
    QObject::connect(svgDisplayWidget, SIGNAL(titleClicked(const QString &)), this, SLOT(previewSvg(const QString &)));
    QObject::connect(btnNext, SIGNAL(released()), this, SLOT(nextQuestion()));
    QObject::connect(btnLast, SIGNAL(released()), this, SLOT(lastQuestion()));
    QObject::connect(btnFinish, SIGNAL(released()), this, SLOT(finish()));
    QObject::connect(btnNewTest, SIGNAL(released()), this, SLOT(newTest()));
    QObject::connect(btnQuit, SIGNAL(released()), this, SLOT(close()));

    rbtngrpInputType = new QButtonGroup (this);
    rbtngrpInputType->addButton(rbtnNetwork);
    rbtngrpInputType->addButton(rbtnFromFile);
    QObject::connect(rbtngrpInputType, SIGNAL(buttonReleased(QAbstractButton *)), this, SLOT(toggleInputType(QAbstractButton *)));

    QObject::connect(answersView, SIGNAL(buttonReleased(Question::Answers)), this, SLOT(setQuestionAnswered(Question::Answers)));

    for (int i = 0; i < 8; ++i) {
        infoTableWidget->setItem(i, 0, new QTableWidgetItem);
    }
    ITW_test_name = infoTableWidget->item(0, 0);
    ITW_test_date = infoTableWidget->item(1, 0);
    ITW_test_timestamp = infoTableWidget->item(2, 0);
    ITW_test_time = infoTableWidget->item(3, 0);
    ITW_test_qnum = infoTableWidget->item(4, 0);
    ITW_test_fnum = infoTableWidget->item(5, 0);
    ITW_test_categories = infoTableWidget->item(6, 0);
    ITW_test_passmark = infoTableWidget->item(7, 0);
    ITW_test_comments = new QTextBrowser (infoTableWidget);
    infoTableWidget->setCellWidget(8, 0, ITW_test_comments);
    infoTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    infoTableWidget->verticalHeader()->setSectionResizeMode(8, QHeaderView::Stretch);
    resultsTableWidget->setColumnCount(1);
    resultsTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    resultsTableWidget->horizontalHeader()->hide();
    
    loadSettings();
    
    // Check app args ----------------------------------------------------------
    if (qApp->arguments().count() > 2) {
        if (qApp->arguments().at(1) == "-port") {
            serverNameLineEdit->setText("Localhost");
            serverPortLineEdit->setText(qApp->arguments().at(2));
            connectSocket();
        }
    } else if (qApp->arguments().count() > 1) {
        openFile(qApp->arguments().at(1));
    }
}
Example #4
0
void GemTest::init(Token *first)
{
    enum testArgType_e { TA_NONE = 0, TA_NUMBER, TA_TEXT};
    struct { const char *name; GemTestID cmdId; testArgType_e argType; } tests[] =
    {
        { "try",        BeginTry,       TA_NONE },
        { "pass",       CheckIfPassed,  TA_NONE },
        { "top",        IsTop,          TA_NONE },
        { "me",         IsMe,           TA_NONE },
        { "myparent",   IsMyParent,     TA_NONE },
        { "myancestor", IsMyAncestor,   TA_NONE },
        { "break",      IsBreak,        TA_NONE },
        { "br",         IsLineBreak,    TA_NONE },
        { "control",    IsControl,      TA_NONE },
        { "@",          GoSelf,         TA_NONE },
        { "final",      GoFinal,        TA_NONE },
        { "child",      NthChild,       TA_NUMBER },
        { "order",      NthOrder,       TA_NUMBER },
        { "count",      ChildCount,     TA_NUMBER },
        { "width",      CellWidth,      TA_NUMBER },
        { "text",       Text,           TA_TEXT },
        { "begins",     TextBegins,     TA_TEXT },
        { 0,            InvalidGemTest, TA_NONE }
    };
    struct { const char *condition; GemClass::GemType type; } gemTypes[] =
    {
        { "gem",        GemClass::Gem },
        { "indent",     GemClass::Indent },
        { "list",       GemClass::List },
        { "deflist",    GemClass::DefinitionList },
        { "table",      GemClass::Table },
        { "part",       GemClass::PartTitle },
        { "chapter",    GemClass::ChapterTitle },
        { "section",    GemClass::SectionTitle },
        { "subsec",     GemClass::SubSectionTitle },
        { "sub2sec",    GemClass::Sub2SectionTitle },
        { "sub3sec",    GemClass::Sub3SectionTitle },
        { "sub4sec",    GemClass::Sub4SectionTitle },
        { "contents",   GemClass::Contents },
        { 0,            GemClass::None }
    };
    struct { const char* condition; GemClass::FlushMode mode; } gemFlushModes[] =
    {
        { "left",       GemClass::FlushLeft },
        { "right",      GemClass::FlushRight },
        { "center",     GemClass::FlushCenter },
        { 0,            GemClass::FlushInherit }
    };
    int i;

    // Destroy existing commands.
    _commands.destroy();

    // Next we'll convert all the shards to test commands.
    for(Shard *it = first; it; it = it->next())
    {
        String con = ((Token*)it)->unEscape();
        if(con.isEmpty()) continue;

        // This'll report unknown commands.
        _addedBit = false;

        // Normally 'false' is the failing condition.
        _failBit = false;
        while(con[0] == '!')
        {
            // Use a negative test.
            con.remove(0, 1);
            _failBit = !_failBit;
        }

        // Check for escalation.
        _escalateBit = false;
        if(con[0] == '^')
        {
            con.remove(0, 1);
            _escalateBit = true;
        }

        // Navigation of the test pointer.
        if((i = CompareCount(con, "parent"))) newTest(GoParent, i);
        else if((i = CompareCount(con, "next"))) newTest(GoNext, i);
        else if((i = CompareCount(con, "prev"))) newTest(GoPrev, i);
        else if((i = CompareCount(con, "first"))) newTest(GoFirst, i);
        else if((i = CompareCount(con, "last"))) newTest(GoLast, i);
        else if((i = CompareCount(con, "following"))) newTest(GoFollowing, i);
        else if((i = CompareCount(con, "preceding"))) newTest(GoPreceding, i);
        
        for(i = 0; tests[i].name; i++)
            if(con == tests[i].name)
            {
                if(tests[i].argType == TA_NUMBER)
                {
                    int arg = 0;
                    if(it->next())
                    {
                        it = it->next();
                        arg = ((Token*)it)->token().toInt();
                    }
                    newTest(tests[i].cmdId, arg);
                }
                else if(tests[i].argType == TA_TEXT)
                {
                    String txt;
                    if(it->next())
                    {
                        it = it->next();
                        txt = ((Token*)it)->unEscape();
                    }
                    newTest(tests[i].cmdId, 0, txt);
                }
                else
                {
                    newTest(tests[i].cmdId);
                }
                break;
            }

        // Types.
        for(i = 0; gemTypes[i].condition; i++)
            if(con == gemTypes[i].condition)
            {
                newTest(GemType, gemTypes[i].type);
                break;
            }

        // Flush modes.
        for(i = 0; gemFlushModes[i].condition; ++i)
            if(con == gemFlushModes[i].condition)
            {
                newTest(GemFlushMode, gemFlushModes[i].mode);
                break;
            }

        // Flags that must be present.
        String lowCon = stringCase(con, LOWERCASE_ALL);
        bool checkForJust = con[0].isUpper();
        if((i = styleForName(lowCon)))
        {
            newTest(checkForJust? ExclusiveFlag : HasFlag, i);
        }
        
        if(!_addedBit)
        {
            // Print a warning message.         
            qWarning() << con << ": Unknown test command.";
        }
    }
}