Пример #1
0
void SyntaxHighlightDlg::LoadLexers(const wxString& theme)
{
#ifdef __WXMSW__
    wxWindowUpdateLocker locker(this);
#endif

    // get the current open editor's lexer name
    wxString currentLexer;
    LEditor *editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(editor) {
        currentLexer = editor->GetContext()->GetName();
        currentLexer.MakeLower();
    }

    //remove old lexers
    if (m_lexersBook->GetPageCount() > 0) {
        m_lexersBook->DeleteAllPages();
    }

    //update the theme name
    EditorConfigST::Get()->SaveStringValue(wxT("LexerTheme"), theme);

    //load all lexers
    EditorConfigST::Get()->LoadLexers(false);

    std::map<wxString, LexerConfPtr>::const_iterator iter = EditorConfigST::Get()->LexerBegin();
    for (; iter != EditorConfigST::Get()->LexerEnd(); iter++) {
        LexerConfPtr lexer = iter->second;

        wxString lexName = lexer->GetName();
        lexName.Trim().Trim(false);
        if(lexName.IsEmpty())
            continue;

        // get the parent node for this lexer
        wxString firstChar = lexName.Mid(0, 1).MakeUpper();
        size_t parentIndex(wxString::npos);
        for(size_t i=0; i<m_lexersBook->GetPageCount(); i++) {
            wxString pageText = m_lexersBook->GetPageText(i);
            pageText.MakeUpper();
            if( pageText.StartsWith(firstChar) ) {
                parentIndex = i;
                break;
            }
        }

        if(parentIndex == wxString::npos) {
            // add parent node
            m_lexersBook->AddPage(CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), currentLexer == iter->second->GetName());

        } else {
            m_lexersBook->InsertPage(parentIndex, CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), currentLexer == iter->second->GetName());
        }
    }
    // The outputview colours are global to all a theme's lexors, so are dealt with separately
    m_colourPickerOutputPanesFgColour->SetColour(wxColour(EditorConfigST::Get()->GetCurrentOutputviewFgColour()));
    m_colourPickerOutputPanesBgColour->SetColour(wxColour(EditorConfigST::Get()->GetCurrentOutputviewBgColour()));
}
Пример #2
0
static void shiftup(MCHeap* heap, size_t index)
{
    size_t i = index, p;
    while (1) {
        if (i == 1)
            break;
        p = parentIndex(i);
        if (MCGenericCompare(heap->values[p], heap->values[i]) <= 0)
            break;
        swapNode(heap, p, i);
        i = p;
    }
}
Пример #3
0
int testIndexes() {
    printf("Test 1. indexovani parent, left, right: ");
    if (parentIndex(2) != 0 || parentIndex(1) != 0 || parentIndex(0) != INT_MAX) {
        printf("NOK - chybny parentIndex\n");
        return 0;
    }
    if (leftIndex(0) != 1 || leftIndex(3) != 7) {
        printf("NOK - chybny leftIndex\n");
        return 0;
    }
    if (rightIndex(0) != 2 || rightIndex(3) != 8) {
        printf("NOK - chybny rightIndex\n");
        return 0;
    }

    MinHeap heap;
    int tmp[] = {1,2,3};
    heap.size = 3;
    for (unsigned int i = 0; i < heap.size; i++) {
        heap.array[i] = tmp[i];
    }

    if (getParent(&heap,0) != INT_MAX || getParent(&heap,1) != 1 ||
            getParent(&heap,2) != 1) {
        printf("NOK - chyba ve funkci getParent\n");
        return 0;
    }
    if (getLeft(&heap,0) != 2 || getLeft(&heap,1) != INT_MAX) {
        printf("NOK - chyba ve funkci getLeft\n");
        return 0;
    }
    if (getRight(&heap,0) != 3 || getRight(&heap,1) != INT_MAX) {
        printf("NOK - chyba ve funkci getRight\n");
        return 0;
    }
    printf("OK\n");
    return 1;
}
Пример #4
0
QDomElement squareWindowSaver::toXml(QDomDocument* doc) const {

  QDomElement element = doc->createElement("square_window_image");
  ::appendTextElement(doc, "index", QString::number(index()), &element);
  const QString hiddenString = ::boolToString(hidden());
  ::appendTextElement(doc, "hidden", hiddenString, &element);
  ::appendTextElement(doc, "parent_index", QString::number(parentIndex()),
                      &element);
  ::appendTextElement(doc, "creation_mode", creationMode_, &element);
  ::appendTextElement(doc, "square_dimension",
                      QString::number(squareDimension_), &element);

  return element;
}
Пример #5
0
void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
	QMenu m;
	// Don't have a gas selection for the last point
	QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
	if (index.sibling(index.row() + 1, index.column()).isValid()) {
		GasSelectionModel *model = GasSelectionModel::instance();
		model->repopulate();
		int rowCount = model->rowCount();
		for (int i = 0; i < rowCount; i++) {
			QAction *action = new QAction(&m);
			action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString());
			connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
			m.addAction(action);
		}
	}
Пример #6
0
QDomElement patternWindowSaver::toXml(QDomDocument* doc) const {

  QDomElement element = doc->createElement("pattern_window_image");
  ::appendTextElement(doc, "index", QString::number(index()), &element);
  const QString hiddenString = ::boolToString(hidden());
  ::appendTextElement(doc, "hidden", hiddenString, &element);
  ::appendTextElement(doc, "parent_index", QString::number(parentIndex()),
                      &element);
  ::appendTextElement(doc, "square_dimension",
                      QString::number(squareDimension_), &element);
  QDomNode historyNode =
    doc->importNode(squareHistory_.firstChildElement("square_history"),
                    true);
  element.appendChild(historyNode);

  return element;
}
Пример #7
0
void decreaseKeyMinHeap(MinHeap *A, long int index, long int key)
{
	long int currentIndex = index, temp, parent;

	/* If the new key is larger than the old key, we do nothing */
	if(key <= A->arr[index])
	{
		A->arr[index] = key;

		while(currentIndex > 1 && A->arr[(parent = parentIndex(currentIndex))] >
								  A->arr[currentIndex])
		{
			/* Swap the two elements */
			temp = A->arr[currentIndex];
			A->arr[currentIndex] = A->arr[parent];
			A->arr[parent] = temp;

			currentIndex = parent;
		}
	}
}
Пример #8
0
QRectF QGraphicsSceneBspTree::rectForIndex(int index) const
{
    if (index <= 0)
        return rect;

    int parentIdx = parentIndex(index);
    QRectF rect = rectForIndex(parentIdx);
    const Node *parent = &nodes.at(parentIdx);

    if (parent->type == Node::Horizontal) {
        if (index & 1)
            rect.setRight(parent->offset);
        else
            rect.setLeft(parent->offset);
    } else {
        if (index & 1)
            rect.setBottom(parent->offset);
        else
            rect.setTop(parent->offset);
    }

    return rect;
}
Пример #9
0
void specActionLibrary::readFromStream(QDataStream& in)
{
	qint32 num, position ;
	in >> num >> position ; // TODO really rely on num?

	foreach(QObject * parent, parents)
	qDebug() << "Parent: " << parent->objectName() ;

	type t ;
	QVector<qint32> parentIndex(num, 0) ;
	int progressToGo = 0, progressStart = 0 ;
	if(progress)
	{
		progressStart = progress->value() ;
		progressToGo = progress->maximum() - progressStart ;

	}

	for(int i = 0 ; i < num ; ++i)
	{
		if(progress) progress->setValue(progressStart + (i * progressToGo) / num);
		in >> t >> parentIndex[i] ;
		specStreamable* streamable = produceItem(in) ;
		specUndoCommand* command = dynamic_cast<specUndoCommand*>(streamable) ;
		if(!command)
		{
			qDebug() << "Error reading command no." << i << "of type" << t ;
			undoStack->clear();
			delete streamable ;

			// Reset loop invariants
			num -= i ;
			i = 0 ;
			parentIndex = QVector<qint32>(num,0) ;
			continue ;
		}
		////// For manually discarding corrupted undo commands:
#ifdef DEBUGCOMMANDREADER
		qDebug() << "Reading item:" << i << "total count:" << undoStack->count() << "/" << num ;
		if (QMessageBox::question(0,tr("Really read?"),
					  tr("Really read command no. ")
					  + QString::number(i)
					  + tr("?  Description is:\n")
					  + command->text(),
					  QMessageBox::Yes | QMessageBox::No,
					  QMessageBox::Yes)
				== QMessageBox::Yes)
#endif
			undoStack->push(command) ;
#ifdef DEBUGCOMMANDREADER
		else
			delete command ;
#endif
	}

	undoStack->setIndex(position) ;
	for(int i = 0 ; i < undoStack->count() ; ++i)
		((specUndoCommand*) undoStack->command(i))->setParentObject(parents[parentIndex[i]]) ;
	qDebug() << "to be read:" << num << "actually on stack:" << undoStack->count() ;
	undoStack->setClean();
}
Пример #10
0
void DiveHandler::changeGas()
{
	QAction *action = qobject_cast<QAction *>(sender());
	QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
	plannerModel->gaschange(index.sibling(index.row() + 1, index.column()), action->text());
}
Пример #11
0
void DiveHandler::changeGas()
{
	QAction *action = qobject_cast<QAction *>(sender());
	QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
	plannerModel->setData(index, action->text());
}