Example #1
0
void tstTeamMngr::testGetAllTeams()
{
  printStartMsg("tstTeamMngr::testGetAllTeams");
  
  TournamentDB* db = getScenario01(true);
  TeamMngr tmngr(db);
  
  // run on empty table
  QList<Team> result = tmngr.getAllTeams();
  CPPUNIT_ASSERT(result.length() == 0);
  
  // actually create a valid team
  CPPUNIT_ASSERT(tmngr.createNewTeam("t1") == OK);
  CPPUNIT_ASSERT(tmngr.createNewTeam("t2") == OK);
  
  // run on filled table
  result = tmngr.getAllTeams();
  CPPUNIT_ASSERT(result.length() == 2);
  Team t = result.at(0);
  CPPUNIT_ASSERT(t.getId() == 1);
  CPPUNIT_ASSERT(t.getName() == "t1");
  t = result.at(1);
  CPPUNIT_ASSERT(t.getId() == 2);
  CPPUNIT_ASSERT(t.getName() == "t2");
  
  delete db;
  printEndMsg();
}
Example #2
0
void TableView::coloringRows(QList<double> x,int start,int end)
{
    QList<QColor> colors;
    colors << QColor(255,255,255) << QColor(255,0,0) << QColor(0,255,0) << QColor(0,0,255) << QColor(255,255,0);
    QTableWidget* table =  getTableWidget();
    if(start<0||start>table->columnCount())
    {
        start = 0;
    }
    if(end<0||end>table->columnCount())
    {
        end = table->columnCount();
    }
    if(0!=table){
        for(int i=0;i<x.length();i++)
        {
            if(table->item(i,0))
            {
                for(int j=start;j<end;j++)
                {
                    int idx = ((int)x[i])%colors.length();
                    table->item(i,j)->setBackgroundColor( colors[idx]);

                }
            }
        }
    }
}
Example #3
0
void XComVb::SetU1Array(const QList<short>& valueArray)
{
	this->SetItemCount(valueArray.length());
	for (int i = 0; i < valueArray.length(); ++i) {
		this->SetU1(valueArray[i]);
	}
}
Example #4
0
void XComVb::SetU8Array(const QList<double>& valueArray)
{
	this->SetItemCount(valueArray.length());
	for (int i = 0; i < valueArray.length(); ++i) {
		this->SetU8(valueArray[i]);
	}
}
Example #5
0
void XComVb::SetBoolArray(const QList<bool>& valueArray)
{
	this->SetItemCount(valueArray.length());
	for (int i = 0; i < valueArray.length(); ++i) {
		this->SetBool(valueArray[i]);
	}
}
Example #6
0
//================
//    PUBLIC SLOTS
//================
void page_autostart::SaveSettings(){
  //qDebug() << "Load AutoStart Files for saving";
  QList<XDGDesktop*> STARTAPPS = LXDG::findAutoStartFiles(true); //also want invalid/disabled items
  //qDebug() << " - done";
  //bool newstartapps = false;
  for(int i=0; i<ui->list_session_start->count(); i++){
    QString file = ui->list_session_start->item(i)->whatsThis();
    bool enabled = ui->list_session_start->item(i)->checkState()==Qt::Checked;
    bool found = false;
    for(int i=0; i<STARTAPPS.length(); i++){
      if(STARTAPPS[i]->filePath==file){
        found = true;
	if(enabled != !STARTAPPS[i]->isHidden){
	  //value is different
	  qDebug() << "Setting Autostart:" << enabled << STARTAPPS[i]->filePath;
	  STARTAPPS[i]->setAutoStarted(enabled);
	}
	break;
      }
    }
    if(!found && enabled){
      //New file/binary/app
      qDebug() << "Adding new AutoStart File:" << file;
      LXDG::setAutoStarted(enabled, file);
      //newstartapps = true;
    }
  } //end loop over GUI items
  //Now cleanup all the STARTAPPS data
  for(int i=STARTAPPS.length()-1; i>=0; i--){ STARTAPPS[i]->deleteLater(); }
}
Example #7
0
void CustomActions::set(QList<Command> cmds)
{
    qSort(cmds);
    bool diff=cmds.length()!=commands.length();

    if (!diff) {
        for (int i=0; i<cmds.length() && !diff; ++i) {
            if (commands[i]!=cmds[i]) {
                diff=true;
            }
        }
    }
    QMenu *m=menu();
    if (diff) {
        foreach (const Command &cmd, commands) {
            m->removeAction(cmd.act);
            disconnect(cmd.act, SIGNAL(triggered()), this, SLOT(doAction()));
            cmd.act->deleteLater();
        }
        commands.clear();

        foreach (const Command &cmd, cmds) {
            Command c(cmd);
            c.act=new Action(c.name, this);
            m->addAction(c.act);
            commands.append(c);
            connect(c.act, SIGNAL(triggered()), this, SLOT(doAction()));
        }
Example #8
0
void ExportGesamt::on_pushDrucken_clicked()
{
    // Erstelle eine liste mit den Objekten für die Einzelansicht
    QList<AActivity*> *listeEinzel = new QList<AActivity*>();
    // Erstelle eine Liste für die Listenansicht
    QList<AActivity*> *listeListe = new QList<AActivity*>();
    for (AActivity *a: liste) {
        if(! actToList.value(a)->isHidden()) {
            listeListe->append(a);
            if (actToList.value(a)->isSelected()) {
                listeEinzel->append(a);
            }
        }
    }

    // Lasse einene Drucker auswählen
    QPrinter *paper = 0;
    QPrinter *pdfListe = 0;
    QPrinter *pdfEinzel = 0;
    if ((ui->checkAusdruck->isChecked()) && (ui->checkEinzel->isChecked() || ui->checkListe->isChecked()))
        paper = Export::getPrinterPaper(p);

    //Drucke die Daten mit dem Export modul
    if (ui->checkEinzel->isChecked() && listeEinzel->length() > 0) {
        if (ui->checkEinzel->isChecked() && ui->checkPDF->isChecked())
            pdfEinzel = Export::getPrinterPDF(p, "Einzelansicht.pdf");
        Export::printSingle(listeEinzel, pdfEinzel, paper);
    }
    if (ui->checkListe->isChecked() && listeListe->length() > 0) {
        if (ui->checkListe->isChecked() && ui->checkPDF->isChecked())
            pdfListe = Export::getPrinterPDF(p, "Listenansicht.pdf");
        Export::printList(listeListe, pdfListe, paper);
    }
}
void rpm1gauge::realtimeDataSlot()
{
  int sum=0;
  QList<QPair<double, double> > templist = mNeedle->returnData();                //data has value and timee
  for(int i=0; i<templist.length();i++){
      QPair<double,double> ifthisworks = templist.at(i);
      ui->customPlot->graph(0)->addData(ifthisworks.first, ifthisworks.second);     //adds data to graph
      sum+=ifthisworks.second;
  }

  //
  QPair<double, double> temppair= templist.at(templist.length()-1);             //most recent data
  double x = temppair.second;
  double timedata = temppair.first;
  ui->lcdNumber->display(x);                                                    //display current value
  ui->lcdNumber->setPalette(Qt::black);
  //
  rpm1subneedle->setCurrentValue(x);                                            //sets needle
  ui->customPlot->graph(1)->clearData();
  ui->customPlot->graph(1)->addData(timedata, x);
  ui->customPlot->graph(0)->removeDataBefore(timedata-300);                     //removes old data out of range
  ui->customPlot->graph(1)->removeDataBefore(timedata-300);
  ui->customPlot->graph(0)->rescaleValueAxis();                                 //scales axis
  ui->customPlot->graph(1)->rescaleValueAxis(true);


  ui->customPlot->xAxis->setRange(timedata+0.25, 300, Qt::AlignRight);          //scales x axis
  ui->customPlot->yAxis->setRange(mNeedle->mMinValue,mNeedle->mMaxValue * 1.05);
  ui->customPlot->replot();

  ui->verticalLayout_2->addWidget(rpm1sub);
}
Example #10
0
void MainUI::GoForward(){
  QList<QWebHistoryItem> bits = webview->history()->forwardItems(50); //max 50 items
  //First remove any action URLs (*never* repeat them)
  for(int i=0; i<bits.length(); i++){
    if( actionUrl(bits[i].url()) ){ bits.removeAt(i); i--; }
  }
  //Now go through and find the proper URL to go to
  QUrl cit = webview->url(); //current page URL
  if(DEBUG){ qDebug() << "---FORWARD CLICKED---" << bits.length(); }
  //Go to the last page-refresh (if any) for the next URL
  int got = -1; // go to index
  for(int i=0; i<bits.length() && got<0; i++){ //i=0 is the desired item
    if( !sameUrls(cit, bits[i].url()) ){
      got = i; //go to this URL (different from current page)
      //Now fast forward to the end of the page-refresh chain (if there is one) for this URL
      for(int j=i+1; j<bits.length(); j++){
        if( sameUrls( bits[i].url(), bits[j].url()) ){ got = j; }
	else{ break; }
      }
    }else if(i==(bits.length()-1)){
      got = i; //last item - go ahead and load it
    }
    if(DEBUG && got < 0){ qDebug() << "Forward History Item Skipped:" << i << bits[i].url(); }
  }
  //fallback in case something above did not work
  if(got<0){ webview->forward(); }
  else{ 
    webview->history()->goToItem(bits[got]); 
  }
}
void SubToolBar::initTextLabel() {
    //text...
    m_textLabel = new QLabel(this);
    m_textLabel->setStyleSheet(getFileContent(":/resources/qss/textbutton.qss"));
    QList<int> fontSizeList;
    fontSizeList << 9 << 10 << 12 << 14 << 18 << 24 << 36 << 48 << 64 << 72 << 96;
    QButtonGroup* textBtnGroup = new QButtonGroup(this);

    QList<TextButton*> textButtonList;
    for(int i = 0; i < fontSizeList.length(); i++) {
        TextButton* textButton = new TextButton(fontSizeList[i], m_textLabel);
        textBtnGroup->addButton(textButton);
        textButtonList.append(textButton);
    }
    textBtnGroup->setExclusive(true);
      int defaultFontSize = ConfigSettings::instance()->value("text", "fontsize").toInt();

    QHBoxLayout* textLayout = new QHBoxLayout();
    textLayout->setMargin(0);
    textLayout->setSpacing(0);
    textLayout->addSpacing(1);
    for(int k = 0; k < textButtonList.length(); k++) {
        textLayout->addWidget(textButtonList[k]);
        textLayout->addSpacing(BUTTON_SPACING);
        if (fontSizeList[k] == defaultFontSize) {
            textButtonList[k]->setChecked(true);
        }
    }
    textLayout->addStretch();
    m_textLabel->setLayout(textLayout);
    addWidget(m_textLabel);
}
void DeepCommandSearcher::run(){
    QList<int> idList;
    if(searchText_m == ""){
        emit signalSearchFinished("");
        return;
    }

    emit signalSetProgressString("Searching match command.");
    emit signalSetProgressMaximumValue(100);

    ClvDataAccessor *accessor = new ClvDataAccessor(clvFilePath_m);
    accessor->open();
    idList = accessor->getIdList(searchText_m, this);
    accessor->close();
    if(idList.length() == 0){
        emit signalSearchFinished("");
        return;
    }

    QString idListString = "";
    int length = idList.length();
    for(int i=0; i<length; i++){
        if(i != 0){
            idListString = QString("%1,%2").arg(idListString, QString::number(idList.at(i)));
        }else{
            idListString = QString::number(idList.at(0));
        }
    }

    emit signalSetProgressValue(100);

    emit signalSearchFinished(idListString);
}
Example #13
0
void tstCatMngr::testGetAllCategories()
{
  printStartMsg("tstCatMngr::testGetAllCategories");
  
  TournamentDB* db = getScenario01(true);
  CatMngr cmngr(db);
  
  // run on empty table
  QList<Category> result = cmngr.getAllCategories();
  CPPUNIT_ASSERT(result.length() == 0);
  
  // actually create a valid category
  CPPUNIT_ASSERT(cmngr.createNewCategory("c1") == OK);
  CPPUNIT_ASSERT(cmngr.createNewCategory("c2") == OK);
  
  // run on filled table
  result = cmngr.getAllCategories();
  CPPUNIT_ASSERT(result.length() == 2);
  Category c = result.at(0);
  CPPUNIT_ASSERT(c.getId() == 1);
  CPPUNIT_ASSERT(c.getName() == "c1");
  c = result.at(1);
  CPPUNIT_ASSERT(c.getId() == 2);
  CPPUNIT_ASSERT(c.getName() == "c2");
  
  delete db;
  printEndMsg();
}
int JoyAxisContextMenu::getTriggerPresetIndex()
{
    int result = 0;

    PadderCommon::inputDaemonMutex.lock();

    JoyAxisButton *paxisbutton = axis->getPAxisButton();
    QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots();

    if (paxisslots->length() == 1)
    {
        JoyButtonSlot *pslot = paxisslots->at(0);
        if (pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton &&
            pslot->getSlotCode() == JoyButtonSlot::MouseLB)
        {
            result = 1;
        }
        else if (pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton &&
                 pslot->getSlotCode() == JoyButtonSlot::MouseRB)
        {
            result = 2;
        }
    }
    else if (paxisslots->length() == 0)
    {
        result = 3;
    }

    PadderCommon::inputDaemonMutex.unlock();

    return result;
}
Example #15
0
QJsonObject protoObject::toJSON() {
    //TODO
    QJsonObject obj;
    QList<QByteArray> properties = this->dynamicPropertyNames();
    QString property;
    protoObject* tmp_val;
    int length = properties.length();


    for(int i = 0; i < length; i++) {
        property = QString(properties.at(i));
        QVariant value = this->property(property.toLatin1());
        if (value.canConvert<QSharedPointer<protoObject> >()) {
            //tmp_val = dynamic_cast<protoObject*>(value.value());
            tmp_val = value.value<QSharedPointer<protoObject> >().data();
            obj.insert(property, tmp_val->toJSON());
            continue;
        };
        if (value.canConvert< QList<QSharedPointer<protoObject> > >()) {
            //qDebug() << "converted to list" << property;
            QList<QSharedPointer<protoObject> > list = value.value< QList<QSharedPointer<protoObject> > >();
            //qDebug() << list;
            QJsonArray tmp_arr;
            int length = list.length();
            for(int j = 0; j < length; j++) {
                tmp_val = list.at(j).data();
                tmp_arr.append(tmp_val->toJSON());
            };
            obj.insert(property, tmp_arr);
            continue;
        };
        obj.insert(property, QJsonValue(this->property(property.toLatin1()).toString()));
    };
    return obj;
}
Example #16
0
bool QiaobianCard::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const{
    if(Self->getPhase() == Player::Draw)
        return targets.length() <= 2 && !targets.isEmpty();
    else if(Self->getPhase() == Player::Play)
        return targets.length() == 1;
    else
        return targets.isEmpty();
}
Example #17
0
bool QiaobianCard::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const
{
    Player::Phase phase = (Player::Phase)Self->getMark("qiaobianPhase");
    if (phase == Player::Draw)
        return targets.length() <= 2 && !targets.isEmpty();
    else if (phase == Player::Play)
        return targets.length() == 1;
    return false;
}
void ListEditorWidget::remove()
{
    saveNamesFromListWidget();
    QList<QListWidgetItem*> selections = listWidget->selectedItems();
    if(selections.length()==0) { return; }
    for(int i=0; i<selections.length(); i++)
    {
	list.removeAt(listWidget->row(selections.at(i)));
    }
    refresh();
}
Example #19
0
//Apply screen configuration
void RRSettings::Apply(QList<ScreenInfo> screens){
  //Read all the settings and create the xrandr options to maintain these settings
  QStringList opts;
  qDebug() << "Apply:" << screens.length();
  for(int i=0; i<screens.length(); i++){
    qDebug() << " -- Screen:" << i << screens[i].ID << screens[i].isactive << screens[i].order;
    if(screens[i].order <0 || !screens[i].isactive){ continue; } //skip this screen - non-active
    opts << "--output" << screens[i].ID << "--mode" << QString::number(screens[i].geom.width())+"x"+QString::number(screens[i].geom.height());
    opts << "--pos" << QString::number(screens[i].geom.x())+"x"+QString::number(screens[i].geom.y());
    if(screens[i].isprimary){ opts << "--primary"; }
  }
  qDebug() << "Run command: xrandr" << opts;
  LUtils::runCmd("xrandr", opts);
}
Example #20
0
// I have a hard time storing QActions as class members.  This is a substitute.
QAction* MemoryWindow::dataFormatMenuItem(const QString& itemName)
{
	QList<QMenu*> menus = menuBar()->findChildren<QMenu*>();
	for (int i = 0; i < menus.length(); i++)
	{
		if (menus[i]->title() != "&Options") continue;
		QList<QAction*> actions = menus[i]->actions();
		for (int j = 0; j < actions.length(); j++)
		{
			if (actions[j]->objectName() == itemName)
				return actions[j];
		}
	}
	return nullptr;
}
void CookieJar::read()
{
    qDebug() << Q_FUNC_INFO;
    qDebug() << COOKIE_PATH;
    QFile f(COOKIE);

    if(!f.exists())
    {
        return;
    }

    if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        return;
    }

    QList<QNetworkCookie> list;

    while(!f.atEnd())
    {
        QList<QByteArray> spl = f.readLine().split(';');
        QList<QByteArray> cookie = spl[0].split('=');

        if(cookie.length() < 2 || cookie[0].isEmpty() || cookie[1].isEmpty())
        {
            continue;
        }

        QMap<QByteArray, QByteArray> add;
        for(int cnt = 1; spl.length() > cnt; cnt++)
        {
            QList<QByteArray> t = spl[cnt].split('=');
            if(t.count() > 1)
            {
                add[t[0].trimmed()] = t[1].trimmed();
            }
        }

        QNetworkCookie c;
        c.setName(cookie[0]);
        c.setValue(cookie[1]);
        c.setPath(add["path"]);
        c.setDomain(add["domain"]);
        c.setExpirationDate(QDateTime::fromString(add["expires"]));
        list.append(c);
    }
    setAllCookies(list);
}
Example #22
0
void ClipboardModel::sortItems(const QModelIndexList &indexList,
                               CompareItems *compare)
{
    ComparisonItem a, b;
    QList< QPair<int, ClipboardItem*> > list;
    QList<int> rows;

    for (int i = 0; i < indexList.length(); ++i) {
        int row = indexList[i].row();
        if ( row >= m_clipboardList.length() )
            return;
        list.append( qMakePair(row, m_clipboardList[row]) );
        rows.append(row);
    }

    qSort(rows);
    qSort( list.begin(), list.end(), compare );

    for (int i = 0; i < list.length(); ++i ) {
        int row1 = list[i].first;
        int row2 = rows[i];
        if (row1 != row2) {
            m_clipboardList[row2] = list[i].second;
            QModelIndex ind = index(row2);
            emit dataChanged(ind, ind);
        }
    }
}
Example #23
0
 void Editor::removeBanner(QString objectName)
 {
     QList<QWidget *> list = findChildren<QWidget *>(objectName);
     for (int i = 0; i < list.length(); i++) {
         removeBanner(list[i]);
     }
 }
Example #24
0
void SellFirst::on_pushButton_clicked()
{
    QString barcode=ui->barcode->text();
    int qty = ui->sellQty->text().toInt();

    TableGoods goods;
    if(goods.isExist(barcode))
    {
        sellManage.addGoods(barcode,ui->VIPNumTxt->text(),qty);
        QList <QStringList> sellInfo = sellManage.getSellInfo();
        int row = sellInfo.length();
         ui->tableWidget->setRowCount(row);
         for(int i=0;i<row;i++)
         {
             for(int j=0;j<3;j++)
             {
                 ui->tableWidget->setItem(i,j,new QTableWidgetItem(sellInfo.at(i).at(j)));
             }
         }
         ui->sumPriceLabel->setText(QString::number(sellManage.getTotal()));
         ui->sumScoreLabel->setText(QString::number(sellManage.getScore()));
    }
    else
    {
        QMessageBox::information(this, "提示", "没有该商品!");
    }
}
Example #25
0
/** Processes all message received on socket */
void PreviewSubscribe::processSocketMessage(const QList<QByteArray> &messageList)
{
    Container &rx = m_socketRx;

    if (messageList.length() < 2)  // in case we received insufficient data
    {
        return;
    }

    // we only handle the first two messges
    const auto &topic = messageList.first();
    rx.ParseFromArray(messageList.last().data(), messageList.last().size());

#ifdef QT_DEBUG
    std::string s;
    gpb::TextFormat::PrintToString(rx, &s);
    DEBUG_TAG(3, m_debugName, "received message" << QString::fromStdString(s));
#endif

    // react to any incoming message

    if (m_state == State::Up)
    {
        emit fsmUpMessageReceived(QPrivateSignal());
    }

    emit socketMessageReceived(topic, rx);
}
Example #26
0
/**
 * Constructor
 */
Telemetry::Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr) : objMngr(objMngr), utalk(utalk)
{
    mutex = new QMutex(QMutex::Recursive);

    // Register all objects in the list
    QList< QList<UAVObject *> > objs = objMngr->getObjects();
    for (int objidx = 0; objidx < objs.length(); ++objidx) {
        // we only need to register one instance per object type
        registerObject(objs[objidx][0]);
    }

    // Listen to new object creations
    connect(objMngr, SIGNAL(newObject(UAVObject *)), this, SLOT(newObject(UAVObject *)));
    connect(objMngr, SIGNAL(newInstance(UAVObject *)), this, SLOT(newInstance(UAVObject *)));

    // Listen to transaction completions
    // TODO should send a status (SUCCESS, FAILED, TIMEOUT)
    connect(utalk, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool)));

    // Get GCS stats object
    gcsStatsObj = GCSTelemetryStats::GetInstance(objMngr);

    // Setup and start the periodic timer
    timeToNextUpdateMs = 0;
    updateTimer = new QTimer(this);
    connect(updateTimer, SIGNAL(timeout()), this, SLOT(processPeriodicUpdates()));
    updateTimer->start(1000);

    // Setup and start the stats timer
    txErrors  = 0;
    txRetries = 0;
}
Example #27
0
RCircle RCircle::createFrom3Points(const RVector& p1,
                                  const RVector& p2,
                                  const RVector& p3) {
    // intersection of two middle lines

    // middle points between first two points:
    RVector mp1 = RVector::getAverage(p1, p2);
    double a1 = p1.getAngleTo(p2) + M_PI / 2.0;
    // direction from middle point to center:
    RVector dir1 = RVector::createPolar(1.0, a1);

    // middle points between last two points:
    RVector mp2 = RVector::getAverage(p2, p3);
    double a2 = p2.getAngleTo(p3) + M_PI / 2.0;
    // direction from middle point to center:
    RVector dir2 = RVector::createPolar(1.0, a2);

    RLine midLine1(mp1, mp1 + dir1);
    RLine midLine2(mp2, mp2 + dir2);

    QList<RVector> ips = midLine1.getIntersectionPoints(midLine2, false);
    if (ips.length()!=1) {
        return RCircle();
    }

    RVector center = ips[0];
    double radius = center.getDistanceTo(p3);
//    double angle1 = center.getAngleTo(p1);
//    double angle2 = center.getAngleTo(p3);
//    bool reversed = RMath::isAngleBetween(center.getAngleTo(p2),
//                                            angle1, angle2, true);

    return RCircle(center, radius);
}
Example #28
0
QList<SortUnitType> analize_file_name(const QString &fileName)
{
    QList<SortUnitType> res;

    for(int i=0; i<fileName.length(); i++)
    {
        const QChar &ch = fileName[i];

        if(ch.isNumber())
        {
            int num = QString(ch).toInt();

            if(res.isEmpty() || !res.last().ch.isNull() )
            {
                res << SortUnitType();
            }

            SortUnitType & resUnit = res[res.length()-1];
            resUnit.num = resUnit.num*10 + num;
        }
        else
        {
            SortUnitType unit;
            unit.ch = ch;
            res << unit;
        }
    }

    return res;
}
void SubToolBar::initColorLabel() {
    m_colorLabel = new QLabel(this);
    m_colorLabel->setStyleSheet(getFileContent(":/resources/qss/colorbtn.qss"));
    QList<ColorButton*> colorBtnList;
    QButtonGroup* colorBtnGroup = new QButtonGroup(m_colorLabel);
    colorBtnGroup->setExclusive(true);

    for(int i = 0; i < COLOR_NUM; i ++) {
        ColorButton* colorBtn = new ColorButton(colorIndexOf(i));
        colorBtn->setObjectName(QString("ColorBtn%1").arg(i+1));
        colorBtnList.append(colorBtn);
        colorBtnGroup->addButton(colorBtn);
    }

    QHBoxLayout* colorLayout = new QHBoxLayout();
    colorLayout->setMargin(0);
    colorLayout->setSpacing(0);
    colorLayout->addSpacing(3);
    for(int i = 0; i < colorBtnList.length(); i++) {
        colorLayout->addWidget(colorBtnList[i]);
        colorLayout->addSpacing(1);
        connect(colorBtnList[i], &ColorButton::updatePaintColor,
                this, &SubToolBar::updateColor);
    }
    colorLayout->addStretch();
    m_colorLabel->setLayout(colorLayout);

    addWidget(m_colorLabel);

    connect(this, &SubToolBar::defaultColorIndexChanged, this, [=](int index){
        colorBtnList[index]->setChecked(true);
    });
}
Example #30
0
File: ta.cpp Project: Dunni/taeval
QList<TA> TA::stringToList(QString aString){  // Convert a string to a list of NonAdminUser objects
    TAList result = TAList();
    QList<QString> list = aString.split(QRegExp("(~`|`~|~~)"));
    for(int i=1;i<list.length()-1;i++) result += TA(list[i]);
    ////qDebug() << list;
    return result;
}