vector<SplitEdge> split(const vector<SplitEdge> &g, int u, int v, int s, int delta, historyIndex &h) { vector<SplitEdge> GHat = g; bool addedWeight = false; bool subtractedU = false; bool subtractedV = false; //cout << endl; for (unsigned i = 0; i < GHat.size(); i++) { if (connects(GHat[i], u, v)) { //cout << "Increasing the weight from " << u << " to " << v << " from " << GHat[i].weight << " to " << GHat[i].weight + delta << endl; GHat[i].weight += delta; addedWeight = true; } if (connects(GHat[i], u, s) && !subtractedU) { //cout << "Decreasing the weight from " << u << " to " << s << " from " << GHat[i].weight << " to " << GHat[i].weight - delta << endl; GHat[i].weight -= delta; subtractedU = true; } if (connects(GHat[i], s, v) && !subtractedV) { //cout << "Decreasing the weight from " << v << " to " << s << " from " << GHat[i].weight << " to " << GHat[i].weight - delta << endl; GHat[i].weight -= delta; subtractedV = true; } } if (!addedWeight) { SplitEdge e = SplitEdge(u, v, delta, u, v); //cout << "Creating edge from " << u << " to " << v << " with weight " << delta << endl; GHat.push_back(e); } if (!subtractedU) { cout << "Error: Couldn't find weight from " << u << " to " << s << " to subtract." << endl; throw logic_error(""); } if (!subtractedV) { cout << "Error: Couldn't find weight from " << v << " to " << s << " to subtract." << endl; throw logic_error(""); } //cout << endl; GHat = removeZeroWeighted(GHat); logSplit(h, s, u, v, delta); return GHat; }
bool key(int code, bool isdown) { if(vmenu<=0) return false; int menusel = menus[vmenu].menusel; if(isdown) { if(code==SDLK_ESCAPE) { set(-1); if(!menustack.empty()) set(menustack.pop()); return true; } else if(code==SDLK_UP || code==-4) menusel--; else if(code==SDLK_DOWN || code==-5) menusel++; int n = menus[vmenu].items.length(); if(menusel<0) menusel = n-1; else if(menusel>=n) menusel = 0; menus[vmenu].menusel = menusel; } else { if(code==SDLK_RETURN || code==-2) { char *action = menus[vmenu].items[menusel].action; if(vmenu==1) connects(getservername(menusel)); menustack.add(vmenu); set(-1); execute(action, true); } } return true; }
Catalog::Catalog(QWidget *parent) : QWidget(parent){ groups = new QTreeWidget(); header = groups->header(); // кнопка сброса фильтра по группам должна лежать на заголовке каталога, // поэтому передаём указатель на него в качестве виджета-предка reset_groups = new QPushButton("X", header); // устанавливаем, чтобы у каталога никогда не отображалась полоса прокрутки groups->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // задаём устанавливаем заголовок каталога по умолчанию default_header = "Выберите группу"; groups->setHeaderLabel(default_header); // заполняем каталог // если не удалось (т.е. какие-то проблемы с БД), устанавливаем ok=false, // чтобы другие виджеты могли увидеть, что с БД проблемы ok = (addGroups() ? true : false); // помещаем на место кнопку сброса фильтра move_button(); // помещаем дерево в layout (для корректного отображения) QHBoxLayout* lt = new QHBoxLayout; lt->addWidget(groups); setLayout(lt); lt->setMargin(0); // соединяем сигналы со слотами connects(); }
WhiteAddDialog::WhiteAddDialog(int gr, QString name, int mode, QWidget *parent) : QDialog(parent), ui(new Ui::whiteAddDialog) { ui->setupUi(this); this->setWindowTitle("Новая деталь"); this->ui->name_box->setEditable(true); this->ui->name_box->setAutoCompletion(true); this->ui->name_box->setEnabled(false); this->ui->name_label->setEnabled(false); HeaderComboBoxDelegate *delegate = new HeaderComboBoxDelegate(); HeaderModel *headermodel = new HeaderModel(); this->ui->group_box->setItemDelegate(delegate); this->ui->group_box->setModel(headermodel); this->ui->id_label->setText(""); this->dialog_mode = mode; params_enabled = false; create_unrequired_list(); disable_params(); fill_groups_box(); fill_weight_box(); fill_unit_box(); if(gr > 0 && name.length() > 0){ // выбираем строку в комбобоксе и устанавливаем названия параметров int group_index = this->ui->group_box->findText(name); this->ui->group_box->setCurrentIndex(group_index); change_group(group_index); } connects(); }
Pult::Pult(char *myIp, int myPort, char* toIp, int toPort, QWidget *parent) : QDialog(parent) { setNetworkData(myIp, myPort); this->toHost = QHostAddress(QString(toIp)); this->toPort = toPort; setWidgets(); connects(); }
void PageExtractStats::draw() { MY_DEBUG; initRemovedButtons(true); layout(); connects(); }
Dialog::Dialog(int port, QWidget *parent) : QDialog(parent) { fromPort = port; createMainWindow(); connects(); socket = new QUdpSocket(this); socket->bind(fromPort); setConnectionData(); }
int Widget::subMint() { QString usrname ,dbname; QString password, dbword; usrname = usrEdit->text(); password = passEdit->text(); if(usrname == NULL || password == NULL) { QMessageBox::information(this,"show","信息未填完",QMessageBox::Ok); return 0; }else { connects(); QSqlQuery query; QString usrQuery = QString("SELECT name FROM usrs WHERE name = '%1'").arg(usrname); query.exec(usrQuery); while(query.next()) { dbname = query.value(0).toString(); } if(dbname != usrname) { QMessageBox::information(this,"show","您还没注册"); return 0; }else { QString passQuery=QString("SELECT password FROM usrs WHERE name = '%1'").arg(usrname); query.exec(passQuery); while(query.next()) { dbword = query.value(0).toString(); } if(dbword != password) { QMessageBox::information(this,"show","您的密码输入错误"); } else { ShowWidget *showWidget = new ShowWidget; showWidget->show(); this->close(); return 0; } } } return 0; }
/*! * \brief GUI::ChangeDeleteUserDialog::ChangeDeleteUserDialog * Konstruktor setzt alle Passwortfelder auf den Passwort echomode und ruft die Funktionen connects, * slotUpdateUserList und clearFields auf. * \param household * \param parent */ GUI::ChangeDeleteUserDialog::ChangeDeleteUserDialog(logic::Household *household, QWidget *parent) : QDialog(parent), mHousehold(household), ui(new Ui::ChangeDeleteUserDialog) { ui->setupUi(this); ui->confirmPasswordLineEdit->setEchoMode(QLineEdit::Password); ui->confirmAgainPasswordLineEdit->setEchoMode(QLineEdit::Password); ui->passwordLineEdit->setEchoMode(QLineEdit::Password); mHousehold->retrieveUserList(mUserList); connects(); slotUpdateUserList(); clearFields(); }
SerialPort::SerialPort(QObject *parent) : QObject(parent) { serial = new QSerialPort(this); serial->setBaudRate(QSerialPort::Baud115200); serial->setDataBits(QSerialPort::Data8); serial->setParity(QSerialPort::NoParity); serial->setStopBits(QSerialPort::OneStop); serial->setFlowControl(QSerialPort::NoFlowControl); timer = new QTimer(this); timer->setInterval(TIMER_INTERVAL_MS); connects(); }
StorageReserveWidget::StorageReserveWidget(ReserveStruct *rstruct, QWidget *parent) : QWidget(parent), ui(new Ui::StorageReserveWidget) { ui->setupUi(this); //ui->table_widget->set_ this->source = rstruct->source_model; model = 0; set_columns_names(); set_layout(); fill_table(); connects(); }
MTable::MTable(QWidget *parent) : QWidget(parent) { // создаём все кнопки и поя ввода даты, который для удобства размещения поместим на специальный виджет controls controls = new QWidget(); from_label = new QLabel("С:"); to_label = new QLabel("По:"); type_label = new QLabel("Тип:"); from_date = new QDateEdit(); to_date = new QDateEdit; type_box = new QComboBox(); refresh_button = new QPushButton("ОБНОВИТЬ"); table = new QTableView(); model = new QSqlQueryModel(); pmodel = new MyProxyModel(); // сохраним высоту строки, потом она нам понадобится, чтобы по неё калибровать ширину некоторых столбцов row_height = table->verticalHeader()->fontMetrics().height() + 2; //hidden - показываем или нет скрытые типы документов. По умолчанию - нет. hidden = false; // фильтр по типу документов. Пока пуст. filter = 0; // связываем модели и представления pmodel->setSourceModel(model); table->setModel(pmodel); // воплощаем всё в реальность set_columns_names(); fill_checkbox(); custom_dates(); custom_table(); set_layout(); connects(); fill(); }
WhiteAddDialog::WhiteAddDialog(int id, int mode, QWidget *parent) : QDialog(parent), ui(new Ui::whiteAddDialog){ ui->setupUi(this); this->setWindowTitle("Редактирование детали"); this->ui->name_box->setEditable(true); this->ui->name_box->setAutoCompletion(true); this->ui->name_box->setEnabled(false); this->ui->name_label->setEnabled(false); HeaderComboBoxDelegate *delegate = new HeaderComboBoxDelegate(); HeaderModel *headermodel = new HeaderModel(); this->ui->group_box->setItemDelegate(delegate); this->ui->group_box->setModel(headermodel); this->dialog_mode = mode; create_unrequired_list(); fill_groups_box(); fill_weight_box(); fill_unit_box(); params_enabled = true; params["id"] = QString::number(id); this->ui->id_label->setText(QString("id = %1").arg(id)); fill_current(); connects(); }
UI::FunctionWidget::FunctionWidget(QWidget* pParent) : QWidget( pParent ) { createUI() ; connects() ; }
vector<SplitEdge> pairing(const vector<int> &Xi,const vector<int> &Xj, int delij, vector<SplitEdge> &B, const vector<SplitEdge> &g, int s, historyIndex &h) { vector<SplitEdge> GHat = g; while (delij > 0) { int u = 0; int v = 0; vector<int> gamXi = setIntersection(Xi, neighbors(GHat, s)); vector<int> gamXj = setIntersection(Xj, neighbors(GHat, s)); if (gamXi.size() == 0 || gamXj.size() == 0) { cout << "Detected 0, dumping status" << endl; cout << "GHat:" << endl; output(GHat); cout << "B:" << endl; output(B); cout << "S: " << s << endl; cout << "delij: " << delij << endl; cout << "Xi:" << endl; output(Xi); cout << "neighbors of s in GHat:" << endl; output(neighbors(GHat, s)); cout << "Xj:" << endl; output(Xj); cout << "gamXi:" << endl; output(gamXi); cout << "gamXj:" << endl; output(gamXj); } u = gamXi[0]; v = gamXj[0]; if (u == v) { cout << "U == V. Quitting" << endl; throw logic_error(""); } int delta = min(min(cG(s, u, GHat), cG(s, v, GHat)),delij); GHat = split(GHat, u, v, s, delta, h); //Add weight delta to (u,v) in B bool found = false; for (unsigned i = 0; i < B.size(); i++) { if (connects(B[i], u, v)) { B[i].weight += delta; found = true; break; } } if (!found) { for (unsigned i = 0; i < GHat.size(); i++) { if (connects(GHat[i], u, v)) { SplitEdge e(GHat[i].end0, GHat[i].end1, delta, GHat[i].orig0, GHat[i].orig1); B.push_back(e); found = true; break; } } } if (!found) { SplitEdge e(u, v, delta, u, v); B.push_back(e); } delij -= delta; } return GHat; }
void ShowWidget::flushEvent() { connects(); model->select(); }