Exemplo n.º 1
0
// Returns a heading item with the given text. Will create and add a new heading under \c parentIndex at \c position if no heading with that text exists yet.  (Use -1 for \c position to append at the bottom.) If \c text is empty, will return the top-level (invisible root) item.
QStandardItem* AMWindowPaneModel::headingItem(const QString& text, QModelIndex parentIndex, int position) {
	if(text.isEmpty())
		return invisibleRootItem();

	QList<QStandardItem*> searchItems = this->findItems(text);
	foreach(QStandardItem* i, searchItems) {
		if(isHeading(i->index()))
			return i;
	}

	// Didn't find it... time to make it:
	QStandardItem* newHeading = new QStandardItem(text);
	newHeading->setFlags(Qt::ItemIsEnabled);	// enabled, but should not be selectable
	// graphics defaults:
	QFont font = QFont("Lucida Grande", 10, QFont::Bold);
	font.setCapitalization(QFont::AllUppercase);
	newHeading->setFont(font);
	newHeading->setData(QBrush(QColor::fromRgb(100, 109, 125)), Qt::ForegroundRole);

	QStandardItem* parent = itemFromIndex(parentIndex);
	if(parent) {
		if(position < 0 || position > parent->rowCount())
			position = parent->rowCount();
		parent->insertRow(position, newHeading);
	}
	else {
		if(position < 0 || position > rowCount())
			position = rowCount();
		insertRow(position, newHeading);
	}

	return newHeading;
}
Exemplo n.º 2
0
//!xerces start element event
void amis::io::NccFileReader::startElement(const   XMLCh* const    uri,
        const   XMLCh* const    localname,
        const   XMLCh* const    qname,
        const   Attributes&	attributes)
{
    //get the name of the node from xerces
    char *node_name_ = XMLString::transcode(qname);
    string node_name;
    node_name.assign(node_name_);
    XMLString::release(&node_name_);

    int lvl = isHeading(node_name);
    //if this is a heading node
    if (lvl > 0)
    {
        processHeading(lvl, &attributes);
    }
    else if(node_name.compare("span") == 0)
    {
        processSpan(&attributes);
    }
    else if(node_name.compare("div") == 0)
    {
        processDiv(&attributes);
    }
    else if(node_name.compare("meta") == 0 ||
            node_name.substr(0, 3).compare("dc:") == 0)
    {
        processMetadata(node_name, &attributes);
    }

    //special condition for links due to the nested <a> element
    else if (node_name.compare("a") == 0)
    {
        string href;
        href.assign(SimpleAttrs::get("href", &attributes));

        mbFlag_GetChars = true;
        mTempChars.erase();

        if (mListType == 0)
        {
            mpCurrentNavPoint->setContent(href);
        }
        else if (mListType == 1)
        {
            //nav list
            mpCurrentNavTarget->setContent(href);
        }
        else if (mListType == 2)
        {
            //page list
            mpCurrentPageTarget->setContent(href);
        }
    }

}
Exemplo n.º 3
0
bool AccessibilityObject::allowsTextRanges() const
{
    // Check type for the AccessibilityObject.
    if (isTextControl() || isWebArea() || isGroup() || isLink() || isHeading() || isListItem() || isTableCell())
        return true;

    // Check roles as the last fallback mechanism.
    AccessibilityRole role = roleValue();
    return role == ParagraphRole || role == LabelRole || role == DivRole || role == FormRole;
}
Exemplo n.º 4
0
bool AMWindowPaneModel::removeHeadingItem(const QString &text)
{
	if(text.isEmpty())
		return false;

	QStandardItem* headingItem = 0;
	QList<QStandardItem*> searchItems = findItems(text);
	foreach(QStandardItem* i, searchItems) {
		if(isHeading(i->index())) {
			headingItem = i;
			break;
		}
	}

	if (headingItem)
		return removeRow(headingItem->row());
	else
		return false;
}
Exemplo n.º 5
0
bool textSource::segment(int level
                        ,int sstatus
                        ,bool PrevIsField  // True if previous sibling block contains a \field
                        ,charprops CharProps
                        )
    {

    wint_t ch;
    curr_pos = Ftell(sourceFile);// After parsing a html-tag, seeking to curr_pos brings you back to the position where the parsed sequence started.                   

    if(Option.keepEOLsequence)
        {
        copyEOLsequence();
        // SourceFile is rewinded
        }

    do
        {
        ch = Getc(sourceFile);
        end_offset = Ftell(sourceFile);
        if(curr_pos >= tagendpos)
            {
            // We are not inside an HTML-tag.
            if(flgs.inhtmltag)
                {
                flgs.firstafterhtmltag = true;
                flgs.inhtmltag = false;
                }
            // Check whether a well-formed HTML tag is ahead. Returns sourceFile
            // in same file position.
            flgs.htmltagcoming = isHTMLtagComing(ch);
//            assert(new_pos == Ftell(sourceFile));
            assert(end_offset == Ftell(sourceFile));
            }
        else if(flgs.htmltagcoming)
            {
            // We are leaving an HTML-tag and entering a new one.
            flgs.inhtmltag = true;
            flgs.htmltagcoming = false;
            }
        /* Scan in advance, checking whether the line to come is a heading and 
        therefore must be preceded with a newline (WritePar will then be set to 
        true.)
        */

        if(  ch ==  '\n'
          || ch == '\r'
          || ch == WEOF
          || ch == 26
          )
            {
            flgs.in_fileName = false;
            heading = isHeading(firsttext,ch,WriteParAfterHeadingOrField);
            if(!skipSegmentation(firsttext,ch))
                {
                doTheSegmentation(CharProps,true,false); // Bart 20040120. true because: Suppose that end of line is end of segment
                if(!WriteParAfterHeadingOrField && heading)
                    {// A normal line after a heading has WritePar==false and heading==true
                    WriteParAfterHeadingOrField = true;
                    heading = false;
                    }
                }
            if(firsttext.EOL)
                firsttext.b.LS = 1;
            }
        else
            {
            updateFlags(ch,flgs);
            int EOL = firsttext.EOL;
            bool sentenceEnd = checkSentenceStartDueToBullet(ch);
            if(  sentenceEnd 
              || flgs.htmltagcoming
              || flgs.inhtmltag
              || (end_offset - begin_offset > MAXSEGMENTLENGTH && isSpace(ch)) // check for buffer overflow
              )
                {
                doTheSegmentation(CharProps,false,false); 
                firsttext.b.SD = 1;
                firsttext.b.LS = 0;
                }
            if(isSpace(ch))
                {
                if(EOL)
                    firsttext.b.LS = 1;
                }
            else
                {
                firsttext.b.LS = 0;
                firsttext.EOL = 0; // resets SD, CR and LF
                }
            }
        curr_pos = end_offset;
        }
    while(ch != WEOF && ch != 26);
    outputtext->PutHandlingLine('\n',flgs); // 20100106 Flush last line
    return false;
    }
Exemplo n.º 6
0
/// setData() is re-implemented from QStandardItemModel to set the widget window title and icon for the Qt::DecorationRole and Qt::DisplayRole/Qt::EditRole
bool AMWindowPaneModel::setData(const QModelIndex &index, const QVariant &value, int role) {

	if(!index.isValid())
		return false;

	switch(role) {

	case Qt::DisplayRole:
	case Qt::EditRole:
		// alias items and heading items can have separate descriptions, but for normal items, the DisplayRole and EditRole should be the window title
		if(isAlias(index) || isHeading(index))
			return AMDragDropItemModel::setData(index, value, role);

		if(internalPane(index)) {
			internalPane(index)->setWindowTitle(value.toString());
			return true;
		}
		else
			return false;

		break;


	case Qt::DecorationRole:
		// alias items and heading items can have separate icons, but for normal items, the Decoration role should be the window icon
		if(isAlias(index) || isHeading(index))
			return AMDragDropItemModel::setData(index, value, role);

		if(internalPane(index)) {
			internalPane(index)->setWindowIcon(value.value<QIcon>());
			return true;
		}
		else
			return false;
		break;

	case AMWindowPaneModel::DockStateRole:
	{

		// docking an alias? dock the target instead.
		if(isAlias(index)) {
			QStandardItem* target = aliasTarget(index);
			if(target)
				return setData(target->index(), value, role);
			else
				return false;
		}

		bool nowDocked = value.toBool();
		bool wasDocked = isDocked(index);

		// set dock state like normal, but emit special signal dockStateChanged() if it's changing.
		if(AMDragDropItemModel::setData(index, value, role)) {

			QWidget* w = internalPane(index);

			if(wasDocked && !nowDocked)
				emit dockStateChanged(w, false, index.data(AMWindowPaneModel::UndockResizeRole).toBool());
			else if(!wasDocked && nowDocked)
				emit dockStateChanged(w, true, index.data(AMWindowPaneModel::UndockResizeRole).toBool());

			return true;
		}
		else
			return false;
		break;
	}
	case AMWindowPaneModel::UndockResizeRole:
		return AMDragDropItemModel::setData(index, value, role);
		break;

	default:
		return AMDragDropItemModel::setData(index, value, role);
	}
}