Ejemplo n.º 1
0
bool typedFloss::operator<(const typedFloss& f) const {

  if (f.type() != type()) {
    return type().value() < f.type().value();
  }
  else if (type() != flossVariable) {
    return code() < f.code();
  }
  else { // both are variable
    return color().intensity() < f.color().intensity();
  }
}
Ejemplo n.º 2
0
QString patternPrinter::flossToCode(const typedFloss& f,
                                    bool useCodeAbbreviations) const {

  const int code = f.code();
  QString codeString;
  if (code != -1) { // valid floss
    if (code >= 0) {
      codeString = ::itoqs(code);
    }
    else { // the code is a string in this case
      if (code == WHITE_CODE) {
        codeString = "White";
      }
      else if (code == ECRU_CODE) {
        codeString = "Ecru";
      }
      else if (code == SNOW_WHITE_CODE) {
        codeString = "Snow White";
      }
      else {
        qWarning() << "String code error.";
        codeString = "N/A";
      }
    }
    if (useCodeAbbreviations) {
      codeString = f.type().prefix() + codeString;
    }
    return codeString;
  }
  else { // use the rgb code instead of the dmc code
    return ::ctos(f.color());
  }
}