예제 #1
0
파일: Programa.cpp 프로젝트: skhaz/oldies
void Programa::setParam(const ParameterList& param)
{
	int cod = param["cod"].toInt();

	if (param["mode"] != "new" && cod != 0)
	{
		query.prepare("update programas set nome = :nome, programa = :programa where cod_programa = :cod");
		query.bindValue(":cod", cod);

		QSqlQuery sql;
		sql.prepare("select nome, programa from programas where cod_programa = :cod limit 1");
		sql.bindValue(":cod", cod);

		if (sql.exec())
		{
			sql.first();
			nomeEdit->setText(sql.value(sql.record().indexOf("nome")).toString());
			textEdit->appendPlainText(sql.value(sql.record().indexOf("programa")).toString());
		}

		else
		{
			QMessageBox::warning(this, "Admin",
				Utf8("Erro na consulta\n%1").arg(sql.lastError().text()));
		}
	}

	else {
		query.prepare("insert into programas (nome, programa) values (:nome, :programa)");
	}

	setWindowTitle(Utf8("%1").arg(nomeEdit->text().isEmpty() ? "Sem nome" : nomeEdit->text()));
}
예제 #2
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MkStrXEQ (QString text, wnd *vp) // execute MicroMir command from its text
{                                     // presentation, several times if KbCount
  int repeat = KbRadix ? KbCount : 1; // was set (by MkMimXEQ function)
     KbRadix = 0;        KbCount = 1; // <- must reset that counter here!
  int N, len = text.length();
  for (int k = 0; k < repeat; k++) {
    for (int i = 0; i < len; i++) {
      int k = text.at(i).unicode();
      if (k == 0x2446) {    // ⑆ used to escape special characters (× and ‹)
        if (i == len-1) break;
        vipOnKeyCode(vp, text.at(++i).unicode());
      }
      else if (k ==  0x2039) {   // ‹
        if ((N = text.indexOf(Utf8("›"),i+1)) > 0) {
          luaP_getglobal("Mk");
          luaP_getfield(-1,text.mid(i+1,N-i-1).cStr()); i=N; MkLuaXEQ("", vp);
      } }
      else if (k == 0xD7) {      // ×
        if ((N = text.indexOf(Utf8("⁝"),i+1)) > 0) {
          KbRadix = 1;                                // applied to next command
          KbCount = text.mid(i+1,N-i-1).toInt(); i=N; // (radix does not matter)
      } }
      else if (Mk_IsCHAR(k)) vipOnKeyCode(vp, k);
      if (qkbhin()) return; //
} } }                       // KB interrupt (currently not used), or an error
예제 #3
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void jdlvFrame::SetWinTitle()
{
  QString title = QString("juego de la vida %1").arg(jdlvVERSION);
  QString worldName = worldFilename;
  if (! worldName.isEmpty()) {
    if (worldName.length() > 32) worldName = Utf8("…") + worldName.right(31);
                                       title.append(Utf8(" • ") + worldName);
  }
  setWindowTitle(title);
}
예제 #4
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MkLuaXEQ (QString text, wnd *vp) // text is only used when stack[-1] = nil
{
  if (lua_isnumber(L,-1)) {                            // MUST check before str
    int mk = lua_tointeger(L,-1);        luaQn_pop(2); // as number is str too,
    if (MiApp_debugKB) fprintf(stderr, ",0x%x\n", mk); // since its convertible
    switch (mk) {                                      // always to string
    case TK_PREFIX: MkPrefix = last_MiCmd_key; break;
    case TK_ESC:    MkPrefix = "Esc";          break;
    case TK_CtrJ:   MkPrefix = "^J";           break;
    case TK_SM1:
    case TK_SM2:
    case TK_SM3: if (MkRecording) { MkStopRecording();  vipBell(); }
                                    MkStartRecording(mk - TK_SM0); return;
    case TK_EM1:
    case TK_EM2:                                  // shall NEVER store MkPrefix
    case TK_EM3: MkStopRecording();    return;    // alone into the Macro, only
    default:     vipOnKeyCode(vp, mk); return;    //    as part of the cmd name
    }                                             // ↓
    if (MkRecording) MkMacro.replace(MkQuoteCmd(MkPrefix), "");
    Twnd->sctw->DisplayInfo(MkPrefix);                  return;
  }
  else if (lua_isstring(L,-1)) text = Utf8(lua_tostring(L,-1));
  else if (lua_isfunction(L,-1)) {
    if (MiApp_debugKB) fprintf(stderr, ",lua\n");
    wpos_off(vp);      luasFunc();  luaQn_pop(1); return;
  }
  if (MiApp_debugKB) fprintf (stderr, ",'%s'\n", text.uStr());
  if (!text.isEmpty()) MkStrXEQ(text,vp);        luaQn_pop(2);
}
예제 #5
0
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
void MkMimXEQ (int kcode, int modMask, QString text, wnd *vp)
{
  int digit = MkToDigit(kcode);
  if (KbRadix && !modMask && digit >= 0) {
    KbCount = KbRadix * KbCount + digit;
    Twnd->sctw->DisplayInfo( Utf8("×%1").arg(KbCount) ); return;
  }
  luaP_getglobal("Mk");
  if (MkPrefix.isEmpty()) { last_MiCmd_key = MkToString(kcode|modMask);
                            luaP_getfield(-1,last_MiCmd_key.uStr()); }
  else {
    if (MkPrefix == "Esc" && !modMask) {
      QString info;
           if (kcode == 'I') { KbCount = 2147483647;
                               KbRadix =  1; info = "(inf)";                 }
      else if (kcode == 'X') { KbRadix = 16; info = "(hex)";    KbCount = 0; }
      else if (digit ==  0 ) { KbRadix =  8; info = "(oct)";    KbCount = 0; }
      else if (digit  >  0 ) { KbRadix = 10; info.setNum( KbCount = digit ); }
      if (KbRadix) {
        Twnd->sctw->DisplayInfo( Utf8("×%1").arg(info) );
        luaQn_pop(1);                   MkPrefix.clear(); return;
    } }
    QString MkStr = MkToString(kcode|modMask);
    last_MiCmd_key = MkPrefix + "," + MkStr;
    luaP_getfield(-1,last_MiCmd_key.uStr()); MkPrefix.clear();
    if (lua_isnil(L,-1)) {
      luaQn_pop(1);    last_MiCmd_key = MkStr; // Try finding CCD with prefix
      luaP_getfield(-1,last_MiCmd_key.uStr()); // 1st, ignore it if not found
  } }
  if (MiApp_debugKB) fprintf(stderr, ",‹%s›", last_MiCmd_key.uStr());
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  if (MkRecording) {
    if (KbRadix) MkMacro.append(Utf8("×")+QString::number(KbCount)+Utf8("⁝"));
    if (text.isEmpty() || !text.at(0).isPrint())
      MkMacro.append(MkQuoteCmd(last_MiCmd_key)); // no printable text exists
    else switch (text.at(0).unicode()) {
      case 0x00D7: // × ← these two characters have special meaning in macros
      case 0x2039: // ‹                                      (must escape them)
               MkMacro.append(Utf8("⑆")+text); break;
      default: MkMacro.append          (text); break;
    }
    if (MkMacro.size() > MkMAX_MACRO_SIZE) { vipBell(); MkStopRecording(); }
  }
  MkLuaXEQ(text, vp);   // Lua stack here: [-2] global "Mk" (not used below)
}                       //                 [-1] Mk[kcode] value (may be nil)
예제 #6
0
TStr TNodeJsUtil::GetClass(const v8::Handle<v8::Object> Obj) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);
    v8::Local<v8::Value> ClassNm = Obj->GetHiddenValue(v8::String::NewFromUtf8(Isolate, "class"));
    const bool EmptyP = ClassNm.IsEmpty();
    if (EmptyP) { return ""; }
    v8::String::Utf8Value Utf8(ClassNm);
    return TStr(*Utf8);
}
예제 #7
0
TStr TNodeJsUtil::GetArgStr(const v8::FunctionCallbackInfo<v8::Value>& Args, const int& ArgN, const TStr& DefVal) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);

    if (ArgN >= Args.Length()) { return DefVal; }
    v8::Handle<v8::Value> Val = Args[ArgN];
    EAssertR(Val->IsString(), TStr::Fmt("Argument %d expected to be string", ArgN));
    v8::String::Utf8Value Utf8(Val);
    return TStr(*Utf8);
}
예제 #8
0
uString* uString::Const(const char* mutf8)
{
    uString* string;
    Xli::MutexLock lock(_Mutex);
    if (!_StringConsts->TryGetValue(mutf8, string))
    {
        uRetain(string = Utf8(mutf8));
        (*_StringConsts)[mutf8] = string; // FIXME: Got exception when using HashMap::Add()
    }

    return string;
}
예제 #9
0
uString* uString::Const(const char* mutf8)
{
    uString* string;
    Xli::String key(mutf8);
    Xli::MutexLock lock(_Mutex);
    if (!_StringConsts->TryGetValue(key, string))
    {
        uRetain(string = Utf8(key.Ptr(), (size_t)key.Length()));
        (*_StringConsts)[key] = string;
    }

    return string;
}
예제 #10
0
TStr TNodeJsUtil::GetArgStr(const v8::FunctionCallbackInfo<v8::Value>& Args, const int& ArgN, const TStr& Property, const TStr& DefVal) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);
    if (Args.Length() > ArgN) {
        if (Args[ArgN]->IsObject() && Args[ArgN]->ToObject()->Has(v8::String::NewFromUtf8(Isolate, Property.CStr()))) {
            v8::Handle<v8::Value> Val = Args[ArgN]->ToObject()->Get(v8::String::NewFromUtf8(Isolate, Property.CStr()));
            EAssertR(Val->IsString(), TStr::Fmt("Argument %d, property %s expected to be string", ArgN, Property.CStr()));
            v8::String::Utf8Value Utf8(Val);
            return TStr(*Utf8);
        }
    }
    return DefVal;
}
예제 #11
0
파일: Programa.cpp 프로젝트: skhaz/oldies
void Programa::submitClicked()
{
	QString programa = textEdit->toPlainText();

	QMessageBox messageBox;
	messageBox.setWindowTitle("Admin");
	messageBox.setText(Utf8("Deseja substituir o programa?"));
	messageBox.setIcon(QMessageBox::Question);
	messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

	switch(messageBox.exec())
	{
		case QMessageBox::Yes:
			if (programa.isEmpty())
			{
				QMessageBox::warning(this, "Admin",
						Utf8("Não é possivel inserir items vazios"));
			}

			else {
				query.bindValue(":nome", nomeEdit->text());
				query.bindValue(":programa", programa);

				if (query.exec())
				{
					emit dataChanged();
				}

				else {
					QMessageBox::warning(this, "Admin",
							Utf8("Houve um erro ao inserir\n%1").arg(query.lastError().text()));
				}
			}

		default:
			break;
	}
}
예제 #12
0
파일: Programa.cpp 프로젝트: skhaz/oldies
void Programa::importClicked()
{
	QString filename = QFileDialog::getOpenFileName(this,
				"Selecione um arquivo", "",	"Programas (*.txt)");

	QFile file(filename);
	if (file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		textEdit->appendPlainText(file.readAll());
	}

	else {
		QMessageBox::warning(this, "Admin",
				Utf8("Houve um erro ao tentar abrir o arquivo: <b>%1</b>").arg(filename));
	}
}
예제 #13
0
uint64 TNodeJsUtil::GetTmMSecs(v8::Handle<v8::Value>& Value) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	if (Value->IsDate()) {
		v8::Local<v8::Date> Date = v8::Handle<v8::Date>::Cast(Value);
		return GetTmMSecs(Date);
	}
	else if (Value->IsString()) {
		v8::String::Utf8Value Utf8(Value);
		TTm Tm = TTm::GetTmFromWebLogDateTimeStr(TStr(*Utf8), '-', ':', '.', 'T');
		return TTm::GetMSecsFromTm(Tm);
	}
	else {
		EAssertR(Value->IsNumber(), "Date is not in a representation of a string, date or number!");
		return GetCppTimestamp(int64(Value->NumberValue()));
	}
}
예제 #14
0
void elMundo::initRegExs(void)
{
    QString RLEst = Utf8("x…=…(\\d+),…y…=…(\\d+)(?:,…rule…=…([bs/0-9]+))?");
    QString CBst  = Utf8("#P…([+0-9-]+)…([+0-9-]+)");
    QString DBLst = Utf8("([0-9]+k)?([0-9]+h)?@!");
    RLEst.replace(Utf8("…"), "\\s*");
    CBst. replace(Utf8("…"), "\\s*");
    DBLst.replace(Utf8("…"), "\\s*");
    reRLEstart.setCaseSensitivity(Qt::CaseInsensitive);
    reRLEstart.setPattern(RLEst);
    reCellBlock.setCaseSensitivity(Qt::CaseInsensitive);
    reCellBlock.setPattern(CBst);
    reDBlifeCmd.setPattern(DBLst);
}
예제 #15
0
uString* uString::Utf8(const char* mutf8)
{
    return mutf8
        ? Utf8(mutf8, strlen(mutf8))
        : NULL;
}
예제 #16
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jdlvFrame::jdlvFrame (const char *fileToLoad) : nextWorld(NULL),
  isChanged(false),
    eM(elModeView), genNo(0), curColor(0), speed(3), timerID(0)
{
  QFont fixedFont(jdlvFONTFACENAME, jdlvFONTSIZE);
        fixedFont.setStyleHint(QFont::TypeWriter);
  primeWorld = new_elMundoA();
  vista = new elVista (this, primeWorld); setCentralWidget(vista);
  vista->setMinimumSize(720, 480);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QToolBar *bottom = new permanentToolBar("ctrl", this);
  bottom->setFloatable(false);
  bottom->setMovable  (false);
  bottom->setIconSize(QSize(28,25));
  showTimeCB = new QAction(QIcon(":/time.png"), QString("time"), this);
  showInfoPB = new QAction(QIcon(":/info.png"), QString("info"), this);
  connect(showTimeCB, SIGNAL(triggered(bool)), this, SLOT(ToggleTime(bool)));
  connect(showInfoPB, SIGNAL(triggered()),     this, SLOT(ShowInfo()));
  bottom->addAction(showTimeCB);
  bottom->addAction(showInfoPB);         showInfoPB->setEnabled(false); //+
  bottom->addWidget(new QLabel(" "));
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QActionGroup *modeGroup = new QActionGroup(this);
  modeEdit = new QAction(QIcon(":/pen-in-box.png"),QString("Edit (X)"),  this);
  modeView = new QAction(QIcon(":/eye-half.png"),  QString("View (Z)"),  this);
  setColor = new QAction(QIcon(":/empty1.png"),    QString("color"),     this);
  connect(modeView, SIGNAL(triggered()), this, SLOT(SetModeView()));
  connect(modeEdit, SIGNAL(triggered()), this, SLOT(SetModeEdit()));
  connect(setColor, SIGNAL(triggered()), this, SLOT(PopupColorMenu()));
  showTimeCB->setCheckable(true);
  modeEdit  ->setCheckable(true); modeEdit->setShortcut(QKeySequence("X"));
  modeView  ->setCheckable(true); modeView->setShortcut(QKeySequence("Z"));
  modeView  ->setChecked  (true);
  modeGroup->addAction(modeView); bottom->addAction(modeView);
  modeGroup->addAction(modeEdit); bottom->addAction(modeEdit);
                                  bottom->addAction(setColor);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *file_menu = menuBar()->addMenu("File");
  openFile =  new QAction(QIcon(":/book.png"), QString("Open.."), this);
  reLoad = new QAction(QIcon(":/reload1.png"), QString("reload"), this);
  connect(openFile, SIGNAL(triggered()), this, SLOT(OpenFile()));
  connect(reLoad,   SIGNAL(triggered()), this, SLOT(DoReload()));
  file_menu->addAction(openFile);
  file_menu->addAction(reLoad);        reLoad->setEnabled(false);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *edit_menu = menuBar()->addMenu("Edit");
  deleteSelected = new QAction(QString("delete"), this);
  deleteSelected->setShortcut(QKeySequence("Del"));
  cropSelected   = new QAction(QString("crop"), this);
  pasteClipboard =
            new QAction(QIcon(":/win-paste.png"),   QString("paste"),    this);
  copyCLR = new QAction(QIcon(":/export-blue.png"), QString("copy"),     this);
  copyBnW = new QAction(QIcon(":/export-mono.png"), QString("copy b/w"), this);
  newWin = new QAction(QIcon(":/windows1.png"),   QString("new window"), this);
  bottom->addAction(pasteClipboard);     pasteClipboard->setEnabled(false); //+
  bottom->addAction(copyCLR); copyCLR->setShortcut(QKeySequence("Ctrl+C"));
  bottom->addAction(copyBnW);
  bottom->addAction(newWin);       newWin->setEnabled(false); //+
  connect(deleteSelected, SIGNAL(triggered()), this, SLOT(DeleteSelected()));
  connect(  cropSelected, SIGNAL(triggered()), this, SLOT(  CropSelected()));
  connect(pasteClipboard, SIGNAL(triggered()), this, SLOT(PasteClipboard()));
  connect(copyCLR, SIGNAL(triggered()), this, SLOT(CopyCLR()));
  connect(copyBnW, SIGNAL(triggered()), this, SLOT(CopyBnW()));
  connect(newWin, SIGNAL(triggered()), this, SLOT(NewWindow()));
  edit_menu->addAction(deleteSelected);
  edit_menu->addAction(  cropSelected); edit_menu->addSeparator();
  edit_menu->addAction(pasteClipboard); edit_menu->addAction(copyCLR);
                                        edit_menu->addAction(copyBnW);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  colorMenu = menuBar()->addMenu("Color");
#define ADD_colorMenu(ico,text,shortcut) \
  colorMenu->addAction(*ico,text)->setShortcut(QKeySequence(shortcut))
  ADD_colorMenu(enBlancoIco,            "blanco",     "B");
  ADD_colorMenu(enRojoIco,              "rojo (red)", "R");
  ADD_colorMenu(enCastanoIco, Utf8("castaño (brown)"),"C");
  ADD_colorMenu(enVerdeIco,          "verde (green)", "V");
  ADD_colorMenu(enAzulIco,             "azul (blue)", "A");
  colorMenu->addSeparator();
  colorMenu->addAction("random Bicolor")->setShortcut(QKeySequence("Ctrl+B"));
  colorMenu->addAction("random Recolor")->setShortcut(QKeySequence("Ctrl+R"));
  colorMenu->addAction("Un-color all")  ->setShortcut(QKeySequence("Ctrl+U"));
  connect(colorMenu, SIGNAL(triggered(QAction*)),
               this, SLOT(SelectColor(QAction*)));
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QLabel *magIcon = new QLabel; magIcon->setPixmap(QPixmap(":/zoom3.png"));
  magText = new QLabel(QString("+1"));
  magText->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  magText->setFont(fixedFont);
  magText->setMinimumSize(QSize(30,25));     bottom->addWidget(magText);
                                             bottom->addWidget(magIcon);
  fitView = new QAction(QIcon(":/full-size.png"), QString("fit"), this);
  connect(fitView, SIGNAL(triggered()), this, SLOT(DoFitView()));
  bottom->addAction(fitView);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  QMenu *play_menu = menuBar()->addMenu("Play");
  playGen = new QLabel(QString("0"));
  playGen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  playGen->setMinimumSize(QSize(66,25));
  prevGen =  new QAction(QIcon(":/step-back.png"),    QString("back"), this);
  nextGen =  new QAction(QIcon(":/go-forward.png") ,  QString("step"), this);
  playStop = new QAction(QIcon(":/fast-forward.png"), QString("go!"),  this);
  connect(prevGen,  SIGNAL(triggered()), this, SLOT(DoPrevGen()));
  connect(nextGen,  SIGNAL(triggered()), this, SLOT(DoNextGen()));
  connect(playStop, SIGNAL(triggered()), this, SLOT(DoPlayStop()));
  play_menu->addAction(nextGen);
  play_menu->addAction(playStop);
  play_menu->addAction(prevGen); prevGen->setEnabled(false);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  speedSlider = new QSlider(Qt::Horizontal, this);
  speedSlider->setMinimum(1); speedSlider->setValue(speed);
  speedSlider->setMaximum(4); speedSlider->setMaximumSize(50,22);
  speedSlider->setSingleStep(1);
  speedSlider->setTickInterval(1);
  speedSlider->setTickPosition(QSlider::TicksBelow);
  connect(speedSlider, SIGNAL(valueChanged(int)), this, SLOT(ChangeSpeed(int)));
  bottom->addWidget(playGen);
  bottom->addAction(nextGen);
  bottom->addWidget(speedSlider);
  bottom->addAction(playStop);
  addToolBar(Qt::BottomToolBarArea, bottom);
  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  if (fileToLoad) LoadTheWorld(fileToLoad);
  else                       SetWinTitle();
  show(); raise();
}
예제 #17
0
inline QString MkQuoteCmd(QString& cmd) { return Utf8("‹") + cmd + Utf8("›"); }
예제 #18
0
TStr TNodeJsUtil::GetStr(const v8::Local<v8::String>& V8Str) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);
    v8::String::Utf8Value Utf8(V8Str);
    return TStr(*Utf8);
}