int rest_num = num - n;
                    forever {
                        QList<int> handcard_list = target->handCards();
                        qShuffle(handcard_list);
                        int give = qrand() % rest_num + 1;
                        rest_num -= give;
                        QList<int> to_give = handcard_list.length() < give ? handcard_list : handcard_list.mid(0, give);
                        ServerPlayer *receiver = room->getOtherPlayers(target).at(qrand() % (target->aliveCount() - 1));
                        DummyCard *dummy = new DummyCard(to_give);
                        room->obtainCard(receiver, dummy, false);
                        delete dummy;
                        if (rest_num == 0 || target->isKongcheng())
                            break;
                    }
                }
                room->broadcastSkillInvoke(objectName(), 2);
            }
        }
        return false;
    }
};

QiceCard::QiceCard() {
    will_throw = false;
    handling_method = Card::MethodNone;
}

bool QiceCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{
    CardStar card = Self->tag.value("qice").value<CardStar>();
    Card *mutable_card = const_cast<Card *>(card);
    if (mutable_card)
Example #2
0
void Property::setValue(const QVariant &value)
{
	if (m_propertyObject)
		m_propertyObject->setProperty(qPrintable(objectName()), value);
}
Example #3
0
bool WeaponSkill::triggerable(const ServerPlayer *target) const{
    return target->hasWeapon(objectName());
}
Example #4
0
QTlenConfigDialog::QTlenConfigDialog(QWidget * parent):QWidget(parent)
{
    if (objectName().isEmpty())
	setObjectName(QString::fromUtf8("configDialog"));
    resize(480, 264);
    horizontalLayout_2 = new QHBoxLayout(this);

    listWidget	    = new QListWidget(this);
    listWidget	    ->setFixedWidth(220);
    listWidget->setIconSize(QSize(64, 64));
    stackedWidget   = new QStackedWidget(this);

    new QListWidgetItem(listWidget);
    new QListWidgetItem(QIcon(QPixmap(":icons/icons/64x64/roster.png")), tr("Roster appearance"), listWidget);
    new QListWidgetItem(QIcon(QPixmap(":icons/icons/64x64/look.png")), tr("Chat appearance"), listWidget);
    new QListWidgetItem(QIcon(QPixmap(":icons/icons/64x64/network.png")), tr("Network"), listWidget);

    connection_page = new QWidget();
    roster_page	    = new QWidget();
    chats_page	    = new QWidget();
    network_page    = new QWidget();
    label		= new QLabel(tr("Login"), connection_page);
    le_login		= new QLineEdit(connection_page);
    label_2		= new QLabel(tr("Password"), connection_page);
    le_password		= new QLineEdit(connection_page);
    le_password		->setEchoMode(QLineEdit::Password);
    cb_autoConnect	= new QCheckBox(connection_page);
    label_3		= new QLabel(connection_page);
    cb_defaultState	= new QComboBox(connection_page);
    QIcon icon		= QIcon(QPixmap(QString::fromUtf8(":/icons/icons/16x16/online.png")));
    QIcon icon1		= QIcon(QPixmap(QString::fromUtf8(":/icons/icons/16x16/chatty.png")));
    QIcon icon2		= QIcon(QPixmap(QString::fromUtf8(":/icons/icons/16x16/away.png")));
    QIcon icon3		= QIcon(QPixmap(QString::fromUtf8(":/icons/icons/16x16/xa.png")));
    QIcon icon4		= QIcon(QPixmap(QString::fromUtf8(":/icons/icons/16x16/dnd.png")));
    QIcon icon5		= QIcon(QPixmap(QString::fromUtf8(":/icons/icons/16x16/invisible.png")));
    cb_defaultState->addItem(icon, QString::fromUtf8("Dostępny"));
    cb_defaultState->addItem(icon1, QString::fromUtf8("Porozmawiajmy"));
    cb_defaultState->addItem(icon2, QString::fromUtf8("Zaraz wracam"));
    cb_defaultState->addItem(icon3, QString::fromUtf8("Wracam później"));
    cb_defaultState->addItem(icon4, QString::fromUtf8("Zajęty"));
    cb_defaultState->addItem(icon5, QString::fromUtf8("Niewidoczny"));
    cb_defaultState->addItem(QString::fromUtf8("-- poprzedni --"));
    cb_defaultState->setEnabled(false);

    formLayout		= new QFormLayout(connection_page);
    formLayout		->setWidget(0, QFormLayout::LabelRole, label);
    formLayout		->setWidget(0, QFormLayout::FieldRole, le_login);
    formLayout		->setWidget(1, QFormLayout::LabelRole, label_2);
    formLayout		->setWidget(1, QFormLayout::FieldRole, le_password);
    formLayout		->setWidget(2, QFormLayout::FieldRole, cb_autoConnect);
    formLayout		->setWidget(3, QFormLayout::LabelRole, label_3);
    formLayout		->setWidget(3, QFormLayout::FieldRole, cb_defaultState);
    stackedWidget->addWidget(connection_page);
    horizontalLayout_2	->addWidget(listWidget);

    verticalLayout = new QVBoxLayout(roster_page);
    cb_showOfflines = new QCheckBox(tr("Show offline users"),roster_page);
    QIcon icon6;
    icon6.addPixmap(QPixmap(QString::fromUtf8(":/icons/icons/view-user-offline-kopete.png")), QIcon::Normal, QIcon::Off);
    cb_showOfflines->setIcon(icon6);

    verticalLayout->addWidget(cb_showOfflines);

    cb_showExtendedInfo = new QCheckBox(tr("Show extended info"), roster_page);

    verticalLayout->addWidget(cb_showExtendedInfo);

    cb_showAvatars = new QCheckBox(tr("Show contacts avatars"), roster_page);

    verticalLayout->addWidget(cb_showAvatars);

    cb_showDescriptions = new QCheckBox(tr("Show contacts descriptions"),roster_page);
    verticalLayout->addWidget(cb_showDescriptions);

    cb_showJidInRoster = new QCheckBox(tr("Show contacts IDs"),roster_page);

    verticalLayout->addWidget(cb_showJidInRoster);

    gb_expandPolicy = new QGroupBox(roster_page);
    verticalLayout_2 = new QVBoxLayout(gb_expandPolicy);
    rb_expandedState = new QRadioButton(gb_expandPolicy);

    verticalLayout_2->addWidget(rb_expandedState);

    rb_collapsedState = new QRadioButton(gb_expandPolicy);

    verticalLayout_2->addWidget(rb_collapsedState);

    rb_previousState = new QRadioButton(gb_expandPolicy);

    verticalLayout_2->addWidget(rb_previousState);


    verticalLayout->addWidget(gb_expandPolicy);

    stackedWidget->addWidget(roster_page);

    verticalLayout_4 = new QVBoxLayout(chats_page);
    scrollArea = new QScrollArea(chats_page);
    scrollArea->setFrameShape(QFrame::NoFrame);
    scrollArea->setFrameShadow(QFrame::Plain);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setWidgetResizable(true);
    scrollAreaWidgetContents = new QWidget();
    scrollAreaWidgetContents->setGeometry(QRect(0, 0, 330, 261));
    verticalLayout_3 = new QVBoxLayout(scrollAreaWidgetContents);
    verticalLayout_3->setMargin(0);
    groupBox = new QGroupBox(scrollAreaWidgetContents);
    formLayout_4 = new QFormLayout(groupBox);
    formLayout_4->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
    label_5 = new QLabel(groupBox);

    formLayout_4->setWidget(0, QFormLayout::LabelRole, label_5);

    le_nick = new QLineEdit(groupBox);

    formLayout_4->setWidget(0, QFormLayout::FieldRole, le_nick);

    label_7 = new QLabel(groupBox);

    formLayout_4->setWidget(4, QFormLayout::LabelRole, label_7);

    label_6 = new QLabel(groupBox);

    formLayout_4->setWidget(3, QFormLayout::LabelRole, label_6);

    pb_myColor = new QPushButton(groupBox);

    formLayout_4->setWidget(3, QFormLayout::FieldRole, pb_myColor);

    pb_myBg = new QPushButton(groupBox);

    formLayout_4->setWidget(4, QFormLayout::FieldRole, pb_myBg);


    verticalLayout_3->addWidget(groupBox);

    groupBox_2 = new QGroupBox(scrollAreaWidgetContents);
    formLayout_5 = new QFormLayout(groupBox_2);
    label_8 = new QLabel(tr("Contact text color"),groupBox_2);

    formLayout_5->setWidget(1, QFormLayout::LabelRole, label_8);

    cb_useJID = new QCheckBox(tr("Use ID instead of contact name"),groupBox_2);

    formLayout_5->setWidget(0, QFormLayout::FieldRole, cb_useJID);

    pb_chatColor = new QPushButton(groupBox_2);

    formLayout_5->setWidget(1, QFormLayout::FieldRole, pb_chatColor);

    pb_chatBg = new QPushButton(groupBox_2);

    formLayout_5->setWidget(2, QFormLayout::FieldRole, pb_chatBg);

    label_9 = new QLabel(tr("Contact text background"),groupBox_2);

    formLayout_5->setWidget(2, QFormLayout::LabelRole, label_9);


    verticalLayout_3->addWidget(groupBox_2);

    scrollArea->setWidget(scrollAreaWidgetContents);

    verticalLayout_4->addWidget(scrollArea);

    stackedWidget->addWidget(chats_page);

    stackedWidget->addWidget(network_page);

    horizontalLayout_2->addWidget(stackedWidget);

    QObject::connect(listWidget, SIGNAL(currentRowChanged(int)), stackedWidget, SLOT(setCurrentIndex(int)));

	settings = new QSettings(QDir::homePath() + "/.qtlen4/config", QSettings::IniFormat);
	le_login->setText(settings->value("/connection/username", "").toString());
	le_password->setText(settings->value("/connection/password", "").toString());
	cb_autoConnect->setChecked(settings->value("/behaviour/autoconnect", false).toBool());
	le_nick->setText(settings->value("/preferences/nick", "").toString());
	cb_showJidInRoster->setChecked(settings->value("/roster/show_jid", false).toBool());
	cb_showOfflines->setChecked(settings->value("/roster/offlines_visible", false).toBool());
	cb_showAvatars->setChecked(settings->value("/roster/show_avatars", false).toBool());
	cb_showDescriptions->setChecked(settings->value("/roster/show_descriptions", false).toBool());
	cb_showExtendedInfo->setChecked(settings->value("/roster/show_ext_info", false).toBool());
	if(!settings->value("/roster/show_ext_info", false).toBool())
	{
	    cb_showJidInRoster->setEnabled(false);
	    cb_showAvatars->setEnabled(false);
	    cb_showDescriptions->setEnabled(false);
	}
	connect(pb_myColor,		SIGNAL(clicked()),	this,	SLOT(setMyColor()));
	connect(pb_myBg,		SIGNAL(clicked()),	this,	SLOT(setMyBg()));
	connect(pb_chatColor,	SIGNAL(clicked()),	this,	SLOT(setChatColor()));
	connect(pb_chatBg,		SIGNAL(clicked()),	this,	SLOT(setChatBg()));
	changed.user = false;
        changed.roster = false;
}
Example #5
0
/**
 *  \copydoc MythUIType::CreateCopy()
 */
void MythUIImage::CreateCopy(MythUIType *parent)
{
    QReadLocker updateLocker(&d->m_UpdateLock);
    MythUIImage *im = new MythUIImage(parent, objectName());
    im->CopyFrom(this);
}
Example #6
0
void AppInstance::setClassId( QString classid )
{
    AppClass *app_class;

    if( classid == classId() ) return;
    if( appLibrary() )
        appLibrary()->id().postLibEvent( new EventDestroyInstance(id()) );
    class_id_ = classid;
    app_class = AppLibrary::getClass(classid);
    if( app_class )
    {
        class_size_ = app_class->size();
        setParent( app_class->parent() );
        appLibrary()->id().postLibEvent( new EventCreateInstance( app_class->id(), id(), objectName() ) );
    }

    return;
}
Example #7
0
TexturePreviewEditor::~TexturePreviewEditor()
{
    LogInfo("Deleting TexturePreviewEditor " + objectName());
}
Example #8
0
void DnDEventLoggerWidget::dragLeaveEvent(QDragLeaveEvent *e)
{
    e->accept();
    m_log->push_back(objectName() + QLatin1String("::") + QLatin1String("dragLeaveEvent") + QLatin1String(" QDragLeaveEvent"));
}
Example #9
0
/**
 * Formats AGI string.
 * This function turns a AGI string into a real string expanding values
 * according to the AGI format specifiers.
 * @param s  string containing the format specifier
 * @param n  logic number
 */
char *AgiEngine::agiSprintf(const char *s) {
	static char agiSprintf_buf[768];
	Common::String p;
	char z[16];

	debugC(3, kDebugLevelText, "logic %d, '%s'", _game.lognum, s);

	while (*s) {
		switch (*s) {
		case '%':
			s++;
			switch (*s++) {
				int i;
			case 'v':
				i = strtoul(s, NULL, 10);
				while (*s >= '0' && *s <= '9')
					s++;
				sprintf(z, "%015i", getvar(i));

				i = 99;
				if (*s == '|') {
					s++;
					i = strtoul(s, NULL, 10);
					while (*s >= '0' && *s <= '9')
						s++;
				}

				if (i == 99) {
					// remove all leading 0
					// don't remove the 3rd zero if 000
					for (i = 0; z[i] == '0' && i < 14; i++)
						;
				} else {
					i = 15 - i;
				}
				safeStrcat(p, z + i);
				break;
			case '0':
				i = strtoul(s, NULL, 10) - 1;
				safeStrcat(p, objectName(i));
				break;
			case 'g':
				i = strtoul(s, NULL, 10) - 1;
				safeStrcat(p, _game.logics[0].texts[i]);
				break;
			case 'w':
				i = strtoul(s, NULL, 10) - 1;
				safeStrcat(p, _game.egoWords[i].word);
				break;
			case 's':
				i = strtoul(s, NULL, 10);
				safeStrcat(p, agiSprintf(_game.strings[i]));
				break;
			case 'm':
				i = strtoul(s, NULL, 10) - 1;
				if (_game.logics[_game.lognum].numTexts > i)
					safeStrcat(p, agiSprintf(_game.logics[_game.lognum].texts[i]));
				break;
			}

			while (*s >= '0' && *s <= '9')
				s++;
			break;

		case '\\':
			s++;
			// FALL THROUGH

		default:
			p += *s++;
			break;
		}
	}

	assert(p.size() < sizeof(agiSprintf_buf));
	strcpy(agiSprintf_buf, p.c_str());
	return agiSprintf_buf;
}
Example #10
0
void
KexiDBSubForm::setFormName(const QString &name)
{
    if (m_formName == name)
        return;

    m_formName = name; //assign, even if the name points to nowhere

    if (name.isEmpty()) {
        delete m_widget;
        m_widget = 0;
        updateScrollBars();
        return;
    }

    QWidget *pw = parentWidget();
    KexiFormView *view = 0;
    QSet<QString> names;
    while (pw) {
        if (KexiUtils::objectIsA(pw, "KexiDBSubForm")) {
            if (names.contains(pw->objectName())) {
//! @todo error message
                return; // Be sure to don't run into a endless-loop cause of recursive subforms.
            }
            names.insert(pw->objectName());
        } else if (! view && KexiUtils::objectIsA(pw, "KexiFormView")) {
            view = static_cast<KexiFormView*>(pw); // we need a KexiFormView*
        }
        pw = pw->parentWidget();
    }

    if (!view || !view->window() || !KexiMainWindowIface::global()->project()->dbConnection())
        return;

    KexiDB::Connection *conn = KexiMainWindowIface::global()->project()->dbConnection();

    // we check if there is a form with this name
    int id = KexiDB::idForObjectName(*conn, name, KexiPart::FormObjectType);
    if ((id == 0) || (id == view->window()->id())) // == our form
        return; // because of recursion when loading

    // we create the container widget
    delete m_widget;
    m_widget = new QWidget(viewport());
    m_widget->setObjectName("KexiDBSubForm_widget");
    m_widget->show();
    addChild(m_widget);
    m_form = new KFormDesigner::Form(m_parentForm);
    m_form->setObjectName(QString("KFormDesigner::Form_") + objectName());
    m_form->createToplevel(m_widget);

    // and load the sub form
    QString data;
    tristate res = conn->loadDataBlock(id, data, QString());
    if (res == true)
        res = KFormDesigner::FormIO::loadFormFromString(m_form, m_widget, data);
    if (res != true) {
        delete m_widget;
        m_widget = 0;
        updateScrollBars();
        m_formName.clear();
        return;
    }
    m_form->setMode(KFormDesigner::Form::DataMode);

    // Install event filters on the whole newly created form
    KFormDesigner::ObjectTreeItem *tree = m_parentForm->objectTree()->lookup(QObject::objectName());
    KFormDesigner::installRecursiveEventFilter(this, tree->eventEater());
}
Example #11
0
void DnDEventLoggerWidget::formatDropEvent(const char *function, const QDropEvent *e, QTextStream &str) const
{
    str << objectName() << "::" << function  << " at " << e->pos().x() << ',' << e->pos().y()
        << " action=" << e->dropAction()
        << ' ' << quintptr(e->mimeData()) << " '" << e->mimeData()->text() << '\'';
}
Example #12
0
QString AirspyGui::getName() const
{
	return objectName();
}
Example #13
0
void XDateEdit::parseDate()
{
  QString dateString = text().trimmed();
  bool    isNumeric;

  if (DEBUG)
    qDebug("%s::parseDate() with dateString %s, _currentDate %s, _allowNull %d",
           qPrintable(parent() ? parent()->objectName() : objectName()),
           qPrintable(dateString),
           qPrintable(_currentDate.toString()), _allowNull);

#ifdef GUIClient_h
  QDate today = ofmgThis->dbDate();
#else
  QDate today = QDate::currentDate();
#endif

  if (_parsed)
  {
    if (DEBUG)
      qDebug("%s::parseDate() looks like we've already parsed this string",
             qPrintable(parent() ? parent()->objectName() : objectName()));
    return;
  }

  _valid = false;

  if (dateString == _nullString || dateString.isEmpty())
    setNull();

  else if (dateString == "0")                           // today
    checkDate(today);

  else if (dateString.contains(QRegExp("^[+-][0-9]+"))) // offset from today
  {
    int offset = dateString.toInt(&isNumeric);
    if (isNumeric)
      checkDate(today.addDays(offset));
  }

  else if (dateString[0] == '#')                        // julian day
  {
    int offset = dateString.right(dateString.length() - 1).toInt(&isNumeric);
    if (isNumeric)
      checkDate(QDate(today.year(), 1, 1).addDays(offset - 1));
  }

  else if (dateString.contains(QRegExp("^[0-9][0-9]?$"))) // date in month
  {
    int offset = dateString.toInt(&isNumeric, 10);
    if (isNumeric)
    {
      if (offset > today.daysInMonth())
        offset = today.daysInMonth();
 
      checkDate(QDate(today.year(), today.month(), 1).addDays(offset - 1));
    }
  }

  else                                                  // interpret with locale
  {
    QString dateFormatStr = QLocale().dateFormat(QLocale::ShortFormat);
    if (DEBUG)
      qDebug("%s::parseDate() trying to parse with %s",
             qPrintable(parent() ? parent()->objectName() : objectName()),
             qPrintable(dateFormatStr));

    QDate tmp = QDate::fromString(dateString, dateFormatStr);
    bool twodigitformat = !(dateFormatStr.indexOf(QRegExp("y{4}")) >= 0);
    if (tmp.isValid())
    {
      if (twodigitformat && tmp.year() < 1950) // Qt docs say 2-digit years are 1900-based so
      {
        qDebug("%s::parseDate() found valid 2-digit year %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
        tmp = tmp.addYears(100); // add backwards-compat with pre-3.0 DLineEdit
        qDebug("%s::parseDate() altered year to %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
      }
    }
    else if (twodigitformat)
    {
      // try 4 digits, ignoring the possibility of '-literals in the format str
      dateFormatStr.replace(QRegExp("y{2}"), "yyyy");
      if (DEBUG)
        qDebug("%s::parseDate() rewriting 2-digit year format string to %s",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               qPrintable(dateFormatStr));
      tmp = QDate::fromString(dateString, dateFormatStr);

      if (tmp.isValid())
      {
        if (tmp.year() < 10)
          tmp = tmp.addYears(today.year() - today.year() % 100);
        if (DEBUG)
          qDebug("%s::parseDate() after changing to 4-digit year, year = %d",
                 qPrintable(parent() ? parent()->objectName() : objectName()),
                 tmp.year());
      }
      else if (DEBUG)
        qDebug("%s::parseDate() after changing to 4-digit year, date still isn't valid",
               qPrintable(parent() ? parent()->objectName() : objectName()));

    }
    else
    {
      // try 2 digits, ignoring the possibility of '-literals in the format str
      dateFormatStr.replace(QRegExp("y{4}"), "yy");
      if (DEBUG)
        qDebug("%s::parseDate() rewriting 4-digit year format string to %s",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               qPrintable(dateFormatStr));
      tmp = QDate::fromString(dateString, dateFormatStr);
      if (tmp.isValid() && tmp.year() < 1950) // Qt docs say 2-digit years are 1900-based so
      {
        qDebug("%s::parseDate() found valid 2-digit year %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
        tmp = tmp.addYears(100); // add backwards-compat with pre-3.0 DLineEdit
        qDebug("%s::parseDate() altered year to %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
      }
    }
    if(!tmp.isValid())
    {
      // still no match -- we will decompose the format and input and
      // build a date based on that information
      QRegExp rx("(\\d+)");
      QRegExp rx2("(m+|y+|d+)");
      rx2.setCaseSensitivity(Qt::CaseInsensitive);
      QStringList numberList;
      QStringList formatList;
      int pos = 0;
      while ((pos = rx.indexIn(dateString, pos)) != -1)
      {
        numberList << rx.cap(1);
        pos += rx.matchedLength();
      }
      pos = 0;
      while((pos = rx2.indexIn(dateFormatStr, pos)) != -1)
      {
        formatList << rx2.cap(1);
        pos += rx2.matchedLength();
      }

      if (DEBUG)
        qDebug("%s::parseDate() aligning numberList %s with formatList %s",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               qPrintable(numberList.join(":")), qPrintable(formatList.join(":")));

      // if we don't have exactly 3 and the numberList is not 2 or 3 then don't bother
      if(formatList.size() == 3 && (numberList.size() == 2 || numberList.size() == 3))
      {
        int year = today.year();
        int day = -1;
        int month = -1;

        pos = 0;
        for (int i = 0; i < formatList.size(); ++i)
        {
          QChar ch = formatList.at(i).toLower().at(0);
          if(ch == 'y' && numberList.size() == 3)
          {
            year = numberList.at(pos).toInt();
            pos++;
          }
          else if(ch == 'm')
          {
            month = numberList.at(pos).toInt();
            pos++;
          }
          else if(ch == 'd')
          {
            day = numberList.at(pos).toInt();
            pos++;
          }
        }

        // if single digit year, move it to the current century
        if (year < 10)
          year += today.year() - today.year() % 100;

        if(day > 0 && month > 0 && year > 0)
          tmp = QDate(year, month, day);
      }
      else if(formatList.size() == 3 && numberList.size() == 1)
      {
        QString ns = numberList.at(0);
        bool isNumber = false;
        (void)ns.toInt(&isNumber);
        if(isNumber && (ns.length() == 6 || ns.length() == 8))
        {
          int year = today.year();
          int day = -1;
          int month = -1;

          pos = 0;
          for (int i = 0; i < formatList.size(); ++i)
          {
            QChar ch = formatList.at(i).toLower().at(0);
            if(ch == 'y')
            {
              if(ns.length() == 8)
              {
                year = ns.mid(pos, 4).toInt();
                pos+=4;
              }
              else
              {
                year = ns.mid(pos, 2).toInt(&isNumber);
                pos+=2;
                if(isNumber)
                {
                  if(year < 50)
                    year += 2000;
                  else
                    year += 1900;
                }
              }
            }
            else if(ch == 'm')
            {
              month = ns.mid(pos, 2).toInt();
              pos+=2;
            }
            else if(ch == 'd')
            {
              day = ns.mid(pos, 2).toInt();
              pos+=2;
            }
          }

          if(day > 0 && month > 0 && year > 0)
            tmp = QDate(year, month, day);
        }
      }
    }

    checkDate(QDate(tmp.year(), tmp.month(), tmp.day()));
  }

  if (!_valid)
    setText("");

  _parsed = true;
}
Example #14
0
/*!
 * \copydoc MythUIType::CreateCopy()
 */
void MythUIButtonTree::CreateCopy(MythUIType *parent)
{
    MythUIButtonTree *bt = new MythUIButtonTree(parent, objectName());
    bt->CopyFrom(this);
}
 virtual QStringList triggerable(TriggerEvent, Room *, ServerPlayer *player, QVariant &, ServerPlayer * &) const{
     return (TriggerSkill::triggerable(player) && !player->isKongcheng()) ? QStringList(objectName()) : QStringList();
 }
Example #16
0
DimstackCustomization::DimstackCustomization(XmdvToolMainWnd *mainwnd, QMdiSubWindow *window)
    : QDialog(window)
{
	//save references to main window, viewManager and pID
	mainWnd = mainwnd;
	viewManager = mainWnd->getViewManager();
	pID = viewManager->getActiveViewWindow()->getPipelineID();


	//get the VisDimstack
	ViewDisplay *vd = viewManager->getActiveViewWindow()->getViewDisplay();;
	assert(typeid(*vd) == typeid(VisDimstack));
	VisDimstack *visDimstack = dynamic_cast<VisDimstack *>(vd);

	//use it to set the lengths of the arrays
	selectionCardinalityLabels.resize(visDimstack->m_dim_size);
	selectionSliders.resize(visDimstack->m_dim_size);

	//set default value of 10 for maximum bins in a dimension
	maxBins = 10;

	//set up the dialog
	if (objectName().isEmpty())
	            setObjectName(QString::fromUtf8("dimstackCustomizationDialog"));
	resize(300,360);
	//setFixedSize(QSize::QSize (300, 360));
	setWindowTitle(QString::fromUtf8("Dimension Stacking Customization"));
	setAttribute(Qt::WA_DeleteOnClose, false);

	windowLayout = new QGridLayout(this);

	maxBinsLabel = new QLabel(this);
	maxBinsLabel->setObjectName(QString::fromUtf8("maxBinsLabel"));
	maxBinsLabel->setText(QString::fromUtf8("Maximum Number of Bins"));
	//maxBinsLabel->setGeometry(QRect(10, 10, 121, 16));
	windowLayout->addWidget(maxBinsLabel, 0, 0);

	binSelectionArea = new QScrollArea(this);
	binSelectionArea->setObjectName(QString::fromUtf8("binSelectionArea"));
	//binSelectionArea->setGeometry(QRect(9, 39, 290, 280));
	windowLayout->addWidget(binSelectionArea, 1, 0, 1, -1);

	selectionAreaContents = new QWidget(binSelectionArea);

	selectionTable = new QFormLayout();
	selectionTable->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);

	//add the top row to the selection table
	nameTitle = new QLabel(selectionAreaContents);
	nameTitle->setObjectName(QString::fromUtf8("nameTitle"));
	nameTitle->setText(QString::fromUtf8("Fieldname"));
	nameTitle->setFrameStyle(QFrame::Panel | QFrame::Raised);

	numBinsTitle = new QLabel(selectionAreaContents);
	numBinsTitle->setObjectName(QString::fromUtf8("numBinsTitle"));
	numBinsTitle->setText(QString::fromUtf8("Number of Bins"));
	numBinsTitle->setFrameStyle(QFrame::Panel | QFrame::Raised);

	//selectionTable->setVerticalSpacing(0);
	selectionTable->addRow(nameTitle, numBinsTitle);

	//dynamically add the rest of the rows here
	//(and while we're at it we set maxBins to the highest cardinality
	// of a dimension if it exceeds the default of 10)
	initRows(visDimstack);

	//set the layout after it has been populated
	//and set the contents of the scroll area
	selectionAreaContents->setLayout(selectionTable);
	binSelectionArea->setWidget(selectionAreaContents);

	//now maxBins is equal to the maximum number of bins of all dimensions in the dataset
	//generate the field for specifying max number of bins
	maxBinsEdit = new QLineEdit(this);
	maxBinsEdit->setObjectName(QString::fromUtf8("maxBinsEdit"));
	maxBinsEdit->setText(QString::number(maxBins));
	//maxBinsEdit->setGeometry(QRect(140, 10, 113, 20));
	windowLayout->addWidget(maxBinsEdit, 0, 1);
	//connect the max number of bins specified to the max range of the slider
	connect(maxBinsEdit, SIGNAL(returnPressed()), this, SLOT(updateSliderRange()));

	applyButton = new QPushButton(this);
	applyButton->setObjectName(QString::fromUtf8("applyButton"));
	applyButton->setText(QString::fromUtf8("Apply"));
	applyButton->setDefault(false);
	//applyButton->setGeometry(QRect(10, 330, 161, 24));
	windowLayout->addWidget(applyButton, 2, 0);
	connect(applyButton, SIGNAL(clicked()), this, SLOT(applyChanges()));

	windowLayout->setVerticalSpacing(4);
	setLayout(windowLayout);

}
    virtual QStringList triggerable(TriggerEvent, Room *room, ServerPlayer *player, QVariant &data, ServerPlayer * &) const{
        if (MasochismSkill::triggerable(player)) {
            DamageStruct damage = data.value<DamageStruct>();
            const Card *card = damage.card;
            if (damage.card == NULL)
                return QStringList();

            QList<int> table_cardids = room->getCardIdsOnTable(card);

            return (table_cardids.length() != 0 && card->getSubcards() == table_cardids) ? QStringList(objectName()) : QStringList();
        }
        return QStringList();
    }
QString Skill::getDescription(bool yellow) const{
    QString des_src = Sanguosha->translate(":" + objectName());
    if (des_src == ":" + objectName())
        return QString();
    return QString("<font color=%1>%2</font>").arg(yellow ? "#FFFF33" : "#FF0080").arg(des_src);
}
Example #19
0
 virtual bool triggerable(const ServerPlayer *i) const{
     return !i->hasSkill(objectName());
 }
QString Skill::getNotice(int index) const{
    if (index == -1)
        return Sanguosha->translate("~" + objectName());

    return Sanguosha->translate(QString("~%1%2").arg(objectName()).arg(index));
}
Example #21
0
 virtual bool isEnabledAtPlay() const{
     return !Self->isKongcheng() && !ClientInstance->turn_tag.value(objectName(), false).toBool();
 }
bool WeaponSkill::triggerable(const ServerPlayer *target) const{
    if (target == NULL) return false;
    if (target->getMark("Equips_Nullified_to_Yourself") > 0) return false;
    return target->hasWeapon(objectName());
}
Example #23
0
void Matrix::save(const QString &fn, const QString &info, bool saveAsTemplate)
{
	QFile f(fn);
	if (!f.isOpen()){
		if (!f.open(QIODevice::Append))
			return;
	}
	bool notTemplate = !saveAsTemplate;

	QTextStream t( &f );
	t.setEncoding(QTextStream::UnicodeUTF8);
	t << "<matrix>\n";
	if (notTemplate)
        t << QString(objectName()) + "\t";
	t << QString::number(numRows())+"\t";
	t << QString::number(numCols())+"\t";
	if (notTemplate)
        t << birthDate() + "\n";
	t << info;
	t << "ColWidth\t" + QString::number(d_column_width)+"\n";
	t << "<formula>\n" + formula_str + "\n</formula>\n";
	t << "TextFormat\t" + QString(txt_format) + "\t" + QString::number(num_precision) + "\n";
	if (notTemplate)
        t << "WindowLabel\t" + windowLabel() + "\t" + QString::number(captionPolicy()) + "\n";
	t << "Coordinates\t" + QString::number(x_start,'g',15) + "\t" +QString::number(x_end,'g',15) + "\t";
	t << QString::number(y_start,'g',15) + "\t" + QString::number(y_end,'g',15) + "\n";
	t << "ViewType\t" + QString::number((int)d_view_type) + "\n";
    t << "HeaderViewType\t" + QString::number((int)d_header_view_type) + "\n";

	if (d_color_map_type != Custom)
		t << "ColorPolicy\t" + QString::number(d_color_map_type) + "\n";
	else
		t << ColorMapEditor::saveToXmlString(d_color_map);

    if (notTemplate){//save data
		t << "<data>\n";
		double* d_data = d_matrix_model->dataVector();
		int d_rows = numRows();
		int d_cols = numCols();
		int cols = d_cols - 1;

		for(int i = 0; i < d_rows; i++){
			int aux = d_cols*i;
			bool emptyRow = true;
			for(int j = 0; j < d_cols; j++){
				if (gsl_finite(d_data[aux + j])){
					emptyRow = false;
					break;
				}
			}
			if (emptyRow)
				continue;

			t << QString::number(i) + "\t";

			for(int j = 0; j < cols; j++){
				double val = d_data[aux + j];
				if (gsl_finite(val))
					t << QString::number(val, 'e', 16);
				t << "\t";
			}
			double val = d_data[aux + cols];
			if (gsl_finite(val))
				t << QString::number(val, 'e', 16);
			t << "\n";
		}
		t << "</data>\n";
    }
    t << "</matrix>\n";
}
bool ArmorSkill::triggerable(const ServerPlayer *target) const{
    if (target == NULL || target->getArmor() == NULL)
        return false;
    return target->hasArmorEffect(objectName());
}
void Correlation::addResultCurve()
{
    ApplicationWindow *app = (ApplicationWindow *)parent();
    if (!app)
        return;

    QLocale locale = app->locale();

    if (d_n > d_table->numRows())
        d_table->setNumRows(d_n);

	int cols = d_table->numCols();
	int cols2 = cols+1;
	d_table->addCol();
	d_table->addCol();
	int n = d_n/2;

#ifdef Q_CC_MSVC
    QVarLengthArray<double> x_temp(d_n), y_temp(d_n);
#else
    double x_temp[d_n], y_temp[d_n];
#endif
	for (int i = 0; i<d_n; i++){
	    double x = i - n;
        x_temp[i] = x;

        double y;
        if(i < n)
			y = d_x[n + i];
		else
			y = d_x[i - n];
        y_temp[i] = y;

		d_table->setText(i, cols, QString::number(x));
		d_table->setText(i, cols2, locale.toString(y, 'g', app->d_decimal_digits));
	}

	QStringList l = d_table->colNames().grep(tr("Lag"));
	QString id = QString::number((int)l.size()+1);
	QString label = objectName() + id;

	d_table->setColName(cols, tr("Lag") + id);
	d_table->setColName(cols2, label);
	d_table->setColPlotDesignation(cols, Table::X);
	d_table->setHeaderColType();

	if (d_graphics_display){
		if (!d_output_graph)
			createOutputGraph();

    	DataCurve *c = new DataCurve(d_table, d_table->colName(cols), d_table->colName(cols2));
#ifdef Q_CC_MSVC
		c->setData(x_temp.data(), y_temp.data(), d_n);
#else
		c->setData(x_temp, y_temp, d_n);
#endif
    	c->setPen(QPen(ColorBox::color(d_curveColorIndex), 1));
		d_output_graph->insertPlotItem(c, Graph::Line);
		d_output_graph->updatePlot();
	}
}
bool Skill::isVisible() const{
    return !objectName().startsWith("#");
}
Example #27
0
bool TriggerSkill::triggerable(const ServerPlayer *target) const{
    return target->isAlive() && target->hasSkill(objectName());
}
Example #28
0
bool Scene::save(QString &dir)
{
    if (_canvas)
        return _canvas->save(dir + "\\" + objectName());
    return false;
}
Example #29
0
bool ArmorSkill::triggerable(const ServerPlayer *target) const{
    return target->hasArmorEffect(objectName()) && target->getArmor()->getSkill() == this;
}
bool Skill::isVisible() const{
    return !objectName().startsWith("#") && !inherits("SPConvertSkill");
}