コード例 #1
0
ファイル: rulesDialog.cpp プロジェクト: spono/QGIS
rulesDialog::rulesDialog( const QMap<QString, TopologyRule>& testMap, QgisInterface *theQgisIface, QWidget *parent )
    : QDialog( parent ), Ui::rulesDialog()
{
  setupUi( this );

  mQgisIface = theQgisIface;

  //setHorizontalHeaderItems();
  mRulesTable->hideColumn( 4 );
  mRulesTable->hideColumn( 5 );

  mTestConfMap = testMap;
  mRulesTable->setSelectionBehavior( QAbstractItemView::SelectRows );
  mRuleBox->addItems( mTestConfMap.keys() );

  mAddTestButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
  mDeleteTestButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) );

  connect( mAddTestButton, SIGNAL( clicked() ), this, SLOT( addRule() ) );
  connect( mAddTestButton, SIGNAL( clicked() ), mRulesTable, SLOT( resizeColumnsToContents() ) );
  // attempt to add new test when Ok clicked
  //connect( buttonBox, SIGNAL( accepted() ), this, SLOT( addTest() ) );
  connect( mDeleteTestButton, SIGNAL( clicked() ), this, SLOT( deleteTest() ) );

  connect( mLayer1Box, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( updateRuleItems( const QString& ) ) );
  connect( mRuleBox, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( showControls( const QString& ) ) );

  mRuleBox->setCurrentIndex( 0 );

  //this resets this plugin up if a project is loaded
  connect( mQgisIface, SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
  //reset plugin if new project is activated
  projectRead();
}
コード例 #2
0
ファイル: TestPage.cpp プロジェクト: botvs/FinancialAnalytics
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;
  }
}
コード例 #3
0
ファイル: TestPage.cpp プロジェクト: botvs/FinancialAnalytics
void TestPage::doKeyPress (QKeyEvent *key)
{
  key->accept();
  
  if (key->state() == Qt::ControlButton)
  {
    switch(key->key())
    {
      case Qt::Key_N:
        slotAccel(NewTest);
	break;
      case Qt::Key_D:
        slotAccel(DeleteTest);
	break;
      case Qt::Key_O:
        slotAccel(OpenTest);
	break;
      case Qt::Key_R:
        slotAccel(RenameTest);
	break;
      case Qt::Key_Y:
        slotAccel(CopyTest);
	break;
      default:
        break;
    }
  }
  else
  {
    switch (key->key())
    {
      case Qt::Key_Delete:
        deleteTest();
        break;
      case Qt::Key_Left: // segfaults if we dont trap this
      case Qt::Key_Right: // segfaults if we dont trap this
        break;      
      case Qt::Key_Enter:
      case Qt::Key_Return:
        openTest();
        break;
      default:
//        QListBox::keyPressEvent(key);
        break;
    }
  }
}
コード例 #4
0
ファイル: TestPage.cpp プロジェクト: botvs/FinancialAnalytics
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();
}
/**
 * FUNCTION NAME: mp2Run
 *
 * DESCRIPTION: This function performs all the key value store related functionalities
 * 				including:
 * 				1) Ring operations
 * 				2) CRUD operations
 */
void Application::mp2Run() {
    int i;

    // For all the nodes in the system
    for( i = 0; i <= par->EN_GPSZ-1; i++) {

        /*
         * 1) Update the ring
         * 2) Receive messages from the network and queue them in the KV store queue
         */
        if ( par->getcurrtime() > (int)(par->STEP_RATE*i) && !mp2[i]->getMemberNode()->bFailed ) {
            if ( mp2[i]->getMemberNode()->inited && mp2[i]->getMemberNode()->inGroup ) {
                // Step 1
                mp2[i]->updateRing();
            }
            // Step 2
            mp2[i]->recvLoop();
        }
    }

    /**
     * Handle messages from the queue and update the DHT
     */
    for ( i = par->EN_GPSZ-1; i >= 0; i-- ) {
        if ( par->getcurrtime() > (int)(par->STEP_RATE*i) && !mp2[i]->getMemberNode()->bFailed ) {
            mp2[i]->checkMessages();
        }
    }
    /**
     * Insert a set of test key value pairs into the system
     */
    if ( par->getcurrtime() == INSERT_TIME ) {
        insertTestKVPairs();
    }

    /**
     * Test CRUD operations
     */
    if ( par->getcurrtime() >= TEST_TIME ) {
        /**************
         * CREATE TEST
         **************/
        /**
         * TEST 1: Checks if there are RF * NUMBER_OF_INSERTS CREATE SUCCESS message are in the log
         *
         */
        if ( par->getcurrtime() == TEST_TIME && CREATE_TEST == par->CRUDTEST ) {
            cout<<endl<<"Doing create test at time: "<<par->getcurrtime()<<endl;
        } // End of create test

        /***************
         * DELETE TESTS
         ***************/
        /**
         * TEST 1: NUMBER_OF_INSERTS/2 Key Value pair are deleted.
         * 		   Check whether RF * NUMBER_OF_INSERTS/2 DELETE SUCCESS message are in the log
         * TEST 2: Delete a non-existent key. Check for a DELETE FAIL message in the lgo
         *
         */
        else if ( par->getcurrtime() == TEST_TIME && DELETE_TEST == par->CRUDTEST ) {
            deleteTest();
        } // End of delete test

        /*************
         * READ TESTS
         *************/
        /**
         * TEST 1: Read a key. Check for correct value being read in quorum of replicas
         *
         * Wait for some time after TEST 1
         *
         * TEST 2: Fail a single replica of a key. Check for correct value of the key
         * 		   being read in quorum of replicas
         *
         * Wait for STABILIZE_TIME after TEST 2 (stabilization protocol should ensure at least
         * 3 replicas for all keys at all times)
         *
         * TEST 3 part 1: Fail two replicas of a key. Read the key and check for READ FAIL message in the log.
         * 				  READ should fail because quorum replicas of the key are not up
         *
         * Wait for another STABILIZE_TIME after TEST 3 part 1 (stabilization protocol should ensure at least
         * 3 replicas for all keys at all times)
         *
         * TEST 3 part 2: Read the same key as TEST 3 part 1. Check for correct value of the key
         * 		  		  being read in quorum of replicas
         *
         * Wait for some time after TEST 3 part 2
         *
         * TEST 4: Fail a non-replica. Check for correct value of the key
         * 		   being read in quorum of replicas
         *
         * TEST 5: Read a non-existent key. Check for a READ FAIL message in the log
         *
         */
        else if ( par->getcurrtime() >= TEST_TIME && READ_TEST == par->CRUDTEST ) {
            readTest();
        } // end of read test

        /***************
         * UPDATE TESTS
         ***************/
        /**
         * TEST 1: Update a key. Check for correct new value being updated in quorum of replicas
         *
         * Wait for some time after TEST 1
         *
         * TEST 2: Fail a single replica of a key. Update the key. Check for correct new value of the key
         * 		   being updated in quorum of replicas
         *
         * Wait for STABILIZE_TIME after TEST 2 (stabilization protocol should ensure at least
         * 3 replicas for all keys at all times)
         *
         * TEST 3 part 1: Fail two replicas of a key. Update the key and check for READ FAIL message in the log
         * 				  UPDATE should fail because quorum replicas of the key are not up
         *
         * Wait for another STABILIZE_TIME after TEST 3 part 1 (stabilization protocol should ensure at least
         * 3 replicas for all keys at all times)
         *
         * TEST 3 part 2: Update the same key as TEST 3 part 1. Check for correct new value of the key
         * 		   		  being update in quorum of replicas
         *
         * Wait for some time after TEST 3 part 2
         *
         * TEST 4: Fail a non-replica. Check for correct new value of the key
         * 		   being updated in quorum of replicas
         *
         * TEST 5: Update a non-existent key. Check for a UPDATE FAIL message in the log
         *
         */
        else if ( par->getcurrtime() >= TEST_TIME && UPDATE_TEST == par->CRUDTEST ) {
            updateTest();
        } // End of update test

    } // end of if ( par->getcurrtime == TEST_TIME)
}