static void checkinputs_splitted(char input, char *buff, char **ptr, t_history *history) { if (input == 127) mvbackspace(buff, ptr); else if (input == 126) { ft_putchar('~'); **ptr = '~'; (*ptr)++; } else if (input == 9) completion(buff, ptr); else if (input < 0) copycutpaste(input, buff, ptr); else if (input == 1) mvcstart(buff, ptr); else if (input == 5) mvcend(ptr); else if (input == 27) mvcursor(buff, ptr, history); else if (ft_isprint(input)) { ft_memmove((*ptr) + 1, (*ptr), ft_strlen((*ptr))); (*ptr)[0] = input; ft_putstr(*ptr); mvcleft(ft_strlen((*ptr)++) - 1); } }
MyInputDialog::MyInputDialog(const char * title, const QString & msg, const QStringList & list, const QString & init, bool existing) : QDialog(0/*, title, TRUE*/), le(0) { setWindowTitle(title); move(QCursor::pos()); QVBoxLayout * vbox = new QVBoxLayout(this); QHBoxLayout * hbox; vbox->setMargin(5); hbox = new QHBoxLayout(); vbox->addLayout(hbox); hbox->setMargin(5); hbox->addWidget(new QLabel(msg, this)); cb = new QComboBox(this); cb->setEditable(!existing); if (! existing) cb->addItem(init); cb->addItems(list); if (! existing) { cb->setCurrentIndex(0); cb->setAutoCompletion(completion()); } hbox->addWidget(cb); QSizePolicy sp = cb->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); cb->setSizePolicy(sp); QFontMetrics fm(QApplication::font()); cb->setMinimumWidth(fm.width("azertyuiopqsdfghjklm")); hbox = new QHBoxLayout(); vbox->addLayout(hbox); hbox->setMargin(5); QPushButton * ok = new QPushButton(tr("&OK"), this); QPushButton * cancel = new QPushButton(tr("&Cancel"), this); QSize bs(cancel->sizeHint()); ok->setDefault(TRUE); ok->setFixedSize(bs); cancel->setFixedSize(bs); hbox->addWidget(ok); hbox->addWidget(cancel); connect(ok, SIGNAL(clicked()), this, SLOT(accept())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); cb->setFocus(); }
std::pair<std::string , std::vector<CompletionPtr> > Completion::completionsFromCOMPDATRecord( DeckRecordConstPtr compdatRecord ) { std::vector<CompletionPtr> completions; std::string well = compdatRecord->getItem("WELL")->getTrimmedString(0); // We change from eclipse's 1 - n, to a 0 - n-1 solution int I = compdatRecord->getItem("I")->getInt(0) - 1; int J = compdatRecord->getItem("J")->getInt(0) - 1; int K1 = compdatRecord->getItem("K1")->getInt(0) - 1; int K2 = compdatRecord->getItem("K2")->getInt(0) - 1; CompletionStateEnum state = CompletionStateEnumFromString( compdatRecord->getItem("STATE")->getTrimmedString(0) ); { DeckItemConstPtr CFItem = compdatRecord->getItem("CF"); if (CFItem->defaultApplied()) throw std::invalid_argument("The connection factor item can not be defaulted"); } double CF = compdatRecord->getItem("CF")->getSIDouble(0); double diameter = compdatRecord->getItem("DIAMETER")->getSIDouble(0); double skinFactor = compdatRecord->getItem("SKIN")->getRawDouble(0); for (int k = K1; k <= K2; k++) { CompletionPtr completion(new Completion(I , J , k , state , CF, diameter, skinFactor )); completions.push_back( completion ); } return std::pair<std::string , std::vector<CompletionPtr> >( well , completions ); }
/* * schedule_tasks * * Description: * Schedule tasks using EDF. * * Inputs: * sched_task - an array of tasks to schedule * n_tasks - number of tasks to schedule * * Outputs: * none * * Returns: * schedule_tasks return 0 upon success. * * Side Effects * Job related fields in sched_task are modified. */ int schedule_tasks(task_t *sched_task, int n_tasks) { double now; /* current time */ double end; /* time to end simulation */ double energy; /* total energy used */ int index; task_t *cur; /* pointer to current task */ tasks = sched_task; ntask = n_tasks; srandom(599); /* all tasks are initially released at t = 0 */ for (index = 0 ; index < n_tasks ; index++) { enqueue(&ready, &tasks[index]); release(&tasks[index]); } wait = NULL; freq = 1.0; volts = 1.0; energy = 0.0; /* run simulation for 2x the hyperperiod */ end = compute_hyperperiod(tasks, n_tasks) * 2; now = 0.0; while(now < end) { /* run next job in ready queue */ if (wait == NULL || (now + (ready->cur_exec - ready->usage)/freq <= wait->next_evt)) { /* job runs to completion (i.e., it's not preempted) */ energy += (ready->cur_exec - ready->usage) * freq * volts * volts; now = completion(now); } else { /* scheduling decision at next_evt */ run_job(ready, ready->job, now, wait->next_evt, freq); ready->usage += (wait->next_evt - now) * freq; energy += (wait->next_evt-now) * freq * volts * volts; now = wait->next_evt; } if (ready == NULL) { /* skip idle time until next release */ now = wait->next_evt; } /* release jobs in wait queue that are at release time */ while(wait && wait->next_evt <= now) { cur = dequeue(&wait); cur->next_evt += cur->deadline; release(cur); enqueue(&ready, cur); } } printf("energy used = %f\n", energy); return 0; }
auto async_foo(CompletionToken&& tok) { std::async_completion<CompletionToken, void(int)> completion(tok); completion.handler(1); return completion.result.get(); }
void ComponentDialog::init_uml_tab() { bool visit = !hasOkButton(); BrowserComponent * bn = (BrowserComponent *) data->get_browser_node(); VVBox * vbox; GridBox * grid = new GridBox(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); grid->addWidget(new QLabel(tr("name : "), grid)); grid->addWidget(edname = new LineEdit(bn->get_name(), grid)); edname->setReadOnly(visit); grid->addWidget(new QLabel(tr("stereotype : "), grid)); grid->addWidget(edstereotype = new QComboBox(grid)); edstereotype->setEditable(true); edstereotype->addItem(toUnicode(data->get_stereotype())); if (! visit) { edstereotype->addItems(BrowserComponent::default_stereotypes()); edstereotype->addItems(ProfiledStereotypes::defaults(UmlComponent)); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentIndex(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); grid->addWidget(vbox = new VVBox(grid)); vbox->addWidget(new QLabel(tr("description :"), vbox)); if (! visit) { SmallPushButton* sButton; connect(sButton = new SmallPushButton(tr("Editor"), vbox), SIGNAL(clicked()), this, SLOT(edit_description())); vbox->addWidget(sButton); } grid->addWidget(comment = new MultiLineEdit(grid)); comment->setReadOnly(visit); comment->setText(bn->get_comment()); QFont font = comment->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); comment->setFont(font); addTab(grid, "Uml"); }
void ComponentDialog::init_l_tab(VVBox *& page, QComboBox *& stereotypefilter, void (ComponentDialog::* filteractivated)(const QString & st), const char * slt, const char * add_slt, const char * remove_slt, QListWidget *& lb_available, QListWidget *& lb, const QList<BrowserClass *> & cls, QString lbl) { bool visit = !hasOkButton(); HHBox * hbox; VVBox * vbox; QPushButton * button; QLabel* label; page = new VVBox(this); if (!visit) { page->addWidget(hbox = new HHBox(page)); hbox->setMargin(5); hbox->addWidget(new QLabel(tr("Stereotype filtering "), hbox)); hbox->addWidget(stereotypefilter = new QComboBox(hbox)); stereotypefilter->setEditable(true); stereotypefilter->setAutoCompletion(completion()); stereotypefilter->addItem(""); stereotypefilter->addItems(BrowserClass::default_stereotypes()); stereotypefilter->addItems(ProfiledStereotypes::defaults(UmlComponent)); stereotypefilter->setCurrentIndex(0); QSizePolicy sp = stereotypefilter->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); stereotypefilter->setSizePolicy(sp); connect(stereotypefilter, SIGNAL(activated(const QString &)), this, slt); page->addWidget(hbox = new HHBox(page)); hbox->addWidget(vbox = new VVBox(hbox)); vbox->setMargin(5); (label = new QLabel(tr("Available classes"), vbox))->setAlignment(Qt::AlignCenter); vbox->addWidget(label); vbox->addWidget(lb_available = new QListWidget(vbox)); lb_available->setSelectionMode(QListWidget::MultiSelection); hbox->addWidget(vbox = new VVBox(hbox)); vbox->setMargin(5); (label = new QLabel("", vbox))->setScaledContents(TRUE); vbox->addWidget(label); vbox->addWidget(button = new QPushButton(vbox)); button->setIcon(*rightPixmap); connect(button, SIGNAL(clicked()), this, add_slt); (label = new QLabel("", vbox))->setScaledContents(TRUE); vbox->addWidget(label); vbox->addWidget(button = new QPushButton(vbox)); button->setIcon(*leftPixmap); connect(button, SIGNAL(clicked()), this, remove_slt); (label = new QLabel("", vbox))->setScaledContents(TRUE); vbox->addWidget(label); hbox->addWidget(vbox = new VVBox(hbox)); }
static int e_completion(long key[], t_cmd *cmd, t_cur *cursor, t_char **list) { if (TAB) { completion(cmd, cursor, list, 1); return (1); } reset_comp(cmd); return (0); }
bool __arrive(int const myepoch) { int const myresult = arrived.fetch_add(1,std::memory_order_acq_rel) + 1; if(__builtin_expect(myresult == expected,0)) { int const newexpected = completion(); expected = newexpected ? newexpected : nexpected.load(std::memory_order_relaxed); arrived.store(0,std::memory_order_relaxed); epoch.store(myepoch+1,std::memory_order_release); return true; } return false; }
auto async_foo(bool fail, CompletionToken&& tok) { std::async_completion<CompletionToken, void(std::error_code, int, int)> completion(tok); if (fail) completion.handler(make_error_code(std::errc::invalid_argument), 1, 2); else completion.handler(std::error_code(), 1, 2); return completion.result.get(); }
void test_smspec_completion() { std::string kw( "CWIT" ); std::string wg( "WELL1" ); int dims[ 3 ] = { 10, 10, 10 }; int ijk[ 3 ] = { 1, 1, 1 }; ERT::smspec_node completion( kw, wg, dims, ijk ); test_assert_true( completion.keyword() == kw ); test_assert_true( completion.type() == ECL_SMSPEC_COMPLETION_VAR ); test_assert_true( completion.num() == 112 ); }
void ParameterSetDialog::init_uml_tab() { bool visit = !hasOkButton(); BrowserParameterSet * bn = (BrowserParameterSet *) data->get_browser_node(); Q3VBox * vbox; Q3Grid * grid = new Q3Grid(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); new QLabel(TR("name : "), grid); edname = new LineEdit(bn->get_name(), grid); edname->setReadOnly(visit); new QLabel(TR("stereotype : "), grid); edstereotype = new Q3ComboBox(TRUE, grid); edstereotype->insertItem(toUnicode(data->get_stereotype())); if (! visit) { edstereotype->insertStringList(BrowserParameterSet::default_stereotypes()); edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlParameterSet)); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentItem(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); vbox = new Q3VBox(grid); new QLabel(TR("description :"), vbox); if (! visit) { connect(new SmallPushButton(TR("Editor"), vbox), SIGNAL(clicked()), this, SLOT(edit_description())); } comment = new MultiLineEdit(grid); comment->setReadOnly(visit); comment->setText(bn->get_comment()); QFont font = comment->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); comment->setFont(font); addTab(grid, "Uml"); }
void ComponentDialog::init_l_tab(Q3VBox *& page, Q3ComboBox *& stereotypefilter, void (ComponentDialog::* filteractivated)(const QString & st), const char * slt, const char * add_slt, const char * remove_slt, Q3ListBox *& lb_available, Q3ListBox *& lb, const Q3ValueList<BrowserClass *> & cls, const char * lbl) { bool visit = !hasOkButton(); Q3HBox * hbox; Q3VBox * vbox; QPushButton * button; page = new Q3VBox(this); if (!visit) { hbox = new Q3HBox(page); hbox->setMargin(5); new QLabel(TR("Stereotype filtering "), hbox); stereotypefilter = new Q3ComboBox(TRUE, hbox); stereotypefilter->setAutoCompletion(completion()); stereotypefilter->insertItem(""); stereotypefilter->insertStringList(BrowserClass::default_stereotypes()); stereotypefilter->insertStringList(ProfiledStereotypes::defaults(UmlComponent)); stereotypefilter->setCurrentItem(0); QSizePolicy sp = stereotypefilter->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); stereotypefilter->setSizePolicy(sp); connect(stereotypefilter, SIGNAL(activated(const QString &)), this, slt); hbox = new Q3HBox(page); vbox = new Q3VBox(hbox); vbox->setMargin(5); (new QLabel(TR("Available classes"), vbox))->setAlignment(Qt::AlignCenter); lb_available = new Q3ListBox(vbox); lb_available->setSelectionMode(Q3ListBox::Multi); vbox = new Q3VBox(hbox); vbox->setMargin(5); (new QLabel("", vbox))->setScaledContents(TRUE); button = new QPushButton(vbox); button->setPixmap(*rightPixmap); connect(button, SIGNAL(clicked()), this, add_slt); (new QLabel("", vbox))->setScaledContents(TRUE); button = new QPushButton(vbox); button->setPixmap(*leftPixmap); connect(button, SIGNAL(clicked()), this, remove_slt); (new QLabel("", vbox))->setScaledContents(TRUE); vbox = new Q3VBox(hbox); }
static void controller_key_bis(t_readline *r, long key) { if (key == 10127586) keyboard_paste(r); if (key == 0x41323b315b1b) go_up(r); if (key == 0x42323b315b1b) go_down(r); if (key == 0x05) keyboard_ctrlc(r); if (key == 04) keyboard_ctrld(r); if (key == 9) completion(r); }
int main(int argc, const char *argv[]) { boost::asio::io_service service { }; auto client_ = std::make_shared<net::http::client>(service); bool show_request = false; bool show_headers = false; for(int i = 1; i < argc; ++i) { auto v = std::string { argv[i] }; if(v == "--headers") { show_headers = true; } else if(v == "--request") { show_request = true; } else { auto req = net::http::request { net::http::uri { argv[i] } }; req << net::http::header("User-agent", "some-user-agent"); auto res = client_->GET( std::move(req) ); res->completion()->on_done([i, show_request, show_headers](const std::shared_ptr<net::http::response> &res) { if(show_request) { std::cout << res->request().bytes() << "\n"; } if(show_headers) { res->each_header([](const net::http::header &h) { std::cout << h.key() << ": " << h.value() << "\n"; }); std::cout << "\n"; } std::cout << res->body(); }); } } // std::cout << "run\n"; service.run(); // std::cout << "done\n"; }
/***************************************************************************//** * @brief * Active SO Interrupt handler * @param[in] *ref * ******************************************************************************/ void SO_IRQ(void *ref) { (void) ref; int p = GPIO_PinInGet(RX_PORT, RX_PIN); if (p != 0) { // should never happen - we should only get the interrupt when the pin goes low GPIO->IFC = 1 << RX_PIN; so_spurious_irq_count++; return; } // disable IRQ GPIO_IntConfig(RX_PORT, RX_PIN, false, // risingEdge false, // fallingEdge false); // enable so_irq_count++; if (! so_busy) { // should never happen while (1) ; } GPIO_PinOutSet(CS_PORT, CS_PIN); // deassert CS // copy completion fn ptr and ref arg, to avoid race condition // if completion fn starts another SPI xfer spi_completion_fn_t *completion = so_completion; void *completion_ref = so_completion_ref; so_busy = false; if (completion) completion(completion_ref); }
/** * unlock the mutex */ ZOOAPI int zkr_lock_unlock(zkr_lock_mutex_t *mutex) { pthread_mutex_lock(&(mutex->pmutex)); zhandle_t *zh = mutex->zh; if (mutex->id != NULL) { int len = strlen(mutex->path) + strlen(mutex->id) + 2; char buf[len]; sprintf(buf, "%s/%s", mutex->path, mutex->id); int ret = 0; int count = 0; struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = (.5)*1000000; ret = ZCONNECTIONLOSS; while (ret == ZCONNECTIONLOSS && (count < 3)) { ret = zoo_delete(zh, buf, -1); if (ret == ZCONNECTIONLOSS) { LOG_DEBUG(("connectionloss while deleting the node")); nanosleep(&ts, 0); count++; } } if (ret == ZOK || ret == ZNONODE) { zkr_lock_completion completion = mutex->completion; if (completion != NULL) { completion(1, mutex->cbdata); } free(mutex->id); mutex->id = NULL; pthread_mutex_unlock(&(mutex->pmutex)); return 0; } LOG_WARN(("not able to connect to server - giving up")); pthread_mutex_unlock(&(mutex->pmutex)); return ZCONNECTIONLOSS; } pthread_mutex_unlock(&(mutex->pmutex)); return ZSYSTEMERROR; }
/***************************************************************************//** * @brief * USART/SPI1 RX Interrupt Handler * @note * Copies Received data in spi_rx_data buffer. * ******************************************************************************/ void USART1_RX_IRQHandler(void) { uint8_t dummy; if (SPI_PORT->IF & USART_IF_RXDATAV) { if (spi_rx_pre_padding_len) { dummy = SPI_PORT->RXDATA; (void) dummy; spi_rx_pre_padding_len--; } else if (spi_rx_len) { *spi_rx_data++ = SPI_PORT->RXDATA; spi_rx_len--; } else if (spi_rx_post_padding_len) { dummy = SPI_PORT->RXDATA; (void) dummy; spi_rx_post_padding_len--; } if ((spi_rx_pre_padding_len == 0) && (spi_rx_len == 0) && (spi_rx_post_padding_len == 0)) { // copy completion fn ptr and ref arg, to avoid race condition // if completion fn starts another SPI xfer spi_completion_fn_t *completion = spi_completion; void *completion_ref = spi_completion_ref; SPI_PORT->IEN &= ~ USART_IEN_RXDATAV; // disable rx interrupt if (! spi_hold_cs_active) GPIO_PinOutSet(CS_PORT, CS_PIN); // deassert CS spi_busy = false; if (completion) completion(completion_ref); } } }
std::pair<std::string , std::vector<CompletionPtr> > Completion::completionsFromCOMPDATRecord( const DeckRecord& compdatRecord ) { std::vector<CompletionPtr> completions; std::string well = compdatRecord.getItem("WELL").getTrimmedString(0); // We change from eclipse's 1 - n, to a 0 - n-1 solution int I = compdatRecord.getItem("I").get< int >(0) - 1; int J = compdatRecord.getItem("J").get< int >(0) - 1; int K1 = compdatRecord.getItem("K1").get< int >(0) - 1; int K2 = compdatRecord.getItem("K2").get< int >(0) - 1; WellCompletion::StateEnum state = WellCompletion::StateEnumFromString( compdatRecord.getItem("STATE").getTrimmedString(0) ); Value<double> connectionTransmissibilityFactor("ConnectionTransmissibilityFactor"); Value<double> diameter("Diameter"); Value<double> skinFactor("SkinFactor"); { const auto& connectionTransmissibilityFactorItem = compdatRecord.getItem("CONNECTION_TRANSMISSIBILITY_FACTOR"); const auto& diameterItem = compdatRecord.getItem("DIAMETER"); const auto& skinFactorItem = compdatRecord.getItem("SKIN"); if (connectionTransmissibilityFactorItem.hasValue(0) && connectionTransmissibilityFactorItem.getSIDouble(0) > 0) connectionTransmissibilityFactor.setValue(connectionTransmissibilityFactorItem.getSIDouble(0)); if (diameterItem.hasValue(0)) diameter.setValue( diameterItem.getSIDouble(0)); if (skinFactorItem.hasValue(0)) skinFactor.setValue( skinFactorItem.get< double >(0)); } const WellCompletion::DirectionEnum direction = WellCompletion::DirectionEnumFromString(compdatRecord.getItem("DIR").getTrimmedString(0)); for (int k = K1; k <= K2; k++) { CompletionPtr completion(new Completion(I , J , k , state , connectionTransmissibilityFactor, diameter, skinFactor, direction )); completions.push_back( completion ); } return std::pair<std::string , std::vector<CompletionPtr> >( well , completions ); }
CodChangeMsgDialog::CodChangeMsgDialog(QWidget * parent, ColMsg * m) : QDialog(parent/*, "Communication message dialog", TRUE*/), msg(m) { setWindowTitle(tr("Communicationg message dialog")); QVBoxLayout * vbox = new QVBoxLayout(this); QHBoxLayout * hbox; vbox->setMargin(5); hbox = new QHBoxLayout(); vbox->addLayout(hbox); hbox->setMargin(5); SmallPushButton * b = new SmallPushButton(tr("message :"), this); hbox->addWidget(b); connect(b, SIGNAL(clicked()), this, SLOT(menu_op())); edoper = new QComboBox(this); edoper->setEditable(true); edoper->setAutoCompletion(completion()); if (msg->operation == 0) edoper->addItem(msg->explicit_operation); else edoper->addItem(msg->operation->definition(TRUE, FALSE)); CodObjCanvas * from; CodObjCanvas * to; msg->in->get_from_to(from, to, msg->is_forward); // gets operations cl = to->get_class(); if (cl != 0) { cl->get_opers(opers, list); edoper->addItems(list); if (!cl->is_writable()) cl = 0; } edoper->setCurrentIndex(0); QSizePolicy sp = edoper->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); edoper->setSizePolicy(sp); hbox->addWidget(edoper); // ok & cancel hbox = new QHBoxLayout(); vbox->addLayout(hbox); hbox->setMargin(5); QPushButton * ok = new QPushButton(tr("&OK"), this); QPushButton * cancel = new QPushButton(tr("&Cancel"), this); QSize bs(cancel->sizeHint()); ok->setDefault(TRUE); ok->setFixedSize(bs); cancel->setFixedSize(bs); hbox->addWidget(ok); hbox->addWidget(cancel); connect(ok, SIGNAL(clicked()), this, SLOT(accept())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); }
StateDialog::StateDialog(StateData * d) : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), state(d) { d->browser_node->edit_start(); if (d->browser_node->is_writable()) { setOkButton(tr("OK")); setCancelButton(tr("Cancel")); } else { setOkButton(QString()); setCancelButton(tr("Close")); } setWindowTitle(tr("State dialog")); visit = !hasOkButton(); BrowserNode * bn = state->browser_node; GridBox * grid; // // general tab // grid = new GridBox(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); grid->addWidget(new QLabel(tr("name : "), grid)); grid->addWidget(edname = new LineEdit(bn->get_name(), grid)); edname->setReadOnly(visit); grid->addWidget(new QLabel(tr("stereotype : "), grid)); grid->addWidget(edstereotype = new QComboBox( grid)); edstereotype->setEditable(!visit); edstereotype->addItem(toUnicode(state->get_stereotype())); if (!visit) { edstereotype->addItems(BrowserState::default_stereotypes()); edstereotype->addItems(ProfiledStereotypes::defaults(UmlState)); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentIndex(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); SmallPushButton* sButton; connect(sButton = new SmallPushButton(tr("specification :"), grid), SIGNAL(clicked()), this, SLOT(menu_specification())); grid->addWidget(sButton); grid->addWidget(edspecification = new QComboBox(grid)); edspecification->setSizePolicy(sp); if (visit) { if (state->get_specification() == 0) edspecification->addItem(""); else edspecification->addItem(state->get_specification()->full_name(TRUE)); } else { edspecification->addItem(""); edspecification->setAutoCompletion(completion()); BrowserOperation::instances(opers); opers.full_names(speclist); edspecification->addItems(speclist); edspecification->setCurrentIndex((state->get_specification() == 0) ? 0 : opers.indexOf(state->get_specification()) + 1); } switch (((BrowserNode *) bn->parent())->get_type()) { case UmlState: case UmlRegion: if ((state->get_reference() != 0) || (bn->firstChild() == 0)) { connect(sButton = new SmallPushButton(tr("reference :"), grid), SIGNAL(clicked()), this, SLOT(menu_reference())); grid->addWidget(sButton); grid->addWidget(edreference = new QComboBox(grid)); edreference->setSizePolicy(sp); if (visit) { if (state->get_reference() == 0) edreference->addItem(""); else edreference->addItem(state->get_reference()->full_name(TRUE)); } else { edreference->addItem(""); edreference->setAutoCompletion(completion()); if (((BrowserState *) bn)->can_reference()) { BrowserState::instances(states, TRUE); QMutableListIterator<BrowserNode *> it(states); while (it.hasNext()) { BrowserState *state = (BrowserState *)it.next(); if (!((BrowserState *) bn)->can_reference(state) || state->is_ref()) { it.remove(); } } } else states.append(state->get_reference()); states.full_names(reflist); edreference->addItems(reflist); edreference->setCurrentIndex((state->get_reference() == 0) ? 0 : states.indexOf(state->get_reference()) + 1); connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int))); } break; } // no break default: edreference = 0; }
static VOID CALLBACK thread_completion(ULONG_PTR param) { ioInfo * info = (ioInfo *) param; completion (info->id, info->len, info->error, info->action); GlobalFree (info); }
EnvDialog::EnvDialog(bool conv, bool noid) : QDialog(0, "Environment dialog", TRUE), conversion(conv) { setCaption(TR("Environment dialog")); QVBoxLayout * vbox = new QVBoxLayout(this); QHBox * htab; QGrid * grid = new QGrid(2, this); QPushButton * button; QString s; vbox->addWidget(grid); grid->setMargin(5); grid->setSpacing(5); new QLabel(grid); new QLabel(TR("MANDATORY, choose a value between 2 and 127 not used by an other person working at the same time on a project with you.\n" "To be safe, if possible choose a value not used by an other person even not working on a given project with you"), grid); new QLabel(TR("Own identifier "), grid); htab = new QHBox(grid); if (conv) s = getenv("BOUML_ID"); // yes ! else if (! noid) s.setNum(user_id()); ed_id = new QLineEdit(s, htab); if (BrowserView::get_project() != 0) { ed_id->setEnabled(FALSE); new QLabel(TR(" The identifier can't be modified while a project is load"), htab); } // new QLabel(grid); new QLabel(TR("\nOptional, to indicate where are the HTML pages of the reference manual. Used by the help (called by the F1 key) to show the\n" "chapter corresponding to the kind of the element selected in the browser"), grid); new QLabel(TR("Manual path"), grid); htab = new QHBox(grid); ed_doc = new QLineEdit(htab); if (!conv) ed_doc->setText(manual_dir()); new QLabel(" ", htab); button = new QPushButton(TR("Browse"), htab); connect(button, SIGNAL(clicked ()), this, SLOT(doc_browse())); // new QLabel(grid); new QLabel(TR("\nOptional, to indicate a web navigator program. If it is not defined the reference manual will be shown with an internal simple viewer"), grid); new QLabel(TR("Navigator"), grid); htab = new QHBox(grid); ed_navigator = new QLineEdit(htab); if (!conv) ed_navigator->setText(navigator_path()); new QLabel(" ", htab); button = new QPushButton(TR("Browse"), htab); connect(button, SIGNAL(clicked ()), this, SLOT(navigator_browse())); // new QLabel(grid); new QLabel(TR("\nOptional, to indicate a template project. This allows to create new projects getting all the template project settings"), grid); new QLabel("Template project", grid); htab = new QHBox(grid); if (conv) s = getenv("BOUML_TEMPLATE"); // yes ! else s = template_project(); ed_template = new QLineEdit(s, htab); new QLabel(" ", htab); button = new QPushButton(TR("Browse"), htab); connect(button, SIGNAL(clicked ()), this, SLOT(template_browse())); // new QLabel(grid); new QLabel(TR("\nOptional, to indicate a text editor (it must creates an own window). Else Bouml will use an internal editor"), grid); new QLabel(TR("Editor path "), grid); htab = new QHBox(grid); if (conv) s = getenv("BOUML_EDITOR"); // yes ! else s = editor(); ed_editor = new QLineEdit(s, htab); new QLabel(" ", htab); button = new QPushButton(TR("Browse"), htab); connect(button, SIGNAL(clicked ()), this, SLOT(editor_browse())); // new QLabel(grid); new QLabel(TR("\nOptional, to choose a language for menus and dialogs (default is English). You may have to select a corresponding character set"), grid); new QLabel(TR("Translation file path "), grid); htab = new QHBox(grid); ed_lang = new QLineEdit(current_lang(), htab); new QLabel(" ", htab); button = new QPushButton(TR("Browse"), htab); connect(button, SIGNAL(clicked ()), this, SLOT(lang_browse())); // new QLabel(grid); new QLabel(TR("\nOptional, to indicate a character set in case you use non ISO_8859-1/latin1 characters. For instance KOI8-R or KOI8-RU for Cyrillic"), grid); new QLabel(TR("Character set "), grid); cb_charset = new QComboBox(FALSE, grid); cb_charset->setAutoCompletion(completion()); QStringList l; QTextCodec * co; int i = 0; l.append(""); while ((co = QTextCodec::codecForIndex(i++)) != 0) { QString na = co->name(); int pos = 0; while ((pos = na.find(' ', pos)) != -1) na.replace(pos, 1, "_"); if (QTextCodec::codecForName(na) == co) l.append(na); } l.sort(); cb_charset->insertStringList(l); if (conv) s = getenv("BOUML_CHARSET"); // yes ! else s = codec(); if (!s.isEmpty() && ((i = l.findIndex(s)) != -1)) cb_charset->setCurrentItem(i); // new QLabel(grid); new QLabel(TR("\nIn case you have a multiple screens configuration the best for you is to ask Bouml to place by default the dialogs in one of these\n" "screens giving the area, else the dialogs will be shown on the center of the virtual screen."), grid); new QLabel(TR("Default screen "), grid); QString x0, y0, x1, y1; int top, left, bottom, right; if (conv) { const char * limits = getenv("BOUML_LIMIT_DESKTOP"); // yes ! if ((limits != 0) && (sscanf(limits, "%d,%d,%d,%d", &left, &top, &right, &bottom) == 4)) { x0.setNum(left); y0.setNum(top); x1.setNum(right); y1.setNum(bottom); } } else { int top, left, bottom, right; UmlDesktop::limits(left, top, right, bottom); x0.setNum(left); y0.setNum(top); x1.setNum(right); y1.setNum(bottom); } htab = new QHBox(grid); new QLabel(TR("left: "), htab); ed_xmin = new QLineEdit(x0, htab); new QLabel(TR(" top: "), htab); ed_ymin = new QLineEdit(y0, htab); new QLabel(TR(" right: "), htab); ed_xmax = new QLineEdit(x1, htab); new QLabel(TR(" bottom: "), htab); ed_ymax = new QLineEdit(y1, htab); // new QLabel(grid); htab = new QHBox(grid); new QLabel(htab); connect(new QPushButton(TR("OK"), htab), SIGNAL(clicked()), this, SLOT(accept())); new QLabel(htab); if (! conv) { connect(new QPushButton(TR("Cancel"), htab), SIGNAL(clicked()), this, SLOT(reject())); new QLabel(htab); } }
FragmentDialog::FragmentDialog(const QStringList & defaults, QString & s, QString & fo, BrowserNode *& d) : QDialog(0, "Fragment dialog", TRUE), name(s), form(fo), refer(d) { setCaption(TR("Fragment dialog")); Q3VBoxLayout * vbox = new Q3VBoxLayout(this); Q3HBoxLayout * hbox; QLabel * lbl1; QLabel * lbl2; SmallPushButton * refer_bt; BrowserNode * bn; vbox->setMargin(5); hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); hbox->addWidget(lbl1 = new QLabel(TR("name : "), this)); name_cb = new Q3ComboBox(TRUE, this); name_cb->insertItem(name); name_cb->setCurrentItem(0); name_cb->insertStringList(defaults); name_cb->setAutoCompletion(completion()); hbox->addWidget(name_cb); QSizePolicy sp = name_cb->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); name_cb->setSizePolicy(sp); hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); hbox->addWidget(refer_bt = new SmallPushButton(TR("refer to : "), this)); connect(refer_bt, SIGNAL(clicked()), this, SLOT(menu_refer())); diag_cb = new Q3ComboBox(FALSE, this); BrowserDiagram::instances(nodes, TRUE); diag_cb->insertItem(""); for (bn = nodes.first(); bn != 0; bn = nodes.next()) diag_cb->insertItem(*(bn->pixmap(0)), bn->full_name(TRUE)); diag_cb->setCurrentItem((refer == 0) ? 0 : nodes.findRef(refer) + 1); diag_cb->setSizePolicy(sp); hbox->addWidget(diag_cb); hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); hbox->addWidget(lbl2 = new QLabel(TR("arguments \n/ value : "), this)); hbox->addWidget(ed_form = new LineEdit(this)); ed_form->setText(form); same_width(lbl1, lbl2, refer_bt); hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); QPushButton * accept = new QPushButton(TR("&OK"), this); QPushButton * cancel = new QPushButton(TR("&Cancel"), this); QSize bs(cancel->sizeHint()); accept->setDefault(TRUE); accept->setFixedSize(bs); cancel->setFixedSize(bs); hbox->addWidget(accept); hbox->addWidget(cancel); connect(accept, SIGNAL(clicked()), this, SLOT(accept())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); }
static void CALLBACK overlapped_completion (DWORD errCode, DWORD len, LPOVERLAPPED overlapped) { completionData * d = (completionData * )overlapped; completion (d->id, len, errCode, d->action); GlobalFree (d); }
ParameterDialog::ParameterDialog(ParameterData * pa) : TabDialog(0, 0, true, Qt::WA_DeleteOnClose), param(pa) { pa->browser_node->edit_start(); if (pa->browser_node->is_writable()) { setOkButton(tr("OK")); setCancelButton(tr("Cancel")); } else { setOkButton(QString()); setCancelButton(tr("Close")); } visit = !hasOkButton(); setWindowTitle(tr("Parameter dialog")); GridBox * grid; HHBox * htab; QString s; // general tab grid = new GridBox(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); grid->addWidget(new QLabel(tr("name :"), grid)); grid->addWidget(edname = new LineEdit(pa->name(), grid)); edname->setReadOnly(visit); QFont font = edname->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); grid->addWidget(new QLabel(tr("stereotype : "), grid)); grid->addWidget(edstereotype = new QComboBox(grid)); edstereotype->setEditable(!visit); edstereotype->addItem(toUnicode(pa->stereotype)); if (! visit) { edstereotype->addItems(BrowserParameter::default_stereotypes()); edstereotype->addItems(ProfiledStereotypes::defaults(UmlParameter)); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentIndex(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); SmallPushButton* sButton; connect(sButton = new SmallPushButton(tr("type :"), grid), SIGNAL(clicked()), this, SLOT(menu_type())); grid->addWidget(sButton); grid->addWidget(edtype = new QComboBox( grid)); edtype->setEditable(!visit); edtype->addItem(pa->get_type().get_full_type()); if (!visit) { BrowserClass::instances(nodes); nodes.full_names(list); edtype->addItems(GenerationSettings::basic_types()); offset = edtype->count(); edtype->addItems(list); edtype->setAutoCompletion(completion()); view = pa->browser_node->container(UmlClass); } edtype->setCurrentIndex(0); edtype->setSizePolicy(sp); grid->addWidget(new QLabel(tr("direction :"), grid)); grid->addWidget(htab = new HHBox(grid)); htab->addWidget(eddir = new QComboBox(htab)); UmlParamDirection dir = pa->get_dir(); eddir->addItem(stringify(dir)); if (! visit) { if (dir != UmlInOut) eddir->addItem(stringify(UmlInOut)); if (dir != UmlIn) eddir->addItem(stringify(UmlIn)); if (dir != UmlOut) eddir->addItem(stringify(UmlOut)); if (dir != UmlReturn) eddir->addItem(stringify(UmlReturn)); } htab->addWidget(new QLabel(tr(" multiplicity : "), htab)); htab->addWidget( edmultiplicity = new QComboBox(htab)); edmultiplicity->setEditable(!visit); edmultiplicity->setSizePolicy(sp); edmultiplicity->addItem(pa->get_multiplicity()); if (!visit) { edmultiplicity->addItem("1"); edmultiplicity->addItem("0..1"); edmultiplicity->addItem("*"); edmultiplicity->addItem("1..*"); } htab->addWidget(new QLabel(tr(" ordering : "), htab)); htab->addWidget(edordering = new QComboBox(htab)); UmlOrderingKind o = pa->get_ordering(); edordering->addItem(stringify(o)); if (!visit) { if (o != UmlUnordered) edordering->addItem(stringify(UmlUnordered)); if (o != UmlOrdered) edordering->addItem(stringify(UmlOrdered)); if (o != UmlLifo) edordering->addItem(stringify(UmlLifo)); if (o != UmlFifo) edordering->addItem(stringify(UmlFifo)); } htab->addWidget(new QLabel(tr(" effect : "), htab)); htab->addWidget(edeffect = new QComboBox(htab)); UmlParamEffect e = pa->get_effect(); edeffect->addItem(stringify(e)); if (!visit) { if (e != UmlNoEffect) edeffect->addItem(stringify(UmlNoEffect)); if (e != UmlCreate) edeffect->addItem(stringify(UmlCreate)); if (e != UmlRead) edeffect->addItem(stringify(UmlRead)); if (e != UmlUpdate) edeffect->addItem(stringify(UmlUpdate)); if (e != UmlDelete) edeffect->addItem(stringify(UmlDelete)); } grid->addWidget(new QLabel(tr("in state : "), grid)); grid->addWidget(edin_state = new LineEdit(pa->in_state, grid)); edin_state->setReadOnly(visit); grid->addWidget(new QLabel(tr("default value :"), grid)); grid->addWidget(htab = new HHBox(grid)); htab->addWidget(edinit = new LineEdit(pa->get_default_value(), htab)); if (visit) { edinit->setReadOnly(TRUE); } else { connect(sButton = new SmallPushButton(tr("Editor"), htab), SIGNAL(clicked()), this, SLOT(edit_init())); htab->addWidget(sButton); } grid->addWidget(new QLabel(grid)); grid->addWidget(htab = new HHBox(grid)); BButtonGroup * bg ; htab->addWidget( bg = new BButtonGroup(2, Qt::Horizontal, QString(), htab)); bg->addWidget(is_control_cb = new QCheckBox(tr("is_control"), bg)); if (pa->is_control) is_control_cb->setChecked(TRUE); is_control_cb->setDisabled(visit); bg->addWidget(unique_cb = new QCheckBox(tr("unique"), bg)); if (pa->unique) unique_cb->setChecked(TRUE); unique_cb->setDisabled(visit); htab->addWidget(bg = new BButtonGroup(3, Qt::Horizontal, QString(), htab)); bg->setExclusive(TRUE); bg->addWidget(standard_rb = new QRadioButton(tr("standard"), bg)); bg->addWidget(exception_rb = new QRadioButton(tr("exception"), bg)); bg->addWidget(stream_rb = new QRadioButton(tr("stream"), bg)); if (pa->exception) exception_rb->setChecked(TRUE); else if (pa->stream) stream_rb->setChecked(TRUE); else standard_rb->setChecked(TRUE); VVBox * vtab; grid->addWidget(vtab = new VVBox(grid)); vtab->addWidget(new QLabel(tr("description :"), vtab)); if (! visit) { connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); vtab->addWidget(sButton); } grid->addWidget(comment = new MultiLineEdit(grid)); comment->setReadOnly(visit); comment->setText(pa->browser_node->get_comment()); comment->setFont(font); addTab(grid, "Uml"); init_tab(ocltab, eduml_selection, pa->uml_selection, "Ocl", SLOT(edit_uml_selection()), TRUE); // C++ init_tab(cppTab, edcpp_selection, pa->cpp_selection, "C++", SLOT(edit_cpp_selection()), GenerationSettings::cpp_get_default_defs()); // Java init_tab(javatab, edjava_selection, pa->java_selection, "Java", SLOT(edit_java_selection()), GenerationSettings::java_get_default_defs()); // USER : list key - value grid = new GridBox(2, this); grid->setMargin(5); grid->setSpacing(5); grid->addWidget(kvtable = new KeyValuesTable(pa->browser_node, grid, visit)); addTab(grid, tr("Properties")); // connect(this, SIGNAL(currentChanged(QWidget *)), this, SLOT(change_tabs(QWidget *))); open_dialog(this); }
ClassInstanceDialog::ClassInstanceDialog(ClassInstanceData * i) : TabDialog(0, "class instance dialog", FALSE, Qt::WA_DeleteOnClose), inst(i), atbl(0), rtbl(0) { setWindowTitle(tr("Class instance dialog")); BrowserNode * bn = inst->get_browser_node(); bn->edit_start(); if (bn->is_writable()) { setOkButton(tr("OK")); setCancelButton(tr("Cancel")); } else { setOkButton(QString()); setCancelButton(tr("Close")); } visit = !hasOkButton(); GridBox * grid; // general tab grid = new GridBox(2, this); grid->setMargin(5); grid->setSpacing(5); grid->addWidget(new QLabel(tr("name : "), grid)); grid->addWidget(edname = new LineEdit(bn->get_name(), grid)); if (visit) edname->setReadOnly(TRUE); grid->addWidget(new QLabel(tr("stereotype :"), grid)); grid->addWidget(edstereotype = new QComboBox( grid)); edstereotype->setEditable(!visit); edstereotype->addItem(toUnicode(bn->get_stereotype())); if (! visit) { edstereotype->addItems(ProfiledStereotypes::defaults(UmlClassInstance)); edstereotype->setAutoCompletion(completion()); } SmallPushButton * b; grid->addWidget(b = new SmallPushButton(tr("class :"), grid)); connect(b, SIGNAL(clicked()), this, SLOT(menu_class())); grid->addWidget(edtype = new QComboBox(grid)); if (visit) { edtype->addItem(inst->get_class()->full_name()); nodes.append(inst->get_class()); } else { BrowserClass::instances(nodes); nodes.full_names(list); edtype->addItems(list); edtype->setCurrentIndex(nodes.indexOf(inst->get_class())); connect(edtype, SIGNAL(activated(int)), this, SLOT(type_changed(int))); } if (visit) cl_container = 0; else { cl_container = (BrowserNode *) bn->parent(); if ((cl_container != 0) && !cl_container->is_writable()) cl_container = 0; } VVBox * vtab; grid->addWidget(vtab = new VVBox(grid)); vtab->addWidget(new QLabel(tr("description :"), vtab)); if (! visit) { connect(b =new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); vtab->addWidget(b); } grid->addWidget(comment = new MultiLineEdit(grid)); comment->setReadOnly(visit); comment->setText(bn->get_comment()); QFont font = comment->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); comment->setFont(font); addTab(grid, "Uml"); // attributes tab atbl = new MyTable(this); atbl->setColumnCount(3); //atbl->setSortingEnabled(true); atbl->setSelectionMode(QTableWidget::NoSelection); // single does not work atbl->verticalHeader()->setSectionsMovable(true); atbl->verticalHeader()->setSectionsMovable(true); atbl->setHorizontalHeaderLabel(0, tr(" Attribute ")); atbl->setHorizontalHeaderLabel(1, tr(" Class ")); atbl->setHorizontalHeaderLabel(2, tr(" Value ")); addTab(atbl, tr("Attributes")); // relation tab if (! inst->relations.isEmpty()) { rtbl = new RelTable(this, inst, visit); addTab(rtbl, tr("Relations")); } // USER : list key - value grid = new GridBox(2, this); grid->setMargin(5); grid->setSpacing(5); grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit)); addTab(grid, tr("Properties")); type_changed(edtype->currentIndex()); connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(update_all_tabs(int))); open_dialog(this); }
BasicDialog::BasicDialog(BasicData * nd, QString s, const QStringList & default_stereotypes, QSize & sz, bool unnamed) : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), data(nd), previous_size(sz) { nd->get_browser_node()->edit_start(); if (nd->get_browser_node()->is_writable()) { setOkButton(TR("OK")); setCancelButton(TR("Cancel")); } else { setOkButton(QString::null); setCancelButton(TR("Close")); } setCaption(TR(s + " dialog")); bool visit = !hasOkButton(); // general tab BrowserNode * bn = data->get_browser_node(); Q3Grid * grid = new Q3Grid(2, this); grid->setMargin(5); grid->setSpacing(5); if (unnamed) edname = 0; else { new QLabel(TR("name : "), grid); edname = new LineEdit(bn->get_name(), grid); edname->setReadOnly(visit); } new QLabel(TR("stereotype : "), grid); edstereotype = new Q3ComboBox(!visit, grid); edstereotype->insertItem(toUnicode(data->get_stereotype())); if (! visit) { edstereotype->insertStringList(default_stereotypes); edstereotype->insertStringList(ProfiledStereotypes::defaults(bn->get_type())); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentItem(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); Q3VBox * vtab = new Q3VBox(grid); new QLabel(TR("description :"), vtab); if (! visit) connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); comment = new MultiLineEdit(grid); comment->setReadOnly(visit); comment->setText(bn->get_comment()); QFont font = comment->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); comment->setFont(font); addTab(grid, "Uml"); // USER : list key - value grid = new Q3Grid(2, this); grid->setMargin(5); grid->setSpacing(5); kvtable = new KeyValuesTable(bn, grid, visit); addTab(grid, TR("Properties")); open_dialog(this); }
AttributeDialog::AttributeDialog(AttributeData * a, bool new_st_attr) : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), new_in_st(new_st_attr), att(a) { a->browser_node->edit_start(); if (a->browser_node->is_writable()) { setOkButton(TR("OK")); setCancelButton(TR("Cancel")); } else { setOkButton(QString::null); setCancelButton(TR("Close")); } visit = !hasOkButton(); ClassData * cld = (ClassData *) ((BrowserNode *) a->browser_node->parent())->get_data(); QString stereotype = cld->get_stereotype(); QString lang_st; in_enum = (stereotype == "enum"); lang_st = GenerationSettings::cpp_class_stereotype(stereotype); cpp_in_enum = in_enum || (lang_st == "enum"); cpp_ignored = !cpp_in_enum && ((lang_st == "typedef") || (lang_st == "ignored")); lang_st = GenerationSettings::java_class_stereotype(stereotype); java_in_enum = in_enum || (lang_st == "enum"); java_in_enum_pattern = !java_in_enum && (lang_st == "enum_pattern"); java_ignored = (lang_st == "ignored"); lang_st = GenerationSettings::php_class_stereotype(stereotype); php_in_enum = in_enum || (lang_st == "enum"); php_ignored = !php_in_enum && (lang_st == "ignored"); lang_st = GenerationSettings::python_class_stereotype(stereotype); python_in_enum = in_enum || (lang_st == "enum"); python_ignored = !python_in_enum && (lang_st == "ignored"); lang_st = GenerationSettings::idl_class_stereotype(stereotype); idl_in_enum = in_enum || (lang_st == "enum"); idl_in_typedef = !idl_in_enum && (lang_st == "typedef"); idl_in_struct = !idl_in_enum && ((lang_st == "struct") || (lang_st == "exception")); idl_in_union = !idl_in_enum && (lang_st == "union"); setCaption((in_enum || java_in_enum_pattern) ? TR("Enum item dialog") : TR("Attribute dialog")); Q3Grid * grid; Q3HBox * htab; QString s; // general tab grid = new Q3Grid(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); new QLabel(TR("class : "), grid); new QLabel(((BrowserNode *) a->get_browser_node()->parent())->full_name(TRUE), grid); new QLabel(TR("name :"), grid); edname = new LineEdit(a->name(), grid); edname->setReadOnly(visit); QFont font = edname->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); if (!java_in_enum_pattern) { new QLabel(TR("stereotype :"), grid); htab = new Q3HBox(grid); edstereotype = new Q3ComboBox(!visit, htab); edstereotype->insertItem(toUnicode(a->get_stereotype())); if (!visit) { edstereotype->insertStringList(BrowserAttribute::default_stereotypes()); edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlAttribute)); if (java_in_enum) { int n = edstereotype->count(); for (attribute_st_rank = 0; attribute_st_rank != n; attribute_st_rank += 1) if (edstereotype->text(attribute_st_rank) == "attribute") break; if (attribute_st_rank == n) { edstereotype->insertItem("attribute"); n += 1; } for (empty_st_rank = 0; empty_st_rank != n; empty_st_rank += 1) if (edstereotype->text(empty_st_rank).isEmpty()) break; if (empty_st_rank == n) edstereotype->insertItem(""); } edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentItem(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); new QLabel(TR(" multiplicity : "), htab); multiplicity = new Q3ComboBox(!visit, htab); multiplicity->setSizePolicy(sp); previous_multiplicity = a->get_multiplicity(); multiplicity->insertItem(previous_multiplicity); if (!visit) { multiplicity->insertItem("1"); multiplicity->insertItem("0..1"); multiplicity->insertItem("*"); multiplicity->insertItem("1..*"); } connect(new SmallPushButton(TR("type :"), grid), SIGNAL(clicked()), this, SLOT(menu_type())); edtype = new Q3ComboBox(!visit, grid); edtype->insertItem(a->get_type().get_full_type()); BrowserClass::instances(nodes); nodes.full_names(list); if (!visit) { QStringList l = GenerationSettings::basic_types(); cld->addFormals(l); edtype->insertStringList(l); offset = edtype->count(); edtype->insertStringList(list); edtype->setAutoCompletion(completion()); view = a->browser_node->container(UmlClass); } edtype->setCurrentItem(0); edtype->setSizePolicy(sp); new QLabel(TR("initial value :"), grid); } else { multiplicity = 0; new QLabel(TR("value :"), grid); } htab = new Q3HBox(grid); edinit = new LineEdit(a->get_init_value(), htab); if (visit) edinit->setReadOnly(TRUE); else connect(new SmallPushButton(TR("Editor"), htab), SIGNAL(clicked()), this, SLOT(edit_init())); Q3ButtonGroup * bg; if (!java_in_enum_pattern) { new QLabel(grid); htab = new Q3HBox(grid); bg = uml_visibility.init(htab, a->get_uml_visibility(), TRUE); if (visit) bg->setEnabled(FALSE); bg = new Q3ButtonGroup(7, Qt::Horizontal, QString::null, htab); bg->setExclusive(FALSE); classattribute_cb = new QCheckBox("static", bg); if (a->get_isa_class_attribute()) classattribute_cb->setChecked(TRUE); classattribute_cb->setDisabled(visit); volatile_cb = new QCheckBox("volatile", bg); if (a->isa_volatile_attribute) volatile_cb->setChecked(TRUE); volatile_cb->setDisabled(visit); constattribute_cb = new QCheckBox(TR("read-only"), bg); if (a->get_isa_const_attribute()) constattribute_cb->setChecked(TRUE); constattribute_cb->setDisabled(visit); derived_cb = new QCheckBox(TR("derived"), bg); if (a->get_is_derived()) derived_cb->setChecked(TRUE); derived_cb->setDisabled(visit); connect(derived_cb, SIGNAL(toggled(bool)), SLOT(derived_changed(bool))); derivedunion_cb = new QCheckBox("union", bg); if (a->get_is_derivedunion()) derivedunion_cb->setChecked(TRUE); derivedunion_cb->setDisabled(visit || !derived_cb->isChecked()); ordered_cb = new QCheckBox(TR("ordered"), bg); if (a->get_is_ordered()) ordered_cb->setChecked(TRUE); ordered_cb->setDisabled(visit); unique_cb = new QCheckBox("unique", bg); if (a->get_is_unique()) unique_cb->setChecked(TRUE); unique_cb->setDisabled(visit); } Q3VBox * vtab = new Q3VBox(grid); new QLabel(TR("description :"), vtab); if (! visit) { connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); connect(new SmallPushButton(TR("Default"), vtab), SIGNAL(clicked()), this, SLOT(default_description())); } comment = new MultiLineEdit(grid); comment->setReadOnly(visit); comment->setText(a->browser_node->get_comment()); comment->setFont(font); vtab = new Q3VBox(grid); new QLabel(TR("constraint :"), vtab); if (! visit) { connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_constraint())); } constraint = new MultiLineEdit(grid); constraint->setReadOnly(visit); constraint->setText(a->constraint); constraint->setFont(font); addTab(grid, "Uml"); // C++ if (! cpp_ignored) { grid = new Q3Grid(2, this); cpptab = grid; grid->setMargin(5); grid->setSpacing(5); if (!cpp_in_enum) { new QLabel(TR("Visibility :"), grid); htab = new Q3HBox(grid); Q3ButtonGroup * bg = cpp_visibility.init(htab, a->get_cpp_visibility(), FALSE, 0, TR("follow uml")); if (visit) bg->setEnabled(FALSE); new QLabel(" ", htab); mutable_cb = new QCheckBox("mutable", htab); if (a->cpp_mutable) mutable_cb->setChecked(TRUE); if (visit) mutable_cb->setDisabled(TRUE); else connect(mutable_cb, SIGNAL(toggled(bool)), this, SLOT(cpp_update())); }
TransitionDialog::TransitionDialog(TransitionData * r) : TabDialog(0, 0, true, Qt::WA_DeleteOnClose), rel(r) { r->browser_node->edit_start(); if (r->browser_node->is_writable()) { setOkButton(tr("OK")); setCancelButton(tr("Cancel")); } else { setOkButton(QString()); setCancelButton(tr("Close")); } setWindowTitle(tr("Transition dialog")); visit = !hasOkButton(); BrowserNode * bn = rel->browser_node; GridBox * grid; // // general tab // grid = new GridBox(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); grid->addWidget(new QLabel(tr("name : "), grid)); grid->addWidget(edname = new LineEdit(bn->get_name(), grid)); edname->setReadOnly(visit); grid->addWidget(new QLabel(tr("stereotype : "), grid)); grid->addWidget(edstereotype = new QComboBox(grid)); edstereotype->setEditable(!visit); edstereotype->addItem(toUnicode(rel->get_stereotype())); if (!visit) { //edstereotype->addItems(rel->get_start()->default_stereotypes(type)); edstereotype->setAutoCompletion(completion()); edstereotype->addItems(ProfiledStereotypes::defaults(UmlTransition)); } edstereotype->setCurrentIndex(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); if (r->get_start_node() != r->get_end_node()) internal_cb = 0; else { grid->addWidget(new QLabel(grid)); grid->addWidget(internal_cb = new QCheckBox(tr("internal"), grid)); internal_cb->setChecked(r->internal()); } VVBox * vtab; grid->addWidget(vtab = new VVBox(grid)); vtab->addWidget(new QLabel(tr("description :"), vtab)); if (! visit) { SmallPushButton* sButton; connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); vtab->addWidget(sButton); } grid->addWidget(comment = new MultiLineEdit(grid)); comment->setReadOnly(visit); comment->setText(bn->get_comment()); //comment->setFont(font); addTab(grid, "Uml"); // UML / OCL init_tab(ocltab, uml, rel->uml, "Ocl", SLOT(edit_uml_trigger()), SLOT(edit_uml_guard()), SLOT(edit_uml_expr()), TRUE); // CPP init_tab(cppTab, cpp, rel->cpp, "C++", SLOT(edit_cpp_trigger()), SLOT(edit_cpp_guard()), SLOT(edit_cpp_expr()), GenerationSettings::cpp_get_default_defs()); // Java init_tab(javatab, java, rel->java, "Java", SLOT(edit_java_trigger()), SLOT(edit_java_guard()), SLOT(edit_java_expr()), GenerationSettings::java_get_default_defs()); // USER : list key - value grid = new GridBox(2, this); grid->setMargin(5); grid->setSpacing(5); grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit)); addTab(grid, tr("Properties")); // connect(this, SIGNAL(currentChanged(QWidget *)), this, SLOT(change_tabs(QWidget *))); open_dialog(this); }