void core::DatabaseMapperDialog::init(const QSqlDatabase &db)
{

	_loMain = new QVBoxLayout();

	_lcbTables = new LabeledComboBox(tr("Tables"));

	tblMapView = new QTableWidget(1, 4);

	tblMapView->verticalHeader()->setVisible(false);


	if(db.isOpen()){
		_lcbTables->getComboBox()->addItems(db.tables(QSql::Tables));
		_lcbTables->getComboBox()->addItems(db.tables(QSql::Views));
	}

	_loMain->addWidget(_lcbTables);
	_loMain->addWidget(tblMapView);

	getMainToolbar()->addAction(ICON_UPDATE, tr("Update"), this, SLOT(updateConnection()));

	getMainMenuBar()->setVisible(false);
	setApplyButtonVisible(false);

	getMainWindow()->centralWidget()->setLayout(_loMain);

	_db = db;

	connect(_lcbTables->getComboBox(), &QComboBox::currentTextChanged, [=](const QString &text){
		fillTable(text);
	});

	fillTable(_lcbTables->getComboBox()->currentText());
}
示例#2
0
DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_new) :
    QDialog(parent),
    ui(new Ui::DecodeAsDialog),
    cap_file_(cf),
    table_names_combo_box_(NULL),
    selector_combo_box_(NULL)
{
    ui->setupUi(this);
    setWindowTitle(wsApp->windowTitleString(tr("Decode As" UTF8_HORIZONTAL_ELLIPSIS)));
    ui->deleteToolButton->setEnabled(false);

    GList *cur;
    for (cur = decode_as_list; cur; cur = cur->next) {
        decode_as_t *entry = (decode_as_t *) cur->data;
        QString table_ui_name = get_dissector_table_ui_name(entry->table_name);
        if (!table_ui_name.isEmpty()) {
            ui_name_to_name_[table_ui_name] = entry->table_name;
        }
    }

    connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(fillTable()));
    fillTable();

    if (create_new) on_newToolButton_clicked();
}
示例#3
0
/* builds the table with the bits for each letter. 1 stands for binary 0 and 2 for binary 1 (used to facilitate arithmetic)*/
void fillTable(int codeTable[], Node *tree, int Code){
    if (tree->letter<27)
        codeTable[(int)tree->letter] = Code;
    else{
        fillTable(codeTable, tree->left, Code*10+1);
        fillTable(codeTable, tree->right, Code*10+2);
    }

    return;
}
void FormMsgLogInspector::loadFile(QString fileName)
{
    // open file
    QFile file(fileName);
    if(!file.open(QFile::ReadOnly | QFile::Text))
    {
        QMessageBox::warning(this, tr("Application"), tr("Cannot read file %1:\n%2.")
                                                      .arg(fileName)
                                                      .arg(file.errorString()));
        return;
    }

    // open text stream
    QTextStream in(&file);

    // set wait mouse cursor
    QApplication::setOverrideCursor(Qt::WaitCursor);

    // read lines
    while(!in.atEnd())
    {
        QString line = in.readLine();
        lines.append(line);
    }

    // fill table
    fillTable();

    // set normal mouse cursor
    QApplication::restoreOverrideCursor();
}
ElementsTableWidget::ElementsTableWidget(std::vector<Float> contents,
        ACL::Data::ElementsContentUnits contentsUnits,
        std::vector<Float> weights, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ElementsTableWidget)
{
    ui->setupUi(this);
    ui->table->addColumn("#", 100);
    ui->table->addColumn("Element", 140);
    ui->table->addColumn("Element Name", 360);
    ui->table->addColumn("Atomic Weight", 400);
    ui->table->verticalHeader()->setVisible(false);
    ui->table->setSelectionMode(QAbstractItemView::NoSelection);
    if (contentsUnits == ACL::Data::ElementsContentUnits::MassPercent)
    {
        ui->table->addColumn("Content, Mass %", 400);
    }
    else
    {
        ui->table->addColumn("Content, # of Atoms", 400);
    }
    fillTable();
    for (int x = 0; x < ELEMENTS_COUNT; ++x)
    {
        qobject_cast<SNumberEdit *> (ui->table->cellWidget(x, 3))->setText(ACL::FMath::toStr(weights[x]));
        qobject_cast<SNumberEdit *> (ui->table->cellWidget(x, 4))->setText(ACL::FMath::toStr(contents[x]));
    }
}
示例#6
0
DBDataTable *database::rawQuery(const std::string &sql, const std::vector<std::string> &args)
{
    sqlite3_stmt *stmt = NULL;

    int err = sqlite3_prepare_v2(m_dbHandle, sql.data(), sql.length(), &stmt, NULL);
    if (err != SQLITE_OK) {
        // error?
    }

    for (int i = 0; i < args.size(); i++) {
        sqlite3_bind_text(stmt, i+1, args[i].data(), args[i].length(), SQLITE_TRANSIENT);
    }

    // replace to shared pointer? how to check result?
    DBDataTable* dataTable = new DBDataTable(0);

    int result = fillTable(stmt, dataTable);
    if (result <= 0) {
        //
        delete dataTable;
        return NULL;
    }

    return dataTable;
}
void UserFunctionListWidget::deleteItem()
{
    if (!currentItem() || m_userFunctions->selectedItems().isEmpty())
        return;
    Evaluator::instance()->unsetUserFunction(getUserFunctionName(currentItem()));
    fillTable();
}
void XMLProtocolParser::handlePlayer(tinyxml2::XMLElement *curChild)
{
    const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute();
    std::string name = "";
    std::string inField = "";
    bool found = false;
    while (attr != nullptr)
    {
        const char *valAttr = attr->Value();
        const char *valName = attr->Name();
        std::string strAttr(valAttr);
        std::string strName(valName);

        if (strName.compare("name") == 0)
        {
            found = fillSetup(valAttr);
            name = valAttr;
        }
        else if (strName.compare("inField") == 0)
        {
            inField = valAttr;
        }

        attr = attr->Next();
    }
    if (!found)
        fillTable(name, inField);
}
示例#9
0
文件: huffman.c 项目: rarry/it
void fillTable(int codeTable[], Node *tree, int code)
{
    int letterIndex = tree->letterIndex;
    if(letterIndex < 27)
    {
        codeTable[letterIndex] = code;
    }
    else
    {
        Node *leftNode = tree->left;
        fillTable(codeTable,leftNode,10*code+1);

        Node *rightNode = tree->right;
        fillTable(codeTable,rightNode,10*code+2);
    }
}
SCTPChunkStatisticsDialog::SCTPChunkStatisticsDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf) :
    QDialog(parent),
    ui(new Ui::SCTPChunkStatisticsDialog),
    selected_assoc(assoc),
    cap_file_(cf)
{
    ui->setupUi(this);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
    ui->tableWidget->verticalHeader()->setClickable(true);
    ui->tableWidget->verticalHeader()->setMovable(true);
#else
    ui->tableWidget->verticalHeader()->setSectionsClickable(true);
    ui->tableWidget->verticalHeader()->setSectionsMovable(true);
#endif


    ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);

#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
    ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif

    this->setWindowTitle(QString(tr("SCTP Chunk Statistics: %1 Port1 %2 Port2 %3")).arg(cf_get_display_name(cap_file_)).arg(selected_assoc->port1).arg(selected_assoc->port2));
 //   connect(ui->tableWidget->verticalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(on_sectionMoved(int, int, int)));

    ctx_menu_.addAction(ui->actionHideChunkType);
    ctx_menu_.addAction(ui->actionChunkTypePreferences);
    ctx_menu_.addAction(ui->actionShowAllChunkTypes);
    initializeChunkMap();
    fillTable();
}
示例#11
0
//-----------------------------------------------------------------------------
// Name: displayFunc( )
// Desc: callback function invoked to draw the client area
//-----------------------------------------------------------------------------
void displayFunc( )
{ 
	    // clear the color and depth buffers
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	 // local variables
    float buffer[FRAMES_PER_BUFFER];

    // wait for data
    while( !g_ready ) usleep( 1000 );

    // copy currently playing audio into buffer
    memcpy( buffer, g_buffer, FRAMES_PER_BUFFER * sizeof(float) );
	// Hand off to audio callback thread
    g_ready = false;

	fillTable();
	
	// TODO: implement display here
	drawHarmonies();
	
    // flush gl commands
    glFlush( );

    // swap the buffers
    glutSwapBuffers( );
}
示例#12
0
TablesDialog::TablesDialog(QWidget *parent, PublicGame &iGame)
    : QDialog(parent), m_game(&iGame)
{
    setupUi(this);

    fillTable();
}
int main(int argc, char * argv[]) {

	int * table;
	int tableRange;

	if(argc == 1)
		tableRange = 10;
	else {
		tableRange = atoi(argv[1]);
		if(tableRange < 1 || tableRange > 10)
			usageAndQuit();
	}	

	table = (int *) malloc(sizeof(int) * (tableRange * tableRange));
	if(table == NULL)
		printf("Memory allocation for table failed.");
	
	fillTable(table, tableRange, (tableRange * tableRange));  

	printTable(table, tableRange, (tableRange * tableRange));

	free(table);

	return 0;	

}
示例#14
0
void tryit(Puzzle *puzzle, PuzzleCreater create, int showpuzzle, int showroot) {
	Table fixes;
	
	puzzle->lastmove = 0;
	puzzle->lastmovecount = 0;
	
	fillTable(fixes, UNFIXED);
	fillTableRow(fixes, 0, FIXED);
	fillTableRow(fixes, TABLE_Y_SIZE - 1, FIXED);
	fillTabelColumn(fixes, 0, FIXED);
	fillTabelColumn(fixes, TABLE_X_SIZE - 1, FIXED);
	
	puzzle->show = 0;
	create(puzzle);
	
	if (showpuzzle != 0) {
		printPuzzle(puzzle);
	}
	
	puzzle->count = 0;
	puzzle->show = showroot;
	
	solve(puzzle, fixes);
	
	if (showpuzzle != 0) {
		printBar();
		printPuzzle(puzzle);
		printf("count: %d\n", puzzle->count);
	}
}
void SCTPChunkStatisticsDialog::on_actionChunkTypePreferences_triggered()
{
    gchar* err = NULL;

    pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types");
    if (!pref) {
        g_log(NULL, G_LOG_LEVEL_ERROR, "Can't find preference sctp/statistics_chunk_types");
        return;
    }

    uat_t *uat = prefs_get_uat_value(pref);
    uat_clear(uat);

    if (!uat_load(uat, &err)) {
        /* XXX - report this through the GUI */
        g_log(NULL, G_LOG_LEVEL_WARNING, "Error loading table '%s': %s", uat->name, err);
        g_free(err);
    }

    UatDialog *uatdialog = new UatDialog(this, uat);
    uatdialog->exec();
    // Emitting PacketDissectionChanged directly from a QDialog can cause
    // problems on macOS.
    wsApp->flushAppSignals();

    ui->tableWidget->clear();
    ui->tableWidget->setRowCount(0);
    ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString(tr("Association"))));
    ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString(tr("Endpoint 1"))));
    ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(QString(tr("Endpoint 2"))));
    fillTable();
}
示例#16
0
文件: bin.c 项目: vokracko/BP-FastNet
int main(int argc, char * argv[])
{
	char input_file[100];
	char lookup_file[100];

	lpm_root * root = NULL;

	if(argc != 4)
	{
		puts("./alg -v4/6 default_rule input_file");
		return 1;
	}

	ipv = strcmp("-v6", argv[1]) == 0 ? 6 : 4;

	sprintf(input_file, "./input/IPv%d/%s", ipv, argv[3]);
	sprintf(lookup_file, "./input/IPv%d/lookup", ipv);

	default_rule = atoi(argv[2]);
	root = INIT(default_rule);
	fillTable(root, input_file);
	printf("%lf\n", lookup(root, lookup_file));

	DESTROY(root);
}
示例#17
0
int main(){
    Node *tree;
    int codeTable[27], codeTable2[27];
    int compress;
    char filename[20];
    FILE *input, *output;

    buildHuffmanTree(&tree);

    fillTable(codeTable, tree, 0);

    invertCodes(codeTable,codeTable2);

    /*get input details from user*/
    printf("Type the name of the file to process:\n");
    scanf("%s",filename);
    printf("Type 1 to compress and 2 to decompress:\n");
    scanf("%d",&compress);

    input = fopen(filename, "r");
    output = fopen("output.txt","w");

    if (compress==1)
        compressFile(input,output,codeTable2);
    else
        decompressFile(input,output, tree);

    return 0;
}
示例#18
0
/**
    Returns a map from a state to all equivalent states.
 **/
std::map<int, std::vector<int>>
DFA::getEquivClasses() const {
    bool** table = new bool*[_states];
    
    for (int i = 0; i < _states; ++i) {
        table[i] = new bool[_states];
        for (int j = 0; j < _states; ++j) {
            table[i][j] = false;
        }
    }
    
    fillTable(table);
    
    std::map<int, std::vector<int>> classes;
    for (int i = 0; i < _states; ++i) {
        bool isMin = true;
        for (int j = 0; j < i; ++j) {
            if (table[i][j] == false) {
                classes[j].push_back(i);
                isMin = false;
            }
        }
        if (isMin) {
            classes[i].push_back(i);
        }
        delete[] table[i];
    }
    
    delete[] table;
    
    return classes;
}
editSpecialOptions::editSpecialOptions( QWidget * parent, QString optionName, QStringList * optionStringList, bool * ok) : QDialog(parent)
{
	setupUi(this);
	globalOk = ok;
	*globalOk = true;
	headerLabel->setText(optionName);
        globalOptionStringList = optionStringList;
	fillTable();
}
SCTPAllAssocsDialog::SCTPAllAssocsDialog(QWidget *parent, capture_file *cf) :
    QDialog(parent),
    ui(new Ui::SCTPAllAssocsDialog),
    cap_file_(cf)
{
    ui->setupUi(this);
    sctp_assocs = (sctp_allassocs_info_t *)g_malloc(sizeof(sctp_allassocs_info_t));
    fillTable();
}
void FormMsgLogInspector::applyFilter(bool)
{
    filterIndex = widget.cbFilter->currentIndex();
    if(filterIndex > 0)
    {
        filter = widget.cbValue->currentText();
        fillTable();
    }
}
void
QFieldContainerView::setFieldContainer(FieldContainerPtr pFC)
{
    clearTable();

    fillTable(pFC, _uiAspect);

    _pFC = pFC;
}
void FormMsgLogInspector::resetFilter(bool)
{
    if(filterIndex > 0)
    {
        filterIndex = 0;
        filter = "";
        fillTable();
    }
}
void Window::toggleVisibility() {
    if (isVisible()) {
        resetIsNew();
        hide();
    } else {
        showNormal();
        trayIcon->setIcon(m_icon); // remove the warning icon, if any
    }
    fillTable(); // updates the contents after resetting the isNew flag
}
void DetermineOptimalSumOfFun::calculate(Money *fee_result, Fun *fun_result) {
//  printParties(vec_parties_.at(0));
//  printTable();
  fillTable();
//  printTable();

  Money fee = findOptimal();
  *fee_result = fee;
  *fun_result = vec_fun_.at(fee);
}
void SCTPChunkStatisticsDialog::on_actionShowAllChunkTypes_triggered()
{
    ui->tableWidget->clear();
    ui->tableWidget->setRowCount(0);
    ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString(tr("Association"))));
    ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString(tr("Endpoint 1"))));
    ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(QString(tr("Endpoint 2"))));
    initializeChunkMap();
    fillTable(true);
}
示例#27
0
static struct fblock *fb_huf_ctor(char *name)
{
	int ret = 0;
	struct fblock *fb;
	struct fb_huf_priv *fb_priv;
	struct proc_dir_entry *fb_proc;
	Node *tree;
	fb = alloc_fblock(GFP_ATOMIC);
	if (!fb)
		return NULL;
	fb_priv = kzalloc(sizeof(*fb_priv), GFP_ATOMIC);
	if (!fb_priv)
		goto err;
	seqlock_init(&fb_priv->lock);
	rwlock_init(&fb_priv->klock);
	fb_priv->port[0] = IDP_UNKNOWN;
	fb_priv->port[1] = IDP_UNKNOWN;

	ret = init_fblock(fb, name, fb_priv);
	if (ret)
		goto err2;

	fb->netfb_rx = fb_huf_netrx;
	fb->event_rx = fb_huf_event;
//	fb->linearize = fb_aes_linearize;
//	fb->delinearize = fb_aes_delinearize;
	fb_proc = proc_create_data(fb->name, 0444, fblock_proc_dir,
				   &fb_huf_proc_fops, (void *)(long) fb);
	if (!fb_proc)
		goto err3;

	ret = register_fblock_namespace(fb);
	if (ret)
		goto err4;

	__module_get(THIS_MODULE);

	
	buildHuffmanTree(&tree);
	fillTable(tree, 0);
	invertCodes();


	return fb;
err4:
	remove_proc_entry(fb->name, fblock_proc_dir);
err3:
	cleanup_fblock_ctor(fb);
err2:
	kfree(fb_priv);
err:
	kfree_fblock(fb);
	return NULL;
}
示例#28
0
void getTable() {
    
    cout << "Please, enter table's height:" << endl;
    cin >> N;
    cout << "Please, enter table's width:" << endl;
    cin >> M;
    
    init_table = Field(N, M);
    fillTable(N, M);
    
}
void
QFieldContainerView::setAspect(UInt32 uiAspect)
{
    // TODO: check if this can be done smarter

    _uiAspect = uiAspect;

    clearTable();

    fillTable(getFieldContainer(), _uiAspect);
}
示例#30
0
void DbGpfsInfo::upsertInfo(SQLHSTMT sqlStmt)
{
    removeRows(sqlStmt,tmptableName);     //clear all related temp tables at first
    fillTable(sqlStmt,tmptableName); //fill temp table
    
    queryTable(sqlStmt,tmptableName,&tempInfo);//query temp table
    queryTable(sqlStmt,tableName,&lastInfo); //query regular table

    updateRegularTable(sqlStmt,tableName, tempInfo, lastInfo); //update regular table
    
}