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


C++ QValueList::size方法代码示例

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


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

示例1: notify

void MediaNotifier::notify(KFileItem &medium)
{
    kdDebug() << "Notification triggered." << endl;

    NotifierSettings *settings = new NotifierSettings();

    if(settings->autoActionForMimetype(medium.mimetype()) == 0L)
    {
        QValueList< NotifierAction * > actions = settings->actionsForMimetype(medium.mimetype());

        // If only one action remains, it's the "do nothing" action
        // no need to popup in this case.
        if(actions.size() > 1)
        {
            NotificationDialog *dialog = new NotificationDialog(medium, settings);
            dialog->show();
        }
    }
    else
    {
        NotifierAction *action = settings->autoActionForMimetype(medium.mimetype());
        action->execute(medium);
        delete settings;
    }
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:25,代码来源:medianotifier.cpp

示例2: symbolsMaxLineLength

int LegendMarker::symbolsMaxLineLength() const
{
QValueList<int> cvs = d_plot->curveKeys();
	
int maxL=0;
QString text=d_text->text();	
QStringList titles=QStringList::split ("\n",text,FALSE);	
for (int i=0;i<(int)titles.count();i++)
	{
	 if (titles[i].contains("\\c{") && (int)cvs.size()>0)
		{
		int pos=titles[i].find("{",0);
        int pos2=titles[i].find("}",pos);
		QString aux=titles[i].mid(pos+1,pos2-pos-1);
		int cv = aux.toInt()-1;
		if (cv < 0)
			continue;

		const QwtPlotCurve *c = d_plot->curve(cvs[cv]);
		if (c)
			{
			int l=c->symbol().size().width();
			if (l>maxL && c->symbol().style() != QwtSymbol::None) 
				maxL=l;
			}
		}
		
	if (titles[i].contains("\\p{"))
		maxL=10;
	}
return maxL;
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:32,代码来源:LegendMarker.cpp

示例3: displayProcessCommand

void ExternalLanguage::displayProcessCommand()
{
	QStringList quotedArguments;
	QValueList<QCString> arguments = m_languageProcess->args();
	
	if ( arguments.size() == 1 )
		quotedArguments << arguments[0];
		
	else
	{
		QValueList<QCString>::const_iterator end = arguments.end();
	
		for ( QValueList<QCString>::const_iterator it = arguments.begin(); it != end; ++it )
		{
			if ( (*it).isEmpty() || (*it).contains( QRegExp("[\\s]") ) )
				quotedArguments << KProcess::quote( *it );
			else
				quotedArguments << *it;
		}
	}
	
// 	outputMessage( "<i>" + quotedArguments.join(" ") + "</i>" );
	outputMessage( quotedArguments.join(" ") );
// 	LanguageManager::self()->logView()->addOutput( quotedArguments.join(" "), LogView::ot_info );
}
开发者ID:zoltanp,项目名称:ktechlab-0.3,代码行数:25,代码来源:externallanguage.cpp

示例4:

void QwtLegend::PrivateData::LegendMap::clear()
{

    /*
       We can't delete the widgets in the following loop, because
       we would get ChildRemoved events, changing d_itemMap, while
       we are iterating.
     */

#if QT_VERSION < 0x040000
    QValueList<QWidget *> widgets;

    QMap<const QwtLegendItemManager *, QWidget *>::const_iterator it;
    for ( it = d_itemMap.begin(); it != d_itemMap.end(); ++it )
        widgets.append(it.data());
#else
    QList<QWidget *> widgets;

    QMap<const QwtLegendItemManager *, QWidget *>::const_iterator it;
    for ( it = d_itemMap.begin(); it != d_itemMap.end(); ++it )
        widgets.append(it.value());
#endif

    d_itemMap.clear();
    d_widgetMap.clear();

    for ( int i = 0; i < (int)widgets.size(); i++ )
        delete widgets[i];
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:29,代码来源:qwt_legend.cpp

示例5: groupClusters

void ClusterPalette::groupClusters() {
    QValueList<int> selected = selectedClusters();
    //To group clusters, there must be more then one cluster !!!
    if(selected.size()>1) {
        emit groupClusters(selected);
        isUpToDate = true;
    }
}
开发者ID:caffeine-xx,项目名称:klusters,代码行数:8,代码来源:clusterPalette.cpp

示例6:

QValueList<int> NewGameView::selectedRows(
  const QValueList<QCheckBox *> &checks )
{
  QValueList<int> rows;

  for( unsigned int i = 0; i < checks.size(); ++i ) {
    if ( checks[ i ]->isChecked() ) {
      rows.append( i + 1 );
    }
  }
  
  return rows;
}
开发者ID:cornelius,项目名称:plutimikation,代码行数:13,代码来源:newgameview.cpp

示例7: wpMulti_chars

/*
 * Returns the list of the chars in this multi
 */
static PyObject* wpMulti_chars( wpMulti* self, PyObject* args )
{
	Q_UNUSED(args);
	if( !self->pMulti || self->pMulti->free )
		return PyFalse;
	QValueList< SERIAL > chars = self->pMulti->chars();
	QValueList< SERIAL >::iterator it = chars.begin();
	PyObject* list = PyList_New( chars.size() );
	while( it != chars.end() )
	{
		P_CHAR pChar = FindCharBySerial( *it );
		if( pChar )
			PyList_Append( list, PyGetCharObject( pChar ) );
		it ++;
	}
	return list;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:20,代码来源:multi.cpp

示例8: wpMulti_items

/*
 * Returns the list of the items in this multi
 */
static PyObject* wpMulti_items( wpMulti* self, PyObject* args )
{
	Q_UNUSED(args);
	if( !self->pMulti || self->pMulti->free )
		return PyFalse;
	QValueList< SERIAL > items = self->pMulti->items();
	QValueList< SERIAL >::iterator it = items.begin();
	PyObject* list = PyList_New( items.size() );
	while( it != items.end() )
	{
		P_ITEM pItem = FindItemBySerial( *it );
		if( pItem )
			PyList_Append( list, PyGetItemObject( pItem ) );
		it ++;
	}
	return list;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:20,代码来源:multi.cpp

示例9: continuation_set_length

void GuideUiScheme::continuation_set_length (int nb_rows)
{
  cont->set_nb_rows (nb_rows);
  if (nb_rows == 0)
    {
      env->set_nb_rows (0);
      mainWindow->removeSpecialSelectionInFiles ();
      repl->removeSpecialSelection ();
    }

  // Open or close the debug frame (continuation & environment)
  QValueList<int> sizes = splitter9->sizes ();

  //  printf ("sizes[0] = %d\n", sizes[0]);
  //  if (sizes.size () >= 2)
  //    printf ("sizes[1] = %d\n", sizes[1]);
  //  fflush (stdout);

  if (nb_rows > 0)
    {
      contenv->show ();
      if (sizes.size () >= 2 && sizes[1] > 10 * sizes[0])
        {
          //          contenv->show ();
          sizes[0] = 600;
          sizes[1] = 400;
          splitter9->setSizes (sizes);
        }
    }
  else
    {
      contenv->hide ();
      //      if (sizes.size () >= 2 && sizes[1] < 10 * sizes[0])
      //        {
      //          contenv->hide ();
      //        }
    }
}
开发者ID:OpenEngineDK,项目名称:other-gambit,代码行数:38,代码来源:guideuischeme.cpp

示例10: selectItems

void ClusterPalette::selectItems(QValueList<int> selectedClusters) {
    //Set isInSelectItems to true to prevent the emission of signals due to selectionChange
    isInSelectItems = true;

    //unselect all the items first
    iconView->selectAll(false);

    //Loop on the clusters to be selected
    QValueList<int>::iterator clusterIterator;

    ClusterPaletteIconViewItem* currentIcon = 0L;
    for(clusterIterator = selectedClusters.begin(); clusterIterator != selectedClusters.end(); ++clusterIterator) {
        currentIcon =  static_cast<ClusterPaletteIconViewItem*>(iconView->findItem(QString("%1").arg(*clusterIterator),Qt::BeginsWith));
        currentIcon->setSelected(true,true);
    }

    //Last item in selection gets focus if it exists
    if(selectedClusters.size() != 0) iconView->setCurrentItem(currentIcon);

    //reset isInSelectItems to false to enable again the the emission of signals due to selectionChange
    isInSelectItems = false;

    isUpToDate = true;
}
开发者ID:caffeine-xx,项目名称:klusters,代码行数:24,代码来源:clusterPalette.cpp

示例11: addRemoveMakefileam

/**
 * Add entries to a variable. Will just add the variables to the existing line, removing duplicates
 * Will preserve += constructs and make sure that the variable only has one copy of the value across
 * all += constructs
 * @param fileName
 * @param variables key=value string of entries to add
 * @param add true= add these key,value pairs, false = remove. You can have empty values for an add - the whole line is
 * removed. For adding, we will not add an empty line.
 */
void AutoProjectTool::addRemoveMakefileam(const QString &fileName, QMap<QString, QString> variables,  bool add)
{
	// input file reading
	QFile fin(fileName);
	if (!fin.open(IO_ReadOnly))
	{
		return ;
	}
	QTextStream ins(&fin);

	// output file writing.
	QFile fout(fileName + "#");
	if (!fout.open(IO_WriteOnly))
	{
		fin.close();
		return ;
	}
	QTextStream outs(&fout);

	// variables
	QRegExp re("^(#kdevelop:[ \t]*)?([A-Za-z][@A-Za-z0-9_]*)[ \t]*([:\\+]?=)[ \t]*(.*)$");

	// build key=map of values to add
	// map can be empty.we never add an empty key, but do remove empty keys from the file..
	QDict< QMap<QString, bool> > interest;
	for (QMap<QString, QString>::Iterator it0 = variables.begin(); it0 != variables.end(); ++it0)
	{
		kdDebug(9020) << "key (" << add<<"): " << it0.key() << "="<< it0.data() << endl;

		QMap<QString, bool>* set = new QMap<QString, bool>();
		if (!it0.data().stripWhiteSpace().isEmpty())
		{
			QStringList variableList = QStringList::split(' ', it0.data());

			for (uint i = 0; i < variableList.count(); i++)
			{
				set->insert(variableList[i], true);
			}
		}
		interest.insert(it0.key(), set);
	}

	bool multiLine = false;
	QString lastLhs;
	QStringList lastRhs;
	QMap<QString, QString> seenLhs;
	while (!fin.atEnd())
	{
		QString s = ins.readLine();
		if (re.exactMatch(s))
		{
			QString lhs = re.cap(2);
			QMap<QString, bool>* ourRhs = interest.find(lhs);

			if (!ourRhs)
			{
				// not interested in this line at all
				// write it out as is..
				outs << s << endl;
			}
			else
			{
				// we are interested in this line..
				QString rhs = re.cap(4).stripWhiteSpace();
				if (rhs[ rhs.length() - 1 ] == '\\')
				{
					// save it for when we have the whole line..
					multiLine = true;
					lastLhs = lhs;
					rhs.setLength(rhs.length() - 1);
					lastRhs += QStringList::split(" ", rhs);
				}
				else
				{
					// deal with it now.

					QStringList bits = QStringList::split(" ", rhs);
					if (add)
					{
						// we are adding our interested values to this line and writing it

						// add this line to we we want to add to remove duplicates.
						for (uint index = 0; index < bits.size(); index++)
						{
							QMap<QString, bool>::iterator findEntry = ourRhs->find(bits[index]);
							if (findEntry == ourRhs->end())
							{
								// we haven't seen it, so add it, so we don't add it again later..
								ourRhs->insert(bits[index], true);
							}
							// else we have this value in our 'to add list' , it is either already been
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:101,代码来源:misc.cpp

示例12: compInitOptionValue

static Bool
kconfigReadOptionValue (CompObject	*object,
			KConfig		*config,
			CompOption	*o,
			CompOptionValue *value)
{
    compInitOptionValue (value);

    switch (o->type) {
    case CompOptionTypeBool:
    case CompOptionTypeBell:
	kconfigBoolToValue (config->readBoolEntry (o->name), o->type, value);
	break;
    case CompOptionTypeInt:
	value->i = config->readNumEntry (o->name);
	break;
    case CompOptionTypeFloat:
	value->f = config->readDoubleNumEntry (o->name);
	break;
    case CompOptionTypeString:
    case CompOptionTypeColor:
    case CompOptionTypeKey:
    case CompOptionTypeButton:
    case CompOptionTypeEdge:
    case CompOptionTypeMatch:
	if (!kconfigStringToValue (object,
				   config->readEntry (o->name), o->type,
				   value))
	    return FALSE;
	break;
    case CompOptionTypeList: {
	int n, i;

	value->list.value  = NULL;
	value->list.nValue = 0;
	value->list.type   = o->value.list.type;

	switch (o->value.list.type) {
	case CompOptionTypeInt: {
	    QValueList< int > list;

	    list = config->readIntListEntry (o->name);

	    n = list.size ();
	    if (n)
	    {
		value->list.value = (CompOptionValue *)
		    malloc (sizeof (CompOptionValue) * n);
		if (value->list.value)
		{
		    for (i = 0; i < n; i++)
			value->list.value[i].i = list[i];

		    value->list.nValue = n;
		}
	    }
	} break;
	case CompOptionTypeBool:
	case CompOptionTypeFloat:
	case CompOptionTypeString:
	case CompOptionTypeColor:
	case CompOptionTypeKey:
	case CompOptionTypeButton:
	case CompOptionTypeEdge:
	case CompOptionTypeBell:
	case CompOptionTypeMatch: {
	    QStringList list;

	    list = config->readListEntry (o->name);

	    n = list.size ();
	    if (n)
	    {
		value->list.value = (CompOptionValue *)
		    malloc (sizeof (CompOptionValue) * n);
		if (value->list.value)
		{
		    for (i = 0; i < n; i++)
		    {
			if (!kconfigStringToValue (object,
						   list[i],
						   value->list.type,
						   &value->list.value[i]))
			    break;

			value->list.nValue++;
		    }

		    if (value->list.nValue != n)
		    {
			compFiniOptionValue (value, o->type);
			return FALSE;
		    }
		}
	    }
	} break;
	case CompOptionTypeList:
	case CompOptionTypeAction:
	    return FALSE;
	}
//.........这里部分代码省略.........
开发者ID:SubwayDesktop,项目名称:compiz-stable,代码行数:101,代码来源:kconfig.cpp

示例13: drawClusterIds

void CorrelationView::drawClusterIds(QPainter& painter){
 QValueList<int> shownClusters;
 QValueList<int>::const_iterator iterator;
 QValueList<int> const clusters = view.clusters();
 for(iterator = clusters.begin(); iterator != clusters.end(); ++iterator)
  shownClusters.append(*iterator);
 qHeapSort(shownClusters);
 
 QFont f("Helvetica",8); 
 painter.setFont(f);
 painter.setPen(colorLegend); //set the color for the legends.

 //Draw the absciss ids
 //The abscissa of the legend for the current correlogram.
 uint X = widthBorder + 2;
 
 //The ordinate of the legend for the current correlogram.
 uint Y = 0;
 int width = nbBins * binWidth + XMARGIN;

 //Variable used to draw the firing rate
 uint firingX = 0;
 uint firingY = 0;
 int clusterIndex = 1;
 int nbClusters = shownClusters.size();
 ItemColors& clusterColors = doc.clusterColors();
 QRect r((QRect)window);
 bool isMargin = true;
 if(r.left() != 0) isMargin = false;
 
 for(iterator = shownClusters.begin(); iterator != shownClusters.end(); ++iterator){
  //the abscissa is increase by the font size to adjust for conversion from world coordinates to viewport coordinates.
  QRect r;
  if(isMargin) r = QRect(worldToViewport(X,-Y).x() + 10,worldToViewport(X,-Y).y() - 2,worldToViewportWidth(width),10);
  else r = QRect(worldToViewport(X,-Y).x() + 10  - XMARGIN,worldToViewport(X,-Y).y() - 2,worldToViewportWidth(width),10);
  painter.drawText(r,Qt::AlignHCenter,QString("%1").arg(*iterator));

  if(shoulderLine){
    QString firingRate = "";
    if(firingRates.contains(*iterator)) firingRate = firingRates[*iterator];
     if(nbClusters == 1){
      firingX = X;
      firingY = heightBorder + YsizeForMaxAmp;
      QRect rf;
      if(isMargin) rf = QRect(worldToViewport(firingX,-firingY).x() + 10,worldToViewport(firingX,-firingY).y() - 17,worldToViewportWidth(width + 20),15);
      else rf = QRect(worldToViewport(firingX,-firingY).x() + 10 - XMARGIN,worldToViewport(firingX,-firingY).y() - 17,worldToViewportWidth(width + 20),15);
      painter.setPen(clusterColors.color(*iterator));
      painter.setBrush(NoBrush);
      painter.drawRect(rf);
      painter.setPen(colorLegend);
      painter.drawText(rf,Qt::AlignCenter,firingRate);
     }
     else if(clusterIndex == 1){
       firingX = X + width + Xspace;
       firingY = heightBorder;
       QRect rf;
       if(isMargin) rf = QRect(worldToViewport(firingX,-firingY).x() + 10,worldToViewport(firingX,-firingY).y() - 13,worldToViewportWidth(width + 20),15);
       else rf = QRect(worldToViewport(firingX,-firingY).x() + 10 - XMARGIN,worldToViewport(firingX,-firingY).y() - 13,worldToViewportWidth(width + 20),15);
       painter.setPen(clusterColors.color(*iterator));
       painter.setBrush(NoBrush);
       painter.drawRect(rf);
       painter.setPen(colorLegend);
       painter.drawText(rf,Qt::AlignCenter,firingRate);
     }
     else{
      firingY = heightBorder + (clusterIndex - 1) * (YsizeForMaxAmp + Yspace) - (Yspace / 2);
      QRect rf;
      if(isMargin) rf = QRect(worldToViewport(firingX,-firingY).x() + 10,worldToViewport(firingX,-firingY).y(),worldToViewportWidth(width + 20),15);
      else rf = QRect(worldToViewport(firingX,-firingY).x() + 10 - XMARGIN,worldToViewport(firingX,-firingY).y(),worldToViewportWidth(width + 20),15);
      painter.setPen(clusterColors.color(*iterator));
      painter.setBrush(NoBrush);
      painter.drawRect(rf);
      painter.setPen(colorLegend);
      painter.drawText(rf,Qt::AlignCenter,firingRate);
      firingX += shift;
     }

   clusterIndex++;
  }

  X += shift;
 }

 //Draw the ordinate ids
 X = 0;
 Y = heightBorder + YsizeForMaxAmp + Yspace - 2;
 uint yshift = YsizeForMaxAmp + Yspace;

 for(iterator = shownClusters.begin(); iterator != shownClusters.end(); ++iterator){
  QRect r(worldToViewport(X,-Y).x(),worldToViewport(X,-Y).y(),10,worldToViewportHeight(YsizeForMaxAmp + Yspace));
  painter.drawText(r,Qt::AlignCenter,QString("%1").arg(*iterator));
  Y += yshift;
 }
}
开发者ID:caffeine-xx,项目名称:klusters,代码行数:94,代码来源:correlationview.cpp

示例14: main

int main( int argc, char ** argv )
{
    //disable qt module support for skim itself; xim will be disabled latter
    setenv("QT_IM_SWITCHER", "imsw-none", 1);
    setenv("QT_IM_MODULE", "xim", 1);
    setenv("XMODIFIER", "@im=none", 1);

    KAboutData about(PACKAGE, "SKIM",
        VERSION " (compiled with libscim " SCIM_VERSION ")",
        description, KAboutData::License_GPL_V2, "(C) 2004 - 2006 LiuCougar",
        I18N_NOOP("IRC:\nserver: irc.freenode.net / channel: #scim\n\nFeedback:\[email protected]"),
        "http://www.scim-im.org");
    about.addAuthor( "LiuCougar (liuspider)", I18N_NOOP("Core Developer"),
      "[email protected]" );
    about.addCredit ( "JamesSu", I18N_NOOP("SCIM Core Author"), "[email protected]" );
    about.addAuthor ( "JanHefti", I18N_NOOP("Doc writer and German translator"),
      "[email protected]" );
    about.addAuthor ( "KitaeKim", I18N_NOOP("Art designer and Korean translator"),
      "[email protected]" );
    about.addAuthor ( "YukikoBando", I18N_NOOP("Japanese translator"),
      "[email protected]" );
    about.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names")
        ,I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));

    QString curarg;

    QStringList otherArgs;

    for(int i = 1; i < argc ; i++)
    {
        curarg = argv[i];
        if( curarg == "--no-stay")
            otherArgs.push_back("no-stay");
        else if (curarg == "-c" ) {
            otherArgs.push_back("c");
            //FIXME
            otherArgs.push_back(argv[++i]);
        } else if( curarg == "-f")
            otherArgs.push_back("force");
    }

    //FIXME: noxim is necessary to disable xim support in qt for this app
    const char* fake_arg1 =  "--noxim";
    char* fake_argv[10] = {argv[0], const_cast<char *>(fake_arg1), 0, 0, 0, 0, 0};
    for(int i = 1; i < argc; i++)
    {
      fake_argv[i+1] = argv[i];
    }
    KCmdLineArgs::init(argc+1, fake_argv, &about);

    KCmdLineArgs::addCmdLineOptions( options );

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    scim::uint32 verbose_level = 0;
    QString verbose_raw = args->getOption("verbose");
    if( verbose_raw.length() && verbose_raw.toInt())
        verbose_level = verbose_raw.toInt();

    scim::DebugOutput::set_verbose_level( verbose_level );
    scim::DebugOutput::enable_debug (SCIM_DEBUG_AllMask);
//     scim::DebugOutput::enable_debug (SCIM_DEBUG_MainMask | SCIM_DEBUG_SocketMask);

    if( args->isSet("l") ) {
      new KInstance(PACKAGE);
      QValueList<SkimPluginInfo *> info = SkimPluginManager::allAvailablePlugins();
      std::cout << I18N_NOOP("Installed skim Plugins:") << "\n" << I18N_NOOP("Name") << "\t\t\t\t" << I18N_NOOP("Comment") << "\n";
      for(uint i = 0; i < info.size(); i++) {
          printf("%-26s\t%s", (const char *)info[i]->pluginName().local8Bit(), (const char *)info[i]->comment().local8Bit());
          if(info[i]->isNoDisplay())
              std::cout << I18N_NOOP(" (Hidden)");
          std::cout << "\n";
      }
      std::cout << "\n" << I18N_NOOP("Note: Hidden plugins can not be disabled.") << "\n";
      return 0;
    }

    QCString p = args->getOption("p"), np = args->getOption("np");
    QStringList enabledPlugins, disabledPlugins;
    if( p.length() )
      enabledPlugins = QStringList::split(",", p);

    if( np.length() )
      disabledPlugins = QStringList::split(",", np);

    if( args->isSet("d") )
        scim::scim_daemon ();

    KApplication * kAppMainThread = new KApplication();
    if( kAppMainThread->isRestored() && !ScimKdeSettings::autoStart() )
      return 127; //when skim should not auto start, restore from session is not permitted

    if (signal(SIGTERM, sighandler) == SIG_IGN)
        signal(SIGTERM, SIG_IGN);
    if (signal(SIGINT, sighandler) == SIG_IGN)
        signal(SIGINT, SIG_IGN);
    if (signal(SIGHUP, sighandler) == SIG_IGN)
        signal(SIGHUP, SIG_IGN);

    new SkimPluginManager(enabledPlugins, disabledPlugins, otherArgs);
//.........这里部分代码省略.........
开发者ID:scim-im,项目名称:skim,代码行数:101,代码来源:main.cpp

示例15: main

int main(int argc, char *argv[]) {
  atexit(exitHelper);
  KInstance inst("d2asc");
  KstDataSourcePtr file;

  KConfig *kConfigObject = new KConfig("kstdatarc", false, false);
  KstDataSource::setupOnStartup(kConfigObject);

  fieldEntry field;
  QValueList<fieldEntry> fieldList;
  char *filename;
  bool do_ave = false, do_skip = false;
  int start_frame=0, n_frames=2000000;
  int n_skip = 0;
  int NS=0, i_S;
  int i;

  if (argc < 3 || argv[1][0] == '-') {
    Usage();
    return -1;
  }

  filename = argv[1];

  for (i = 2; i < argc; i++) {
    if (argv[i][0] == '-') {
      if (argv[i][1] == 'f') {
        i++;
        start_frame = atoi(argv[i]);
      } else if (argv[i][1] == 'n') {
        i++;
        n_frames = atoi(argv[i]);
      } else if (argv[i][1] == 's') {
        i++;
        n_skip = atoi(argv[i]);
        if (n_skip>0) do_skip = true;
      } else if (argv[i][1] == 'a') {
        do_ave = true;
      } else if (argv[i][1] == 'x') {
        i++;
        field.field = argv[i];
        field.doHex = true;
        fieldList.append(field);
      } else {
        Usage();
      }
    } else {
      field.field = argv[i];
      field.doHex = false;
      fieldList.append(field);
    }
  }

  if (!do_skip) {
    do_ave = false;
  }

  file = KstDataSource::loadSource(filename);
  if (!file || !file->isValid() || file->isEmpty()) {
    fprintf(stderr, "d2asc error: file %s has no data\n", filename);
    return -2;
  }
  /** make vectors and fill the list **/
  QPtrList<KstRVector> vlist;

  for (i=0; i<int(fieldList.size()); i++) {
    if (!file->isValidField(fieldList[i].field)) {
      fprintf(stderr, "d2asc error: field %s in file %s is not valid\n",
              fieldList[i].field.latin1(), filename);
      return -3;
    }
    KstRVectorPtr v = new KstRVector(file, fieldList[i].field, KstObjectTag("tag", KstObjectTag::globalTagContext), start_frame, n_frames, n_skip, n_skip>0, do_ave);
    vlist.append(v);
  }

  /* find NS */
  for (i = 0; i < int(fieldList.size()); i++) {
    while (vlist.at(i)->update(-1) != KstObject::NO_CHANGE)
      ; // read vector
    if (vlist.at(i)->length() > NS) {
      NS = vlist.at(i)->length();
    }
  }

  for (i_S = 0; i_S < NS; i_S++) {
    for (i = 0; i < int(fieldList.size()); i++) {
      if (fieldList[i].doHex) {
        printf("%4x ",  (int)vlist.at(i)->interpolate(i_S, NS));
      } else {
        printf("%.16g ", vlist.at(i)->interpolate(i_S, NS));
      }
    }
    printf("\n");
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:95,代码来源:d2asc.cpp


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