コード例 #1
0
ファイル: optionstreemodel.cpp プロジェクト: AlekSi/Jabbin
QModelIndex OptionsTreeModel::parent(const QModelIndex& modelindex) const
{
	if (!modelindex.isValid() || flat_) 
		return QModelIndex();
	
	QString option = indexToOptionName(modelindex);
	
	QString parent_option = getParentName(option);
	
	return index(parent_option);
}
コード例 #2
0
ファイル: optionstreemodel.cpp プロジェクト: AlekSi/Jabbin
void OptionsTreeModel::optionAboutToBeInserted(const QString& option)
{
	QString parentname(getParentName(option));
	
	// FIXME? handle cases when parent doesn't exist either.
	
	QModelIndex parent(index(parentname));
	
	QStringList children = tree_->getChildOptionNames(parentname,true,true);
	children << option;
	children.sort();
	int row = children.indexOf(option);
	
	emit beginInsertRows(parent, row, row);
	
}
コード例 #3
0
ファイル: optionstreemodel.cpp プロジェクト: AlekSi/Jabbin
void OptionsTreeModel::optionAboutToBeRemoved(const QString& option)
{
	QString parentname(getParentName(option));
	
	QModelIndex parent(index(parentname));
	
	QStringList children = tree_->getChildOptionNames(parentname,true,true);
	children.sort();
	int row = children.indexOf(option);
	
	if (row != -1) {
		realRemove.push(true);
		emit beginRemoveRows(parent, row, row);
	} else {
		realRemove.push(false);
	}
}
コード例 #4
0
ファイル: optionstreemodel.cpp プロジェクト: AlekSi/Jabbin
/**
 * Get index of given @a option
 * @param option the option to retrieve the index for
 * @param sec Section the new index should point to
 * @return a QModelIndex to @a option
 */
QModelIndex OptionsTreeModel::index(const QString &option, Section sec) const
{
	if (option == "") {
		return QModelIndex();
	}
	
	if (flat_) {
		QStringList options = tree_->getChildOptionNames("",false,false);
		options.sort();
		int row = options.indexOf(option);
		return createIndex(row, sec, nameToIndex(options.at(row)));
	} else {
		QString parentname(getParentName(option));
		
		QStringList children = tree_->getChildOptionNames(parentname,true,true);
		children.sort();
		int row = children.indexOf(option);
		
		return createIndex(row, sec, nameToIndex(option));
	}
}
コード例 #5
0
void EspMessageInfo::write_esp_ng_ipp()
{
    const char *parent=getParentName();
    const char *baseclass=parent;
    if (!baseclass)
    {
        switch(espm_type_)
        {
            case espm_struct:
                baseclass="CEspNgStruct";
                break;
            case espm_request:
                baseclass="CEspNgRequest";
                break;
            default:
                baseclass="CEspNgResponse";
                break;
        }
    }
    outf("class CNg%s : public %s,\n", name_, baseclass);

    outf("   implements IEsp%s\n", name_);
    outs("{\n");
    
    outs("protected:\n");
    int pcount=0;
    ParamInfo *pi=NULL;
    for (pi=getParams();pi!=NULL;pi=pi->next)
        pcount++;

    outs(1, "int m_pcount;\n");
    outf(1, "IEspNgParameter *m_params[%d];\n", pcount);

    outs("public:\n\n");

    outs(1,"StringBuffer m_serviceName;\n");
    outs(1,"StringBuffer m_methodName;\n");
    outs(1,"StringBuffer m_msgName;\n");
    
    outs(1,"IMPLEMENT_IINTERFACE;\n\n");
    
    outs(1, "void init_params()\n");
    outs(1, "{\n");
    outf(2, "m_pcount=%d;\n", pcount);
    int pidx=0;
    for (pi=getParams();pi!=NULL;pi=pi->next)
    {
        pi->write_esp_ng_declaration(pidx++);
    }
    outs(1, "}\n\n");
    
    outs(1, "virtual IEspNgParameterIterator * getParameterIterator()\n");
    outs(1, "{\n");
    outs(2, "return new EspNgParameterIterator(m_params, m_pcount);\n");
    outs(1, "}\n");

    //default constructor
    outf(1, "CNg%s(const char *serviceName){\n", name_);
    outs(2, "m_serviceName.append(serviceName);\n");
    outs(2, "init_params();\n");
    outs(1, "}\n");

    //default destructor -- bhegerle
    outf(1, "~CNg%s() {\n", name_);
    outs(2, "for(int i=0; i < m_pcount; i++)\n");
    outs(3, "m_params[i]->Release();\n");
    outs(1, "}\n");
    
    if (espm_type_==espm_response)
    {
        outs(1,"virtual void setRedirectUrl(const char *url){CEspNgResponse::setRedirectUrl(url);}\n");
        outs(1,"virtual const IMultiException & getExceptions(){return CEspNgResponse::getExceptions();}\n");
        outs(1,"virtual void noteException(IException & e){CEspNgResponse::noteException(e);}\n");
    }
    
    outs("\n");
    write_esp_methods_ng(espaxm_both);

    outf(1, "virtual void copy(IConst%s &from){/*not implemented*/}\n", name_); 
    outf(1, "virtual const char * queryName(){return \"%s\";}\n", name_); 

    outs("};\n\n");
}