Esempio n. 1
0
QStringList ListItem::getPathPieces(){
    int lastPos = m_componentList.count()-1;
    QStringList d;
    //Create our parts in PRIORITY ORDER
    //Logic should allow all but the first to be empty

    //Split-off/Distinguishing point in path
    int startDistinguished = MAX(m_minSplitPointIndex-1,0);
    int endDistinguished = MAX(MAX(m_minSplitPointIndex+1,m_maxSplitPointIndex),0);
    d.append(sect(startDistinguished, endDistinguished)); //0

    //Last path element before name
    int lastDir = (MAX(endDistinguished, lastPos-1));
    d.append(sect(lastDir, lastDir+1)); //1

    //The name - normally but not always
    d.append(sect(lastDir+1,lastDir+2)); //2

    //String of dirs between split-point and last post
    d.append(sect(endDistinguished, lastDir)); //3 ** Remove if NULL

    //Initial string of dirs before split point
    d.append(sect(0, startDistinguished)); //5

    Q_ASSERT(d.length() ==5);

    return d;
}
void OXMLi_ListenerState_Footnote::startElement (OXMLi_StartElementRequest * rqst)
{
	if (nameMatches(rqst->pName, NS_W_KEY, "footnotes"))
	{
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "footnote"))
	{
		const gchar* id = attrMatches(NS_W_KEY, "id", rqst->ppAtts);
		if(id)
		{
			OXML_SharedSection sect(new OXML_Section(id));
			rqst->sect_stck->push(sect);
		}
		rqst->handled = true;
	}
}
Esempio n. 3
0
void DiagTableHeader::paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const
{
    painter->rotate(-45);
    QTableWidgetItem* widget = ((QTableWidget*)parentWidget())->horizontalHeaderItem(logicalIndex);
    QStyleOption opt;
    opt.initFrom(this->viewport());
    QStylePainter sect(this->viewport());
    sect.rotate(-45);
    sect.drawControl(QStyle::CE_HeaderSection, opt); // this doesn't seem to do anything
    if (widget)
    {
        painter->drawText(rect.left(), rect.bottom(), widget->text());
    }
    else
    {
        painter->drawText(rect.left(), rect.bottom(), "123");
    }
}
void cRawParser::ParseTRR(cXmlNode& node) {
    USE_PREFIX(node);
    cTrackedRide ride;
    ride.name = ParseString(node, wxT(RAWXML_TRR), wxT("name"), NULL, useprefix).ToAscii();
    ride.attraction.name = ParseString(node, wxT(RAWXML_TRR), wxT("nametxt"), NULL, useprefix).ToAscii();
    ride.attraction.description = ParseString(node, wxT(RAWXML_TRR), wxT("description"), NULL, useprefix).ToAscii();
    wxLogVerbose(wxString::Format(_("Adding trr %s to %s."), wxString(ride.name.c_str(), wxConvLocal).c_str(), m_output.GetFullPath().c_str()));

    foreach (const cXmlNode& child, node.children()) {
        DO_CONDITION_COMMENT_FOR(child);

        if (child(RAWXML_ATTRACTION)) {
            ParseAttraction(child, ride.attraction);
        } else if (child(RAWXML_RIDE)) {
            ParseRide(child, ride.ride);
        } else if (child(RAWXML_TRR_SECTION)) {
            cTrackedRideSection section;
            unsigned long split = 1;
            string sect(child());
            boost::trim(sect);
            OPTION_PARSE(unsigned long, section.cost, ParseUnsigned(child, RAWXML_TRR_SECTION, wxT("cost")));
            OPTION_PARSE(unsigned long, split, ParseUnsigned(child, RAWXML_TRR_SECTION, wxT("split")));

            if (split) {
                boost::char_separator<char> sep(" ,");
                typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
                tokenizer tok(sect, sep);
                foreach(const string& token, tok) {
                    section.name = token;
                    ride.sections.push_back(section);
                }
            } else {
                section.name = sect;
                ride.sections.push_back(section);
            }
        } else if (child(RAWXML_TRR_SECTION_UNIQUE)) {
Esempio n. 5
0
void AbstractAssembler::block_comment(const char* comment) {
  if (sect() == CodeBuffer::SECT_INSTS) {
    code_section()->outer()->block_comment(offset(), comment);
  }
}
inline int AbstractAssembler::locator() const {
  return CodeBuffer::locator(offset(), sect());
}
Esempio n. 7
0
void Listener :: exec ( const QPoint & Loc ) {

  { const ActList AL = FindActs ( CurrDev ) ;
    if ( ! AL . isEmpty ( ) ) { setActiveAction ( AL . first ( ) ) ; }//fi
  }

  ActPtr Act = QMenu :: exec ( Loc ) ;

  if ( Act ) {

    const QString AN = Act -> objectName ( ) ; // Primary key.
    CurrDev = sect ( AN , 0 ) ; // SysPath.
    const UdevDev Dev ( UdevContext , CurrDev ) ;
    QString Node = Dev . DevNode ( ) ;
    const QString MP = Mounts :: DecodeIFS ( sect ( AN , 1 ) ) ;
      // Mountpoint/dm-name if any.
    const bool Cont = isLUKS ( Dev ) ,     // It's container.
               MoM  = ! MP . isEmpty ( ) ; // It's mounted or mapped.
    int RC = 0 ; // Return code for command.

    if ( MoM || ! Suppl ) {
      // Currently Suppl may be Eject, Remove or UnmountAll.

      loKey C , T , S ;
      if ( MoM ) {
        if ( Cont ) { C = kLockCmd   ; T = kLockTO   ; S = kLockShow   ;
        }    else   { C = kUnmntCmd  ; T = kUnmntTO  ; S = kUnmntShow  ;
        }//fi
      } else {
        if ( Cont ) { C = kUnlockCmd ; T = kUnlockTO ; S = kUnlockShow ;
        }    else   { C = kMountCmd  ; T = kMountTO  ; S = kMountShow  ;
        }//fi
      }//fi

      RC = ExecCmd ( Opt . toStr ( C ) , MoM ? MP : Node ,
                     Opt . toInt ( T ) , Opt . toBool ( S ) ) ;

    }//fi

    const UdevDev WD ( WDisk ( Dev ) ) ; // whole disk.
    bool Show = Opt . toBool ( kEjectShow ) ;
    RefreshMInfo ( ) ;

    { const bool
        A = Opt . toBool ( kAutoEject ) ,
        D = Opt . toStr  ( kEjectCmd  ) . isEmpty ( ) ,
        L = ( MPoints ( Dev ) + Holders ( Dev ) ) . isEmpty ( ) ,
        S = Suppl == reqEject || Suppl == reqRemove ,
        E = Ejectable ( WD  ) ;
      if ( MoM && ( L || Suppl ) && A && ! D && E && ! S ) {
        Suppl = reqEject ; Show = Opt . toBool ( kAutoEjShow ) ;
      }//fi
    }

    if ( RC ) { SetActions ( Dev ) ; // workaround for setChecked ()

    } else if ( Suppl == reqUnmtAll ) {

      UnmntAll ( Dev , Opt . toBool ( kUnmntShow ) ) ;

    } else if ( Suppl ) { // Eject or Remove.

      QStringList Msg , NL ; Node = WD . DevNode ( ) ;

      foreach ( const QString P , Parts ( WD ) << WD . SysPath ( ) ) {
        const UdevDev D ( UdevContext , P ) ;
        const QString N = D . DevNode ( ) ; NL += N ;
        UnmntAll ( D , false ) ; RefreshMInfo ( ) ;
        foreach ( const QString M , MPoints ( D ) ) {
          Msg << N + tr ( " mounted on " ) + M ;
        }//done
        foreach ( const QString M , Holders ( D ) ) {
          Msg << N + tr ( " mapped on "  ) + M ;
        }//done
        UdevEnum En ( UdevContext ) ; En . MatchSubsys ( Subsys_Block ) ;
        En . MatchSysAttr ( SA_BackFile , N . toLatin1 ( ) ) ;
        En . ScanDevs ( ) ;
        foreach ( const UdevPair M , En . GetList ( ) ) {
          Msg << N + tr ( " mapped on " ) +
                       UdevDev ( UdevContext , M . first ) . DevNode ( ) ;
        }//done
      }//done

      const QStringList F ( "[1-9]*" ) ;
      foreach ( const QString P , QDir ( "/proc" ) . entryList ( F , Drs ) ) {
        const QDir D ( "/proc/" + P + "/fd" ) ;
        foreach ( const QFileInfo I , D . entryInfoList ( QDir :: Files ) ) {
          const QString N = I . symLinkTarget ( ) ;
          if ( NL . contains ( N ) ) { Msg << N + tr ( " used by PId " ) + P ;
          }//fi
        }//done
      }//done

      if ( ! Msg . isEmpty ( ) ) {

        QMessageBox :: critical (
          this , TPref + tr ( "Error" ) ,
          tr ( "Device "  ) + Node +
          tr ( " in use:" ) + "\n" + Msg . join ( "\n" )
        ) ;

      } else {

        QString Cmd ; int TO ;
        if ( Suppl == reqEject ) {
          Cmd = Opt . toStr ( kEjectCmd ) ;
          TO  = Opt . toInt ( kEjectTO  ) ;
        } else {
          Cmd  = Opt . toStr  ( kRemoveCmd  ) ;
          TO   = Opt . toInt  ( kRemoveTO   ) ;
          Show = Opt . toBool ( kRemoveShow ) ;
        }//fi

        ExecCmd ( Cmd , Node , TO , Show ) ;

      }//fi

    }//fi
Esempio n. 8
0
const char* AbstractAssembler::code_string(const char* str) {
  if (sect() == CodeBuffer::SECT_INSTS || sect() == CodeBuffer::SECT_STUBS) {
    return code_section()->outer()->code_string(str);
  }
  return NULL;
}