当前位置: 首页>>代码示例>>C++>>正文


C++ QCString::insert方法代码示例

本文整理汇总了C++中QCString::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ QCString::insert方法的具体用法?C++ QCString::insert怎么用?C++ QCString::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QCString的用法示例。


在下文中一共展示了QCString::insert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: escape

QCString KDEsuClient::escape(const QCString &str)
{
    QCString copy = str;
    int n = 0;
    while((n = copy.find("\\", n)) != -1)
    {
        copy.insert(n, '\\');
        n += 2;
    }
    n = 0;
    while((n = copy.find("\"", n)) != -1)
    {
        copy.insert(n, '\\');
        n += 2;
    }
    copy.prepend("\"");
    copy.append("\"");
    return copy;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例2: if

void UmlClass::uml2java(bool rec) {
  if (isJavaExternal())
    set_JavaDecl(JavaSettings::externalClassDecl());
  else {
    QCString st = JavaSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "enum_pattern")
      set_JavaDecl(JavaSettings::enumPatternDecl());
    else if (st == "enum")
      set_JavaDecl(JavaSettings::enumDecl());
    else if (st == "interface")
      set_JavaDecl(JavaSettings::interfaceDecl());
    else if (st == "@interface") {
      QCString s = JavaSettings::interfaceDecl();
      int index = s.find("interface");
      
      if (index != -1)
	s.insert(index, '@');
      set_JavaDecl(s);
    }
    else if (st == "ignored") {
      set_JavaDecl("");
      return;
    }
    else
      set_JavaDecl(JavaSettings::classDecl());
    
    if (rec) {
      const QVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2java(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_JavaSource(JavaSettings::sourceContent());
  }
}
开发者ID:gregsmirnov,项目名称:bouml,代码行数:51,代码来源:UmlClass.cpp

示例3: makeLDIFfieldString

QString LDIFConverter::makeLDIFfieldString( QString formatStr, QString value, bool allowEncode )
{
  if ( value.isEmpty() )
    return QString();

  // append format if not given
  if (formatStr.find(':') == -1)
    formatStr.append(": %1\n");

  // check if base64-encoding is needed
  bool printable = true;
  unsigned int i, len;
  len = value.length();
  for (i = 0; i<len; ++i ) {
     if (!value[i].isPrint()) {
        printable = false;
        break;
     }
  }

  if (printable) // always encode if we find special chars...
    printable = (value.find('\n') == -1);

  if (!printable && allowEncode) {
    // encode to base64
    value = KCodecs::base64Encode( value.utf8() );
    int p = formatStr.find(':');
    if (p>=0)
      formatStr.insert(p, ':');
  }

  // generate the new string and split it to 72 chars/line
  QCString txt = (formatStr.arg(value)).utf8();

  if (allowEncode) {
    len = txt.length();
    if (len && txt[len-1] == '\n')
      --len;
    i = 72;
    while (i < len) {
      txt.insert(i, "\n ");
      i += 72+1;
      len += 2;
    }
  }

  return QString::fromUtf8(txt);
}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例4: set_java

void UmlOperation::set_java(const char * return_form,
			    const char * params, QCString body,
			    bool inlinep) {
  QCString s = JavaSettings::operationDef();
  int index = s.find("${type}");
  
  s.replace(index, 7, return_form);
  s.insert(s.find("${)}", index), params);
  
  if (inlinep) {
    s.replace(s.findRev("${body}"), 7, body);
    set_JavaDef(s);
  }
  else {
    set_JavaDef(s);
    set_JavaBody(body);
  }
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例5: onKeyDown

void cTextField::onKeyDown(QKeyEvent *e) {
	int key = e->key();
	Qt::ButtonState state = e->state();

	// Handle special chars
	if (key == Qt::Key_Backspace) {
		// Replace the selection with an empty string
		if (selection_ != 0) {
			replaceSelection("");
		} else if (caret_ > 0) {
			setCaret(caret_ - 1);
			text_.remove(caret_, 1);
			invalidateText();
		}
	} else if (key == Qt::Key_Delete) {
		if (selection_ != 0) {
			replaceSelection("");
		} else if (caret_ < text_.length()) {
 			text_.remove(caret_, 1);
			invalidateText();
		}
	} else if (key == Qt::Key_Left) {
		if (caret_ > 0) {
			setCaret(caret_ - 1);
			if ((state & Qt::ShiftButton) != 0) {
				selection_++;
				invalidateText();
			} else {
				if (selection_ != 0) {
					selection_ = 0;
					invalidateText();
				}
			}
		}
	} else if (key == Qt::Key_Right) {
		if (caret_ < text_.length()) {
			setCaret(caret_ + 1);
			if ((state & Qt::ShiftButton) != 0) {
				selection_--;
				invalidateText();
			} else {
				if (selection_ != 0) {
					selection_ = 0;
					invalidateText();
				}
			}
		}
	} else if (key == Qt::Key_V && (state & Qt::ControlButton) != 0) {
		QClipboard *clipboard = qApp->clipboard();
		QString text = clipboard->text();
		if (!text.isEmpty()) {
			QCString ltext = text.latin1();
			replaceSelection(ltext);
		}
	} else if (key == Qt::Key_C && (state & Qt::ControlButton) != 0) {
		QClipboard *clipboard = qApp->clipboard();
		QCString text = getSelection();
		if (!text.isEmpty()) {
			clipboard->setText(QString(text), QClipboard::Clipboard);
		}
	} else if (key == Qt::Key_X && (state & Qt::ControlButton) != 0) {
		QClipboard *clipboard = qApp->clipboard();
		QCString text = getSelection();
		if (!text.isEmpty()) {
			clipboard->setText(QString(text), QClipboard::Clipboard);
			replaceSelection("");
		}
	} else if (key == Qt::Key_Return) {
		onEnter();
	} else if (key == Qt::Key_Home) {
        int oldCaret = caret_;
		selection_ = 0;
		setCaret(0);
		invalidateText();
		/*if (key.mod & KMOD_SHIFT) {
			selection_--;
			invalidateText();
		} else {
			if (selection_ != 0) {
				selection_ = 0;
				invalidateText();
			}
		}*/
	} else if (key == Qt::Key_End) {
		setCaret(text_.length());
		selection_ = 0;		
		invalidateText();
	} else if (text_.length() < maxLength_) {	
		char ch = e->text().at(0).latin1();

		// Check if the character is supported by the current font.
		if (ch != 0) {
			cSurface *chs = AsciiFonts->getCharacter(font_, ch);
			if (chs) {
				QCString replacement;
				replacement.insert(0, ch);
				replaceSelection(replacement);
			}
		}
	}
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:101,代码来源:textfield.cpp

示例6: new_one


//.........这里部分代码省略.........
  if (! pfunc) {
    typeform = (pretype.isEmpty())
      ? QCString("${type}")
      : pretype + " ${type}";
    
    container->compute_type(type, typespec, typeform);
  }
  else {
    typespec.explicit_type = type.simplifyWhiteSpace();
    
    int index = typespec.explicit_type.find("${name}");
    
    if (index != -1)
      typespec.explicit_type.remove(index, 7);
  }
  
  QCString decl = CppSettings::attributeDecl("");
  int index = decl.find("${type}");
  
  if ((index == -1) ||
      (decl.find("${const}") == -1) ||
      (decl.find("${name}") == -1) ||
      (decl.find("${mutable}") == -1) ||
      (decl.find("${volatile}") == -1) ||
      (decl.find(';') == -1)) {
    decl = "    ${comment}${static}${mutable}${volatile}${const}${type} ${name}${value};";
    index = decl.find("${type}");
  }
  
  if (pfunc)
    decl.replace(index, decl.find("${name}") + 7 - index, type);
  else {
    if (!modifier.isEmpty())
      decl.insert(index + 7, QCString(" ") + modifier);
        
    if (typeform != "${type}")
      decl.replace(index, 7, typeform);
    else if (typespec.type == 0) {
      QCString t = typespec.explicit_type;
      int index2;
      
      if (!t.isEmpty() &&
	  (t.at(t.length() - 1) == '>') &&
	  ((index2 = t.find('<')) > 0)) {
	stereotype = t.left(index2);
	typespec.explicit_type =
	  // may be a,b ...
	  t.mid(index2 + 1, t.length() - 2 - index2);
	decl.replace(index, 7, "${stereotype}<${type}>");
      }
    }
    
    if (!array.isEmpty())
      decl.insert(decl.find("${name}") + 7, "${multiplicity}");
    
    if (!bitfield.isEmpty())
      decl.insert(decl.find(';'), QCString(" : ") + bitfield);
  }
  
  if (typenamep) {
    int index = decl.find("${const}") + 8; // find cannot return -1
    int index2 = decl.find("${mutable}") + 10; // find cannot return -1
    int index3 = decl.find("${volatile}") + 11; // find cannot return -1
    
    if (index2 > index) index = index2;
    if (index3 > index) index = index3;
开发者ID:,项目名称:,代码行数:67,代码来源:

示例7: text

void RTFGenParser::text(const QString &text)
{
    if (m_res_size)
        return;
    unsigned size = res.length();
    if (size > m_max_size){
        textPos = start_pos;
        m_res_size = size;
        return;
    }
    for (int i = 0; i < (int)(text.length()); i++){
        QChar c = text[i];
        if (c.isSpace()){
            unsigned size = res.length();
            if (size > m_max_size){
                textPos = start_pos + i;
                m_res_size = size;
                return;
            }
        }
        // In Qt, unless you force the paragraph direction with (Left/Right)
        // Ctrl-Shift (also known as Key_Direction_L and Key_Direction_R),
        // the P tag won't have a DIR attribute at all. In such cases, unlike
        // HTML, Qt will render the paragraph LTR or RTL according to the
        // first strong character (as Unicode TR#9 defines). Thus, if the
        // direction isn't known yet, we check each character till we find
        // a strong one.
        if ((m_lastParagraphPos != 0) && (m_paragraphDir == DirUnknown))
        {
            switch(c.direction())
            {
            case QChar::DirL:
                res.insert(m_lastParagraphPos, "\\ltrpar");
                m_paragraphDir = DirLTR;
                break;
            case QChar::DirR:
                res.insert(m_lastParagraphPos, "\\rtlpar");
                m_paragraphDir = DirRTL;
                break;
            default: // to avoid warnings
                break;
            }
        }

        unsigned short u = c.unicode();
        if (c == '\r' || c == '\n')
            continue;
        if ((c == '{') || (c == '}') || (c == '\\')){
            char b[5];
            snprintf(b, sizeof(b), "\\\'%02x", u & 0xFF);
            res += b;
            m_bSpace = false;
            continue;
        }
        if (u < 0x80){
            if (m_bSpace)
                res += ' ';
            res += (char)u;
            m_bSpace = false;
            continue;
        }
        QString s;
        s += c;
        if (m_codec){
            QCString plain = m_codec->fromUnicode(s);
            if ((plain.length() == 1) && (m_codec->toUnicode(plain) == s)){
                char b[5];
                snprintf(b, sizeof(b), "\\\'%02x", plain[0] & 0xFF);
                res += b;
                m_bSpace = false;
                continue;
            }
        }
        res += "\\u";
        res += QString::number(s[0].unicode());
        res += '?';
        m_bSpace = false;
    }
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:79,代码来源:rtfgen.cpp

示例8: generate

void UmlTransition::generate(QList<UmlTransition> trs, UmlClass * machine, UmlClass * anystate, UmlState * state, QCString & body, QCString indent, bool completion)
{
  UmlTransition * tr;
  bool guard = FALSE;
  
  for (tr = trs.first(); tr != 0; tr = trs.next()) {
    body += indent;
    
    if (!tr->cppGuard().isEmpty()) {
      // manage guard
      body += ((tr == trs.getFirst()) ? "if (" : "else if (")
	+ tr->cppGuard() + ") {\n";
      guard = TRUE;
    }
    else
      // no gard : it is the last transition, may be the first
      body += ((tr == trs.getFirst()) ? "{\n" : "else {\n");

    // the target state
    UmlItem * tg = tr->target();
    bool self_external = (state == tg) && tr->isExternal();
    
    while (tg->kind() != aState)
      tg = tg->parent();
    
    // the parent common to the current and the target state
    UmlState * common = state;
    
    if (self_external) {
      // execute exit behavior
      if (!state->cppExitBehavior().isEmpty())
	body += indent + "  _doexit(stm);\n";
    }
    else {
      bool fromExit = 
	// the exit behavior is made entering in the exit point
	(tr->parent()->kind() == anExitPointPseudoState);
      
      // compute common parent and manage exit behavior
      if (tr->target()->kind() != aTerminatePseudoState) {
	while (! ((UmlState *) tg)->inside(common)) {
	  if (!fromExit && !common->cppExitBehavior().isEmpty())
	    body += indent + "  stm" + common->path() + "._doexit(stm);\n";
	  fromExit = FALSE;
	  
	  switch (common->parent()->kind()) {
	  case aState:
	    common = (UmlState *) common->parent();
	    break;
	  case aRegion:
	    common = (UmlState *) common->parent()->parent();
	    break;
	  default:
	    UmlCom::trace("Error : transition from '" + state->name()
			  + "' goes outside the state machine");
	    throw 0;
	  }
	}
      }
    }
    
    // manage transition activity
    if (!tr->cppActivity().isEmpty())
      body += "#ifdef VERBOSE_STATE_MACHINE\n" + indent + 
	"  puts(\"DEBUG : execute activity of transition " + tr->name() +
	  "\");\n#endif\n" + tr->cppActivity();
  
    // manage entry behavior
    if (self_external) {
      if (state->needCreate())
	body += indent + "  create(stm);\n";
    }
    else if (tr->target()->kind() != aTerminatePseudoState) {
      if (tg != common) {
	QCString enter;
	UmlState * tg_parent;
      
	// the enter behavior of the target state will be managed
	// generating a call to create
	for (tg_parent = (UmlState *) tg->parent();
	     tg_parent != common;
	     tg_parent = (UmlState *) tg_parent->parent())
	  if (!tg_parent->cppEntryBehavior().isEmpty())
	    enter.insert(0,
			 indent + "  stm" + tg_parent->path() + "._doentry(stm);\n");
	    
	if (!enter.isEmpty())
	  body += enter;
      }

      // set the current state if needed
      if (tg != state)
	body += indent + "  stm._set_currentState(stm"
	  + ((UmlState *) tg)->path() + ");\n#ifdef VERBOSE_STATE_MACHINE\n" +
	    indent + "  puts(\"DEBUG : current state is now " + ((UmlState *) tg)->prettyPath() +
	      "\");\n#endif\n";
    }

    // do the transition
    if (tr->target()->kind() == aState) {
//.........这里部分代码省略.........
开发者ID:gregsmirnov,项目名称:bouml,代码行数:101,代码来源:UmlTransition.cpp

示例9: set_cpp

void UmlOperation::set_cpp(const char * return_form_or_inherit,
			   const char * params, QCString body,
			   bool inlinep, const char * if_def,
			   const char * end_if) {
  if (*return_form_or_inherit == ':') {
    // inherit
    if (inlinep) {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${)}");
      
      s.resize(index + 5);
      s.insert(index, params);
      s.append(" ");
      s.append(return_form_or_inherit);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      set_CppDef("");
    }
    else {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${)}");
      
      s.resize(index + 5);
      s.insert(index, params);
      s.append(";");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      s = remove_throw(CppSettings::operationDef());
      index = s.find("${)}");
      s.resize(index + 5);
      s.insert(index, params);
      s.append(" ");
      s.append(return_form_or_inherit);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDef(s);
    }
  }
  else {
    // return
    if (inlinep) {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${type}");
      
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      s.resize(s.findRev(";") + 1);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      set_CppDef("");
    }
    else {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${type}");
      
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      s = remove_throw(CppSettings::operationDef());
      index = s.find("${type}");
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      conditional(s, if_def, end_if);
      set_CppDef(s);
      
      set_CppBody(body);
    }
  }
}
开发者ID:,项目名称:,代码行数:94,代码来源:


注:本文中的QCString::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。