示例#1
0
void RDFormPost::LoadUrlEncoding(char first)
{
  char *data=new char[post_content_length+1];
  int n;
  QStringList lines;
  QStringList line;

  data[0]=first;
  if((n=read(0,data+1,post_content_length-1))<0) {
    post_error=RDFormPost::ErrorMalformedData;
    return;
  }
  data[post_content_length]=0;

  /*
   * Uncomment this to dump the raw post data to "/tmp/output.dat".
   */
  /*
  int out=open("/tmp/output.dat",O_WRONLY|O_CREAT);
  if(out<0) {
    int err=errno;
    printf("Content-type: text/html\n\n");
    printf("Couldn't open file [%s]\n",strerror(err));
    exit(0);
  }
  write(out,data,post_content_length);
  ::close(out);
  printf("Content-type: text/html\n\n");
  printf("POST DUMPED TO \"/tmp/output.dat\"!\n");
  exit(0);
  */
  lines=lines.split("&",data);
  for(unsigned i=0;i<lines.size();i++) {
    line=line.split("=",lines[i]);
    switch(line.size()) {
    case 1:
      post_values[line[0]]="";
      post_filenames[line[0]]=false;
      break;

    case 2:
      post_values[line[0]]=RDFormPost::urlDecode(line[1]);
      post_filenames[line[0]]=false;
      break;
    }
  }

  post_error=RDFormPost::ErrorOk;
  delete data;
}
示例#2
0
RKText::RKText (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
	RK_TRACE (PLUGIN);

	// create layout and label
	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());

	label = new QLabel (QString::null, this);
	label->setAlignment (Qt::AlignAuto | Qt::ExpandTabs | Qt::WordBreak);
	vbox->addWidget (label);

	QString initial_text;
	QStringList lines = lines.split ("\n", element.text (), false);
	for (unsigned int i=0; i < lines.count (); i++) {
		QString line = lines[i].stripWhiteSpace ();
		if (!line.isEmpty ()) {
			initial_text.append (line + '\n');
		}
	}

	// strip final newline
	initial_text.truncate (initial_text.length () -1);

	// create and add property
	addChild ("text", text = new RKComponentPropertyBase (this, true));
	connect (text, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (textChanged (RKComponentPropertyBase *)));

	// initialize
	text->setValue (initial_text);
}
示例#3
0
//----------------------------------------------------------------------------
// Import from CSV file
//
// CSV Format : Last Name / First Name / Birthday / address1 / address2 / ZIP / City / Phone
//----------------------------------------------------------------------------
QStringList get_substr_csv( std::string str )
{
    QRegExp     sSeparator( "[;\t]" );
    QStringList listStr;

    return listStr.split( sSeparator, str.c_str(), true );
}
示例#4
0
QList< bool > KLCPUFuses::stringToBoolValList(const QString & boolList) const
{
    QStringList list;
    QList< bool > retVal;

    list = list.split( ",", boolList );
    for (QStringList::iterator it = list.begin(); it != list.end(); ++it)
    {
        if ( (*it).stripWhiteSpace().length() != 0 )
            retVal.append( (*it).stripWhiteSpace().upper() == TRUE_STRING );
    }
    return retVal;
}
示例#5
0
KLCPUFuses::KLCPUFuses(QDomDocument &, QDomElement & parent)
{
    if ( parent.nodeName().upper() == "FUSES" )
    {
        for( QDomNode n = parent.firstChild(); !n.isNull(); n = n.nextSibling() )
        {
            if ( n.isElement() )
            {
                QDomElement ele = n.toElement();
                if ( n.nodeName().upper() == "LOW_CAN_BE_CHANGED" )
                    m_lowCanBeChanged = stringToBoolValList( ele.text() );
                else if ( n.nodeName().upper() == "LOW_NAMES" )
                {
                    QStringList list;
                    list = list.split(",", ele.text());
                    m_lowNames = list;
                }
                else if ( n.nodeName().upper() == "HIGH_CAN_BE_CHANGED" )
                    m_highCanBeChanged = stringToBoolValList( ele.text() );
                else if ( n.nodeName().upper() == "HIGH_NAMES" )
                {
                    QStringList list;
                    list = list.split(",", ele.text());
                    m_highNames = list;
                }
                else if ( n.nodeName().upper() == "EXT_CAN_BE_CHANGED" )
                    m_extCanBeChanged = stringToBoolValList( ele.text() );
                else if ( n.nodeName().upper() == "EXT_NAMES" )
                {
                    QStringList list;
                    list = list.split(",", ele.text());
                    m_extNames = list;
                }
            }
        }
    }
}
示例#6
0
void RDFormPost::LoadUrlEncoding()
{
    char *data=new char[post_content_length+1];
    int n;
    QStringList lines;
    QStringList line;

    if((n=read(0,data,post_content_length))<0) {
        post_error=RDFormPost::ErrorMalformedData;
        return;
    }
    data[post_content_length]=0;
    lines=lines.split("&",data);
    for(unsigned i=0; i<lines.size(); i++) {
        line=line.split("=",lines[i]);
        if(line.size()==2) {
            post_values[line[0]]=UrlDecode(line[1]);
            post_filenames[line[0]]=false;
        }
    }

    post_error=RDFormPost::ErrorOk;
    delete data;
}
VCSFileInfoMap* ClearcaseManipulator::retreiveFilesInfos(const QString& directory) {


  VCSFileInfoMap* fileInfoMap = new VCSFileInfoMap();

  char CCcommand[1024];
  sprintf(CCcommand, "cleartool desc -fmt \"%%m;%%En;%%Rf;%%Sn;%%PVn\\n\" %s/*", directory.ascii());
  FILE* outputFile = popen(CCcommand, "r");

  char* line = NULL;
  size_t numRead;
  while (!feof(outputFile)) {
    getline(&line,&numRead,outputFile);

    if (numRead > 0) {
      int pos = 0;
      int lastPos = -1;

      QStringList outputList;
      outputList = outputList.split(CT_DESC_SEPARATOR, QString(line), true );
      outputList[Name] = QString(basename((char*)outputList[Name].ascii()));

      VCSFileInfo::FileState state;
      if (outputList[ClearcaseManipulator::State] == "unreserved" || outputList[ClearcaseManipulator::State] == "reserved") {
	state = VCSFileInfo::Modified;
      }
      else if (outputList[ClearcaseManipulator::State] == "") {
	state = VCSFileInfo::Uptodate;
      }
      else {
	state = VCSFileInfo::Unknown;
      }


      (*fileInfoMap)[outputList[ClearcaseManipulator::Name]] = VCSFileInfo(outputList[ClearcaseManipulator::Name], outputList[ClearcaseManipulator::Version], outputList[ClearcaseManipulator::RepositoryVersion], state);
    }
  }

  pclose(outputFile);

  return fileInfoMap;
}
示例#8
0
文件: rdcae.cpp 项目: WMFO/rivendell
void RDCae::UpdateMeters()
{
  char msg[1501];
  int n;
  QStringList args;

  while((n=cae_meter_socket->readBlock(msg,1500))>0) {
    msg[n]=0;
    args=args.split(" ",msg);
    if(args[0]=="ML") {
      if(args.size()==6) {
	if(args[1]=="I") {
	  cae_input_levels[args[2].toInt()][args[3].toInt()][0]=args[4].toInt();
	  cae_input_levels[args[2].toInt()][args[3].toInt()][1]=args[5].toInt();
	}
	if(args[1]=="O") {
	  cae_output_levels[args[2].toInt()][args[3].toInt()][0]=
	    args[4].toInt();
	  cae_output_levels[args[2].toInt()][args[3].toInt()][1]=
	    args[5].toInt();
	}
      }
    }
    if(args[0]=="MO") {
      if(args.size()==5) {
	cae_stream_output_levels[args[1].toInt()][args[2].toInt()][0]=
	    args[3].toInt();
	cae_stream_output_levels[args[1].toInt()][args[2].toInt()][1]=
	    args[4].toInt();
      }
    }
    if(args[0]=="MP") {
      if(args.size()==4) {
	cae_output_positions[args[1].toInt()][args[2].toInt()]=args[3].toUInt();
      }
    }
  }
}
示例#9
0
void RDFormPost::LoadMultipartEncoding()
{
    std::map<QString,QString> headers;
    bool header=true;
    char *data=NULL;
    FILE *f=NULL;
    ssize_t n=0;
    QString sep;
    QString name;
    QString filename;
    QString tempdir;
    int fd=-1;

    if((f=fdopen(0,"r"))==NULL) {
        post_error=RDFormPost::ErrorInternal;
        return;
    }



    /*
    int out=open("/tmp/output.dat",O_WRONLY|O_CREAT);
    while((n=getline(&data,(size_t *)&n,f))>0) {
      write(out,data,n);
    }
    ::close(out);
    printf("Content-type: text/html\n\n");
    printf("DONE!\n");
    */








    if((n=getline(&data,(size_t *)&n,f))<=0) {
        post_error=RDFormPost::ErrorMalformedData;
        return;
    }
    sep=QString(data).stripWhiteSpace();

    //
    // Get message parts
    //
    while((n=getline(&data,(size_t *)&n,f))>0) {
        if(QString(data).stripWhiteSpace().contains(sep)>0) {  // End of part
            if(fd>=0) {
                ftruncate(fd,lseek(fd,0,SEEK_CUR)-2);  // Remove extraneous final CR/LF
                ::close(fd);
                fd=-1;
            }
            name="";
            filename="";
            headers.clear();
            header=true;
            continue;
        }
        if(header) {  // Read header
            if(QString(data).stripWhiteSpace().isEmpty()) {
                if(!headers["content-disposition"].isNull()) {
                    QStringList fields;
                    fields=fields.split(";",headers["content-disposition"]);
                    if(fields.size()>0) {
                        if(fields[0].lower().stripWhiteSpace()=="form-data") {
                            for(unsigned i=1; i<fields.size(); i++) {
                                QStringList pairs;
                                pairs=pairs.split("=",fields[i]);
                                if(pairs[0].lower().stripWhiteSpace()=="name") {
                                    name=pairs[1].stripWhiteSpace();
                                    name.replace("\"","");
                                }
                                if(pairs[0].lower().stripWhiteSpace()=="filename") {
                                    filename=post_tempdir+"/"+pairs[1].stripWhiteSpace();
                                    filename.replace("\"","");
                                    fd=open(filename,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
                                }
                            }
                        }
                    }
                }
                header=false;
            }
            else {
                QStringList hdr;
                hdr=hdr.split(":",QString(data).stripWhiteSpace());
                // Reconcaternate trailing sections so we don't split on the
                // useless M$ drive letter supplied by IE
                for(unsigned i=2; i<hdr.size(); i++) {
                    hdr[1]+=hdr[i];
                }
                headers[hdr[0].lower()]=hdr[1];
            }
        }
        else {  // Read data
            if(filename.isEmpty()) {
                QString str=post_values[name].toString();
                str+=QString(data);
                post_filenames[name]=false;
                post_values[name]=str.stripWhiteSpace();
            }
            else {
                post_filenames[name]=true;
                post_values[name]=filename;
                write(fd,data,n);
            }
        }
    }
    free(data);
    post_error=RDFormPost::ErrorOk;
}
示例#10
0
void MainObject::DispatchCommand(QString cmd)
{
    bool processed=false;
    int line;
    QTime time;
    bool ok=false;
    bool overwrite=!edit_modified;
    QStringList cmds;
    QString verb;

    cmd=cmd.stripWhiteSpace();
    if(cmd.right(1)=="!") {
        overwrite=true;
        cmd=cmd.left(cmd.length()-1).stripWhiteSpace();
    }
    cmds=cmds.split(" ",cmd);
    verb=cmds[0].lower();

    //
    // No loaded log needed for these
    //
    if(verb=="deletelog") {
        if(rda->user()->deleteLog()) {
            if(cmds.size()==2) {
                Deletelog(cmds[1]);
            }
            else {
                fprintf(stderr,"deletelog: invalid command arguments\n");
            }
        }
        else {
            fprintf(stderr,"deletelog: insufficient privileges [Delete Log]\n");
        }
        processed=true;
    }

    if((verb=="exit")||(verb=="quit")||(verb=="bye")) {
        if(overwrite) {
            exit(0);
        }
        else {
            OverwriteError(verb);
        }
        processed=true;
    }

    if((verb=="help")||(verb=="?")) {
        Help(cmds);
        processed=true;
    }

    if(verb=="listlogs") {
        ListLogs();
        processed=true;
    }

    if(verb=="listservices") {
        Listservices();
        processed=true;
    }

    if(verb=="load") {
        if(overwrite) {
            if(cmds.size()==2) {
                Load(cmds[1]);
            }
            else {
                fprintf(stderr,"load: invalid command arguments\n");
            }
        }
        else {
            OverwriteError("load");
        }
        processed=true;
    }

    if(verb=="new") {
        if(overwrite) {
            if(cmds.size()==2) {
                New(cmds[1]);
            }
            else {
                fprintf(stderr,"new: invalid command arguments\n");
            }
        }
        else {
            OverwriteError("new");
        }
        processed=true;
    }

    //
    // These need a log loaded
    //
    if((processed)||(edit_log_event!=NULL)) {
        if(verb=="addcart") {
            if(rda->user()->addtoLog()) {
                if(cmds.size()==3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)) {
                        unsigned cartnum=cmds[2].toUInt(&ok);
                        if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) {
                            Addcart(line,cartnum);
                        }
                        else {
                            fprintf(stderr,"addcart: invalid cart number\n");
                        }
                    }
                    else {
                        fprintf(stderr,"addcart: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"addcart: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,"addcart: insufficient privileges [Add Log Items]\n");
            }
            processed=true;
        }

        if(verb=="addchain") {
            if(rda->user()->addtoLog()) {
                if(cmds.size()==3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)) {
                        Addchain(line,cmds[2]);
                    }
                    else {
                        fprintf(stderr,"addchain: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"addchain: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,"addchain: insufficient privileges [Add Log Items]\n");
            }
            processed=true;
        }

        if(verb=="addmarker") {
            if(rda->user()->addtoLog()) {
                if(cmds.size()==2) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)) {
                        Addmarker(line);
                    }
                    else {
                        fprintf(stderr,"addmarker: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"addmarker: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,"addmarker: insufficient privileges [Add Log Items]\n");
            }
            processed=true;
        }

        if(verb=="addtrack") {
            if(rda->user()->addtoLog()) {
                if(cmds.size()==2) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)) {
                        Addtrack(line);
                    }
                    else {
                        fprintf(stderr,"addtrack: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"addtrack: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,"addtrack: insufficient privileges [Add Log Items]\n");
            }
            processed=true;
        }

        if(verb=="header") {
            Header();
            processed=true;
        }

        if(verb=="list") {
            List();
            processed=true;
        }

        if(verb=="remove") {
            if(rda->user()->removefromLog()) {
                if(cmds.size()==2) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)&&(line<edit_log_event->size())) {
                        Remove(line);
                    }
                    else {
                        fprintf(stderr,"remove: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"remove: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,"remove: insufficient privileges [Delete Log Items]\n");
            }
            processed=true;
        }

        if(verb=="save") {
            if(rda->user()->arrangeLog()) {
                Save();
            }
            else {
                fprintf(stderr,"save: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="saveas") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==2) {
                    if(cmds[1].length()>64) {
                        fprintf(stderr,"saveas: log name too long\n");
                    }
                    Saveas(cmds[1]);
                }
                else {
                    fprintf(stderr,"saveas: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "saveas: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setautorefresh") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==2) {
                    QString arg=cmds[1].lower();
                    if((arg=="yes")||(arg=="true")||(arg=="y")) {
                        Setautorefresh(true);
                        processed=true;
                    }
                    if((arg=="no")||(arg=="false")||(arg=="n")) {
                        Setautorefresh(false);
                        processed=true;
                    }
                    if(!processed) {
                        fprintf(stderr,"setautorefresh: invalid command argument\n");
                    }
                }
                else {
                    fprintf(stderr,"setautorefresh: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "setautorefresh: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setcart") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)&&(line<edit_log_event->size())) {
                        unsigned cartnum=cmds[2].toUInt(&ok);
                        if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) {
                            Setcart(line,cartnum);
                        }
                        else {
                            fprintf(stderr,"setcart: invalid cart number\n");
                        }
                    }
                    else {
                        fprintf(stderr,"setcart: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"setcart: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "setcart: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setcomment") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()>=3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)&&(line<edit_log_event->size())) {
                        cmds.remove(cmds.begin());
                        cmds.remove(cmds.begin());
                        Setcomment(line,cmds.join(" "));
                    }
                    else {
                        fprintf(stderr,"setcomment: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"setcomment: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "setcomment: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setdesc") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()>=2) {
                    cmds.erase(cmds.begin());
                    Setdesc(cmds.join(" "));
                }
                else {
                    fprintf(stderr,"setdesc: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "setdesc: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setenddate") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==1) {
                    Setenddate(QDate());
                }
                else {
                    if(cmds.size()==2) {
                        QDate date=QDate::fromString(cmds[1],Qt::ISODate);
                        if(date.isValid()) {
                            Setenddate(date);
                        }
                        else {
                            fprintf(stderr,"setenddate: invalid date format\n");
                        }
                    }
                    else {
                        fprintf(stderr,"setenddate: invalid command arguments\n");
                    }
                }
            }
            else {
                fprintf(stderr,
                        "setenddate: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setlabel") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)&&(line<edit_log_event->size())) {
                        Setlabel(line,cmds[2]);
                    }
                    else {
                        fprintf(stderr,"setlabel: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"setlabel: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "setlabel: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setpurgedate") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==1) {
                    Setpurgedate(QDate());
                }
                else {
                    if(cmds.size()==2) {
                        QDate date=QDate::fromString(cmds[1],Qt::ISODate);
                        if(date.isValid()) {
                            Setpurgedate(date);
                        }
                        else {
                            fprintf(stderr,"setpurgedate: invalid date format\n");
                        }
                    }
                    else {
                        fprintf(stderr,"setpurgedate: invalid command arguments\n");
                    }
                }
            }
            else {
                fprintf(stderr,
                        "setpurgedate: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setservice") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==2) {
                    Setservice(cmds[1]);
                }
                else {
                    fprintf(stderr,"setservice: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "setservice: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="setstartdate") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==1) {
                    Setstartdate(QDate());
                }
                else {
                    if(cmds.size()==2) {
                        QDate date=QDate::fromString(cmds[1],Qt::ISODate);
                        if(date.isValid()) {
                            Setstartdate(date);
                        }
                        else {
                            fprintf(stderr,"setstartdate: invalid date format\n");
                        }
                    }
                    else {
                        fprintf(stderr,"setstartdate: invalid command arguments\n");
                    }
                }
            }
            else {
                fprintf(stderr,
                        "setstartdate: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="settime") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()>=3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)&&(line<edit_log_event->size())) {
                        RDLogLine::TimeType ttype=RDLogLine::NoTime;
                        if(cmds[2].lower()=="hard") {
                            ttype=RDLogLine::Hard;
                        }
                        if(cmds[2].lower()=="none") {
                            ttype=RDLogLine::Relative;
                        }
                        switch(ttype) {
                        case RDLogLine::Hard:
                            if(cmds.size()>=4) {
                                time=RDGetWebTime(cmds[3],&ok);
                                if(ok) {
                                    Settime(line,ttype,time);
                                }
                                else {
                                    fprintf(stderr,"settime: invalid time value\n");
                                }
                            }
                            else {
                                fprintf(stderr,"settime: missing time value\n");
                            }
                            break;

                        case RDLogLine::Relative:
                            Settime(line,ttype);
                            break;

                        case RDLogLine::NoTime:
                            fprintf(stderr,"settime: invalid time type\n");
                            break;
                        }
                    }
                    else {
                        fprintf(stderr,"settime: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"settime: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "settime: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="settrans") {
            if(rda->user()->arrangeLog()) {
                if(cmds.size()==3) {
                    line=cmds[1].toInt(&ok);
                    if(ok&&(line>=0)&&(line<edit_log_event->size())) {
                        RDLogLine::TransType trans=RDLogLine::NoTrans;
                        if(cmds[2].lower()=="play") {
                            trans=RDLogLine::Play;
                        }
                        if(cmds[2].lower()=="segue") {
                            trans=RDLogLine::Segue;
                        }
                        if(cmds[2].lower()=="stop") {
                            trans=RDLogLine::Stop;
                        }
                        if(trans!=RDLogLine::NoTrans) {
                            Settrans(line,trans);
                        }
                        else {
                            fprintf(stderr,"settrans: invalid transition type\n");
                        }
                    }
                    else {
                        fprintf(stderr,"settrans: invalid line number\n");
                    }
                }
                else {
                    fprintf(stderr,"settrans: invalid command arguments\n");
                }
            }
            else {
                fprintf(stderr,
                        "settrans: insufficient privileges [Rearrange Log Items]\n");
            }
            processed=true;
        }

        if(verb=="unload") {
            if(overwrite) {
                Unload();
            }
            else {
                OverwriteError("unload");
            }
            processed=true;
        }
    }
    else {
        fprintf(stderr,"%s: no log loaded\n",(const char *)verb);
        processed=true;
    }

    if(!processed) {
        fprintf(stderr,"invalid command\n");
    }
    PrintPrompt();
}
示例#11
0
// -----------------------------------------------------------------------
// Is called if the "Replace"-button is pressed.
void ChangeDialog::slotButtReplace()
{
  Expr.setWildcard(true);  // switch into wildcard mode
  Expr.setPattern(CompNameEdit->text());
  if(!Expr.isValid()) {
    QMessageBox::critical(this, tr("Error"),
	  tr("Regular expression for component name is invalid."));
    return;
  }

  // create dialog showing all found components
  QDialog *Dia = new QDialog(this);
  Dia->setCaption(tr("Found Components"));
  QVBoxLayout *Dia_All = new QVBoxLayout(Dia);
  Dia_All->setSpacing(3);
  Dia_All->setMargin(5);
  
  QScrollArea *Dia_Scroll = new QScrollArea(Dia);
  //Dia_Scroll->setMargin(5);
  Dia_All->addWidget(Dia_Scroll);
  
  QVBoxLayout *Dia_Box = new QVBoxLayout(Dia_Scroll->viewport());
  Dia_Scroll->insertChild(Dia_Box);
  QLabel *Dia_Label = new QLabel(tr("Change properties of\n")
                               + tr("these components ?"), Dia);
  Dia_All->addWidget(Dia_Label);
  
  QHBoxLayout *Dia_h = new QHBoxLayout(Dia);
  Dia_h->setSpacing(5);
  QPushButton *YesButton = new QPushButton(tr("Yes"));
  QPushButton *CancelButton = new QPushButton(tr("Cancel"));
  Dia_h->addWidget(YesButton);
  Dia_h->addWidget(CancelButton);
  connect(YesButton, SIGNAL(clicked()), Dia, SLOT(accept()));
  connect(CancelButton, SIGNAL(clicked()), Dia, SLOT(reject()));
  
  Dia_All->addLayout(Dia_h);

  QList<QCheckBox *> pList;
  QCheckBox *pb;
  Component *pc;
  QStringList List;
  QString str;
  int i1, i2;
  // search through all components
  for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) {
    if(matches(pc->Model)) {
      if(Expr.search(pc->Name) >= 0)
        for(Property *pp = pc->Props.first(); pp!=0; pp = pc->Props.next())
          if(pp->Name == PropNameEdit->currentText()) {
            pb = new QCheckBox(pc->Name);
            Dia_Box->addWidget(pb);   
            pList.append(pb);
            pb->setChecked(true);
            i1 = pp->Description.find('[');
            if(i1 < 0)  break;  // no multiple-choice property

            i2 = pp->Description.findRev(']');
            if(i2-i1 < 2)  break;
            str = pp->Description.mid(i1+1, i2-i1-1);
            str.replace( QRegExp("[^a-zA-Z0-9_,]"), "" );
            List = List.split(',',str);
            if(List.findIndex(NewValueEdit->text()) >= 0)
              break;    // property value is okay

            pb->setChecked(false);
            pb->setEnabled(false);
            break;
          }
    }
  }
/*
  QColor theColor;
  if(pList.isEmpty()) {
    YesButton->setEnabled(false);
    theColor =
       (new QLabel(tr("No match found!"), Dia_Box))->paletteBackgroundColor();
  }
  else  theColor = pList.current()->paletteBackgroundColor();
*/
  //Dia_Scroll->viewport()->setPaletteBackgroundColor(theColor);
  Dia->resize(50, 300);


  // show user all components found
  int Result = Dia->exec();
  if(Result != QDialog::Accepted) return;


  bool changed = false;
  // change property values
  
  QListIterator<QCheckBox *> i(pList);
  while(i.hasNext()){
    pb = i.next();
    if(!pb->isChecked())  continue;

    for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) {
      if(pb->text() != pc->Name)  continue;

      for(Property *pp = pc->Props.first(); pp!=0; pp = pc->Props.next()) {
        if(pp->Name != PropNameEdit->currentText())  continue;

        int tx_Dist, ty_Dist, tmp;
        pc->textSize(tx_Dist, ty_Dist);
        tmp = pc->tx+tx_Dist - pc->x1;
        if((tmp > 0) || (tmp < -6))  tx_Dist = 0; // remember text position
        tmp = pc->ty+ty_Dist - pc->y1;
        if((tmp > 0) || (tmp < -6))  ty_Dist = 0;

        pp->Value = NewValueEdit->text();

        int dx, dy;
        pc->textSize(dx, dy);   // correct text position
        if(tx_Dist != 0) {
          pc->tx += tx_Dist-dx;
          tx_Dist = dx;
        }
        if(ty_Dist != 0) {
          pc->ty += ty_Dist-dy;
          ty_Dist = dy;
        }

        // apply changes to schematic symbol
        Doc->recreateComponent(pc);
        changed = true;
        break;
      }
      break;
    }
  }

  delete Dia_All;
  delete Dia;
  if(changed) accept();
  else reject();
}