Esempio n. 1
0
void MainWindow::init()
{
//QTime t = QTime::currentTime();
	m_tikzEditorView->setPasteEnabled();

	TikzCommandInserter::loadCommands();
//qCritical() << "TikzCommandInserter::loadCommands()" << t.msecsTo(QTime::currentTime());
	m_commandInserter->setEditor(m_tikzEditorView->editor());
	if (m_insertAction)
		m_insertAction->setMenu(m_commandInserter->getMenu());
	else
		m_commandInserter->showItemsInDockWidget();
//qCritical() << "setMenu()" << t.msecsTo(QTime::currentTime());
	m_tikzHighlighter->setHighlightingRules(m_commandInserter->getHighlightingRules());
//qCritical() << "setHighlightingRules()" << t.msecsTo(QTime::currentTime());
//	m_tikzHighlighter->rehighlight(); // avoid that textEdit emits the signal contentsChanged() when it is still empty
	connect(m_userCommandInserter, SIGNAL(insertTag(QString)), m_commandInserter, SLOT(insertTag(QString)));

	// the following disconnect ensures that the following signal is not unnecessarily triggered twice when a file is loaded in a new window
	disconnect(m_tikzEditorView, SIGNAL(contentsChanged()),
	           m_tikzPreviewController, SLOT(regeneratePreviewAfterDelay()));

	applySettings(); // must do this in order to load the command completions
//qCritical() << "applySettings()" << t.msecsTo(QTime::currentTime());

	if (m_buildAutomatically)
		connect(m_tikzEditorView, SIGNAL(contentsChanged()),
		        m_tikzPreviewController, SLOT(regeneratePreviewAfterDelay()));

	if (m_tikzPreviewController->tempDir().isEmpty()) // then the temporary directory could not be created
		m_logTextEdit->updateLog(tr("Error: unable to create a temporary directory in \"%1\". This program will not work!").arg(m_tikzPreviewController->tempDirLocation()), true);
//qCritical() << "init()" << t.msecsTo(QTime::currentTime());
}
void TikzCommandInserter::insertTag(QListWidgetItem *item)
{
	if (item && !item->font().bold() && !item->text().isEmpty())
	{
		const int num = item->data(Qt::UserRole).toInt();
		const TikzCommand cmd = m_tikzCommandsList.at(num);
		emit showStatusMessage(cmd.description, 0);
		insertTag(cmd.command, cmd.dx, cmd.dy);
	}
}
Esempio n. 3
0
	void LJBloggingPlatform::handleAddLJUser ()
	{
		auto rootWM = Core::Instance ().GetCoreProxy ()->GetRootWindowsManager ();
		QString name = QInputDialog::getText (rootWM->GetPreferredWindow (),
				tr ("Add LJ User"),
				tr ("Enter LJ user name:"));
		if (name.isEmpty ())
			return;

		emit insertTag (QString ("<lj user=\"%1\" />").arg (name));
	}
void TikzCommandInserter::insertTag()
{
	QAction *action = qobject_cast<QAction*>(sender());
	if (action)
	{
		const int num = action->data().toInt();
		const TikzCommand cmd = m_tikzCommandsList.at(num);
		emit showStatusMessage(cmd.description, 0);
		insertTag(cmd.command, cmd.dx, cmd.dy);
	}
}
Esempio n. 5
0
void BaseTreeView::slotInsertTag()
{
  if (currentItem() )
  {
    DirInfo dirInfo;

    dirInfo.mimeType = "";
    dirInfo.preText = "";
    dirInfo.postText = "";
    emit insertTag( currentURL(), dirInfo );
  }
}
Esempio n. 6
0
bool TagDB::insertTag(string tagID, string tagName, ItemTagDB& itemTagDB) {
    if (grassDB.check(tagID) != -1) {
        return false;
    }
    Tag newTag;
    newTag.tagID = tagID;
    newTag.tagName = tagName;
    newTag.viewCounts = 0;
    newTag.dateAdd = Utils::getTimeNow();
    newTag.dateUpdate = "Today";
    return insertTag(newTag, itemTagDB);
}
Esempio n. 7
0
	void LJBloggingPlatform::handleAddLJPoll ()
	{
		PollDialog pollDlg;
		if (pollDlg.exec () == QDialog::Rejected)
			return;

		QStringList pqParts;
		QString pqPart = QString ("<lj-pq type=\"%1\" %2>%3%4</lj-pq>");
		bool isPqParam = false;
		for (const auto& pollType : pollDlg.GetPollTypes ())
		{
			const auto& map = pollDlg.GetPollFields (pollType);
			QStringList pqParams;
			if (pollType == "check" ||
					pollType == "radio" ||
					pollType == "drop")
			{
				isPqParam = false;
				for (const auto& value : map.values ())
					pqParams << QString ("<lj-pi>%1</lj-pi>")
							.arg (value.toString ());
			}
			else
			{
				isPqParam = true;
				for (const auto& key : map.keys ())
					pqParams << QString ("%1=\"%2\"")
							.arg (key)
							.arg (map [key].toString ());
			}
			pqParts << pqPart
					.arg (pollType)
					.arg (isPqParam ? pqParams.join (" ") : QString ())
					.arg (pollDlg.GetPollQuestion (pollType))
					.arg (!isPqParam ? pqParams.join (" ") : QString ());
		}

		QString pollPart = QString ("<lj-poll name=\"%1\" whovote=\"%2\" whoview=\"%3\">%4</lj-poll>")
				.arg (pollDlg.GetPollName ())
				.arg (pollDlg.GetWhoCanVote ())
				.arg (pollDlg.GetWhoCanView ())
				.arg (pqParts.join (""));
		emit insertTag (pollPart);
	}
QMenu *TikzCommandInserter::getMenu(const TikzCommandList &commandList)
{
	QMenu *menu = new QMenu(commandList.title, m_parentWidget);
	const int numOfCommands = commandList.commands.size();
	QAction *action = new QAction("test", menu);
	int whichSection = 0;

	// get left margin of the menu (to be added to the minimum width of the menu)
	menu->addAction(action);
	QFont actionFont = action->font();
	actionFont.setPointSize(actionFont.pointSize() - 1);
	QFontMetrics actionFontMetrics(actionFont);
	int menuLeftMargin = menu->width() - actionFontMetrics.boundingRect(action->text()).width();
	menu->removeAction(action);
	int menuMinimumWidth = 0;

	for (int i = 0; i < numOfCommands; ++i)
	{
		const QString name = commandList.commands.at(i).name;
		if (name.isEmpty()) // add separator or submenu
		{
			if (commandList.commands.at(i).type == 0)
			{
				action = new QAction(menu);
				action->setSeparator(true);
				menu->addAction(action);
			}
			else // type == -1, so add submenu; this assumes that the i-th command with type == -1 corresponds with the i-th submenu (see getCommands())
			{
				menu->addMenu(getMenu(commandList.children.at(whichSection)));
				++whichSection;
			}
		}
		else // add command
		{
			action = new QAction(name, menu);
			action->setData(commandList.commands.at(i).number); // link to the corresponding item in m_tikzCommandsList
			action->setStatusTip(commandList.commands.at(i).description);
			menuMinimumWidth = qMax(menuMinimumWidth, actionFontMetrics.boundingRect(commandList.commands.at(i).description).width());
			connect(action, SIGNAL(triggered()), this, SLOT(insertTag()));
			connect(action, SIGNAL(hovered()), this, SLOT(updateDescriptionMenuItem()));
			menu->addAction(action);
		}
	}

	// if the menu does not only contain submenus, then we add a menu item
	// at the bottom of the menu which shows the description of the currently
	// highlighted menu item
	if (whichSection < menu->actions().size())
	{
		action = new QAction(this);
		action->setSeparator(true);
		menu->addAction(action);

		action = new QAction(this);
		QFont actionFont = action->font();
		actionFont.setPointSize(actionFont.pointSize() - 1);
		action->setFont(actionFont);
		connect(action, SIGNAL(triggered()), this, SLOT(insertTag()));
		menu->addAction(action);

		// make sure that the menu width does not change when the content
		// of the above menu item changes
		menu->setMinimumWidth(menuMinimumWidth + menuLeftMargin);
	}

	return menu;
}
Esempio n. 9
0
 void appendTag(tag *tag) {
   insertTag(Text.end(),tag);
   }
Esempio n. 10
0
bool PropertyBag::loadMergeFromString(const string &data) {
	enum eElanPropBagReadState {
		SearchingForOpenTag,
		ReadingOpenTag,
		ReadingTagContents
	} curstate = SearchingForOpenTag;
	
	string tagname;
	string tagvalue;
	string closetag;
	
	unsigned char previous=0;
	string possibleClosingTag;
	bool isPossibleClosingTag=false;
	
	for (string::const_iterator iter = data.begin(); iter != data.end(); ++iter) {
		const unsigned char b = (unsigned char)(*iter);
		
		switch (curstate) {
		case SearchingForOpenTag: {
			if (b == '<') {
				// we've found our open tag!
				curstate = ReadingOpenTag;
			}
		}
		break;
		
		case ReadingOpenTag: {
			if (b == '>') {
				// end of tag
				curstate = ReadingTagContents;
				closetag = "</" + tagname + ">";
			} else {
				// add the character to the name of the tag
				tagname += b;
			}
		}
		break;
		
		case ReadingTagContents: {
			// Add the character to the contents of the tag
			tagvalue += b;
			
			// If we are possibly reading the closing tag now
			if (isPossibleClosingTag) {
				// Build the string for what may be the closing tag
				possibleClosingTag += b;
				
				// Otherwise, search for the real closing tag
				if (possibleClosingTag == closetag) {
					// Remove that closing tag from the tag contents
					tagvalue = replace(tagvalue, closetag, "");
					
					// Put the completed tag into the bag here
					insertTag(tagname, tagvalue);
					
					// Reset the state
					curstate = SearchingForOpenTag;
					tagname = "";
					tagvalue = "";
				}
				
				// Has it become impossible that this is the closing tag?
				if (b == '>') {
					isPossibleClosingTag = false;
				}
			}
			
			// Have we begun to encounter what may be the closing tag?
			if (previous == '<' && b == '/') {
				isPossibleClosingTag = true;
				possibleClosingTag = "</";
			}
		}
		break;
		}
		; // end switch
		
		previous = b;
	}
	
	return(true);
}
Esempio n. 11
0
/**
 * Them moi mot tag.
 * @param tagName
 * @return bool
 */
bool TagDB::insertTag(string tagName, ItemTagDB& itemTagDB) {
    int64_t temp = Utils::convertStringToInt(LASTID);
    string lastID = Utils::convertIntToString(temp + 1);
    return insertTag(lastID, tagName, itemTagDB);
}