Пример #1
0
bool MainWindow::loadFile(const QString& fileName)
{
	std::string cpath = fileName.toStdString();
	auto& factory = DocumentFactory::instance();
	auto possibleDocuments = factory.documentsToLoadFile(cpath);
	std::string selectedDocument;
	if (possibleDocuments.empty())
	{
		QStringList items;
		for (const auto& doc : factory.documents())
			items.push_back(QString::fromStdString(doc.name));

		bool ok = false;
		QString item = QInputDialog::getItem(this, tr("Unknown file type"), tr("Document type:"), items, 0, false, &ok);
		if (!ok)
			return false;

		selectedDocument = item.toStdString();
	}
	else if (possibleDocuments.size() == 1)
	{
		selectedDocument = possibleDocuments.front();
	}
	else
	{
		QStringList items;
		for (const auto& c : possibleDocuments)
			items.push_back(QString::fromStdString(c));

		bool ok = false;
		QString item = QInputDialog::getItem(this, tr("Choose document type"), tr("Document type:"), items, 0, false, &ok);
		if (!ok)
			return false;

		selectedDocument = item.toStdString();
	}

	auto document = factory.create(selectedDocument);
	if(!document)
	{
		statusBar()->showMessage(tr("Could not create the document"), 2000);
		return false;
	}

	ChangeDir cd(fileName);
	setDocument(document);

	if (!document->loadFile(cpath))
	{
		setDocument(nullptr);
		setCurrentFile("");
		statusBar()->showMessage(tr("Loading failed"), 2000);
		return false;
	}

	setCurrentFile(fileName);
	statusBar()->showMessage(tr("File loaded"), 2000);
	return true;
}
Пример #2
0
ItemText::ItemText(const QString &text, bool isRichText, QWidget *parent)
    : QTextEdit(parent)
    , ItemWidget(this)
    , m_textDocument()
    , m_searchTextDocument()
    , m_textFormat(isRichText ? Qt::RichText : Qt::PlainText)
{
    init(m_textDocument, font());
    init(m_searchTextDocument, font());

    setUndoRedoEnabled(false);

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFrameStyle(QFrame::NoFrame);

    // Selecting text copies it to clipboard.
    connect( this, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()) );

    setReadOnly(true);

    if (isRichText)
        m_textDocument.setHtml( text.left(defaultMaxBytes) );
    else
        m_textDocument.setPlainText( text.left(defaultMaxBytes) );
    setDocument(&m_textDocument);
    updateSize();
}
Пример #3
0
TextLayer::TextLayer(const int layer_id , QGraphicsItem *parent , QGraphicsScene *scene )
    : QGraphicsItem(parent,scene),evesum(0),modus(Show),border(1.),currentprintrender(false),
    hi(Metric("30px")),wi(Metric("110px")),bgcolor(QColor(Qt::white)),SwapLockBreak(false),
    bordercolor(QColor(Qt::red)),Rotate(0),check_view_area_time(0),ActionHover(false),
    format(DIV_ABSOLUTE),mount(new TextController)
{
    mount->q = this;
    setAcceptsHoverEvents(true);
    wisub_border = wi + border;
    history.clear();
    id = layer_id;
    setAcceptDrops(true);
    setFlag(QGraphicsItem::ItemIsSelectable,true);
    setFlag(QGraphicsItem::ItemIsFocusable,true);
    setFlag(QGraphicsItem::ItemIsMovable,false);
    setSelected(false);
    _doc = new QTextDocument();  
    _doc->setHtml(tr("<p>Write your text<p>"));
        QTextFrame  *Tframe = _doc->rootFrame();
        QTextFrameFormat rootformats = Tframe->frameFormat();
        rootformats.setWidth(wi);
        rootformats.setBorder(0);
        Tframe->setFrameFormat(rootformats);
        _doc->setPageSize(QSizeF(wi,hi)); 
        DLayout = _doc->documentLayout();
    setDocument(_doc);
    mount->txtControl()->document()->toHtml().size();  /* connect all */
    setZValue(1.99999);
    RestoreMoveAction();
    init();
}
Пример #4
0
void RenderWindow::fileOpen(const QString & filename)
{
  QDomDocument doc;
  QString errMsg;
  int errLine, errColm;
  QFile file(filename);
  if(!doc.setContent(&file, &errMsg, &errLine, &errColm))
  {
    QMessageBox::critical(this, tr("Error Loading File"),
      tr("There was an error opening the file %1."
         "\n\n%2 on line %3 column %4.")
         .arg(filename).arg(errMsg).arg(errLine).arg(errColm) );
    return;
  }

  QDomElement root = doc.documentElement();
  if(root.tagName() != "report")
  {
    QMessageBox::critical(this, tr("Not a Valid File"),
      tr("The file %1 does not appear to be a valid file."
         "\n\nThe root node is not 'report'.").arg(filename) );
    return;
  }

  _report->setText(filename);
  setDocument(doc);
}
PagePreviewWebView::PagePreviewWebView(QWidget* parent) 
  : QWebView(parent)
{
  
    /* combobox with the html files */
    m_combobox = new QComboBox(this);
     
    /* verify the type of the doc and update the combobox */
    connect(KDevelop::ICore::self()->documentController(), SIGNAL(documentActivated(KDevelop::IDocument*)), 
	    SLOT(setDocument(KDevelop::IDocument*)));        
   
    /* for every change in the combobox, update the combobox */
    connect(m_combobox, SIGNAL(currentIndexChanged(int)), SLOT(previewDocumentCombo(int)));
  
    //switch on timer
    m_timer = new QTimer();
    m_timer->setSingleShot(true);
    connect(KDevelop::ICore::self()->documentController(), SIGNAL(documentContentChanged(KDevelop::IDocument*)), SLOT(timerPreview()));
    
    //switch off timer
    connect(m_timer, SIGNAL(timeout()), SLOT(previewDocument()));    
    
    if(KDevelop::IDocument* doc = KDevelop::ICore::self()->documentController()->activeDocument()){
      setDocument(doc);    
    }  
    

  
}
KPrSlidesSorterDocumentModel::KPrSlidesSorterDocumentModel(KPrViewModeSlidesSorter *viewModeSlidesSorter, QWidget *parent, KoPADocument *document)
   : QAbstractListModel(parent)
   , m_viewModeSlidesSorter(viewModeSlidesSorter)
{
    setDocument(document);
    setSupportedDragActions(Qt::MoveAction);
}
Пример #7
0
DocumentListModel::DocumentListModel(Document *d, QObject *parent)
		: QAbstractListModel(parent)
		, m_doc(d)/* m_scene(0), m_view(0),*/ 
		, m_iconSize(48,0) 
		, m_sceneRect(0,0,1024,768)
		, m_dirtyTimer(0)
		, m_queuedIconGenerationMode(false)
{
	if(!m_blankPixmap)
	{
		m_blankPixmap = new QPixmap(48,48 * (1/AppSettings::liveAspectRatio()));
		m_blankPixmap->fill(Qt::lightGray);
		QPainter painter(m_blankPixmap);
		painter.setPen(QPen(Qt::black,1,Qt::DotLine));
		painter.drawRect(m_blankPixmap->rect().adjusted(0,0,-1,-1));
		painter.end();
	}
	m_blankPixmapRefCount ++;
	
	connect(&m_needPixmapTimer, SIGNAL(timeout()), this, SLOT(makePixmaps()));
		
	if(m_doc)
		setDocument(d);
		
	if(MainWindow::mw())
	{
		m_sceneRect = MainWindow::mw()->standardSceneRect();
		connect(MainWindow::mw(), SIGNAL(aspectRatioChanged(double)), this, SLOT(aspectRatioChanged(double)));
	}
			
	setSceneRect(m_sceneRect);
}
Пример #8
0
/**
 * Constructs a new JTextArea with the specified number of rows
 * and columns, and the given model.  All of the constructors
 * feed through this constructor.
 *
 * @param doc the model to use, or create a default one if NULL
 * @param text the text to be displayed, NULL if none
 * @param rows the number of rows >= 0
 * @param columns the number of columns >= 0
 * @exception IllegalArgumentException if the rows or columns
 *  arguments are negative.
 */
/*public*/ JTextArea::JTextArea(Document* doc, QString text, int rows, int columns, QWidget *parent) : QTextEdit(parent){
    //super();
 common();
    this->rows = rows;
    setColumns(columns);
    if (doc == NULL) {
        doc = createDefaultModel();
    }
    else
     setDocument(doc);
    if (text != NULL) {
        setText(text);
//        select(0, 0);
    }
    if (rows < 0) {
        throw new IllegalArgumentException("rows: " + QString::number(rows));
    }
    if (columns < 0) {
        throw new IllegalArgumentException("columns: " + QString::number(columns));
    }
#if 0
    LookAndFeel.installProperty(this,
                                "focusTraversalKeysForward",
                                JComponent.
                                getManagingFocusForwardTraversalKeys());
    LookAndFeel.installProperty(this,
                                "focusTraversalKeysBackward",
                                JComponent.
                                getManagingFocusBackwardTraversalKeys());
#endif
}
Пример #9
0
// -----------------------------------------------------------------
// Name : detachDocument
// -----------------------------------------------------------------
guiTabbedFrame_Document * guiTabbedFrame::detachDocument()
{
    guiDocument * pDoc = guiFrame::unsetDocument();
    if (pDoc == NULL) {
        return NULL;
    }

    int size = m_pDocumentsList.size();
    if (size < 2)
    {
        setDocument(pDoc);
        return NULL;
    }

    guiTabbedFrame_Document * ret = NULL;
    for (list<guiTabbedFrame_Document*>::iterator it = m_pDocumentsList.begin(); it != m_pDocumentsList.end(); ++it) {
        if ((*it)->m_pDoc == pDoc)
        {
        	ret = *it;
        	it = m_pDocumentsList.erase(it);
            break;
        }
    }
    if (m_pDocumentsList.empty()) {
        m_pDoc = NULL;
    } else {
        setMainDocument((*(m_pDocumentsList.begin()))->m_pDoc);
    }

    return ret;
}
Пример #10
0
MdiChild::MdiChild()
{
	_document = new Document(this);
	docLayout = new PlainTextDocumentLayout(_document);
	_document->setDocumentLayout(docLayout);
	setDocument(_document);
	syntaxHightlighter = new SyntaxHighlighter(_document);
	syntaxHightlighter->setDocument(_document);
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowIcon(QIcon::fromTheme("text-x-generic"));
	isUntitled = true;
	autoindent = true;
	snipples=NULL;
	snipplesActivateOk=NULL;
	replaceTabsBySpacesOk = NULL;
	//setTabStopWidth(20);
	setCursorWidth(3);
	connect(document(), SIGNAL(contentsChanged()),
		this, SLOT(documentContentsChanged()));
	connect(document(), SIGNAL(modificationChanged(bool)),
		this, SLOT(documentWasModified()));
	connect(document(), SIGNAL(fileNameChanged(QString)),
		this, SLOT(setCurrentFile(QString)));
	connect(docLayout, SIGNAL(docChanged(int, int, int)), this, SLOT(documentChanged(int, int, int)));
}
Пример #11
0
void ExpandingLabel::setLabelText(const QString& theText) {
	QTextDocument *doc = new QTextDocument(this);
	doc->setHtml(theText);
	setDocument(doc);
	setToolTip(theText);
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	setAlignment(Qt::AlignCenter);
	setContextMenuPolicy(Qt::NoContextMenu);
}
Пример #12
0
Highlighter::Highlighter(QPlainTextEdit *edit, const QColor &col)
    : QSyntaxHighlighter(edit),
      d(new HighlighterPrivate(this, col))
{
    d->plainTextEdit = edit;
    setDocument(d->plainTextEdit->document());
    d->plainTextEdit->installEventFilter(this);
    d->plainTextEdit->viewport()->installEventFilter(this);
}
Пример #13
0
void CodeEditorBox::onComboSelectionChanged(int index)
{
    QModelIndex proxyIndex = mProxyModel->index(index, 0);
    QModelIndex mRow = mProxyModel->mapToSource(proxyIndex);
    int mIndex = mRow.row();

    if(mIndex >=0 && index>=0 && mDocComboBox) {
        setDocument(Main::documentManager()->docModel()->item(mIndex)->data().value<Document *>(), -1, 0);
    }
}
Пример #14
0
bool JSON::parse(Variant & root, const std::string & document)
{
    auto tokenizer = createJSONTokenizer();

    // Set document
    tokenizer.setDocument(document);

    // Begin parsing
    return readDocument(root, tokenizer);
}
Пример #15
0
bool HRFile::doRead(const std::string & fileName)
{
	if(!HObject::FileIO.open(fileName.c_str(), HDocument::oReadOnly)) {
		setLatestError(BaseFile::FileNotReadable);
		return false;
	}
	
	setDocument(HObject::FileIO);

	return true;
}
NodeIteratorImpl::NodeIteratorImpl(NodeImpl *rootNode, long whatToShow, NodeFilterImpl *filter, bool expandEntityReferences)
    :TraversalImpl(rootNode, whatToShow, filter, expandEntityReferences), m_referenceNode(0), m_beforeReferenceNode(true), m_detached(false), m_doc(0)
{
    if (root()) {
        setDocument(root()->getDocument());
        if (document()) {
            document()->attachNodeIterator(this);
            document()->ref();
        }
    }
}
Пример #17
0
void TreeScope::setParentTreeScope(TreeScope& newParentScope)
{
    // A document node cannot be re-parented.
    ASSERT(!rootNode().isDocumentNode());

    newParentScope.guardRef();
    if (m_parentTreeScope)
        m_parentTreeScope->guardDeref();
    m_parentTreeScope = &newParentScope;
    setDocument(newParentScope.document());
}
Пример #18
0
void ContactBrowser::init( const QContact& contact, ContactDocument::ContactDocumentType docType)
{
    mLink.clear();
    if (!mDocument)
        mDocument = new ContactDocument(this);
    mDocument->textDocument()->setTextWidth(width() - 10);
    mDocument->init(this, contact, docType);
    setDocument(mDocument->textDocument());
    loadLinks(contact.customField(QDL::CLIENT_DATA_KEY));
    verifyLinks();
}
Пример #19
0
void ChatEdit::setSession(ChatSessionImpl *session)
{
	m_session = session;
	setDocument(session->getInputField());
	setFocus();
	QFont chatEditFont = qApp->font();
	Config cfg = Config("appearance");
	cfg.beginGroup("chat");
	chatEditFont.setPointSize(cfg.value("chatFontSize", qApp->font().pointSize()));
	cfg.endGroup();
	session->getInputField()->setDefaultFont(chatEditFont);
}
Пример #20
0
void ItemText::highlight(const QRegExp &re, const QFont &highlightFont, const QPalette &highlightPalette)
{
    m_searchTextDocument.clear();
    if ( re.isEmpty() ) {
        setDocument(&m_textDocument);
    } else {
        bool plain = m_textFormat == Qt::PlainText;
        const QString &text = plain ? m_textDocument.toPlainText() : m_textDocument.toHtml();
        if (plain)
            m_searchTextDocument.setPlainText(text);
        else
            m_searchTextDocument.setHtml(text);

        QTextCursor cur = m_searchTextDocument.find(re);
        int a = cur.position();
        while ( !cur.isNull() ) {
            QTextCharFormat fmt = cur.charFormat();
            if ( cur.hasSelection() ) {
                fmt.setBackground( highlightPalette.base() );
                fmt.setForeground( highlightPalette.text() );
                fmt.setFont(highlightFont);
                cur.setCharFormat(fmt);
            } else {
                cur.movePosition(QTextCursor::NextCharacter);
            }
            cur = m_searchTextDocument.find(re, cur);
            int b = cur.position();
            if (a == b) {
                cur.movePosition(QTextCursor::NextCharacter);
                cur = m_searchTextDocument.find(re, cur);
                b = cur.position();
                if (a == b) break;
            }
            a = b;
        }
        setDocument(&m_searchTextDocument);
    }

    update();
}
Пример #21
0
/**
 * Parses a text document and builds the navigation tree for it
 */
void NavigationWidget::parse(QTextDocument *document) {
    const QSignalBlocker blocker(this);
    Q_UNUSED(blocker);

    setDocument(document);
    clear();
    _lastHeadingItemList.clear();

    for (int i = 0; i < document->blockCount(); i++) {
        QTextBlock block = document->findBlockByNumber(i);
        int elementType = block.userState();

        // ignore all non headline types
        if ((elementType < pmh_H1) || (elementType > pmh_H6)) {
            continue;
        }

        QString text = block.text();

        text.remove(QRegularExpression("^#+"))
                .remove(QRegularExpression("#+$"))
                .remove(QRegularExpression("^\\s+"))
                .remove(QRegularExpression("^=+$"))
                .remove(QRegularExpression("^-+$"));

        if (text.isEmpty()) {
            continue;
        }

        QTreeWidgetItem *item = new QTreeWidgetItem();
        item->setText(0, text);
        item->setData(0, Qt::UserRole, block.position());
        item->setToolTip(0, tr("headline %1").arg(elementType - pmh_H1 + 1));

        // attempt to find a suitable parent item for the element type
        QTreeWidgetItem *lastHigherItem = findSuitableParentItem(elementType);

        if (lastHigherItem == NULL) {
            // if there wasn't a last higher level item then add the current
            // item to the top level
            addTopLevelItem(item);
        } else {
            // if there was a last higher level item then add the current
            // item as child of that item
            lastHigherItem->addChild(item);
        }

        _lastHeadingItemList[elementType] = item;
    }

    expandAll();
}
Пример #22
0
WordTokenizer::WordTokenizer(const Document *pDocument) :
	Tokenizer(NULL)
{
	string cmdLine("antiword");

	// Run antiword
	Document *pOutputDocument = runHelperProgram(pDocument, cmdLine);
	if (pOutputDocument != NULL)
	{
		// Give the result to the parent class
		setDocument(pOutputDocument);
	}
}
Пример #23
0
static void loadDocument(const std::wstring &_fileName)
{
	SyncDocument *newDoc = SyncDocument::load(_fileName);
	if (newDoc) {
		// update MRU list
		mruFileList.insert(_fileName);
		mruFileList.update();
		DrawMenuBar(hwnd);

		// set new document
		setDocument(newDoc);
		setWindowFileName(_fileName.c_str());
	}
	else
		error("failed to open file");
}
void TestDocumentFileLoadJob::startLoadFromFile()
{
    TestDocumentFileSynchronizer* testSynchronizer = qobject_cast<TestDocumentFileSynchronizer*>( synchronizer() );

    TestDocumentFileLoadThread* loadThread =
        new TestDocumentFileLoadThread( this, testSynchronizer->header(), file() );
    loadThread->start();
    while( !loadThread->wait(100) )
        QApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 100 );

    TestDocument* document = loadThread->document();
    testSynchronizer->setDocument( document );

    delete loadThread;

    setDocument( document );
}
Пример #25
0
MLScriptEditor::MLScriptEditor( QWidget* par /*= NULL*/ )
:QPlainTextEdit(par),regexps(),synt(NULL),synhigh(NULL),comp(NULL)
{
	QTextDocument* mydoc = new QTextDocument(this);
	QPlainTextDocumentLayout* ld = new QPlainTextDocumentLayout(mydoc);
	mydoc->setDocumentLayout(ld);
	setDocument(mydoc);

	narea = new MLNumberArea(this);
	connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
	//connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateCursorPos(int)));
	connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
	connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

	updateLineNumberAreaWidth(0);
	highlightCurrentLine();
}
Пример #26
0
BoundTextEdit::BoundTextEdit(QWidget *parent) :
	QTextEdit(parent)
{
	_model = new TextModelLavaan(this);
	setDocument(_model);

	connect(this,	&BoundTextEdit::cursorPositionChanged,	this, &BoundTextEdit::cursorPositionChangedHandler);
	connect(_model, &TextModelLavaan::errorStateChanged,	this, &BoundTextEdit::errorStateChangedHandler);
	connect(_model, &TextModelLavaan::contentsChanged,		this, &BoundTextEdit::contentsChangedHandler);

	this->setLineWrapMode(QTextEdit::NoWrap);
	this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	this->setAcceptRichText(false);
	
	
	
	int id = QFontDatabase::addApplicationFont(":/fonts/FiraCode-Retina.ttf");
	QString family = QFontDatabase::applicationFontFamilies(id).at(0);
	
	QFont font(family);
	font.setStyleHint(QFont::Monospace);
	font.setPointSize(10);
	this->setFont(font);

	QFontMetrics metrics(font);
	this->setTabStopWidth(metrics.width("  ") + 2);

	_errorStylesheet = "padding: 4px; padding-right: 1.5em; background-color: rgba(255,0,0,128); margin-left: 100%;";
	_okStylesheet    = "padding: 4px; padding-right: 1.5em; margin-left: 100%;";

#ifdef __APPLE__
	_okMessage = "\u2318 + Enter to apply";
#else
	_okMessage = "Ctrl + Enter to apply";
#endif

	_status = new QLabel(this);
	_status->setWordWrap(true);
	_status->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
	_status->setAlignment(Qt::AlignBottom | Qt::AlignRight);
	_status->setStyleSheet(_okStylesheet);
	_status->setText(_okMessage);
	_status->setAttribute(Qt::WA_TransparentForMouseEvents);
	
	_applied = true;
}
Пример #27
0
DocumentEditor::DocumentEditor(DocumentEditor* document_, QWidget *parent_) : ScintillaExt(parent_), _watcher(document_->_watcher) {
	_notified = true;
	//codec
	setUtf8(true);
	_codec = document_->_codec;
	_bomMode = document_->_bomMode;
	_hasBom = document_->_hasBom;
	_charsetAutoDetect = document_->_charsetAutoDetect;

	//document info
	_autoDetectEol = document_->_autoDetectEol;
	_autoDetectIndent = document_->_autoDetectIndent;
	_isNew = document_->isNew();
	_fullPath = document_->getFullPath();

	setDocument(document_->document());

	_clone = document_;
	_isCloned = true;
	document_->_clone = this;
	document_->_isCloned = true;

	QsciLexer* l = document_->lexer();
	if(l != 0) {
		QString lexLang = l->language();
		QsciLexer* newLex = LexerManager::getInstance().lexerFactory(lexLang, this);
		if(newLex == 0) {
			//could not find the lexer
			newLex = LexerManager::getInstance().getAutoLexer(this);
		}
		setLexer(newLex);
	}

	//macro
	_macro = new QsciMacro(this);

	//load settings
	Settings settings;
	settings.applyToDocument(this);

	markerDefine(QPixmap(":/images/ledblue.png").scaled(40,16, Qt::KeepAspectRatio, Qt::SmoothTransformation), MARKER_BOOK);

	//connection
	connect(this, SIGNAL(marginClicked(int,int, Qt::KeyboardModifiers)), this, SLOT(toggleBookmark(int,int, Qt::KeyboardModifiers)));
}
Пример #28
0
void MdiChild::setView(MdiChild *mdiChild)
{
	_document = mdiChild->view();
	setDocument(_document);
	bool modified = document()->isModified();
	setCurrentFile(_document->fileName());
	document()->setModified(modified);
	isUntitled = mdiChild->isUntitled;
	setWindowModified(modified);
	setWindowTitle(userFriendlyCurrentFile() + "[*]");

	connect(_document, SIGNAL(contentsChanged()),
		this, SLOT(documentContentsChanged()));
	connect(document(), SIGNAL(modificationChanged(bool)),
		this, SLOT(documentWasModified()));
	connect(_document, SIGNAL(fileNameChanged(QString)),
		this, SLOT(setCurrentFile(QString)));
}
Пример #29
0
TEST(DocumentList, NewWaitingCustomEntity) {
    lc::storage::DocumentList::getInstance().newWaitingCustomEntityEvent().connect<onEventReceived>();

    auto doc1 = std::make_shared<lc::storage::DocumentImpl>(std::make_shared<lc::storage::StorageManagerImpl>());

    auto customEntityStorage = std::make_shared<lc::meta::CustomEntityStorage>("plugin", "entity", lc::geo::Coordinate());
    std::make_shared<lc::operation::AddBlock>(doc1, customEntityStorage)->execute();

    auto builder = lc::builder::InsertBuilder();
    builder.setDisplayBlock(customEntityStorage);
    builder.setDocument(doc1);
    builder.setLayer(std::make_shared<lc::meta::Layer>());

    std::make_shared<lc::operation::EntityBuilder>(doc1)->appendEntity(builder.build())->execute();

    ASSERT_TRUE(eventReceived);
    ASSERT_EQ(1, lc::storage::DocumentList::getInstance().waitingCustomEntities("plugin").size());
}
Пример #30
0
GlslTextEdit::GlslTextEdit(QWidget *parent) 
:   PlainTextWithLineNumberAreaSupport(parent)
,   m_highlighter(NULL)
,   m_completer(NULL)
,   m_lineNumberArea(NULL)
,   m_gotDocumentAssigned(false)
,   m_font(new QFont("Consolas, Courier New, Courier", 9))
{
    m_highlighter = new GlslHighlighter();
    m_lineNumberArea = new LineNumberArea(*this);

    connect(this, SIGNAL(cursorPositionChanged()),
        this, SLOT(highlightCurrentLine()));

    highlightCurrentLine();

    setDocument(NULL, GLSLT_Undefined);
}