bool KexiDataTableView::setData(KexiDB::Cursor *cursor)
{
//js if (!m_first)
//js  clearColumns();
    if (!cursor) {
        clearColumns();
        m_cursor = 0;
        return true;
    }
    if (cursor != m_cursor) {
        clearColumns();
    }
    m_cursor = cursor;

    if (!m_cursor->query()) {
        kDebug() << "WARNING: cursor should have query schema defined!\n--aborting setData().";
        m_cursor->debug();
        clearColumns();
        return false;
    }

    if (m_cursor->fieldCount() < 1) {
        clearColumns();
        return true;
    }

    if (!m_cursor->isOpened() && !m_cursor->open()) {
        kDebug() << "WARNING: cannot open cursor\n--aborting setData(). \n" <<
        m_cursor->serverErrorMsg();
        m_cursor->debug();
        clearColumns();
        return false;
    }

    KexiTableViewData *tv_data = new KexiTableViewData(m_cursor);
    KexiDataTable* dataTable = qobject_cast<KexiDataTable*>(parentWidget());
    if (dataTable) {
        dataTable->loadTableViewSettings(tv_data);
    }

    QString windowTitle(m_cursor->query()->caption());
    if (windowTitle.isEmpty())
        windowTitle = m_cursor->query()->name();

    setWindowTitle(windowTitle);

    //PRIMITIVE!! data setting:
    tv_data->preloadAllRows();

    KexiTableView::setData(tv_data);
    return true;
}
Esempio n. 2
0
bool KexiDataTableView::setData(KexiDB::Cursor *cursor)
{
//js	if (!m_first)
//js		clearColumns();
	if (!cursor) {
		clearColumns();
		m_cursor = 0;
		return true;
	}
	if (cursor!=m_cursor) {
		clearColumns();
	}
	m_cursor = cursor;

	if (!m_cursor->query()) {
		kdDebug() << "KexiDataTableView::setData(): WARNING: cursor should have query schema defined!\n--aborting setData()." << endl;
		m_cursor->debug();
		clearColumns();
		return false;
	}

	if (m_cursor->fieldCount()<1) {
		clearColumns();
		return true;
	}

	if (!m_cursor->isOpened() && !m_cursor->open()) {
		kdDebug() << "KexiDataTableView::setData(): WARNING: cannot open cursor\n--aborting setData(). \n" <<
			m_cursor->serverErrorMsg() << endl;
		m_cursor->debug();
		clearColumns();
		return false;
	}

	KexiTableViewData *tv_data = new KexiTableViewData(m_cursor);

	QString caption = m_cursor->query()->caption();
	if (caption.isEmpty())
		caption = m_cursor->query()->name();

	setCaption( caption );

	//PRIMITIVE!! data setting:
	tv_data->preloadAllRows();

	KexiTableView::setData(tv_data);
	return true;
}
Esempio n. 3
0
void TraceWindow::Init() {
  ListWindowBase::Init(IDD_CALLSTACK, (DLGPROC)ListWindowBase::DlgProc, kViewX, kViewY, kViewW, kViewH);

  SetScrollMax(0);

  clearColumns();
  AddCol("addr", 52, true, NULL);
  AddCol("from", 52, true, NULL);
  AddCol("label", 120, false, NULL);

  if (m_small_font == NULL) {
    LOGFONT  lf;
    memset(&lf, 0, sizeof(LOGFONT));
    lf.lfHeight      = kFontSize - 2;
    lf.lfWidth      = 0;
    lf.lfEscapement    = 0;
    lf.lfOrientation  = 0;
    lf.lfWeight      = FW_NORMAL;
    lf.lfItalic      = FALSE;
    lf.lfUnderline    = FALSE;
    lf.lfStrikeOut    = FALSE;
    lf.lfCharSet    = SHIFTJIS_CHARSET;
    lf.lfOutPrecision  = OUT_DEFAULT_PRECIS;
    lf.lfClipPrecision  = CLIP_DEFAULT_PRECIS;
    lf.lfQuality    = DEFAULT_QUALITY;
    lf.lfPitchAndFamily  = DEFAULT_PITCH | FF_DONTCARE;
    strcpy(lf.lfFaceName, "MS ゴシック");
    m_small_font = CreateFontIndirect(&lf);
  }
}
Esempio n. 4
0
//-------------------------------------------------------------------------------------------------
// event handler
void TraceWindow::OnCommand(int p_ctrlID, int p_notify) {
  switch (p_ctrlID) {
  case IDC_CMB_CATEGORY:
    switch (p_notify) {
    case CBN_SELCHANGE:
      HWND cmb = GetDlgItem(m_dlg->getHwnd(), IDC_CMB_CATEGORY);
      m_category = SendMessage(cmb, CB_GETCURSEL, 0L, 0L);
      
      clearColumns();
      switch (m_category) {
      case TraceWindow::kCat_CallStack:
        AddCol("addr", 52, true, NULL);
        AddCol("from", 52, true, NULL);
        AddCol("label", 120, false, NULL);
        break;
      case TraceWindow::kCat_JumpLog:
        AddCol("addr", 52, true, NULL);
        AddCol("count", 170, true, NULL);
        break;
      }
      SetScrollMax(GetAllLine());

      m_head = 0;
      SetScrollPos(m_dlg->getHwnd(), SB_VERT, m_head, true);
      
      Draw();
      break;
    }
    break;
  }
}
Esempio n. 5
0
RunsTableModel::RunsTableModel(QObject *parent)
	: Super(parent)
{
	clearColumns(col_COUNT);
	setColumn(col_runs_isRunning, ColumnDefinition("runs.isRunning", tr("Runnig")));
	setColumn(col_runs_id, ColumnDefinition("runs.id", tr("id")).setReadOnly(true));
	setColumn(col_relays_name, ColumnDefinition("relayName", tr("Relay")));
	setColumn(col_runs_leg, ColumnDefinition("runs.leg", tr("Leg")));
	setColumn(col_classes_name, ColumnDefinition("classes.name", tr("Class")));
	setColumn(col_startNumber, ColumnDefinition("startNumber", tr("SN", "start number")).setToolTip(tr("Start number")));
	setColumn(col_competitors_siId, ColumnDefinition("competitors.siId", tr("SI")).setToolTip(tr("Registered SI")).setReadOnly(true));
	setColumn(col_competitorName, ColumnDefinition("competitorName", tr("Name")));
	setColumn(col_registration, ColumnDefinition("registration", tr("Reg")));
	setColumn(col_runs_license, ColumnDefinition("licence", tr("Lic")).setToolTip(tr("License")));
	setColumn(col_runs_ranking, ColumnDefinition("ranking", tr("Rank")).setToolTip(tr("Ranking")));
	setColumn(col_runs_siId, ColumnDefinition("runs.siId", tr("SI")).setToolTip(tr("Actual SI")).setCastType(qMetaTypeId<quickevent::core::si::SiId>()));
	setColumn(col_runs_checkTimeMs, ColumnDefinition("runs.checkTimeMs", tr("Check")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()));
	setColumn(col_runs_startTimeMs, ColumnDefinition("runs.startTimeMs", tr("Start")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()));
	setColumn(col_runs_timeMs, ColumnDefinition("runs.timeMs", tr("Time")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()));
	setColumn(col_runs_finishTimeMs, ColumnDefinition("runs.finishTimeMs", tr("Finish")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()));
	setColumn(col_runs_notCompeting, ColumnDefinition("runs.notCompeting", tr("NC")).setToolTip(tr("Not competing")));
	setColumn(col_runs_cardRentRequested, ColumnDefinition("runs.cardLent", tr("RR")).setToolTip(tr("Card rent requested")));
	setColumn(col_cardInLentTable, ColumnDefinition("cardInLentTable", tr("RT", "cardInLentTable")).setToolTip(tr("Card in rent table")));
	setColumn(col_runs_cardReturned, ColumnDefinition("runs.cardReturned", tr("R")).setToolTip(tr("Card returned")));
	setColumn(col_disqReason, ColumnDefinition("disqReason", tr("Error")).setToolTip(tr("Disqualification reason")).setReadOnly(true));
	setColumn(col_runs_disqualified, ColumnDefinition("runs.disqualified", tr("DISQ")).setToolTip(tr("Disqualified")));
	setColumn(col_competitors_note, ColumnDefinition("competitors.note", tr("Note")));

	connect(this, &RunsTableModel::dataChanged, this, &RunsTableModel::onDataChanged, Qt::QueuedConnection);
}
Esempio n. 6
0
LegsModel::LegsModel(QObject *parent)
	: Super(parent)
{
	clearColumns(col_COUNT);
	setColumn(col_runs_leg, ColumnDefinition("runs.leg", tr("Leg", "relays.leg")).setToolTip(tr("Leg")));
	setColumn(col_competitorName, ColumnDefinition("competitorName", tr("Name")).setReadOnly(true));
	setColumn(col_runs_registration, ColumnDefinition("competitors.registration", tr("Reg")));
	setColumn(col_runs_siId, ColumnDefinition("runs.siid", tr("SI")).setReadOnly(false).setCastType(qMetaTypeId<quickevent::core::si::SiId>()));
	setColumn(col_runs_startTimeMs, ColumnDefinition("runs.startTimeMs", tr("Start")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()));
	setColumn(col_runs_timeMs, ColumnDefinition("runs.timeMs", tr("Time")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()).setReadOnly(true));
	setColumn(col_runs_notCompeting, ColumnDefinition("runs.notCompeting", tr("NC", "runs.notCompeting")).setToolTip(tr("Not competing")));
	setColumn(col_runs_disqualified, ColumnDefinition("runs.disqualified", tr("D", "runs.disqualified")).setToolTip(tr("Disqualified")));
	setColumn(col_runs_misPunch, ColumnDefinition("runs.misPunch", tr("E", "runs.misPunch")).setToolTip(tr("Card mispunch")));
}
Esempio n. 7
0
Model::Model(QObject *parent)
	: Super(parent)
{
	clearColumns(col_COUNT);
	setColumn(col_cards_id, ColumnDefinition("cards.id", "ID").setReadOnly(true));
	setColumn(col_cards_siId, ColumnDefinition("cards.siId", tr("SI")).setReadOnly(true).setCastType(qMetaTypeId<quickevent::si::SiId>()));
	setColumn(col_classes_name, ColumnDefinition("classes.name", tr("Class")));
	setColumn(col_competitorName, ColumnDefinition("competitorName", tr("Name")));
	setColumn(col_competitors_registration, ColumnDefinition("competitors.registration", tr("Reg")));
	setColumn(col_runs_startTimeMs, ColumnDefinition("runs.startTimeMs", tr("Start")).setCastType(qMetaTypeId<quickevent::og::TimeMs>()).setReadOnly(true));
	setColumn(col_runs_timeMs, ColumnDefinition("runs.timeMs", tr("Time")).setCastType(qMetaTypeId<quickevent::og::TimeMs>()).setReadOnly(true));
	setColumn(col_runs_finishTimeMs, ColumnDefinition("runs.finishTimeMs", tr("Finish")).setCastType(qMetaTypeId<quickevent::og::TimeMs>()).setReadOnly(true));
	setColumn(col_runs_misPunch, ColumnDefinition("runs.misPunch", tr("Error")).setToolTip(tr("Card mispunch")).setReadOnly(true));
	setColumn(col_runs_disqualified, ColumnDefinition("runs.disqualified", tr("DISQ")).setToolTip(tr("Disqualified")));
	setColumn(col_runs_cardLent, ColumnDefinition("runs.cardLent", tr("L")).setToolTip(tr("Card lent")).setReadOnly(true));
	setColumn(col_runs_cardReturned, ColumnDefinition("runs.cardReturned", tr("R")).setToolTip(tr("Card returned")));
	setColumn(col_cards_checkTime, ColumnDefinition("cards.checkTime", tr("CTIME")).setToolTip(tr("Card check time")).setReadOnly(true));
	setColumn(col_cards_startTime, ColumnDefinition("cards.startTime", tr("STIME")).setToolTip(tr("Card start time")).setReadOnly(true));
	setColumn(col_cards_finishTime, ColumnDefinition("cards.finishTime", tr("FTIME")).setToolTip(tr("Card finish time")).setReadOnly(true));
}
/*!
  \internal
  Sets the new constraints in the simplex solver and returns whether the problem
  is feasible.

  This method sets the new constraints, normalizes them, creates the simplex matrix
  and runs the first simplex phase.
*/
bool QSimplex::setConstraints(const QList<QSimplexConstraint *> newConstraints)
{
    ////////////////////////////
    // Reset to initial state //
    ////////////////////////////
    clearDataStructures();

    if (newConstraints.isEmpty())
        return true;    // we are ok with no constraints

    // Make deep copy of constraints. We need this copy because we may change
    // them in the simplification method.
    for (int i = 0; i < newConstraints.size(); ++i) {
        QSimplexConstraint *c = new QSimplexConstraint;
        c->constant = newConstraints[i]->constant;
        c->ratio = newConstraints[i]->ratio;
        c->variables = newConstraints[i]->variables;
        constraints << c;
    }

    // Remove constraints of type Var == K and replace them for their value.
    if (!simplifyConstraints(&constraints)) {
        qWarning() << "QSimplex: No feasible solution!";
        clearDataStructures();
        return false;
    }

    ///////////////////////////////////////
    // Prepare variables and constraints //
    ///////////////////////////////////////

    // Set Variables direct mapping.
    // "variables" is a list that provides a stable, indexed list of all variables
    // used in this problem.
    QSet<QSimplexVariable *> variablesSet;
    for (int i = 0; i < constraints.size(); ++i)
        variablesSet += \
            QSet<QSimplexVariable *>::fromList(constraints[i]->variables.keys());
    variables = variablesSet.toList();

    // Set Variables reverse mapping
    // We also need to be able to find the index for a given variable, to do that
    // we store in each variable its index.
    for (int i = 0; i < variables.size(); ++i) {
        // The variable "0" goes at the column "1", etc...
        variables[i]->index = i + 1;
    }

    // Normalize Constraints
    // In this step, we prepare the constraints in two ways:
    // Firstly, we modify all constraints of type "LessOrEqual" or "MoreOrEqual"
    // by the adding slack or surplus variables and making them "Equal" constraints.
    // Secondly, we need every single constraint to have a direct, easy feasible
    // solution. Constraints that have slack variables are already easy to solve,
    // to all the others we add artificial variables.
    //
    // At the end we modify the constraints as follows:
    //  - LessOrEqual: SLACK variable is added.
    //  - Equal: ARTIFICIAL variable is added.
    //  - More or Equal: ARTIFICIAL and SURPLUS variables are added.
    int variableIndex = variables.size();
    QList <QSimplexVariable *> artificialList;

    for (int i = 0; i < constraints.size(); ++i) {
        QSimplexVariable *slack;
        QSimplexVariable *surplus;
        QSimplexVariable *artificial;

        Q_ASSERT(constraints[i]->helper.first == 0);
        Q_ASSERT(constraints[i]->artificial == 0);

        switch(constraints[i]->ratio) {
        case QSimplexConstraint::LessOrEqual:
            slack = new QSimplexVariable;
            slack->index = ++variableIndex;
            constraints[i]->helper.first = slack;
            constraints[i]->helper.second = 1.0;
            break;
        case QSimplexConstraint::MoreOrEqual:
            surplus = new QSimplexVariable;
            surplus->index = ++variableIndex;
            constraints[i]->helper.first = surplus;
            constraints[i]->helper.second = -1.0;
            // fall through
        case QSimplexConstraint::Equal:
            artificial = new QSimplexVariable;
            constraints[i]->artificial = artificial;
            artificialList += constraints[i]->artificial;
            break;
        }
    }

    // All original, slack and surplus have already had its index set
    // at this point. We now set the index of the artificial variables
    // as to ensure they are at the end of the variable list and therefore
    // can be easily removed at the end of this method.
    firstArtificial = variableIndex + 1;
    for (int i = 0; i < artificialList.size(); ++i)
        artificialList[i]->index = ++variableIndex;
    artificialList.clear();

    /////////////////////////////
    // Fill the Simplex matrix //
    /////////////////////////////

    // One for each variable plus the Basic and BFS columns (first and last)
    columns = variableIndex + 2;
    // One for each constraint plus the objective function
    rows = constraints.size() + 1;

    matrix = (qreal *)malloc(sizeof(qreal) * columns * rows);
    if (!matrix) {
        qWarning() << "QSimplex: Unable to allocate memory!";
        return false;
    }
    for (int i = columns * rows - 1; i >= 0; --i)
        matrix[i] = 0.0;

    // Fill Matrix
    for (int i = 1; i <= constraints.size(); ++i) {
        QSimplexConstraint *c = constraints[i - 1];

        if (c->artificial) {
            // Will use artificial basic variable
            setValueAt(i, 0, c->artificial->index);
            setValueAt(i, c->artificial->index, 1.0);

            if (c->helper.second != 0.0) {
                // Surplus variable
                setValueAt(i, c->helper.first->index, c->helper.second);
            }
        } else {
            // Slack is used as the basic variable
            Q_ASSERT(c->helper.second == 1.0);
            setValueAt(i, 0, c->helper.first->index);
            setValueAt(i, c->helper.first->index, 1.0);
        }

        QHash<QSimplexVariable *, qreal>::const_iterator iter;
        for (iter = c->variables.constBegin();
             iter != c->variables.constEnd();
             ++iter) {
            setValueAt(i, iter.key()->index, iter.value());
        }

        setValueAt(i, columns - 1, c->constant);
    }

    // Set objective for the first-phase Simplex.
    // Z = -1 * sum_of_artificial_vars
    for (int j = firstArtificial; j < columns - 1; ++j)
        setValueAt(0, j, 1.0);

    // Maximize our objective (artificial vars go to zero)
    solveMaxHelper();

    // If there is a solution where the sum of all artificial
    // variables is zero, then all of them can be removed and yet
    // we will have a feasible (but not optimal) solution for the
    // original problem.
    // Otherwise, we clean up our structures and report there is
    // no feasible solution.
    if ((valueAt(0, columns - 1) != 0.0) && (qAbs(valueAt(0, columns - 1)) > 0.00001)) {
        qWarning() << "QSimplex: No feasible solution!";
        clearDataStructures();
        return false;
    }

    // Remove artificial variables. We already have a feasible
    // solution for the first problem, thus we don't need them
    // anymore.
    clearColumns(firstArtificial, columns - 2);

    return true;
}
void SearchResults::rebuild()
{
  EnterCriticalSection(&lock);

  static char colNames[colCount][32] = {
    "Name", "Date", "Size", "Game name", "Lineup", "Length", "Mode"
  };
  int colPos[colCount];
  getColPos(colPos);
  int colOrder[colCount];
  int numOrder = 0;
  for (int i = 0; i < colCount; i++)
    if (colPos[cfg.colOrder[i]] >= 0)
      colOrder[numOrder++] = colPos[cfg.colOrder[i]];

  Dictionary<uint32> selected;
  for (int sel = ListView_GetNextItem(hWnd, -1, LVNI_SELECTED); sel >= 0;
      sel = ListView_GetNextItem(hWnd, sel, LVNI_SELECTED))
    selected.set(items[sel].path, 1);
  int scrollPosX = GetScrollPos(hWnd, SB_HORZ);
  int scrollPosY = GetScrollPos(hWnd, SB_VERT);
  if (items.length() > 0)
  {
    RECT rc;
    ListView_GetItemRect(hWnd, 0, &rc, LVIR_BOUNDS);
    scrollPosY *= rc.bottom - rc.top;
  }

  setRedraw(false);
  clear();
  clearColumns();
  for (int i = 0; i < colCount; i++)
    if (colPos[i] >= 0)
      insertColumn(colPos[i], colNames[i]);
  if (colPos[colName] >= 0)
    setColumnUTF8(colPos[colName], true);
  ListView_SetColumnOrderArray(hWnd, numOrder, colOrder);

  int colSort = (cfg.colSort[0] & 0x80000000 ? ~cfg.colSort[0] : cfg.colSort[0]);
  if (colSort >= 0 && colSort < colCount && colPos[colSort] >= 0 && items.length() > 0)
  {
    HBITMAP image = NULL;
    if (cfg.colSort[0] & 0x80000000)
      image = getApp()->getImageLibrary()->getBitmap("SortUp");
    else
      image = getApp()->getImageLibrary()->getBitmap("SortDown");
    if (image)
    {
      HWND hHeader = ListView_GetHeader(hWnd);
      HDITEM hdi;
      memset(&hdi, 0, sizeof hdi);
      hdi.mask = HDI_FORMAT;
      Header_GetItem(hHeader, colSort, &hdi);
      hdi.mask |= HDI_BITMAP;
      hdi.fmt |= HDF_BITMAP | HDF_BITMAP_ON_RIGHT;
      hdi.hbm = image;
      Header_SetItem(hHeader, colSort, &hdi);
    }
  }

  items.sort(compItems);
  for (int i = 0; i < items.length(); i++)
    addItem(i, false);

  for (int i = 0; i < items.length(); i++)
    if (selected.has(items[i].path))
      ListView_SetItemState(hWnd, i, LVIS_SELECTED, LVIS_SELECTED);
  for (int i = 0; i < colCount; i++)
    if (colPos[i] >= 0)
      setColumnWidth(colPos[i], cfg.colWidth[i]);
  setRedraw(true);
  ListView_Scroll(hWnd, scrollPosX, scrollPosY);

  LeaveCriticalSection(&lock);
}
Esempio n. 10
0
void iduTable::finalize( void )
{
    clearColumns();
    clearFilters();
}
Esempio n. 11
0
GUIListGadget::~GUIListGadget()
{
    clearItems();
    clearColumns();
}