// @brief Unique environment instance allocator // @note meta: Metatable // @note _U1: Instance size // @note _U2: Array size // @note _U3: Hash size static int UniqueAlloc (lua_State * L) { lua_newuserdata(L, uI(L, lua_upvalueindex(1))); // meta, ud lua_insert(L, 1); // ud, meta lua_setmetatable(L, 1); // ud lua_createtable(L, sI(L, lua_upvalueindex(2)), sI(L, lua_upvalueindex(3))); // ud, env lua_setfenv(L, 1); // ud return 1; }
void loop() { lBreak(); sM(); sE(); sR(); sR(); sY(); wBreak(); sC(); sH(); sR(); sI(); sS(); sT(); sM(); sA(); sS(); lBreak(); }
// Private members QString FalfMediaPlayer::getData(dataType t) { if (!isActive()) return ""; infoFile.open(QIODevice::ReadOnly); QTextStream sI(&infoFile); sI.setCodec("UTF-8"); QString buffer; switch (t) { case ANY: buffer = sI.readLine(); break; case TITLE: buffer = sI.readLine(); buffer = buffer.mid(7); break; case ALBUM: for (unsigned short int i = 0 ; i < 2 ; i++) buffer = sI.readLine(); buffer = buffer.mid(7); break; case ARTIST: for (unsigned short int i = 0 ; i < 3 ; i++) buffer = sI.readLine(); buffer = buffer.mid(8); break; case VER: for (unsigned short int i = 0 ; i < 5 ; i++) buffer = sI.readLine(); buffer = buffer.mid(12); break; } infoFile.close(); return buffer.simplified(); }
// This is the main constructor. PropertiesDialog::PropertiesDialog(QWidget *parent, const QVector<QString> Qheader, const QString sourceInput, const QString targetInput) : QDialog(parent) { // We first set up the standard elements of the interface, which are only two labels and two buttons. sourceLabel = new QLabel(sourceInput); targetLabel = new QLabel(targetInput); saveCloseButton = new QPushButton(tr("Save and Close")); cancelButton = new QPushButton(tr("Cancel")); // We dynamically create two lists of checkboxes as well, which represent potential properties. // Only variables that were not already selected as source and target nodes are included as options. QVectorIterator<QString> it(Qheader); while (it.hasNext()) { QPointer<QCheckBox> tempBoxOne = new QCheckBox(it.peekNext(), this); QPointer<QCheckBox> tempBoxTwo = new QCheckBox(it.next(), this); if (tempBoxOne->text() != sourceInput && tempBoxOne->text() != targetInput) { sourceVector.push_back(tempBoxOne); } else { delete tempBoxOne; } if (tempBoxTwo->text() != targetInput && tempBoxTwo->text() != sourceInput) { targetVector.push_back(tempBoxTwo); if (sourceInput == targetInput) { tempBoxTwo->setEnabled(false); } } else { delete tempBoxTwo; } } // We then set up the signals. Basically, save and close is the only signal that will send information from the properties dialog // to the main dialog. connect(saveCloseButton, SIGNAL(clicked()), this, SLOT(saveAndClose())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // In case the user decides not to set properties. // Then we create our layout. QPointer<QVBoxLayout> mainLayout = new QVBoxLayout; QPointer<QHBoxLayout> mainBodyLayout = new QHBoxLayout; QPointer<QVBoxLayout> mainBodyLeft = new QVBoxLayout; QPointer<QVBoxLayout> mainBodyRight = new QVBoxLayout; mainBodyLeft->addWidget(sourceLabel); QVectorIterator<QPointer<QCheckBox> > sI(sourceVector); while (sI.hasNext()) { mainBodyLeft->addWidget(sI.next()); } mainBodyRight->addWidget(targetLabel); QVectorIterator<QPointer<QCheckBox> > tI(targetVector); while (tI.hasNext()) { mainBodyRight->addWidget(tI.next()); } mainBodyLayout->addLayout(mainBodyLeft); mainBodyLayout->addLayout(mainBodyRight); mainLayout->addLayout(mainBodyLayout); QPointer<QHBoxLayout> lowerLayout = new QHBoxLayout; lowerLayout->addWidget(saveCloseButton); lowerLayout->addWidget(cancelButton); mainLayout->addLayout(lowerLayout); setLayout(mainLayout); setWindowTitle(tr("Set Properties")); setFixedHeight(sizeHint().height()); // And that finishes our constructor }