Example #1
0
bool SuitsFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel *sourceModel) const
{
	if (!anyChecked) {
		return true;
	}

	// Checked means 'Show', Unchecked means 'Hide'.
	QString suit(d->suit);
	// only show empty suit dives if the user checked that.
	if (suit.isEmpty()) {
		if (rowCount() > 0)
			return checkState[rowCount() - 1];
		else
			return true;
	}

	// there is a suit selected
	QStringList suitList = stringList();
	if (!suitList.isEmpty()) {
		suitList.removeLast(); // remove the "Show Empty Suits";
		for (int i = 0; i < rowCount(); i++) {
			if (checkState[i] && (suit.indexOf(stringList()[i]) != -1)) {
				return true;
			}
		}
	}
	return false;
}
Example #2
0
void datalogProgram ::fact(){
    predicate mypredicate;
    if (tokens.at(vecIndex).getTokenType() == ID){
        mypredicate.ident = tokens.at(vecIndex).getText();
        match(ID);
        match(LEFT_PAREN);
        if (tokens.at(vecIndex).getTokenType() == STRING){
            parameter aParam;
            aParam.textValue =tokens.at(vecIndex).getText();
            domain.push_back(tokens.at(vecIndex).getText());
            mypredicate.myParameters.push_back(aParam);
            match(STRING);
            stringList(mypredicate.myParameters);
            match(RIGHT_PAREN);
            match(PERIOD);
            facts.push_back(mypredicate);
        }
        else{
            if (currentStatus == true){
                currentStatus = false;
                falseTok = tokens.at(vecIndex);
            }
        }
        
    }
    else{
        if (currentStatus == true){
            currentStatus = false;
            falseTok = tokens.at(vecIndex);
        }
    }
}
Example #3
0
QVariant PoolModel::data(const QModelIndex& _index, int _role) const {
  if (!_index.isValid()) {
    return QVariant();
  }

  switch (_role) {
  case ROLE_HOST:
    return QUrl::fromUserInput(stringList()[_index.row()]).host();
  case ROLE_PORT:
    return QUrl::fromUserInput(stringList()[_index.row()]).port();
  default:
    break;
  }

  return QStringListModel::data(_index, _role);
}
Example #4
0
void
NameListModel::setInUse (const QString & name, bool used)
{
  int row = stringList().indexOf (name);
  usage[name].inUse = used;
  emit dataChanged (index (row,0), index(row,0));
}
Example #5
0
SieveArgument * SieveParser::argument()
{
    whitespace();

    SieveArgument * sa = new SieveArgument;
    sa->setParser( this );
    sa->setStart( pos() );

    if ( nextChar() == ':' )
        sa->setTag( tag().lower() );
    else if ( nextChar() >= '0' && nextChar() <= '9' )
        sa->setNumber( number() );
    else
        sa->setStringList( stringList() );

    sa->setError( error() );
    sa->setEnd( pos() );

    // hack: if we set a number, clear the error so the arguments()
    // will read the next argument, too
    if ( sa->number() )
        setError( "" );

    return sa;
}
Example #6
0
void
NameListModel::setSelected (const QString & name, bool selected)
{
  int row = stringList().indexOf (name);
  usage[name].selected = selected;
  emit dataChanged (index (row,0), index(row,0));
}
Example #7
0
// UnLoad the representation
bool GLC_3DRep::unload()
{
	bool unloadSucess= false;
	if ((NULL != m_pGeomList) && !m_pGeomList->isEmpty())
	{
		if (fileName().isEmpty())
		{
			QStringList stringList("GLC_3DRep::unload()");
			stringList.append("Cannot unload rep without filename");
			GLC_ErrorLog::addError(stringList);
		}
		else
		{
			const int size= m_pGeomList->size();
			for (int i= 0; i < size; ++i)
			{
				delete (*m_pGeomList)[i];
			}
			m_pGeomList->clear();

			(*m_pIsLoaded)= false;
			unloadSucess= true;
		}
	}
	return unloadSucess;
}
Example #8
0
// Load the representation
bool GLC_3DRep::load()
{
	bool loadSucces= false;

	if(!(*m_pIsLoaded))
	{
		Q_ASSERT(m_pGeomList->isEmpty());
		if (fileName().isEmpty())
		{
			QStringList stringList("GLC_3DRep::load");
			stringList.append("Representation : " + GLC_Rep::name());
			stringList.append("Empty File Name");
			GLC_ErrorLog::addError(stringList);
		}
		else
		{
			GLC_3DRep newRep= GLC_Factory::instance()->create3DRepFromFile(fileName());
			if (!newRep.isEmpty())
			{
				const int size= newRep.m_pGeomList->size();
				for (int i= 0; i < size; ++i)
				{
					m_pGeomList->append(newRep.m_pGeomList->at(i));
				}
				newRep.m_pGeomList->clear();
				(*m_pIsLoaded)= true;
				loadSucces= true;
			}
		}
	}

	return loadSucces;

}
void updateTreeWithRemovedNode(
        Process::MessageNode& rootNode,
        const State::Address& addr)
{
    // Find the message node
    Process::MessageNode* node_ptr = Device::try_getNodeFromString(rootNode, stringList(addr));

    if(node_ptr)
    {
        auto& node = *node_ptr;
        // Recursively set the user value to nil.
        rec_removeUserValue(node);

        // If it is empty, delete it
        rec_cleanup(node);


        if(node.values.previousProcessValues.isEmpty()
        && node.values.followingProcessValues.isEmpty()
        && node.childCount() == 0)
        {
            rec_delete(node);
        }
    }
}
Example #10
0
// Return true if the binary rep is up to date
bool BSRep::isUsable(const QDateTime& timeStamp)
{
    bool isUpToDate= false;
    if (open(QIODevice::ReadOnly))
    {
        if (headerIsOk())
        {
            isUpToDate= timeStampOk(timeStamp);
            isUpToDate= isUpToDate && close();
        }
    }
    else
    {
        std::string message(std::string("BSRep::loadRep Enable to open the file ") + m_FileInfo.fileName());
        FileFormatException fileFormatException(message, m_FileInfo.fileName(), FileFormatException::FileNotFound);
        close();
        throw(fileFormatException);
    }

    if (!isUpToDate && TraceLog::isEnable())
    {
        std::stringList stringList("BSRep::isUsable");
        stringList.append("File " + m_FileInfo.filePath() + " not Usable");
        TraceLog::addTrace(stringList);
    }
    return isUpToDate;
}
Example #11
0
void printDB(struct Node *head, char *print_buf, int sd_current)
{
    char temp_str[BUFSIZ];
    sprintf(print_buf, "| SID   | Lname     | Fname     | M | GPA  |\n");
    
    sprintf(temp_str, "+-------+-----------+-----------+---+------+\n");
    strcat(print_buf, temp_str);
    
    stringList(head, print_buf);
    
    sprintf(temp_str, "+-------+-----------+-----------+---+------+\n\n");
    strcat(print_buf, temp_str);

    /*printf("%s", print_buf);*/
    if ( send( sd_current, print_buf, strlen(print_buf) + 1, 0) == -1)
    {
        perror( "send" );
        exit( 1 );
    }
    /*
    printf("| SID   | Lname     | Fname     | M | GPA  |\n");
    printf("+-------+-----------+-----------+---+------+\n");
    printList(head);
    printf("+-------+-----------+-----------+---+------+\n\n");
    */
}
Example #12
0
QString
GpgServerModel::defaultServer() const
{
	const QStringList &servers = stringList();

	if (servers.isEmpty())
		return QString();
	return servers.at(qMax<int>(0, m_defaultRow));
}
Example #13
0
int
GpgServerModel::defaultRow() const
{
	// only in case there is not set any default yet promote the first entry of the list
	if ((m_defaultRow >= 0) || stringList().empty())
		return m_defaultRow;
	else
		return 0;
}
Example #14
0
QVariant LanguageListModel::data(const QModelIndex& index, int role) const
{
    if (role==Qt::DecorationRole)
    {
#if 0 //#ifndef NOKDE
        static QMap<QString,QVariant> iconCache;

        QString langCode=stringList().at(index.row());
        if (!iconCache.contains(langCode))
        {
            QString code=QLocale(langCode).name();
            QString path;
            if (code.contains('_')) code=QString::fromRawData(code.unicode()+3, 2).toLower();
            if (code!="C")
            {
                static const QString flagPath("l10n/%1/flag.png");
                path=QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("locale/") + flagPath.arg(code));
            }
            iconCache[langCode]=QIcon(path);
        }
        return iconCache.value(langCode);
#endif
    }
    else if (role==Qt::DisplayRole)
    {
        const QString& code=stringList().at(index.row());
        if (code.isEmpty()) return code;
        //qDebug()<<"languageCodeToName"<<code;
        static QVector<QString> displayNames(stringList().size());
        if (displayNames.at(index.row()).length())
            return displayNames.at(index.row());
#ifndef NOKDE
            return QVariant::fromValue<QString>(
                displayNames[index.row()]=KConfigGroup(m_systemLangList,code).readEntry("Name")%QStringLiteral(" (")%code%')');
#else
        QLocale l(code);
//        if (l.language()==QLocale::C && code!="C")
        return QVariant::fromValue<QString>(
            displayNames[index.row()]=QLocale::languageToString(l.language())%QStringLiteral(" (")%code%')');
#endif
    }
    return QStringListModel::data(index, role);
}
Example #15
0
QVariant FilesModel::data( const QModelIndex & index, int role ) const
{
    static QIcon folderIcon(QPixmap("res/folder.png"));
    static QIcon fileIcon(QPixmap("res/file.png"));

    // returning the icon to show
    if( role == Qt::DecorationRole )
        return m_fileInfoList[ index.row() ].isDir() ? qVariantFromValue( folderIcon ) : qVariantFromValue( fileIcon );
    
    // in case of edit/display_text of the item returning the correspoding text 
    if( role == Qt::DisplayRole || role == Qt::EditRole )
		return stringList()[ index.row() ];

    // in case of copy/status_bar_tip of the item returning the full path of the file/folder
    if( role == Qt::StatusTipRole )
		return m_currentFolder + "/" + stringList()[ index.row() ];
        
    return QVariant();
}
Example #16
0
void
GpgServerModel::setDefault(const QString &server)
{
	if (server.isEmpty()) {
		setDefault(-1);
	} else {
		const int row = stringList().indexOf(server);
		Q_ASSERT(row >= 0);
		setDefault(row);
	}
}
 virtual QVariant data ( const QModelIndex & index, int role ) const
 {
     if (role == Qt::DecorationRole)
     {
         QFileInfo fileInfo(stringList()[index.row()]);
         QFileIconProvider iconProv;
         return QVariant(iconProv.icon(fileInfo));
     }
     else
     {
         return QStringListModel::data(index, role);
     }
 }
Example #18
0
void
GpgServerModel::setDefault(const int row)
{
	Q_ASSERT(row < stringList().count());

	if (m_defaultRow == row)
		return;

	const int oldRow = m_defaultRow;
	m_defaultRow = row;
	if (oldRow >= 0)
		emit dataChanged(index(oldRow, 0), index(oldRow, 0));
	if (row >= 0)
		emit dataChanged(index(row, 0), index(row, 0));
}
Example #19
0
  CustomHeaderStrategy::CustomHeaderStrategy()
    : HeaderStrategy()
  {
    KConfigGroup customHeader( KMKernel::config(), "Custom Headers" );
    if ( customHeader.hasKey( "headers to display" ) ) {
      mHeadersToDisplay = customHeader.readListEntry( "headers to display" );
      for ( QStringList::iterator it = mHeadersToDisplay.begin() ; it != mHeadersToDisplay.end() ; ++ it )
	*it = (*it).lower();
    } else
      mHeadersToDisplay = stringList( standardHeaders, numStandardHeaders );

    if ( customHeader.hasKey( "headers to hide" ) ) {
      mHeadersToHide = customHeader.readListEntry( "headers to hide" );
      for ( QStringList::iterator it = mHeadersToHide.begin() ; it != mHeadersToHide.end() ; ++ it )
	*it = (*it).lower();
    }

    mDefaultPolicy = customHeader.readEntry( "default policy", "hide" ) == "display" ? Display : Hide ;
  }
void updateTreeWithRemovedUserMessage(
        Process::MessageNode& rootNode,
        const State::Address& addr)
{
    // Find the message node
    Process::MessageNode* node = Device::try_getNodeFromString(rootNode, stringList(addr));

    if(node)
    {
        node->values.userValue = State::OptionalValue{};

        // If it is empty, delete it.
        if(node->values.previousProcessValues.isEmpty()
        && node->values.followingProcessValues.isEmpty()
        && node->childCount() == 0)
        {
            rec_delete(*node);
        }
    }
}
Example #21
0
    RichHeaderStrategy()
      : HeaderStrategy(),
	mHeadersToDisplay( stringList( richHeaders, numRichHeaders ) ) {}
Example #22
0
QString LanguageListModel::langCodeForSortModelRow(int row)
{
    return stringList().at(m_sortModel->mapToSource(m_sortModel->index(row,0)).row());
}
Example #23
0
    StandardHeaderStrategy()
      : HeaderStrategy(),
	mHeadersToDisplay( stringList( standardHeaders, numStandardHeaders) ) {}
Example #24
0
    BriefHeaderStrategy()
      : HeaderStrategy(),
	mHeadersToDisplay( stringList( briefHeaders, numBriefHeaders ) ) {}
Example #25
0
// Load Material
void GLC_3dsToWorld::loadMaterial(Lib3dsMaterial* p3dsMaterial)
{
	GLC_Material* pMaterial= new GLC_Material;
	// Set the material name
	const QString materialName(p3dsMaterial->name);
	pMaterial->setName(materialName);
	// Check if there is a texture
	if (p3dsMaterial->texture1_map.name[0])
	{
		const QString textureName(p3dsMaterial->texture1_map.name);
		// Retrieve the .3ds file path
		QFileInfo fileInfo(m_FileName);
		QString textureFileName(fileInfo.absolutePath() + QDir::separator());
		textureFileName.append(textureName);

		// TGA file type are not supported
		if (!textureName.right(3).contains("TGA", Qt::CaseInsensitive))
		{
			QFile textureFile(textureFileName);

			if (textureFile.open(QIODevice::ReadOnly))
			{
				// Create the texture and assign it to the material
				GLC_Texture *pTexture = new GLC_Texture(textureFile);
				pMaterial->setTexture(pTexture);
				m_ListOfAttachedFileName << textureFileName;
				textureFile.close();
			}
			else
			{
				QStringList stringList(m_FileName);
				stringList.append("Open File : " + textureFileName + " failed");
				GLC_ErrorLog::addError(stringList);
			}

		}
		else
		{
			QStringList stringList(m_FileName);
			stringList.append("Image : " + textureFileName + " not suported");
			GLC_ErrorLog::addError(stringList);
		}
	}

	// Ambient Color
	QColor ambient;
	ambient.setRgbF(p3dsMaterial->ambient[0], p3dsMaterial->ambient[1], p3dsMaterial->ambient[2]);
	ambient.setAlphaF(p3dsMaterial->ambient[3]);
	pMaterial->setAmbientColor(ambient);
	// Diffuse Color
	QColor diffuse;
	diffuse.setRgbF(p3dsMaterial->diffuse[0], p3dsMaterial->diffuse[1], p3dsMaterial->diffuse[2]);
	diffuse.setAlphaF(p3dsMaterial->diffuse[3]);
	pMaterial->setDiffuseColor(diffuse);
	// Specular Color
	QColor specular;
	specular.setRgbF(p3dsMaterial->specular[0], p3dsMaterial->specular[1], p3dsMaterial->specular[2]);
	specular.setAlphaF(p3dsMaterial->specular[3]);
	pMaterial->setSpecularColor(specular);
	// Shininess

	if (0 != p3dsMaterial->shininess)
	{
		float matShininess= p3dsMaterial->shininess * 128.0f;
		if (matShininess > 128.0f) matShininess= 128.0f;
		if (matShininess < 5.0f) matShininess= 20.0f;
		pMaterial->setShininess(matShininess);
	}
	// Transparency

	pMaterial->setOpacity(1.0 - p3dsMaterial->transparency);

	// Add the material to the hash table
	m_Materials.insert(materialName, pMaterial);
}
stringList volumeAverageFunctionObject::columnNames()
{
    return stringList(1,"average");
}
Example #27
0
void CreateCurvesFromAddresses(
        const QList<const Scenario::ConstraintModel*>& selected_constraints,
        const std::vector<Device::FullAddressSettings>& addresses,
        const iscore::CommandStackFacade& stack)
{
    if(selected_constraints.empty())
        return;

    // They should all be in the same scenario so we can select the first.
    // FIXME check that the other "cohesion" methods also use ScenarioInterface and not Scenario::ProcessModel
    auto scenar = dynamic_cast<Scenario::ScenarioInterface*>(
                                selected_constraints.first()->parent());


    int added_processes = 0;
    // Then create the commands
    auto big_macro = new Scenario::Command::AddMultipleProcessesToMultipleConstraintsMacro;

    for(const auto& constraint : selected_constraints)
    {
        // Generate brand new ids for the processes
        auto process_ids = getStrongIdRange<Process::ProcessModel>(addresses.size(), constraint->processes);
        auto macro_tuple = Scenario::Command::makeAddProcessMacro(*constraint, addresses.size());
        auto macro = std::get<0>(macro_tuple);
        auto& bigLayerVec = std::get<1>(macro_tuple);

        Path<Scenario::ConstraintModel> constraintPath{*constraint};
        const Scenario::StateModel& ss = startState(*constraint, *scenar);
        const auto& es = endState(*constraint, *scenar);

        std::vector<State::Address> existing_automations;
        for(const auto& proc : constraint->processes)
        {
            if(auto autom = dynamic_cast<const Automation::ProcessModel*>(&proc))
                existing_automations.push_back(autom->address());
        }

        int i = 0;
        for(const Device::FullAddressSettings& as : addresses)
        {
            // First, we skip the curve if there is already a curve
            // with this address in the constraint.
            if(contains(existing_automations, as.address))
                continue;

            // Then we set-up all the necessary values
            // min / max
            double min = as.domain.min.val.isNumeric()
                    ? State::convert::value<double>(as.domain.min)
                    : 0;

            double max = as.domain.max.val.isNumeric()
                    ? State::convert::value<double>(as.domain.max)
                    : 1;

            // start value / end value
            double start = std::min(min, max);
            double end = std::max(min, max);
            Process::MessageNode* s_node = Device::try_getNodeFromString(
                        ss.messages().rootNode(),
                        stringList(as.address));
            if(s_node)
            {
                if(auto val = s_node->value())
                {
                    start = State::convert::value<double>(*val);
                    min = std::min(start, min);
                    max = std::max(start, max);
                }
            }

            Process::MessageNode* e_node = Device::try_getNodeFromString(
                        es.messages().rootNode(),
                        stringList(as.address));
            if(e_node)
            {
                if(auto val = e_node->value())
                {
                    end = State::convert::value<double>(*val);
                    min = std::min(end, min);
                    max = std::max(end, max);
                }
            }

            // Send the command.
            macro->addCommand(new Scenario::Command::CreateCurveFromStates{
                                  Path<Scenario::ConstraintModel>{constraintPath},
                                  bigLayerVec[i],
                                  process_ids[i],
                                  as.address,
                                  start, end, min, max
                              });

            i++;
            added_processes++;
        }
        big_macro->addCommand(macro);
    }

    if(added_processes > 0)
    {
        CommandDispatcher<> disp{stack};
        disp.submitCommand(big_macro);
    }
    else
    {
        delete big_macro;
    }
}
Example #28
0
int FilesModel::rowCount( const QModelIndex & parent ) const
{
	return stringList().count();
}
Example #29
0
int LanguageListModel::sortModelRowForLangCode(const QString& langCode)
{
    return m_sortModel->mapFromSource(index(stringList().indexOf(langCode))).row();
}
Example #30
0
bool PoolModel::setData(const QModelIndex& _index, const QVariant& _value, int _role) {
  bool res = QStringListModel::setData(_index, _value, _role);
  Settings::instance().setMiningPoolList(stringList());
  return res;
}