static void output_statistics_table (const struct two_sample_test *t2s, const struct sign_test_params *param) { int i; struct tab_table *table = tab_create (1 + t2s->n_pairs, 4); tab_title (table, _("Test Statistics")); tab_headers (table, 0, 1, 0, 1); tab_hline (table, TAL_2, 0, tab_nc (table) - 1, 1); tab_vline (table, TAL_2, 1, 0, tab_nr (table) - 1); /* Vertical lines inside the box */ tab_box (table, -1, -1, -1, TAL_1, 0, 0, tab_nc (table) - 1, tab_nr (table) - 1); /* Box around entire table */ tab_box (table, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (table) - 1, tab_nr (table) - 1); tab_text (table, 0, 1, TAT_TITLE | TAB_LEFT, _("Exact Sig. (2-tailed)")); tab_text (table, 0, 2, TAT_TITLE | TAB_LEFT, _("Exact Sig. (1-tailed)")); tab_text (table, 0, 3, TAT_TITLE | TAB_LEFT, _("Point Probability")); for (i = 0 ; i < t2s->n_pairs; ++i) { variable_pair *vp = &t2s->pairs[i]; struct string pair_name; ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); ds_put_cstr (&pair_name, " - "); ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); tab_text (table, 1 + i, 0, TAB_LEFT, ds_cstr (&pair_name)); ds_destroy (&pair_name); tab_double (table, 1 + i, 1, TAB_RIGHT, param[i].one_tailed_sig * 2, NULL, RC_PVALUE); tab_double (table, 1 + i, 2, TAB_RIGHT, param[i].one_tailed_sig, NULL, RC_PVALUE); tab_double (table, 1 + i, 3, TAB_RIGHT, param[i].point_prob, NULL, RC_PVALUE); } tab_submit (table); }
static void reliability_statistics_model_alpha (struct tab_table *tbl, const struct reliability *rel) { const struct variable *wv = rel->wv; const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; const struct cronbach *s = &rel->sc[0]; tab_text (tbl, 0, 0, TAB_CENTER | TAT_TITLE, _("Cronbach's Alpha")); tab_text (tbl, 1, 0, TAB_CENTER | TAT_TITLE, _("N of Items")); tab_double (tbl, 0, 1, TAB_RIGHT, s->alpha, NULL); tab_double (tbl, 1, 1, TAB_RIGHT, s->n_items, wfmt); }
/* Dumps out the values of all the split variables for the case C. */ void output_split_file_values (const struct dataset *ds, const struct ccase *c) { const struct dictionary *dict = dataset_dict (ds); const struct variable *const *split; struct tab_table *t; size_t split_cnt; int i; split_cnt = dict_get_split_cnt (dict); if (split_cnt == 0) return; t = tab_create (3, split_cnt + 1); tab_vline (t, TAL_GAP, 1, 0, split_cnt); tab_vline (t, TAL_GAP, 2, 0, split_cnt); tab_text (t, 0, 0, TAB_NONE, _("Variable")); tab_text (t, 1, 0, TAB_LEFT, _("Value")); tab_text (t, 2, 0, TAB_LEFT, _("Label")); split = dict_get_split_vars (dict); for (i = 0; i < split_cnt; i++) { const struct variable *v = split[i]; char *s; const char *val_lab; const struct fmt_spec *print = var_get_print_format (v); tab_text_format (t, 0, i + 1, TAB_LEFT, "%s", var_get_name (v)); s = data_out (case_data (c, v), dict_get_encoding (dict), print); tab_text_format (t, 1, i + 1, 0, "%.*s", print->w, s); free (s); val_lab = var_lookup_value_label (v, case_data (c, v)); if (val_lab) tab_text (t, 2, i + 1, TAB_LEFT, val_lab); } tab_submit (t); }
void HaiQTextEdit::process_tab(QKeyEvent event) { QTextCursor cursor=textCursor(); // workaround for linux - here Shift+Tab is Qt::Key_Backtab if (event.key() == Qt::Key_Backtab && cursor.selectionStart()==cursor.selectionEnd()) cursor.select(QTextCursor::LineUnderCursor); if (cursor.selectionStart()!=cursor.selectionEnd()) { QTextCursor cursor1=cursor; cursor1.setPosition(cursor.selectionStart()); QTextCursor cursor2=cursor; cursor2.setPosition(cursor.selectionEnd()); bool done=false; while ((cursor1.blockNumber()<=cursor2.blockNumber())&&(!done)) { cursor1.movePosition(QTextCursor::StartOfBlock); if (event.key() == Qt::Key_Backtab || (event.key() == Qt::Key_Tab && event.modifiers()==Qt::ShiftModifier)) { QString blocktxt=cursor1.block().text(); if (blocktxt.count()>0) { int number=num_tab_spaces; if (number==0) number=4; if (blocktxt[0]=='\t') cursor1.deleteChar(); else if (blocktxt.mid(0,number)==" ") { int count; for (count=1; count<=number; count++) cursor1.deleteChar(); } } } else cursor1.insertText(tab_text(cursor1)); if (!cursor1.movePosition(QTextCursor::NextBlock)) done=true; } } else cursor.insertText(tab_text(cursor)); }
/* Create a table which can be populated with the encodings for the covariance matrix COV */ struct tab_table * covariance_dump_enc_header (const struct covariance *cov, int length) { struct tab_table *t = tab_create (cov->dim, length); int n; int i; tab_title (t, "Covariance Encoding"); tab_box (t, TAL_2, TAL_2, 0, 0, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1); tab_hline (t, TAL_2, 0, tab_nc (t) - 1, 1); for (i = 0 ; i < cov->n_vars; ++i) { tab_text (t, i, 0, TAT_TITLE, var_get_name (cov->vars[i])); tab_vline (t, TAL_1, i + 1, 0, tab_nr (t) - 1); } n = 0; while (i < cov->dim) { struct string str; int idx = i - cov->n_vars; const struct interaction *iact = categoricals_get_interaction_by_subscript (cov->categoricals, idx); int df; ds_init_empty (&str); interaction_to_string (iact, &str); df = categoricals_df (cov->categoricals, n); tab_joint_text (t, i, 0, i + df - 1, 0, TAT_TITLE, ds_cstr (&str)); if (i + df < tab_nr (t) - 1) tab_vline (t, TAL_1, i + df, 0, tab_nr (t) - 1); i += df; n++; ds_destroy (&str); } return t; }
static void output_frequency_table (const struct two_sample_test *t2s, const struct sign_test_params *param, const struct dictionary *dict) { int i; struct tab_table *table = tab_create (3, 1 + 4 * t2s->n_pairs); const struct variable *wv = dict_get_weight (dict); const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; tab_set_format (table, RC_WEIGHT, wfmt); tab_title (table, _("Frequencies")); tab_headers (table, 2, 0, 1, 0); /* Vertical lines inside the box */ tab_box (table, 0, 0, -1, TAL_1, 1, 0, tab_nc (table) - 1, tab_nr (table) - 1 ); /* Box around entire table */ tab_box (table, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (table) - 1, tab_nr (table) - 1 ); tab_text (table, 2, 0, TAB_CENTER, _("N")); for (i = 0 ; i < t2s->n_pairs; ++i) { variable_pair *vp = &t2s->pairs[i]; struct string pair_name; ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); ds_put_cstr (&pair_name, " - "); ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); tab_text (table, 0, 1 + i * 4, TAB_LEFT, ds_cstr (&pair_name)); ds_destroy (&pair_name); tab_hline (table, TAL_1, 0, tab_nc (table) - 1, 1 + i * 4); tab_text (table, 1, 1 + i * 4, TAB_LEFT, _("Negative Differences")); tab_text (table, 1, 2 + i * 4, TAB_LEFT, _("Positive Differences")); tab_text (table, 1, 3 + i * 4, TAB_LEFT, _("Ties")); tab_text (table, 1, 4 + i * 4, TAB_LEFT, _("Total")); tab_double (table, 2, 1 + i * 4, TAB_RIGHT, param[i].neg, NULL, RC_WEIGHT); tab_double (table, 2, 2 + i * 4, TAB_RIGHT, param[i].pos, NULL, RC_WEIGHT); tab_double (table, 2, 3 + i * 4, TAB_RIGHT, param[i].ties, NULL, RC_WEIGHT); tab_double (table, 2, 4 + i * 4, TAB_RIGHT, param[i].ties + param[i].neg + param[i].pos, NULL, RC_WEIGHT); } tab_submit (table); }
static void reliability_statistics_model_split (struct tab_table *tbl, const struct reliability *rel) { const struct variable *wv = rel->wv; const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; tab_text (tbl, 0, 0, TAB_LEFT, _("Cronbach's Alpha")); tab_text (tbl, 1, 0, TAB_LEFT, _("Part 1")); tab_text (tbl, 2, 0, TAB_LEFT, _("Value")); tab_text (tbl, 2, 1, TAB_LEFT, _("N of Items")); tab_text (tbl, 1, 2, TAB_LEFT, _("Part 2")); tab_text (tbl, 2, 2, TAB_LEFT, _("Value")); tab_text (tbl, 2, 3, TAB_LEFT, _("N of Items")); tab_text (tbl, 1, 4, TAB_LEFT, _("Total N of Items")); tab_text (tbl, 0, 5, TAB_LEFT, _("Correlation Between Forms")); tab_text (tbl, 0, 6, TAB_LEFT, _("Spearman-Brown Coefficient")); tab_text (tbl, 1, 6, TAB_LEFT, _("Equal Length")); tab_text (tbl, 1, 7, TAB_LEFT, _("Unequal Length")); tab_text (tbl, 0, 8, TAB_LEFT, _("Guttman Split-Half Coefficient")); tab_double (tbl, 3, 0, TAB_RIGHT, rel->sc[1].alpha, NULL); tab_double (tbl, 3, 2, TAB_RIGHT, rel->sc[2].alpha, NULL); tab_double (tbl, 3, 1, TAB_RIGHT, rel->sc[1].n_items, wfmt); tab_double (tbl, 3, 3, TAB_RIGHT, rel->sc[2].n_items, wfmt); tab_double (tbl, 3, 4, TAB_RIGHT, rel->sc[1].n_items + rel->sc[2].n_items, wfmt); { /* R is the correlation between the two parts */ double r = rel->sc[0].variance_of_sums - rel->sc[1].variance_of_sums - rel->sc[2].variance_of_sums ; /* Guttman Split Half Coefficient */ double g = 2 * r / rel->sc[0].variance_of_sums; /* Unequal Length Spearman Brown Coefficient, and intermediate value used in the computation thereof */ double uly, tmp; r /= sqrt (rel->sc[1].variance_of_sums); r /= sqrt (rel->sc[2].variance_of_sums); r /= 2.0; tab_double (tbl, 3, 5, TAB_RIGHT, r, NULL); /* Equal length Spearman-Brown Coefficient */ tab_double (tbl, 3, 6, TAB_RIGHT, 2 * r / (1.0 + r), NULL); tab_double (tbl, 3, 8, TAB_RIGHT, g, NULL); tmp = (1.0 - r*r) * rel->sc[1].n_items * rel->sc[2].n_items / pow2 (rel->sc[0].n_items); uly = sqrt( pow4 (r) + 4 * pow2 (r) * tmp); uly -= pow2 (r); uly /= 2 * tmp; tab_double (tbl, 3, 7, TAB_RIGHT, uly, NULL); } }
static void reliability_summary_total (const struct reliability *rel) { int i; const int n_cols = 5; const int heading_columns = 1; const int heading_rows = 1; const int n_rows = rel->sc[0].n_items + heading_rows ; struct tab_table *tbl = tab_create (n_cols, n_rows); tab_headers (tbl, heading_columns, 0, heading_rows, 0); tab_title (tbl, _("Item-Total Statistics")); /* Vertical lines for the data only */ tab_box (tbl, -1, -1, -1, TAL_1, heading_columns, 0, n_cols - 1, n_rows - 1); /* Box around table */ tab_box (tbl, TAL_2, TAL_2, -1, -1, 0, 0, n_cols - 1, n_rows - 1); tab_hline (tbl, TAL_2, 0, n_cols - 1, heading_rows); tab_vline (tbl, TAL_2, heading_columns, 0, n_rows - 1); tab_text (tbl, 1, 0, TAB_CENTER | TAT_TITLE, _("Scale Mean if Item Deleted")); tab_text (tbl, 2, 0, TAB_CENTER | TAT_TITLE, _("Scale Variance if Item Deleted")); tab_text (tbl, 3, 0, TAB_CENTER | TAT_TITLE, _("Corrected Item-Total Correlation")); tab_text (tbl, 4, 0, TAB_CENTER | TAT_TITLE, _("Cronbach's Alpha if Item Deleted")); for (i = 0 ; i < rel->sc[0].n_items; ++i) { double cov, item_to_total_r; double mean, weight, var; const struct cronbach *s = &rel->sc[rel->total_start + i]; tab_text (tbl, 0, heading_rows + i, TAB_LEFT| TAT_TITLE, var_to_string (rel->sc[0].items[i])); moments1_calculate (s->total, &weight, &mean, &var, 0, 0); tab_double (tbl, 1, heading_rows + i, TAB_RIGHT, mean, NULL); tab_double (tbl, 2, heading_rows + i, TAB_RIGHT, s->variance_of_sums, NULL); tab_double (tbl, 4, heading_rows + i, TAB_RIGHT, s->alpha, NULL); moments1_calculate (rel->sc[0].m[i], &weight, &mean, &var, 0,0); cov = rel->sc[0].variance_of_sums + var - s->variance_of_sums; cov /= 2.0; item_to_total_r = (cov - var) / (sqrt(var) * sqrt (s->variance_of_sums)); tab_double (tbl, 3, heading_rows + i, TAB_RIGHT, item_to_total_r, NULL); } tab_submit (tbl); }
static void case_processing_summary (casenumber n_valid, casenumber n_missing, const struct dictionary *dict) { const struct variable *wv = dict_get_weight (dict); const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; casenumber total; int n_cols = 4; int n_rows = 4; int heading_columns = 2; int heading_rows = 1; struct tab_table *tbl; tbl = tab_create (n_cols, n_rows); tab_headers (tbl, heading_columns, 0, heading_rows, 0); tab_title (tbl, _("Case Processing Summary")); /* Vertical lines for the data only */ tab_box (tbl, -1, -1, -1, TAL_1, heading_columns, 0, n_cols - 1, n_rows - 1); /* Box around table */ tab_box (tbl, TAL_2, TAL_2, -1, -1, 0, 0, n_cols - 1, n_rows - 1); tab_hline (tbl, TAL_2, 0, n_cols - 1, heading_rows); tab_vline (tbl, TAL_2, heading_columns, 0, n_rows - 1); tab_text (tbl, 0, heading_rows, TAB_LEFT | TAT_TITLE, _("Cases")); tab_text (tbl, 1, heading_rows, TAB_LEFT | TAT_TITLE, _("Valid")); tab_text (tbl, 1, heading_rows + 1, TAB_LEFT | TAT_TITLE, _("Excluded")); tab_text (tbl, 1, heading_rows + 2, TAB_LEFT | TAT_TITLE, _("Total")); tab_text (tbl, heading_columns, 0, TAB_CENTER | TAT_TITLE, _("N")); tab_text (tbl, heading_columns + 1, 0, TAB_CENTER | TAT_TITLE, _("%")); total = n_missing + n_valid; tab_double (tbl, 2, heading_rows, TAB_RIGHT, n_valid, wfmt); tab_double (tbl, 2, heading_rows + 1, TAB_RIGHT, n_missing, wfmt); tab_double (tbl, 2, heading_rows + 2, TAB_RIGHT, total, wfmt); tab_double (tbl, 3, heading_rows, TAB_RIGHT, 100 * n_valid / (double) total, NULL); tab_double (tbl, 3, heading_rows + 1, TAB_RIGHT, 100 * n_missing / (double) total, NULL); tab_double (tbl, 3, heading_rows + 2, TAB_RIGHT, 100 * total / (double) total, NULL); tab_submit (tbl); }
void HaiQTextEdit::process_key(QKeyEvent event) { if ((event.text()!="")&&(textCursor().selectedText().count()<=1)) { ///this is to avoid spreading of marker highlighting bool holdmodified=document()->isModified(); QTextCharFormat format=currentCharFormat(); format.clearBackground(); setCurrentCharFormat(format); document()->setModified(holdmodified); } if ((event.key()==Qt::Key_Tab)||(event.key()==Qt::Key_Backtab)||(event.text()=="\t")) { process_tab(event); } else if (event.key()==Qt::Key_Insert && QApplication::keyboardModifiers() == Qt::NoModifier) { setOverwriteMode(!overwriteMode()); } else if ((event.key()==Qt::Key_Home)&&((event.modifiers()==Qt::NoModifier)||(event.modifiers()==Qt::ShiftModifier))) { bool shift_key=(event.modifiers()==Qt::ShiftModifier); QTextCursor cursor=textCursor(); int col=cursor.columnNumber(); QString txt=cursor.block().text(); if (shift_key) cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::KeepAnchor); else cursor.movePosition(QTextCursor::StartOfLine); int ct=0; while ((ct<txt.count())&&((txt[ct]==' ')||(txt[ct]=='\t'))) { if (shift_key) cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor); else cursor.movePosition(QTextCursor::Right); ct++; } int col2=cursor.columnNumber(); if (col2==col) { //moved nowhere if (shift_key) cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::KeepAnchor); else cursor.movePosition(QTextCursor::StartOfLine); } setTextCursor(cursor); } else if (event.key()==Qt::Key_Backspace) { process_backspace(); return; } else if ((event.key()==Qt::Key_Space)&&(event.modifiers()==Qt::ControlModifier)) { return; // don't process a space, because Ctrl+Space is for completion } else { QTextEdit::keyPressEvent(&event); } if ((event.key()==Qt::Key_Enter)||(event.key()==Qt::Key_Return)) { indent_to_previous_line(); QTextCursor cursor=textCursor(); do_marker_highlighting(cursor); QString line=cursor.block().previous().text(); QStringList symbols=split_into_symbols(line); if ((symbols.count()>0)&& ( (symbols[symbols.count()-1]=="{") || (((symbols[symbols.count()-1]!=";"))&&((symbols[0]=="if") || (symbols[0]=="else") || (symbols[0]=="while") || (symbols[0]=="do") || (symbols[0]=="for"))) ) ) { QString line2=cursor.block().text(); QStringList symbols2=split_into_symbols(line2); if ((symbols2.count()==0)||(symbols2[0]!="}")) //only indent if there is not a "{" starting the line cursor.insertText(tab_text(cursor)); } //kind of a hack if (!blocks_highlighted_for_braces.isEmpty()) { blocks_highlighted_for_braces << textCursor().block(); } } if (event.text()=="}") { QTextCursor cursor=textCursor(); QString line=cursor.block().text(); QStringList symbols=split_into_symbols(line); if (symbols.count()==1) { //unindent to last brace QTextBlock block=cursor.block(); bool found=false; int braces_level=1; while ((!found)&&(block.isValid())) { block=block.previous(); QString line2=block.text(); QStringList symbols=split_into_symbols(line2); for (int j=symbols.count()-1; j>=0; j--) { if (symbols[j]=="{") braces_level--; if (symbols[j]=="}") braces_level++; if (braces_level==0) found=true; } } if (found) { QString line2=block.text(); for (int j=0; j<line.count(); j++) cursor.deletePreviousChar(); int j=0; while ((j<line2.count())&&((line2[j]==' ')||(line2[j]=='\t'))) { cursor.insertText(QString(line2[j])); j++; } cursor.insertText("}"); } } } if ((event.text()==")")||(event.text()=="}")/*||(event.text()==">")*/) { highlight_braces(event.text(),true); } if ((event.text()=="(")||(event.text()=="{")/*||(event.text()=="<")*/) { highlight_braces(event.text(),false); } }