Example #1
0
    void shouldRetagItemsOnModify()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        QScopedPointer<Akonadi::MonitorInterface> monitor(data.createMonitor());
        QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::itemChanged);

        auto t1 = Akonadi::Tag(42);
        t1.setName(QStringLiteral("42"));
        data.createTag(t1);

        auto t2 = Akonadi::Tag(43);
        t2.setName(QStringLiteral("43"));
        data.createTag(t2);

        auto i1 = Akonadi::Item(42);
        i1.setPayloadFromData("42");
        i1.setTag(Akonadi::Tag(42));
        data.createItem(i1);

        // WHEN
        i1.setPayloadFromData("42-bis");
        i1.clearTag(Akonadi::Tag(42));
        i1.setTag(Akonadi::Tag(43));
        data.modifyItem(i1);

        // THEN
        QVERIFY(data.tagItems(t1.id()).isEmpty());
        QCOMPARE(data.tagItems(t2.id()).size(), 1);
        QCOMPARE(data.tagItems(t2.id()).at(0), i1);

        QCOMPARE(spy.size(), 1);
        QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Item>(), i1);
    }
Example #2
0
    void shouldRemoveTags()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        QScopedPointer<Akonadi::MonitorInterface> monitor(data.createMonitor());
        QSignalSpy tagSpy(monitor.data(), &Akonadi::MonitorInterface::tagRemoved);
        QSignalSpy itemSpy(monitor.data(), &Akonadi::MonitorInterface::itemChanged);

        auto c1 = Akonadi::Collection(42);
        data.createCollection(c1);

        auto t1 = Akonadi::Tag(42);
        t1.setName(QStringLiteral("42"));
        data.createTag(t1);

        auto t2 = Akonadi::Tag(43);
        t2.setName(QStringLiteral("43"));
        data.createTag(t2);

        auto i1 = Akonadi::Item(42);
        i1.setPayloadFromData("42");
        i1.setParentCollection(c1);
        i1.setTag(Akonadi::Tag(t1.id()));
        data.createItem(i1);

        auto i2 = Akonadi::Item(43);
        i2.setPayloadFromData("43");
        i2.setParentCollection(c1);
        i2.setTag(Akonadi::Tag(t2.id()));
        data.createItem(i2);

        const auto itemSet = QSet<Akonadi::Item>() << i1 << i2;

        // WHEN
        data.removeTag(t2);

        // THEN
        QCOMPARE(data.tags().size(), 1);
        QCOMPARE(data.tags().at(0), t1);

        QVERIFY(!data.tag(t2.id()).isValid());

        QCOMPARE(data.tagItems(t1.id()).size(), 1);
        QCOMPARE(data.tagItems(t1.id()).at(0), i1);
        QVERIFY(data.tagItems(t2.id()).isEmpty());

        QCOMPARE(data.items().toList().toSet(), itemSet);

        QVERIFY(data.item(i1.id()).isValid());
        QVERIFY(data.item(i2.id()).isValid());
        QVERIFY(!data.item(i2.id()).tags().contains(t2));

        QCOMPARE(tagSpy.size(), 1);
        QCOMPARE(tagSpy.takeFirst().at(0).value<Akonadi::Tag>(), t2);

        QCOMPARE(itemSpy.size(), 1);
        QCOMPARE(itemSpy.first().at(0).value<Akonadi::Item>(), i2);
        QVERIFY(!itemSpy.first().at(0).value<Akonadi::Item>().tags().contains(t2));
    }
string SocketData::createSendData(){
	string sendData;
	sendData += createStartTag(TAG_SOCKETDATA);
	sendData += mSignal.createSendData();
	sendData += createTag(TAG_SOCKETNAME, mName);
	if(mData != "") sendData += createTag(TAG_DATA, mData);
	sendData += mExecData.createSendData();
	sendData += createEndTag(TAG_SOCKETDATA);
	return sendData;
}
Example #4
0
void MainPage::createActions(void)
{
	MAction *newAction = new MAction("icon-m-toolbar-add", 
					 tr("Create a new tag"),
					 this);
	newAction->setLocation(MAction::ToolBarLocation);
 	connect(newAction, SIGNAL(triggered()),
 		this, SLOT(createTag()));
	addAction(newAction);

	MAction *killallAction = new MAction(tr("Remove all tags"),
					     this);
	killallAction->setLocation(MAction::ApplicationMenuLocation);
 	connect(killallAction, SIGNAL(triggered()),
 		this, SLOT(removeAllTags()));
	addAction(killallAction);

	MAction *aboutAction = new MAction(tr("About..."), this);
	aboutAction->setLocation(MAction::ApplicationMenuLocation);
 	connect(aboutAction, SIGNAL(triggered()),
 		this, SLOT(showAbout()));
	addAction(aboutAction);

	MAction *helpAction = new MAction(tr("Instructions..."), this);
	helpAction->setLocation(MAction::ApplicationMenuLocation);
 	connect(helpAction, SIGNAL(triggered()),
 		this, SLOT(showHelp()));
	addAction(helpAction);
}
Example #5
0
    void shouldCreateTags()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        QScopedPointer<Akonadi::MonitorInterface> monitor(data.createMonitor());
        QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::tagAdded);

        auto t1 = Akonadi::Tag(42);
        t1.setName(QStringLiteral("42"));
        auto t2 = Akonadi::Tag(43);
        t2.setName(QStringLiteral("43"));

        // WHEN
        data.createTag(t1);
        data.createTag(t2);

        // THEN
        QCOMPARE(data.tags().size(), 2);
        QVERIFY(data.tags().contains(t1));
        QVERIFY(data.tags().contains(t2));
        QCOMPARE(data.tag(t1.id()), t1);
        QCOMPARE(data.tag(t2.id()), t2);

        QCOMPARE(spy.size(), 2);
        QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Tag>(), t1);
        QCOMPARE(spy.takeFirst().at(0).value<Akonadi::Tag>(), t2);
    }
Example #6
0
static void processBlock (tokenInfo *const token)
{
	boolean blockStart = FALSE;
	boolean blockEnd   = FALSE;

	if (strcmp (vStringValue (token->name), "begin") == 0)
	{
		currentContext->nestLevel++;
		blockStart = TRUE;
	}
	else if (strcmp (vStringValue (token->name), "end") == 0)
	{
		currentContext->nestLevel--;
		blockEnd = TRUE;
	}

	if (findBlockName (token))
	{
		verbose ("Found block: %s\n", vStringValue (token->name));
		if (blockStart)
		{
			createTag (token);
			verbose ("Current context %s\n", vStringValue (currentContext->name));
		}
		if (blockEnd && currentContext->kind == K_BLOCK && currentContext->nestLevel <= 1)
		{
			verbose ("Dropping context %s\n", vStringValue (currentContext->name));
			currentContext = popToken (currentContext);
		}
	}
}
Example #7
0
TagParser::TagParser(string tag_type, string tags)
{
    //ctor
    mTagType = tag_type;
    mTag.clear();
    mTagParser = NULL;
    //mTagVector = NULL;
    createTag(tags);
}
//override
string ExecData::createSendData() {
	string sendData;
	sendData += createStartTag(TAG_EXECDATA);
	if (mAppId != "") {
		sendData += createTag(TAG_APPID, mAppId);
	}
	stringstream ss;
	if (mStartTime != 0) {
		ss << mStartTime;
		sendData += createTag(TAG_STARTTIME, ss.str());
		ss.clear();
		ss.str("");
	}
	if (mExecTime != 0) {
		ss << mExecTime;
		sendData += createTag(TAG_EXECTIME, ss.str());
		ss.clear();
		ss.str("");
	}
	if (mDeviceName[0] != "") {
		sendData += createTag(TAG_DEVICENAME_SELECTED, mDeviceName[0]);
	}
	if (mDeviceName[1] != "") {
		sendData += createTag(TAG_DEVICENAME, mDeviceName[1]);
	}
	if (mDeviceType[0] != 0) {
		ss << mDeviceType[0];
		sendData += createTag(TAG_DEVICETYPE_SELECTED, ss.str());
		ss.clear();
		ss.str("");
	}
	if (mDeviceType[1] != 0) {
		ss << mDeviceType[1];
		sendData += createTag(TAG_DEVICETYPE, ss.str());
		ss.clear();
		ss.str("");
	}
	if(mKernelNum != 0){
		ss << mKernelNum;
		sendData += createTag(TAG_KERNELNUM, ss.str());
		ss.clear();
		ss.str("");
	}
	//kernellist
	if (mKernelCodeList.size() != 0) {
		sendData += createStartTag(TAG_KERNELLIST);
		for (int i = 0; i < mKernelCodeList.size(); i++) {
			sendData += mKernelCodeList[i].createSendData();
		}
		sendData += createEndTag(TAG_KERNELLIST);
	}
	sendData += createEndTag(TAG_EXECDATA);
	return sendData;
}
Example #9
0
void generator()
{
	int i;
	int numFile;
	int numTags;
	int tagsInserted;
	char file[256];
	char subfolder[256];
	char *tag;
	char *insertedTags[GENERATOR_NUM_TAGS];

	//Init insertedTags DB
	for ( i = 0; i<GENERATOR_NUM_TAGS; i++)
	{
		insertedTags[i]=NULL;
	}

	createFolderIfNotExists(GENERATOR_FOLDER);

	for ( numTags=100; numTags <= GENERATOR_NUM_TAGS; numTags+=100)
	{
		sprintf(subfolder, "%s/%d", GENERATOR_FOLDER, numTags);
		createFolderIfNotExists(subfolder);

		for ( numFile = 0; numFile < GENERATOR_NUM_TAGS; numFile++) 
		{
			tagsInserted = 0;

			while (tagsInserted != numTags)
			{
				//fprintf(stderr, "%d-%d\n", numTags,tagsInserted);
				tag = createTag();

				if (!hasTag(insertedTags, tag))
				{
					insertedTags[tagsInserted++] = tag;
				}
				else
				{
					free(tag);
				}
			}
			sprintf(file, "%s/%04d.txt", subfolder, numFile+1);
			writeTagsOnFile(insertedTags, numTags, file);

			for ( i = 0; i<GENERATOR_NUM_TAGS && (insertedTags[i]!= NULL); i++)
			{
				free(insertedTags[i]);
				insertedTags[i]=NULL;
			}

		}
	}
}
//override
string WorkItemSizeList::createSendData(){
	string sendData;
	stringstream ss;
	for(int i=0;i<mDim;i++){
		ss << mSizeList[i];
		sendData += createTag(TAG_WORKSIZE,ss.str());
		ss.clear();
		ss.str("");
	}
	return sendData;
}
Example #11
0
Tag* TagManager::getTag(const QString& newtag)
{
    for(tagSetIt it= begin(); it != end(); it++)
    {
        if((*it)->getName()==newtag) {
            qDebug()<<"Gotcha!";
            return *it;
        }
    }
    qDebug()<<"created Tag: " << newtag;
    return createTag(newtag);
}
Example #12
0
//override
string KernelCode::createSendData() {
	string sendData;
	sendData += createStartTag(TAG_KERNEL);
	if (mName != "")
		sendData += createTag(TAG_KERNELNAME, mName);
	if (mHash != "")
		sendData += createTag(TAG_KERNELHASH, mHash);
	if (mFuncNum != 0) {
		stringstream ss;
		ss << mFuncNum;
		sendData += createTag(TAG_FUNCNUM, ss.str());
	}
	//funclist
	sendData += createStartTag(TAG_FUNCLIST);
	for (int i = 0; i < mFuncDataList.size(); i++) {
		sendData += mFuncDataList[i].createSendData();
	}
	sendData += createEndTag(TAG_FUNCLIST);
	sendData += createEndTag(TAG_KERNEL);
	return sendData;
}
Example #13
0
static void findDocBookTags(void)
{
    const char *line;

    while ((line = (const char*)readLineFromInputFile()) != NULL)
    {
        const char *cp = line;

        for (; *cp != '\0'; cp++)
        {
            if (*cp == '<')
            {
                cp++;

                /* <section id="..."> */
                if (getWord("section", &cp))
                {
                    createTag(K_SECTION, cp);
                    continue;
                }
                /* <sect1 id="..."> */
                if (getWord("sect1", &cp))
                {
                    createTag(K_SECT1, cp);
                    continue;
                }
                /* <sect2 id="..."> */
                if (getWord("sect2", &cp))
                {
                    createTag(K_SECT2, cp);
                    continue;
                }
                /* <sect3 id="..."> */
                if (getWord("sect3", &cp) ||
                        getWord("sect4", &cp) ||
                        getWord("sect5", &cp))
                {
                    createTag(K_SECT3, cp);
                    continue;
                }
                /* <chapter id="..."> */
                if (getWord("chapter", &cp))
                {
                    createTag(K_CHAPTER, cp);
                    continue;
                }
                /* <appendix id="..."> */
                if (getWord("appendix", &cp))
                {
                    createTag(K_APPENDIX, cp);
                    continue;
                }
            }
        }
    }
}
Example #14
0
static void findAbaqusTags(void)
{
    const char *line;

    while ((line = (const char*)readLineFromInputFile()) != NULL)
    {
        const char *cp = line;

        for (; *cp != '\0'; cp++)
        {
            if (*cp == '*')
            {
                cp++;

                /* Parts*/
                if (getWord("part", &cp))
                {
                    createTag(K_PART, cp);
                    continue;
                }
                /* Assembly */
                if (getWord("assembly", &cp))
                {
                    createTag(K_ASSEMBLY, cp);
                    continue;
                }
                /* Steps */
                if (getWord("step", &cp))
                {
                    createTag(K_STEP, cp);
                    continue;
                }
            }
        }
    }
}
Example #15
0
std::string AbstractDynamicEntry::printToStdOut() const
{
    std::stringstream returnValue;
    returnValue << "\ttag=" << createTag(m_tag) << ", value=";
    if (hasString())
    {
        returnValue << m_stringValue;
    }
    else
    {
        returnValue << "0x" << std::hex << m_value;
    }
    returnValue << "\n";

    return returnValue.str();
}
Example #16
0
static void processTypedef (tokenInfo *const token)
{
	/*Note: At the moment, only identifies typedef name and not its contents */
	int c;

	/* Get identifiers */
	c = skipWhite (vGetc ());
	while (isIdentifierCharacter (c))
	{
		readIdentifier (token, c);
		c = skipWhite (vGetc ());
	}

	/* Skip bus width definition */
	if (c == '[')
	{
		skipPastMatch ("[]");
		c = skipWhite (vGetc ());
	}

	/* Skip typedef contents */
	if (c == '{')
	{
		skipPastMatch ("{}");
		c = skipWhite (vGetc ());
	}

	/* Skip past class parameter override */
	if (c == '#')
	{
		c = skipWhite (vGetc ());
		if (c == '(')
		{
			skipPastMatch ("()");
		}
		c = skipWhite (vGetc ());
	}

	/* Read new typedef identifier */
	if (isIdentifierCharacter (c))
	{
		readIdentifier (token, c);
	}

	/* Use last identifier to create tag */
	createTag (token);
}
Example #17
0
static void processFunction (tokenInfo *const token)
{
	int c;
	tokenInfo *classType;

	/* Search for function name
	 * Last identifier found before a '(' or a ';' is the function name */
	c = skipWhite (vGetc ());
	do
	{
		readIdentifier (token, c);
		c = skipWhite (vGetc ());
		/* Identify class type prefixes and create respective context*/
		if (isLanguage (Lang_systemverilog) && c == ':')
		{
			c = vGetc ();
			if (c == ':')
			{
				verbose ("Found function declaration with class type %s\n", vStringValue (token->name));
				classType = newToken ();
				vStringCopy (classType->name, token->name);
				classType->kind = K_CLASS;
				createContext (classType);
				currentContext->classScope = TRUE;
			}
			else
			{
				vUngetc (c);
			}
		}
	} while (c != '(' && c != ';' && c != EOF);

	if ( vStringLength (token->name) > 0 )
	{
		verbose ("Found function: %s\n", vStringValue (token->name));

		/* Create tag */
		createTag (token);

		/* Get port list from function */
		processPortList (c);
	}
}
Example #18
0
    void shouldListTagItems()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        auto t1 = Akonadi::Tag(42);
        t1.setName(QStringLiteral("42"));
        data.createTag(t1);

        auto i1 = Akonadi::Item(42);
        i1.setPayloadFromData("42");
        i1.setTag(Akonadi::Tag(42));

        // WHEN
        data.createItem(i1);

        // THEN
        QCOMPARE(data.tagItems(t1.id()).size(), 1);
        QCOMPARE(data.tagItems(t1.id()).at(0), i1);
    }
Example #19
0
void PendingSwap::Impl::initialize(ParallelSetup& pl, std::vector<char> myChainSer, nat runid) 
{
  auto tag = createTag( pl.getChainComm().getRank() ); 
  // std::cout << SyncOut() << SHOW(tag) << std::endl; 
  assert(tag < pl.getMaxTag()); 

  auto myId = _swap.getMyId(pl,runid); 
  auto remoteId = _swap.getRemoteId(pl,runid);

  auto ourRunBatch = runid % pl.getRunsParallel();
  auto myBatch = myId % pl.getChainsParallel();
  auto  remoteBatch = remoteId % pl.getChainsParallel(); 
  
  auto numInMyBatch = pl.getMesh().getNumRanksInDim(nat(ourRunBatch), nat(myBatch)); 
  auto numInRemoteBatch = pl.getMesh().getNumRanksInDim(nat(ourRunBatch), nat(remoteBatch)); 

  auto myCoords = pl.getMyCoordinates(); 

  // determine from who i receive 
  // auto srcRankInRun =  ; 
  auto remRank =  pl.getRunComm().mapToRemoteRank( pl.getRankInRun( { {nat(ourRunBatch), nat(remoteBatch), nat(myCoords[2] % numInRemoteBatch) }  } )); 

  nat myRankInRun =  pl.getRankInRun( myCoords ); 

  assert( int(myRankInRun) == pl.getRunComm().getRank() ); 

  pl.getRunComm().createRecvRequest(int(remRank), int(tag), nat(myChainSer.size()), _recvReq);

  // send stuff 
  for(nat i = 0 ; i < numInRemoteBatch; ++i)
    {
      if( i % numInMyBatch == myCoords[2])
	{
	  auto hisRemoteRank = pl.getRunComm().mapToRemoteRank( pl.getRankInRun( {{ nat(ourRunBatch), nat(remoteBatch), nat(i) } })); 
	  
	  _sentReqs.push_back(  CommRequest()  );
	  auto &&elem = _sentReqs.back();
	  pl.getRunComm().createSendRequest(myChainSer, hisRemoteRank, nat(tag) , elem); 
	}
    }
}
Example #20
0
static void processFunction (tokenInfo *const token)
{
	int c;

	/* Search for function name
	 * Last identifier found before a '(' or a ';' is the function name */
	c = skipWhite (vGetc ());
	do
	{
		readIdentifier (token, c);
		c = skipWhite (vGetc ());
	} while (c != '(' && c != ';' && c != EOF);

	if ( vStringLength (token->name) > 0 )
	{
		verbose ("Found function: %s\n", vStringValue (token->name));

		/* Create tag */
		createTag (token);

		/* Get port list from function */
		processPortList (c);
	}
}
Example #21
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    EdamProtocol *edam = EdamProtocol::GetInstance();

    ui->setupUi(this);

    pdfCache * pdf = new pdfCache(this);

    CustomNetworkAccessManager *nm = new CustomNetworkAccessManager(ui->editor->page()->networkAccessManager(), this, pdf);
    edam->setCNAM(nm);
    ui->editor->page()->setNetworkAccessManager(nm);

    Speller::setSettings(new DBSpellSettings(this, ui->editor));

    ui->editor->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->editor->load(QUrl("qrc:///html/noteajax.html"));

    jsB = new jsBridge(this, pdf);
    jsB->setWebView(ui->editor);
    enmlWritter = new enml2(this);

    connect(ui->editor->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJSObject()));

    loaded = false;
    editingEnabled = false;


    tagsActions = new QActionGroup(this);
    newTag = new TagLabel(this);
    newTag->hide();
    ui->tagsBar->addWidget(newTag);

    appIcon = QIcon(":img/hippo64.png");

    trayIcon = NULL;

    bool sysTrayEnabled = sql::readSyncStatus("systemTray", true).toBool();

    if (QSystemTrayIcon::isSystemTrayAvailable() && sysTrayEnabled)
        enableSystemTrayIcon(true);

    connect(edam, SIGNAL(AuthenticateFailed()), this, SLOT(authentificationFailed()));
    connect(edam, SIGNAL(syncFinished()), this, SLOT(syncFinished()));
    connect(edam, SIGNAL(syncStarted(int)), this, SLOT(syncStarted(int)));
    connect(edam, SIGNAL(noteGuidChanged(QString,QString)), this, SLOT(changeNoteGuid(QString,QString)));
    connect(ui->notebooks, SIGNAL(itemSelectionChanged()), this, SLOT(switchNotebook()));
    connect(ui->tags, SIGNAL(itemSelectionChanged()), this, SLOT(switchTag()));
    connect(ui->tags, SIGNAL(tagAdded(QString,QString)), this, SLOT(addTag(QString,QString)));
    connect(ui->tags, SIGNAL(tagsUpdated()), this, SLOT(updateTagsToolBar()));
    connect(ui->tags, SIGNAL(tagsUpdated()), this, SLOT(switchTag()));
    connect(ui->NotesList, SIGNAL(noteSwitched()), this, SLOT(switchNote()));
    connect(ui->action_Abaut, SIGNAL(triggered()), this, SLOT(loadAboutInfo()));
    connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeWindow()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionSync, SIGNAL(triggered()), this, SLOT(sync()));
    connect(ui->noteTitle, SIGNAL(textEdited(QString)), this, SLOT(noteTitleChange(QString)));
    connect(ui->actionAccount_info, SIGNAL(triggered()), this, SLOT(showUserInfo()));
    connect(ui->editor->page(), SIGNAL(linkClicked(QUrl)), this, SLOT(openURL(QUrl)));
    connect(ui->editor->page(), SIGNAL(microFocusChanged()), this, SLOT(updateEditButtonsState()));
    connect(ui->editor, SIGNAL(selectionChanged()), this, SLOT(updateSelectionButtonsState()));
    connect(ui->editor->page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
    connect(ui->editor, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(editorContextMenuRequested(QPoint)));
    connect(ui->editor, SIGNAL(fileInserted(QString)), this, SLOT(insertFile(QString)));
    connect(ui->notebooks, SIGNAL(noteMoved(QString,QString)), this, SLOT(moveNote(QString,QString)));
    connect(ui->notebooks, SIGNAL(noteDeleted(QString)), this, SLOT(deleteNote(QString)));
    connect(ui->notebooks, SIGNAL(noteRestored(QString,QString)), this, SLOT(restoreNote(QString,QString)));
    connect(ui->NotesList, SIGNAL(noteDeleted(QString)), this, SLOT(deleteNote(QString)));
    connect(ui->NotesList, SIGNAL(noteRestored(QString)), this, SLOT(restoreNote(QString)));
    connect(ui->NotesList, SIGNAL(noteCreated()), this, SLOT(newNote()));
    connect(ui->NotesList, SIGNAL(reloaded()), this, SLOT(updateCurrentNoteName()));
    connect(ui->editButton, SIGNAL(toggled(bool)), this, SLOT(setEditable(bool)));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->toolBox, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
    connect(ui->editor->page(), SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(linkHovered(QString,QString,QString)));
    connect(jsB, SIGNAL(hintMessage(QString,int)), ui->statusbar, SLOT(showMessage(QString,int)));
    connect(jsB, SIGNAL(noteChanged(QString)), this, SLOT(updateTagsToolBar(QString)));
    connect(jsB, SIGNAL(activeNoteSelectionChanged(bool)), ui->actionDelete_Note, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(activeNoteSelectionChanged(bool)), ui->editButton, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(editingStarted(bool)), ui->editButton, SLOT(setChecked(bool)));
    connect(jsB, SIGNAL(titleUpdated(QString,QString)), this, SLOT(updateNoteTitle(QString,QString)));
    connect(jsB, SIGNAL(conflictAdded(qint64,QString,bool)), this, SLOT(addConflict(qint64,QString,bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionNote_Info, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionExport, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionPrint, SLOT(setEnabled(bool)));
    connect(ui->editor, SIGNAL(tagUpdated(QString,bool)), this, SLOT(updateTag(QString,bool)));
    connect(tagsActions, SIGNAL(triggered(QAction*)), this, SLOT(tagClicked(QAction*)));
    connect(newTag, SIGNAL(tagCreated(QString)), this, SLOT(createTag(QString)));
    connect(ui->actionKeep_only_this_Version, SIGNAL(triggered()), this, SLOT(keepThisVersion()));
    connect(ui->actionNote_Info, SIGNAL(triggered()), this, SLOT(showNoteInfo()));
    connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(exportNote()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(this, SIGNAL(titleChanged(QString,QString)), jsB, SIGNAL(titleChanged(QString,QString)));


    setWindowIcon(appIcon);
    setWindowTitle("Hippo Notes");

    setTabOrder(ui->noteTitle, ui->editor);

    ui->notebooks->setSortingEnabled(true);
    ui->notebooks->sortByColumn(0, Qt::AscendingOrder);
    ui->editBar->setVisible(false);

    ui->mainToolBar->addAction(ui->actionNew_Note);
    ui->mainToolBar->addAction(ui->actionSync);

    QFontComboBox *font = new QFontComboBox(this);
    font->setDisabled(true);
    font->setFontFilters(QFontComboBox::ScalableFonts);
    font->setEditable(false);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), font, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(updateFont(QFont)), font, SLOT(setCurrentFont(QFont)));
    connect(font, SIGNAL(activated(QString)), this, SLOT(changeFont(QString)));
    ui->editBar->addWidget(font);

    QComboBox *fontSize = new QComboBox(this);
    fontSize->setDisabled(true);
    fontSize->setEditable(false);
    for (int i = 1; i <= 7; i++)
        fontSize->addItem(QString::number(i));
    connect(this, SIGNAL(editButtonsStateChanged(bool)), fontSize, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(updateFontSize(int)), fontSize, SLOT(setCurrentIndex(int)));
    connect(fontSize, SIGNAL(activated(QString)), this, SLOT(changeFontSize(QString)));
    ui->editBar->addWidget(fontSize);

    QAction *boldIco = ui->editor->pageAction(QWebPage::ToggleBold);
    boldIco->setIcon(QIcon::fromTheme("format-text-bold"));
    ui->editBar->addAction(boldIco);

    QAction *italicIco = ui->editor->pageAction(QWebPage::ToggleItalic);
    italicIco->setIcon(QIcon::fromTheme("format-text-italic"));
    ui->editBar->addAction(italicIco);

    QAction *underlineIco = ui->editor->pageAction(QWebPage::ToggleUnderline);
    underlineIco->setIcon(QIcon::fromTheme("format-text-underline"));
    ui->editBar->addAction(underlineIco);

    QAction *strikethroughIco = ui->editor->pageAction(QWebPage::ToggleStrikethrough);
    strikethroughIco->setIcon(QIcon::fromTheme("format-text-strikethrough"));
    ui->editBar->addAction(strikethroughIco);

    ui->editBar->addSeparator();

    QAction *undoIco = ui->editor->pageAction(QWebPage::Undo);
    undoIco->setIcon(QIcon::fromTheme("edit-undo"));
    undoIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
    ui->editBar->addAction(undoIco);
    ui->menu_Edit->addAction(undoIco);

    QAction *redoIco = ui->editor->pageAction(QWebPage::Redo);
    redoIco->setIcon(QIcon::fromTheme("edit-redo"));
    redoIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z));
    ui->editBar->addAction(redoIco);
    ui->menu_Edit->addAction(redoIco);

    ui->editBar->addSeparator();

    QAction *rformatIco = ui->editor->pageAction(QWebPage::RemoveFormat);
    rformatIco->setIcon(QIcon::fromTheme("edit-clear"));
    ui->editBar->addAction(rformatIco);

    ui->editBar->addSeparator();

    QAction *leftIco = ui->editor->pageAction(QWebPage::AlignLeft);
    leftIco->setIcon(QIcon::fromTheme("format-justify-left"));
    ui->editBar->addAction(leftIco);

    QAction *centerIco = ui->editor->pageAction(QWebPage::AlignCenter);
    centerIco->setIcon(QIcon::fromTheme("format-justify-center"));
    ui->editBar->addAction(centerIco);

    QAction *rightIco = ui->editor->pageAction(QWebPage::AlignRight);
    rightIco->setIcon(QIcon::fromTheme("format-justify-right"));
    ui->editBar->addAction(rightIco);

    QAction *fillIco = ui->editor->pageAction(QWebPage::AlignJustified);
    fillIco->setIcon(QIcon::fromTheme("format-justify-fill"));
    ui->editBar->addAction(fillIco);

    ui->editBar->addSeparator();

    QAction *indentIco = ui->editor->pageAction(QWebPage::Indent);
    indentIco->setIcon(QIcon::fromTheme("format-indent-more"));
    ui->editBar->addAction(indentIco);

    QAction *outdentIco = ui->editor->pageAction(QWebPage::Outdent);
    outdentIco->setIcon(QIcon::fromTheme("format-indent-less"));
    ui->editBar->addAction(outdentIco);

    QAction *superscriptIco = ui->editor->pageAction(QWebPage::ToggleSuperscript);
    superscriptIco->setIcon(QIcon::fromTheme("format-text-superscript"));
    ui->editBar->addAction(superscriptIco);

    QAction *subscriptIco = ui->editor->pageAction(QWebPage::ToggleSubscript);
    subscriptIco->setIcon(QIcon::fromTheme("format-text-subscript"));
    ui->editBar->addAction(subscriptIco);

    QAction *unorderedIco = ui->editor->pageAction(QWebPage::InsertUnorderedList);
    unorderedIco->setIcon(QIcon::fromTheme("format-list-unordered"));
    ui->editBar->addAction(unorderedIco);

    QAction *orderedIco = ui->editor->pageAction(QWebPage::InsertOrderedList);
    orderedIco->setIcon(QIcon::fromTheme("format-list-ordered"));
    ui->editBar->addAction(orderedIco);

    QAction *lineIco = new QAction("Insert horizontal line", this);
    lineIco->setIcon(QIcon::fromTheme("insert-horizontal-rule"));
    lineIco->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), lineIco, SLOT(setEnabled(bool)));
    connect(lineIco, SIGNAL(triggered()), this, SLOT(insertHorizontalLine()));
    ui->editBar->addAction(lineIco);

    ui->menu_Edit->addSeparator();

    QAction *cutIco = ui->editor->pageAction(QWebPage::Cut);
    cutIco->setIcon(QIcon::fromTheme("edit-cut"));
    cutIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X));
    ui->menu_Edit->addAction(cutIco);

    QAction *copyIco = ui->editor->pageAction(QWebPage::Copy);
    copyIco->setIcon(QIcon::fromTheme("edit-copy"));
    copyIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
    ui->menu_Edit->addAction(copyIco);

    QAction *pasteIco = ui->editor->pageAction(QWebPage::Paste);
    pasteIco->setIcon(QIcon::fromTheme("edit-paste"));
    pasteIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
    ui->menu_Edit->addAction(pasteIco);

    QAction *pasteSpecialIco = ui->editor->pageAction(QWebPage::PasteAndMatchStyle);
    pasteSpecialIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
    ui->menu_Edit->addAction(pasteSpecialIco);

    ui->menu_Edit->addSeparator();

    QAction *insertUrlIco = new QAction("Create link", this);
    insertUrlIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
    insertUrlIco->setDisabled(true);
    insertUrlIco->setIcon(QIcon::fromTheme("insert-link"));
    connect(this, SIGNAL(selectionButtonsStateChanged(bool)), insertUrlIco, SLOT(setDisabled(bool)));
    connect(insertUrlIco, SIGNAL(triggered()), this, SLOT(insertUrl()));
    ui->menu_Edit->addAction(insertUrlIco);

    QAction *todoIco = new QAction("Insert To-do Checkbox", this);
    todoIco->setIcon(QIcon::fromTheme("checkbox"));
    todoIco->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), todoIco, SLOT(setEnabled(bool)));
    connect(todoIco, SIGNAL(triggered()), jsB, SIGNAL(insertToDo()));
    ui->menu_Edit->addAction(todoIco);

    QAction *insertImage = new QAction("Insert Image", this);
    insertImage->setIcon(QIcon::fromTheme("insert-image"));
    insertImage->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), insertImage, SLOT(setEnabled(bool)));
    connect(insertImage, SIGNAL(triggered()), this, SLOT(insertImg()));
    ui->menu_Edit->addAction(insertImage);

    QAction *insertFile = new QAction("Insert File", this);
    insertFile->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), insertFile, SLOT(setEnabled(bool)));
    connect(insertFile, SIGNAL(triggered()), this, SLOT(insertFile()));
    ui->menu_Edit->addAction(insertFile);

    QAction *encryptIco = new QAction("Encrypt Selected Text...", this);
    encryptIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_X));
    encryptIco->setDisabled(true);
    encryptIco->setIcon(QIcon::fromTheme("document-edit-encrypt"));
    connect(this, SIGNAL(selectionButtonsStateChanged(bool)), encryptIco, SLOT(setDisabled(bool)));
    connect(encryptIco, SIGNAL(triggered()), jsB, SIGNAL(encryptText()));
    ui->menu_Edit->addAction(encryptIco);

    ui->menu_Edit->addSeparator();

    QAction *options = new QAction("&Options...", this);
    options->setIcon(QIcon::fromTheme("preferences-other"));
    connect(options, SIGNAL(triggered()), this, SLOT(showOptions()));
    ui->menu_Edit->addAction(options);


    clearConflictBar();
    connect(jsB, SIGNAL(showConflict()), ui->conflictBar, SLOT(show()));
    connect(jsB, SIGNAL(showConflict()), ui->conflictBarBottom, SLOT(show()));

    conflictsGroup = new QActionGroup(this);
    connect(conflictsGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeNoteVersion(QAction*)));

    searchIndex = new SearchIndex(this);
    connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(search()));
    connect(edam, SIGNAL(syncFinished()), searchIndex, SLOT(buildSearchIndex()));
    connect(jsB, SIGNAL(noteUpdated(QString)), searchIndex, SLOT(updateNoteIndex(QString)));
    connect(edam, SIGNAL(noteUpdated(QString)), searchIndex, SLOT(dropNoteIndex(QString)));
    connect(ui->searchInput, SIGNAL(returnPressed()), this, SLOT(search()));

    QByteArray mainWindowGeometry = sql::readSyncStatus("mainWindowGeometry").toString().toLatin1();
    if (!mainWindowGeometry.isEmpty())
        restoreGeometry(QByteArray::fromBase64(mainWindowGeometry));

    QByteArray mainWidgetsSplitterState = sql::readSyncStatus("mainWidgetsSplitterState").toString().toLatin1();
    if (!mainWidgetsSplitterState.isEmpty())
        ui->mainWidgetsSplitter->restoreState(QByteArray::fromBase64(mainWidgetsSplitterState));

    //showWindow();
    edam->init();
}
void Engine::createExifTagNode()
{
    TagNode* exifTagNode = createTag(0, TagNode::TYPE_TITLE, i18n("EXIF"), i18n("All EXIF data read from the image."), Constants::ICON_TAG_EXIF);
    m_exifTitleTag = dynamic_cast<TagNodeTitle*>(exifTagNode);
    m_exifTitleTag->setReadonly(true);
}
Example #23
0
static void findTag (tokenInfo *const token)
{
	if (currentContext->kind != K_UNDEFINED)
	{
		/* Drop context, but only if an end token is found */
		dropContext (token);
	}

	if (token->kind == K_CONSTANT && vStringItem (token->name, 0) == '`')
	{
		/* Bug #961001: Verilog compiler directives are line-based. */
		int c = skipWhite (vGetc ());
		readIdentifier (token, c);
		createTag (token);
		/* Skip the rest of the line. */
		do {
			c = vGetc();
		} while (c != EOF && c != '\n');
		vUngetc (c);
	}
	else if (token->kind == K_BLOCK)
	{
		/* Process begin..end blocks */
		processBlock (token);
	}
	else if (token->kind == K_FUNCTION || token->kind == K_TASK)
	{
		/* Functions are treated differently because they may also include the
		 * type of the return value.
		 * Tasks are treated in the same way, although not having a return
		 * value.*/
		processFunction (token);
	}
	else if (token->kind == K_ASSERTION)
	{
		if (vStringLength (currentContext->blockName) > 0)
		{
			vStringCopy (token->name, currentContext->blockName);
			createTag (token);
			skipToSemiColon ();
		}
	}
	else if (token->kind == K_TYPEDEF)
	{
		processTypedef (token);
	}
	else if (token->kind == K_CLASS)
	{
		processClass (token);
	}
	else if (token->kind == K_IGNORE && isSingleStatement (token))
	{
		currentContext->singleStat = TRUE;
	}
	else if (isVariable (token))
	{
		int c = skipWhite (vGetc ());

		tagNameList (token, c);
	}
	else if (token->kind != K_UNDEFINED && token->kind != K_IGNORE)
	{
		int c = skipWhite (vGetc ());

		if (isIdentifierCharacter (c))
		{
			readIdentifier (token, c);
			while (getKind (token) == K_IGNORE)
			{
				c = skipWhite (vGetc ());
				readIdentifier (token, c);
			}
			createTag (token);

			/* Get port list if required */
			c = skipWhite (vGetc ());
			if (c == '(' && hasSimplePortList (token))
			{
				processPortList (c);
			}
			else
			{
				vUngetc (c);
			}
		}
	}
}
Example #24
0
static void tagNameList (tokenInfo* token, int c)
{
	verilogKind localKind;
	boolean repeat;

	/* Many keywords can have bit width.
	*   reg [3:0] net_name;
	*   inout [(`DBUSWIDTH-1):0] databus;
	*/
	if (c == '(')
		c = skipPastMatch ("()");
	c = skipWhite (c);
	if (c == '[')
		c = skipPastMatch ("[]");
	c = skipWhite (c);
	if (c == '#')
	{
		c = vGetc ();
		if (c == '(')
			c = skipPastMatch ("()");
	}
	c = skipWhite (c);

	do
	{ 
		repeat = FALSE;

		while (c == '`' && c != EOF)
		{
			c = skipMacro (c);
		}
		if (isIdentifierCharacter (c))
		{
			readIdentifier (token, c);
			localKind = getKind (token);
			/* Create tag in case name is not a known kind ... */
			if (localKind == K_UNDEFINED)
			{
				createTag (token);
			}
			/* ... or else continue searching for names */
			else
			{
				/* Update kind unless it's a port or an ignored keyword */
				if (token->kind != K_PORT && localKind != K_IGNORE)
				{
					token->kind = localKind;
				}
				repeat = TRUE;
			}
		}
		else
			break;
		c = skipWhite (vGetc ());

		if (c == '[')
			c = skipPastMatch ("[]");
		c = skipWhite (c);
		if (c == '=')
		{
			c = skipWhite (vGetc ());
			if (c == '{')
				skipPastMatch ("{}");
			else
			{
				/* Skip until end of current name, kind or parameter list definition */
				do
					c = vGetc ();
				while (c != EOF && c != ','  &&  c != ';' && c != ')');
			}
		}
		if (c == ',')
		{
			c = skipWhite (vGetc ());
			repeat = TRUE;
		}
	} while (repeat);
	vUngetc (c);
}
Example #25
0
static void processClass (tokenInfo *const token)
{
	/*Note: At the moment, only identifies typedef name and not its contents */
	int c;
	tokenInfo *extra;
	tokenInfo *parameters = NULL;

	/* Get identifiers */
	c = skipWhite (vGetc ());
	if (isIdentifierCharacter (c))
	{
		readIdentifier (token, c);
		c = skipWhite (vGetc ());
	}

	/* Find class parameters list */
	if (c == '#')
	{
		c = skipWhite (vGetc ());
		if (c == '(')
		{
			parameters = newToken ();
			do
			{
				c = skipWhite (vGetc ());
				readIdentifier (parameters, c);
				updateKind (parameters);
				verbose ("Found class parameter %s\n", vStringValue (parameters->name));
				if (parameters->kind == K_UNDEFINED)
				{
					parameters->kind = K_CONSTANT;
					parameters = pushToken (parameters, newToken ());
					c = vGetc();
					while (c != ',' && c != ')' && c != EOF)
					{
						c = vGetc();
					}
				}
			} while (c != ')' && c != EOF);
			c = vGetc ();
			parameters = popToken (parameters);
		}
		c = skipWhite (vGetc ());
	}

	/* Search for inheritance information */
	if (isIdentifierCharacter (c))
	{
		extra = newToken ();

		readIdentifier (extra, c);
		c = skipWhite (vGetc ());
		if (strcmp (vStringValue (extra->name), "extends") == 0)
		{
			readIdentifier (extra, c);
			vStringCopy (token->inheritance, extra->name);
			verbose ("Inheritance %s\n", vStringValue (token->inheritance));
		}
		deleteToken (extra);
	}

	/* Use last identifier to create tag */
	createTag (token);

	/* Add parameter list */
	while (parameters)
	{
		createTag (parameters);
		parameters = popToken (parameters);
	}
}
Example #26
0
static void processPortList (int c)
{
	if ((c = skipWhite (c)) == '(')
	{
		tokenInfo *token = newToken ();

		/* Get next non-whitespace character after ( */
		c = skipWhite (vGetc ());

		while (c != ';' && c != EOF)
		{
			if (c == '[')
			{
				c = skipPastMatch ("[]");
			}
			else if (c == '(')
			{
				c = skipPastMatch ("()");
			}
			else if (c == '{')
			{
				c = skipPastMatch ("{}");
			}
			else if (c == '`')
			{
				c = skipMacro (c);
			}
			else if (c == '=')
			{
				/* Search for next port or end of port declaration */
				while (c != ',' && c != ')' && c != EOF)
				{
					c = skipWhite (vGetc ());
				}
			}
			else if (isIdentifierCharacter (c))
			{
				readIdentifier (token, c);
				updateKind (token);
				if (token->kind == K_UNDEFINED)
				{
					/* Only add port name if it is the last keyword.
					 * First keyword can be a dynamic type, like a class name */
					c = skipWhite (vGetc ());
					if (! isIdentifierCharacter (c) || c == '`')
					{
						verbose ("Found port: %s\n", vStringValue (token->name));
						token->kind = K_PORT;
						createTag (token);
					}
				}
				else
				{
					c = skipWhite (vGetc ());
				}
			}
			else
			{
				c = skipWhite (vGetc ());
			}
		}

		if (! isIdentifierCharacter (c)) vUngetc (c);

		deleteToken (token);
	}
}
Example #27
0
static void processTypedef (tokenInfo *const token)
{
	/*Note: At the moment, only identifies typedef name and not its contents */
	int c;

	/* Get typedef type */
	c = skipWhite (vGetc ());
	if (isIdentifierCharacter (c))
	{
		readIdentifier (token, c);
		/* A typedef class is just a prototype */
		if (strcmp (vStringValue (token->name), "class") == 0)
		{
			currentContext->prototype = TRUE;
		}
	}

	/* Skip remaining identifiers */
	c = skipWhite (vGetc ());
	while (isIdentifierCharacter (c))
	{
		readIdentifier (token, c);
		c = skipWhite (vGetc ());
	}

	/* Skip bus width definition */
	if (c == '[')
	{
		skipPastMatch ("[]");
		c = skipWhite (vGetc ());
	}

	/* Skip typedef contents */
	if (c == '{')
	{
		skipPastMatch ("{}");
		c = skipWhite (vGetc ());
	}

	/* Skip past class parameter override */
	if (c == '#')
	{
		c = skipWhite (vGetc ());
		if (c == '(')
		{
			skipPastMatch ("()");
			c = skipWhite (vGetc ());
		}
	}

	/* Read typedef name */
	if (isIdentifierCharacter (c))
	{
		readIdentifier (token, c);
	}
	else
	{
		vUngetc (c);
	}
	/* Use last identifier to create tag */
	createTag (token);
}