Esempio n. 1
0
void AnovaForm::dependentChanged()
{
	const QList<ColumnInfo> &assigned = _dependentListModel->assigned();
	if (assigned.length() == 0)
		_anovaModel->setDependent(ColumnInfo("", 0));
	else
		_anovaModel->setDependent(assigned.last());
}
Esempio n. 2
0
QueryServersUserInterface::QueryServersUserInterface()
{
   
   lastUsedServerId = 0;
   sortColumn = 0;
   lastSortColumn = 0;
   sortAscending = true;

   columns.push_back(ColumnInfo("SERVER NAME", 3));
   columns.push_back(ColumnInfo("STAT", 250));
   columns.push_back(ColumnInfo("PING", 330));
   columns.push_back(ColumnInfo("PLAYERS", 420));
   columns.push_back(ColumnInfo("ADDRESS", 550));

   selectedId = 0xFFFFFF;

   sort();
   shouldSort = false;
}
Esempio n. 3
0
void UMemoryModel::initCommonColumn()
{
    //地址。
    while(columnInfos_.size() < 2)
    {
        columnInfos_.append(ColumnInfo());
    }
    columnInfos_[0].title = "Addr";
    columnInfos_[0].getDataFunction = UMemoryModel_GetAddress;

    //取4位16进制。
    columnInfos_[1].title = "Hex";
    columnInfos_[1].getDataFunction = UMemoryModel_GetHex;
    columnInfos_[1].dataColorFunction = UMemoryModel_GetHexColor;
}
Esempio n. 4
0
void AnovaForm::termsChanged()
{
	QList<ColumnInfo> terms = _anovaModel->terms();
	terms.prepend(ColumnInfo("~OVERALL", 0));
	//ui->marginalMeans->setVariables(terms);
}
void TimeSeries::describeParamsAndColumns(UDRInvocationInfo &info)
{
  InternalColumns internalCols(info);

  // create PARTITION BY output columns, one passthru column
  // for every column that appears in PARTITION BY
  const PartitionInfo &part = info.in().getQueryPartitioning();
  int numPartCols = part.getNumEntries();

  for (int pc=0; pc<numPartCols; pc++)
    info.addPassThruColumns(0, part.getColumnNum(pc), part.getColumnNum(pc));

  // since we work locally in a partition, set the function type
  // of this TMUDF to REDUCER
  info.setFuncType(UDRInvocationInfo::REDUCER);

  // produce the time column, it has the same type as the
  // ORDER BY column that defines the input time value
  // and its name is specified by parameter 0
  const TypeInfo &timeType =
    info.in().getColumn(internalCols.getTimeSliceInColNum()).getType();

  info.out().addColumn(ColumnInfo(info.par().getString(0).c_str(),
                                  timeType));

  // produce aggregate columns
  for (int a=0; a<internalCols.getNumAggrCols(); a++)
    {
      TimeSeriesAggregate tsa = internalCols.getAggrColumn(a);
      std::string outColName(info.par().getString(2*a + 2));
      TypeInfo inColType(
           info.in().getColumn(tsa.getInputColNum()).getType());

      // append suffix to input column name to form the output column
      // name, make those all capitals to avoid delimited identifiers
      outColName += "_";
      if (tsa.isFirstVal())
        outColName += "F";
      else
        outColName += "L";
      if (tsa.isConstInterpol())
        outColName += "C";
      else
        outColName += "L";
      if (tsa.isIgnoreNulls())
        outColName += "I";

      if (tsa.isConstInterpol())
        {
          // add a column with the same data type as the original
          // column, but make it nullable if it isn't already
          inColType.setNullable(true);
          info.out().addColumn(ColumnInfo(outColName.c_str(), inColType));
        }
      else
        // add a "DOUBLE" output column to allow interpolation
        info.out().addColumn(ColumnInfo(
                                  outColName.c_str(),
                                  TypeInfo(TypeInfo::DOUBLE_PRECISION,
                                           0,
                                           true)));
    }

  // add formal parameters with types that match the actual ones
  for (int p=0; p<info.par().getNumColumns(); p++)
    {
      char parName[20];

      snprintf(parName, sizeof(parName), "PAR_%d", p);
      info.addFormalParameter(ColumnInfo(parName,
                                         info.par().getColumn(p).getType()));
    } 
}
Esempio n. 6
0
void SQLCommandPanel::ExecuteSql()
{
    wxBusyInfo infoDlg(_("Executing sql..."), wxTheApp->GetTopWindow());
    
    clWindowUpdateLocker locker(this);
    std::set<int> textCols;
    std::set<int> blobCols;
    DatabaseLayerPtr m_pDbLayer = m_pDbAdapter->GetDatabaseLayer(m_dbName);
    if (m_pDbLayer->IsOpen()) {
        // test for empty command string
        wxArrayString arrCmdLines = wxStringTokenize( m_scintillaSQL->GetText(), wxT("\n"), wxTOKEN_STRTOK );
        int cmdLines = 0;
        for( size_t i = 0; i < arrCmdLines.GetCount(); i++) {
            if( ! arrCmdLines[i].Trim(false).StartsWith( wxT("--") ) ) cmdLines++;
        }
        
        // save the history
        SaveSqlHistory();
        
        if ( cmdLines > 0 ) {
            try {
                m_colsMetaData.clear();
                if (!m_pDbAdapter->GetUseDb(m_dbName).IsEmpty()) m_pDbLayer->RunQuery(m_pDbAdapter->GetUseDb(m_dbName));
                // run query
                DatabaseResultSet* pResultSet = m_pDbLayer->RunQueryWithResults(m_scintillaSQL->GetText());

                // clear variables
                if(m_gridTable->GetNumberCols()) {
                    m_gridTable->DeleteCols(0, m_gridTable->GetNumberCols());

                }

                if(m_gridTable->GetNumberRows()) {
                    m_gridTable->DeleteRows(0, m_gridTable->GetNumberRows());
                }

                m_gridValues.clear();

                if( !pResultSet ) {
                    wxMessageBox( _("Unknown SQL error."), _("DB Error"), wxOK | wxICON_ERROR );
                    return;
                }

                int rows = 0;
                int cols = pResultSet->GetMetaData()->GetColumnCount();
                m_colsMetaData.resize(cols);
                
                // create table header
                m_gridTable->AppendCols(cols);
                for (int i = 1; i<= pResultSet->GetMetaData()->GetColumnCount(); i++) {
                    m_gridTable->SetColLabelValue(i-1,pResultSet->GetMetaData()->GetColumnName(i));
                    m_colsMetaData.at(i-1) = ColumnInfo(pResultSet->GetMetaData()->GetColumnType(i), pResultSet->GetMetaData()->GetColumnName(i) );
                }

                m_gridTable->BeginBatch();
                // fill table data
                while (pResultSet->Next()) {
                    wxString value;
                    m_gridTable->AppendRows();
                    for (int i = 1; i<= pResultSet->GetMetaData()->GetColumnCount(); i++) {

                        switch (pResultSet->GetMetaData()->GetColumnType(i)) {
                        case ResultSetMetaData::COLUMN_INTEGER:
                            if(m_pDbAdapter->GetAdapterType() == IDbAdapter::atSQLITE) {
                                value = pResultSet->GetResultString(i);

                            } else {
                                value = wxString::Format(wxT("%i"),pResultSet->GetResultInt(i));
                            }
                            break;

                        case ResultSetMetaData::COLUMN_STRING:
                            value =  pResultSet->GetResultString(i);
                            break;

                        case ResultSetMetaData::COLUMN_UNKNOWN:
                            value = pResultSet->GetResultString(i);
                            break;

                        case ResultSetMetaData::COLUMN_BLOB: {
                            if(textCols.find(i) != textCols.end()) {
                                // this column should be displayed as TEXT rather than BLOB
                                value = pResultSet->GetResultString(i);

                            } else if(blobCols.find(i) != blobCols.end()) {
                                // this column should be displayed as BLOB
                                wxMemoryBuffer buffer;
                                pResultSet->GetResultBlob(i, buffer);
                                value = wxString::Format(wxT("BLOB (Size:%u)"), buffer.GetDataLen());

                            } else {
                                // first time
                                wxString strCol = pResultSet->GetResultString(i);
                                if(IsBlobColumn(strCol)) {
                                    blobCols.insert(i);
                                    wxMemoryBuffer buffer;
                                    pResultSet->GetResultBlob(i, buffer);
                                    value = wxString::Format(wxT("BLOB (Size:%u)"), buffer.GetDataLen());

                                } else {
                                    textCols.insert(i);
                                    value = strCol;
                                }
                            }
                            break;
                        }
                        case ResultSetMetaData::COLUMN_BOOL:
                            value = wxString::Format(wxT("%b"),pResultSet->GetResultBool(i));
                            break;

                        case ResultSetMetaData::COLUMN_DATE: {
                            wxDateTime dt = pResultSet->GetResultDate(i);
                            if(dt.IsValid()) {
                                value = dt.Format();
                            } else {
                                value.Clear();
                            }
                        }
                        break;

                        case ResultSetMetaData::COLUMN_DOUBLE:
                            value = wxString::Format(wxT("%f"),pResultSet->GetResultDouble(i));
                            break;

                        case ResultSetMetaData::COLUMN_NULL:
                            value = wxT("NULL");
                            break;

                        default:
                            value = pResultSet->GetResultString(i);
                            break;
                        }

                        m_gridValues[std::make_pair(rows,  i-1)] = value;

                        // truncate the string to a reasonable string
                        if(value.Length() > 100) {
                            value = value.Mid(0, 100);
                            value.Append(wxT("..."));
                        }

                        // Convert all whitespace chars into visible ones
                        value.Replace(wxT("\n"), wxT("\\n"));
                        value.Replace(wxT("\r"), wxT("\\r"));
                        value.Replace(wxT("\t"), wxT("\\t"));
                        m_gridTable->SetCellValue(rows, i-1, value);
                    }
                    rows++;
                }

                m_gridTable->EndBatch();

                m_pDbLayer->CloseResultSet(pResultSet);

                // show result status
                m_labelStatus->SetLabel(wxString::Format(_("Result: %i rows"),rows));
                Layout();

                GetParent()->Layout();

            } catch (DatabaseLayerException& e) {
                // for some reason an exception is thrown even if the error code is 0...
                if(e.GetErrorCode() != 0) {
                    wxString errorMessage = wxString::Format(_("Error (%d): %s"), e.GetErrorCode(), e.GetErrorMessage().c_str());
                    wxMessageDialog dlg(this,errorMessage,_("DB Error"),wxOK | wxCENTER | wxICON_ERROR);
                    dlg.ShowModal();
                }

            } catch( ... ) {
                wxMessageDialog dlg(this,_("Unknown error."),_("DB Error"),wxOK | wxCENTER | wxICON_ERROR);
                dlg.ShowModal();

            }
        }

    } else {
        wxMessageBox(_("Cant connect!"));
    }
}