int Flu_Combo_Box :: handle( int event ) { if( event == FL_KEYDOWN && Fl::event_key( FL_Tab ) ) return Fl_Group::handle( event ); // is it time to popup? bool open = ( event == FL_PUSH ) && (!Fl::event_inside( &input ) || ( !editable() && Fl::event_inside( &input ) ) ); open |= ( event == FL_KEYDOWN ) && Fl::event_key( ' ' ); if( open ) { fl_cursor( FL_CURSOR_DEFAULT ); _valbox = FL_THIN_DOWN_BOX; redraw(); // remember old current group Fl_Group *c = Fl_Group::current(); // set current group to 0 so this is a top level popup window Fl_Group::current( 0 ); Popup *_popup = new Popup( this, _cbox, popHeight ); // show it and make FLTK send all events there value( value() ); _popup->show(); Fl::grab( *_popup ); Fl::focus( _cbox ); _popped = true; Fl::pushed( _cbox ); // wait for a selection to be made while( _popped ) Fl::wait(); // restore things and delete the popup _popup->hide(); Fl::grab( 0 ); delete _popup; Fl_Group::current( c ); Fl::focus( this ); _valbox = FL_UP_BOX; redraw(); return 1; } if( input.handle(event) ) { if( !editable() && ( event == FL_ENTER || event == FL_LEAVE ) ) fl_cursor( FL_CURSOR_DEFAULT ); return 1; } else return 0; }
textbox& textbox::editable(bool able) { auto editor = get_drawer_trigger().editor(); if(editor) editor->editable(able); return *this; }
void CustInfo::setMode() { if(_x_privileges && (!_x_privileges->check("MaintainCustomerMasters"))) return; _delete->setDisabled(id() == -1); if (_editMode == _edit->isChecked()) return; _editMode = _edit->isChecked(); if (_editMode) { setCanEdit(true); _list->hide(); _delete->show(); _customerNumber->hide(); _customerNumberEdit->show(); _customerNumberEdit->setEnabled(_x_metrics && _x_metrics->value("CRMAccountNumberGeneration") != "A"); } else { _customerNumber->setText(_customerNumberEdit->text()); _delete->hide(); _list->show(); _customerNumberEdit->hide(); _customerNumber->show(); _customerNumberEdit->setEnabled(true); setId(-1); } emit editable(_editMode); }
bool CLineEdit::setEditMode(bool p) { if (p == _editMode) return p; if (!_canEdit) return false; _editMode=p; _modeAct->setChecked(p); if (_x_metrics) { if (_editMode) _menuLabel->setPixmap(QPixmap(":/widgets/images/edit.png")); else _menuLabel->setPixmap(QPixmap(":/widgets/images/magnifier.png")); if (!_x_metrics->boolean("DisableAutoComplete") && _editMode) disconnect(this, SIGNAL(textEdited(QString)), this, SLOT(sHandleCompleter())); else if (!_x_metrics->boolean("DisableAutoComplete")) connect(this, SIGNAL(textEdited(QString)), this, SLOT(sHandleCompleter())); } setDisabled(_editMode && _x_metrics->value("CRMAccountNumberGeneration") == "A"); if (!_editMode) selectAll(); emit editable(p); return p; }
int QwtCounter::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: buttonReleased((*reinterpret_cast< double(*)>(_a[1]))); break; case 1: valueChanged((*reinterpret_cast< double(*)>(_a[1]))); break; case 2: btnReleased(); break; case 3: btnClicked(); break; case 4: textChanged(); break; } _id -= 5; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = numButtons(); break; case 1: *reinterpret_cast< double*>(_v) = step(); break; case 2: *reinterpret_cast< double*>(_v) = minVal(); break; case 3: *reinterpret_cast< double*>(_v) = maxVal(); break; case 4: *reinterpret_cast< int*>(_v) = stepButton1(); break; case 5: *reinterpret_cast< int*>(_v) = stepButton2(); break; case 6: *reinterpret_cast< int*>(_v) = stepButton3(); break; case 7: *reinterpret_cast< double*>(_v) = value(); break; case 8: *reinterpret_cast< bool*>(_v) = editable(); break; } _id -= 9; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setNumButtons(*reinterpret_cast< int*>(_v)); break; case 1: setStep(*reinterpret_cast< double*>(_v)); break; case 2: setMinValue(*reinterpret_cast< double*>(_v)); break; case 3: setMaxValue(*reinterpret_cast< double*>(_v)); break; case 4: setStepButton1(*reinterpret_cast< int*>(_v)); break; case 5: setStepButton2(*reinterpret_cast< int*>(_v)); break; case 6: setStepButton3(*reinterpret_cast< int*>(_v)); break; case 7: setValue(*reinterpret_cast< double*>(_v)); break; case 8: setEditable(*reinterpret_cast< bool*>(_v)); break; } _id -= 9; } else if (_c == QMetaObject::ResetProperty) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 9; } #endif // QT_NO_PROPERTIES return _id; }
Flu_Combo_Box :: Flu_Combo_Box( int X, int Y, int W, int H, const char* l ) : Fl_Group( X, Y, W, H, l ), input( X, Y, W, H ) { box( FL_DOWN_BOX ); align( FL_ALIGN_LEFT ); pop_height( 100 ); _cbox = NULL; _valbox = FL_UP_BOX; input_callback( NULL ); input.box( FL_FLAT_BOX ); input.callback( input_cb, this ); input.when( FL_WHEN_ENTER_KEY_ALWAYS ); input.color( FL_WHITE, selection_color()); input.textfont( FL_HELVETICA ); input.textsize( FL_NORMAL_SIZE ); input.textcolor( FL_FOREGROUND_COLOR ); input.resize( X+Fl::box_dx(box()), Y+Fl::box_dy(box()), W-18-Fl::box_dw(box()), H-Fl::box_dh(box()) ); editable( true ); end(); }
textbox& textbox::enable_caret() { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if (editor) editor->editable(editor->attr().editable, true); return *this; }
textbox& textbox::editable(bool able) { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if(editor) editor->editable(able, false); return *this; }
void FLineEdit::mousePressEvent ( QMouseEvent * event ) { if (m_readOnly) { m_readOnly = false; emit editable(true); } QLineEdit::mousePressEvent(event); }
void XComboBox::setCode(QString pString) { if (DEBUG) qDebug("%s::setCode(%d %d %s) with _codes.count %d and _ids.count %d", objectName().toAscii().data(), pString.isNull(), pString.isEmpty(), pString.toAscii().data(), _codes.count(), _ids.count()); if (pString.isEmpty()) { setId(-1); setCurrentText(pString); } else if (count() == _codes.count()) { for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++) { if (_codes.at(counter) == pString) { if (DEBUG) qDebug("%s::setCode(%s) found at %d with _ids.count %d & _lastId %d", objectName().toAscii().data(), pString.toAscii().data(), counter, _ids.count(), _lastId); setCurrentIndex(counter); if (_ids.count() && _lastId!=_ids.at(counter)) setId(_ids.at(counter)); return; } else if (DEBUG) qDebug("%s::setCode(%s) not found (%s)", qPrintable(objectName()), qPrintable(pString), qPrintable(_codes.at(counter))); } } else // this is an ad-hoc combobox without a query behind it? { setCurrentItem(findText(pString)); if (DEBUG) qDebug("%s::setCode(%s) set current item to %d using findData()", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); if (_ids.count() > currentItem()) setId(_ids.at(currentItem())); if (DEBUG) qDebug("%s::setCode(%s) current item is %d after setId", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); } if (editable()) { setId(-1); setCurrentText(pString); } }
void KComboBox::setLineEdit( QLineEdit *edit ) { if ( !editable() && edit && !qstrcmp( edit->className(), "QLineEdit" ) ) { // uic generates code that creates a read-only KComboBox and then // calls combo->setEditable( true ), which causes QComboBox to set up // a dumb QLineEdit instead of our nice KLineEdit. // As some KComboBox features rely on the KLineEdit, we reject // this order here. delete edit; edit = new KLineEdit( this, "combo edit" ); } QComboBox::setLineEdit( edit ); d->klineEdit = dynamic_cast<KLineEdit*>( edit ); setDelegate( d->klineEdit ); // Connect the returnPressed signal for both Q[K]LineEdits' if (edit) connect( edit, SIGNAL( returnPressed() ), SIGNAL( returnPressed() )); if ( d->klineEdit ) { // someone calling KComboBox::setEditable( false ) destroys our // lineedit without us noticing. And KCompletionBase::delegate would // be a dangling pointer then, so prevent that. Note: only do this // when it is a KLineEdit! connect( edit, SIGNAL( destroyed() ), SLOT( lineEditDeleted() )); connect( d->klineEdit, SIGNAL( returnPressed( const QString& )), SIGNAL( returnPressed( const QString& ) )); connect( d->klineEdit, SIGNAL( completion( const QString& )), SIGNAL( completion( const QString& )) ); connect( d->klineEdit, SIGNAL( substringCompletion( const QString& )), SIGNAL( substringCompletion( const QString& )) ); connect( d->klineEdit, SIGNAL( textRotation( KCompletionBase::KeyBindingType )), SIGNAL( textRotation( KCompletionBase::KeyBindingType )) ); connect( d->klineEdit, SIGNAL( completionModeChanged( KGlobalSettings::Completion )), SIGNAL( completionModeChanged( KGlobalSettings::Completion))); connect( d->klineEdit, SIGNAL( aboutToShowContextMenu( QPopupMenu * )), SIGNAL( aboutToShowContextMenu( QPopupMenu * )) ); connect( d->klineEdit, SIGNAL( completionBoxActivated( const QString& )), SIGNAL( activated( const QString& )) ); }
void QbsParser::taskAdded(const ProjectExplorer::Task &task) { ProjectExplorer::Task editable(task); QString filePath = task.file.toString(); if (!filePath.isEmpty()) editable.file = Utils::FileName::fromUserInput(m_workingDirectory.absoluteFilePath(filePath)); IOutputParser::taskAdded(editable); }
void GraphicButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (!editable()) { emit clicked(); return; } Q_UNUSED(event) setCursor(Qt::OpenHandCursor); resizeMode = false; }
void GraphicButton::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if (!editable()) return; if (resizeMode) { m_rect.setWidth(event->pos().x()); m_rect.setHeight(event->pos().y()); update(); } else this->setPos(event->scenePos()-event->buttonDownPos(Qt::LeftButton)); }
void GraphicButton::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (!editable()) return; if ((event->pos().x() < m_rect.width()-5) && (event->pos().y() < m_rect.height()-5)) setCursor(Qt::ClosedHandCursor); else { setCursor(Qt::SizeFDiagCursor); resizeMode = true; } }
void GraphicButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); if (editable() || focused()) { if (focused()) painter->setPen(QPen(Qt::red, 1)); else painter->setPen(QPen(Qt::black, 1)); painter->setBrush(QBrush(Qt::transparent)); painter->drawRect(m_rect); } }
void XComboBox::setText(const QString &pString) { if (count()) { for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++) { if (text(counter) == pString) { setCurrentItem(counter); return; } } } if (editable()) { setId(-1); setCurrentText(pString); } }
void TKComboBox::paintEvent(QPaintEvent*) { QRect r; if (editable()){ #ifdef __GNUC__ #warning "Left out for now, lacking a style expert (Werner)" #endif //r = QRect( style().comboButtonRect( 0, 0, width(), height() ) ); r = QRect(4, 2, width()-height()-2, height()-4); } else { r = QRect(4, 2, width()-height()-2, height()-4); } int by = 2; int bx = r.x() + r.width(); int bw = width() - bx - 2; int bh = height()-4; QPainter p( this ); const QColorGroup& g = colorGroup(); QRect fr(2,2,width()-4,height()-4); if ( hasFocus()) { p.fillRect( fr, g.brush( QColorGroup::Highlight ) ); } else { p.fillRect( fr, g.brush( QColorGroup::Base ) ); } QRect r1(1,1,width()-1,height()-1); qDrawShadePanel( &p, r1, g, true, 1 ); static const char* arrow_down[] = { "7 7 2 1", "X c Gray0", " c None", "XXXXXXX", "XXXXXXX", " ", "XXXXXXX", " XXXXX ", " XXX ", " X "}; QPixmap pixmap(arrow_down); style().drawControl( QStyle::CE_PushButton, &p, this, QRect( bx, by, bw, bh ), colorGroup() ); style().drawItem( &p, QRect( bx, by, bw, bh), AlignCenter, colorGroup(), isEnabled(), &pixmap, QString::null ); if ( hasFocus()) { style().drawPrimitive( QStyle::PE_FocusRect, &p, fr, g ); } if (!editable()) { p.setClipRect(r); p.setPen( g.text() ); p.setBackgroundColor( g.background() ); if ( listBox()->item(currentItem()) ) { QListBoxItem * item = listBox()->item(currentItem()); const QPixmap *pix = item->pixmap(); QString text = item->text(); int x = r.x(); if ( pix ) { p.drawPixmap( x, r.y() + ( r.height() - pix->height() ) / 2 +1, *pix ); x += pix->width()+3; } if (!text.isEmpty()) p.drawText( x, r.y(), r.width()-x, r.height(), AlignLeft|AlignVCenter|SingleLine, text ); } } p.end(); }
void textbox::handle_event(const SDL_Event& event, bool was_forwarded) { if(!enabled()) return; scrollarea::handle_event(event); if(hidden()) return; bool changed = false; const int old_selstart = selstart_; const int old_selend = selend_; //Sanity check: verify that selection start and end are within text //boundaries if(is_selection() && !(size_t(selstart_) <= text_.size() && size_t(selend_) <= text_.size())) { WRN_DP << "out-of-boundary selection\n"; selstart_ = selend_ = -1; } int mousex, mousey; const Uint8 mousebuttons = SDL_GetMouseState(&mousex,&mousey); if(!(mousebuttons & SDL_BUTTON(1))) { grabmouse_ = false; } SDL_Rect const &loc = inner_location(); bool clicked_inside = !mouse_locked() && (event.type == SDL_MOUSEBUTTONDOWN && (mousebuttons & SDL_BUTTON(1)) && point_in_rect(mousex, mousey, loc)); if(clicked_inside) { set_focus(true); } if ((grabmouse_ && (!mouse_locked() && event.type == SDL_MOUSEMOTION)) || clicked_inside) { const int x = mousex - loc.x + text_pos_; const int y = mousey - loc.y; int pos = 0; int distance = x; for(unsigned int i = 1; i < char_x_.size(); ++i) { if(static_cast<int>(yscroll_) + y < char_y_[i]) { break; } // Check individually each distance (if, one day, we support // RTL languages, char_x_[c] may not be monotonous.) if(abs(x - char_x_[i]) < distance && yscroll_ + y < char_y_[i] + line_height_) { pos = i; distance = abs(x - char_x_[i]); } } cursor_ = pos; if(grabmouse_) selend_ = cursor_; update_text_cache(false); if(!grabmouse_ && mousebuttons & SDL_BUTTON(1)) { grabmouse_ = true; selstart_ = selend_ = cursor_; } else if (! (mousebuttons & SDL_BUTTON(1))) { grabmouse_ = false; } set_dirty(); } //if we don't have the focus, then see if we gain the focus, //otherwise return if(!was_forwarded && focus(&event) == false) { if (!mouse_locked() && event.type == SDL_MOUSEMOTION && point_in_rect(mousex, mousey, loc)) events::focus_handler(this); return; } if(event.type != SDL_KEYDOWN || (!was_forwarded && focus(&event) != true)) { draw(); return; } const SDL_keysym& key = reinterpret_cast<const SDL_KeyboardEvent&>(event).keysym; const SDLMod modifiers = SDL_GetModState(); const int c = key.sym; const int old_cursor = cursor_; if(editable_) { if(c == SDLK_LEFT && cursor_ > 0) --cursor_; if(c == SDLK_RIGHT && cursor_ < static_cast<int>(text_.size())) ++cursor_; // ctrl-a, ctrl-e and ctrl-u are readline style shortcuts, even on Macs if(c == SDLK_END || (c == SDLK_e && (modifiers & KMOD_CTRL))) cursor_ = text_.size(); if(c == SDLK_HOME || (c == SDLK_a && (modifiers & KMOD_CTRL))) cursor_ = 0; if((old_cursor != cursor_) && (modifiers & KMOD_SHIFT)) { if(selstart_ == -1) selstart_ = old_cursor; selend_ = cursor_; } } else if(c == SDLK_LEFT || c == SDLK_RIGHT || c == SDLK_END || c == SDLK_HOME) { pass_event_to_target(event); } if(editable_) { if(c == SDLK_BACKSPACE) { changed = true; if(is_selection()) { erase_selection(); } else if(cursor_ > 0) { --cursor_; text_.erase(text_.begin()+cursor_); } } if(c == SDLK_u && (modifiers & KMOD_CTRL)) { // clear line changed = true; cursor_ = 0; text_.resize(0); } if(c == SDLK_DELETE && !text_.empty()) { changed = true; if(is_selection()) { erase_selection(); } else { if(cursor_ < static_cast<int>(text_.size())) { text_.erase(text_.begin()+cursor_); } } } } else if(c == SDLK_BACKSPACE || c == SDLK_DELETE || (c == SDLK_u && (modifiers & KMOD_CTRL))) { pass_event_to_target(event); } #if SDL_VERSION_ATLEAST(2, 0, 0) ucs4::char_t character = key.scancode; #else ucs4::char_t character = key.unicode; #endif //movement characters may have a "Unicode" field on some platforms, so ignore it. if(!(c == SDLK_UP || c == SDLK_DOWN || c == SDLK_LEFT || c == SDLK_RIGHT || c == SDLK_DELETE || c == SDLK_BACKSPACE || c == SDLK_END || c == SDLK_HOME || c == SDLK_PAGEUP || c == SDLK_PAGEDOWN)) { if(character != 0) { DBG_G << "Char: " << character << ", c = " << c << "\n"; } if((event.key.keysym.mod & copypaste_modifier) //on windows SDL fires for AltGr lctrl+ralt (needed to access @ etc on certain keyboards) #ifdef _WIN32 && !(event.key.keysym.mod & KMOD_ALT) #endif ) { switch(c) { case SDLK_v: // paste { if(!editable()) { pass_event_to_target(event); break; } changed = true; if(is_selection()) erase_selection(); std::string str = copy_from_clipboard(false); //cut off anything after the first newline str.erase(std::find_if(str.begin(),str.end(),utils::isnewline),str.end()); ucs4::string s = utils::string_to_ucs4string(str); if(text_.size() < max_size_) { if(s.size() + text_.size() > max_size_) { s.resize(max_size_ - text_.size()); } text_.insert(text_.begin()+cursor_, s.begin(), s.end()); cursor_ += s.size(); } } break; case SDLK_c: // copy { if(is_selection()) { const size_t beg = std::min<size_t>(size_t(selstart_),size_t(selend_)); const size_t end = std::max<size_t>(size_t(selstart_),size_t(selend_)); ucs4::string ws(text_.begin() + beg, text_.begin() + end); std::string s = utils::ucs4string_to_string(ws); copy_to_clipboard(s, false); } } break; } } else if(editable_) { if(character >= 32 && character != 127) { changed = true; if(is_selection()) erase_selection(); if(text_.size() + 1 <= max_size_) { text_.insert(text_.begin()+cursor_,character); ++cursor_; } } } else { pass_event_to_target(event); } } if(is_selection() && (selend_ != cursor_)) selstart_ = selend_ = -1; //since there has been cursor activity, make the cursor appear for //at least the next 500ms. show_cursor_ = true; show_cursor_at_ = SDL_GetTicks(); if(changed || old_cursor != cursor_ || old_selstart != selstart_ || old_selend != selend_) { text_image_ = NULL; handle_text_changed(text_); } set_dirty(true); }
rePropertyEditor::rePropertyEditor() { editable(true); parent(0); }
/* CENTRAL METHOD to parse and render html request*/ int handle(cchar* q0,int conn){ int len=(int)strlen(q0); if(len>1000){ p("checkSanity len>1000"); return 0;// SAFETY! } char* q=editable(q0); checkSanity(q,len); while(q[0]=='/')q++; enum result_format format = html;//txt; html DANGER WITH ROBOTS enum result_verbosity verbosity = normal; if (eq(q, "favicon.ico"))return 0; if(contains(q,"robots.txt")){ Writeline(conn,"User-agent: *\n"); Writeline("Disallow: /\n"); return 0; } char* jsonp=strstr(q,"jsonp");// ?jsonp=fun if(jsonp){ jsonp[-1]=0; jsonp+=6; format = json; } else jsonp=(char*)"parseResults"; if (endsWith(q, ".json")) { format = json; q[len-5]=0; } if (endsWith(q, ".xml")) { format = xml; q[len-4]=0; } if (endsWith(q, ".csv")||endsWith(q, ".tsv")) { format = csv; q[len-4]=0; } if (endsWith(q, ".txt")) { format = txt; q[len-4]=0; } if (endsWith(q, ".html")) { format = html; q[len-5]=0; } if (startsWith(q, ".js")) { q[len-3]=0; Writeline(conn, jsonp); Writeline(conn, "("); format = js; } // todo : dedup!! if (startsWith(q, "all/")) { cut_to(q," +"); cut_to(q," -"); q = q + 4; showExcludes=false; verbosity = alle; } if (startsWith(q, "long/")){ verbosity = longer; q = q + 5; } if (startsWith(q, "full/")) { verbosity = verbose; q = q + 5; } if (startsWith(q, "verbose/")) { verbosity = verbose; q = q + 8; } if (startsWith(q, "short/")) { verbosity = shorter; q = q + 6; } if (startsWith(q, "html/")) { format = html; if(!contains(q,".")&&!contains(q,":")) verbosity=verbose; q = q + 5; } if (startsWith(q, "plain/")) { format = txt; q = q + 6; } if (startsWith(q, "text/")) { format = txt; q = q + 5; } if (startsWith(q, "txt/")) { format = txt; q = q + 4; } if (startsWith(q, "xml/")) { format = xml; q = q + 4; } if (startsWith(q, "csv/")||startsWith(q, "tsv/")) { format = csv; q = q + 4; } if (startsWith(q, "json/")) { format = json; q = q + 5; } if (startsWith(q, "js/")) { q = q + 3; Writeline(conn, jsonp); Writeline(conn, "("); format = js; } if (startsWith(q, "long/")) { verbosity = longer; q = q + 5; } if (startsWith(q, "verbose/")) { verbosity = verbose; q = q + 8; } if (startsWith(q, "short/")) { verbosity = shorter; q = q + 6; } if (startsWith(q, "excludes/")||startsWith(q, "includes/")||startsWith(q, "excluded/")||startsWith(q, "included/")||startsWith(q, "showview/")) { showExcludes=true; verbosity=longer; q = q + 9; } else showExcludes=false; excluded.clear(); included.clear(); if(contains(q,"statement count")){Writeline(conn,itoa((int)context->statementCount).data());return 0;} if(contains(q,"node count")){Writeline(conn,itoa(context->nodeCount).data());return 0;} if (startsWith(q, "all/")) { cut_to(q," +"); cut_to(q," -"); q = q + 4; showExcludes=false; verbosity = alle; } // bool get_topic=false; bool get_topic=true; bool sort=false; if (startsWith(q, "ee/")||startsWith(q, "ee ")) { q[2]=' '; get_topic=true; } if (startsWith(q, "entities/")) { q[8]=' '; get_topic=true; // verbosity=longer; } if(hasWord(q)) loadView(q); if(contains(q,"exclude")||contains(q,"include")){ verbosity=normal; showExcludes=true; } p(q); // !!!!!!!!!!!!!!!!!!!!!!!!!!! // NodeVector all = parse(q); // <<<<<<<< HANDLE QUERY WITH NETBASE! // // !!!!!!!!!!!!!!!!!!!!!!!!!!! autoIds=false; int size=(int)all.size(); if(showExcludes){ for (int i = 0; i < size; i++) { // todo : own routine!!! Node* node = (Node*) all[i]; if(!contains(all,getAbstract(node->name))) all.push_back(getAbstract(node->name)); N parent= getType(node); if(parent){ if(!contains(all,parent))all.push_back(parent); N abs= getAbstract(parent->name); if(parent&&!contains(all,abs))all.push_back(abs); } } show(excluded); } const char* html_block="<!DOCTYPE html><html><head><META HTTP-EQUIV='CONTENT-TYPE' CONTENT='text/html; charset=UTF-8'/></head>"\ "<body><div id='netbase_results'></div>\n<script>var results="; // if((int)all.size()==0)Writeline("0"); // Writeline(conn,q); char buff[10000]; bool use_json= format == json || format == js || format == html; if (format == xml && (startsWith(q,"select")||contains(q," where "))){Writeline(conn,query2(q));return 0;} if (format == xml)Writeline(conn, "<results>\n"); if (format == html)Writeline(conn,html_block); if (use_json)Writeline(conn, "{\"results\":[\n"); const char* statement_format_xml = " <statement id='%d' subject=\"%s\" predicate=\"%s\" object=\"%s\" sid='%d' pid='%d' oid='%d'/>\n"; const char* statement_format_text = " $%d %s %s %s %d->%d->%d\n"; const char* statement_format_json = " { \"id\":%d, \"subject\":\"%s\", \"predicate\":\"%s\", \"object\":\"%s\", \"sid\":%d, \"pid\":%d, \"oid\":%d}"; const char* statement_format_csv = "%d\t%s\t%s\t%s\t%d\t%d\t%d\n"; const char* statement_format = 0; if (format == xml)statement_format = statement_format_xml; if (format == html)statement_format = statement_format_json; if (format == json)statement_format = statement_format_json; if (format == txt)statement_format = statement_format_text; if (format == csv)statement_format = statement_format_csv; const char* entity_format = 0; const char* entity_format_txt = "%s #%d (statements:%d) %s\n"; const char* entity_format_xml = "<entity name=\"%s\" id='%d' statementCount='%d' description='%s'>\n"; const char* entity_format_json = " {\"name\":\"%s\", \"id\":%d, \"statementCount\":%d, \"description\":\"%s\""; const char* entity_format_csv = "%s\t%d\t%d\t%s\n"; if(all.size()==1)entity_format_csv = "";//statements! if (format == xml)entity_format = entity_format_xml; if (format == txt)entity_format = entity_format_txt; if (format == csv)entity_format = entity_format_csv; if (use_json) entity_format = entity_format_json; Node* last=0; warnings=0; char* entity=0; if(startsWith(q,"all")){ entity=(char*)cut_to(q," "); entity=keep_to(entity,"limit"); } sortNodes(all); int count=(int)all.size(); int good=0; for (int i = 0; i < count && i<resultLimit; i++) { Node* node = (Node*) all[i]; if(!checkNode(node))continue; if(node->id==0)continue; if(last==node)continue; if(eq(node->name,"◊"))continue; last=node; if(verbosity ==normal && entity&& eq(entity,node->name))continue; char* text=getText(node); // if(use_json && get_topic){ // if(empty(text))continue;//! no description = no entity? BAD for amazon etc // if(isAbstract(node))continue; // N t=getTopic(node); // } good++; if (use_json)if(good>1)Writeline(conn, "},\n"); sprintf(buff, entity_format, node->name, node->id,node->statementCount,text); Writeline(conn, buff); // if(verbosity != alle && !get_topic) // loadView(node); bool got_topic=false; if(use_json && get_topic){ N c=getClass(node); N t=getTopic(node); N ty=getType(node); // if(!c)c=t; if(!t)t=ty; if(t==node)t=ty; if(t!=Entity && checkNode(t)){ got_topic=true; Writeline(conn, ",\n\t \"topicid\":"+itoa(t->id)); Writeline(conn, ", \"topic\":\""+string(t->name)+"\""); } if(c && c!=t){ Writeline(conn, ",\n\t \"classid\":"+itoa(c->id)); Writeline(conn, ", \"class\":\""+string(c->name)+"\""); } if(ty&& c!=ty && ty!=t){ Writeline(conn, ",\n\t \"typeid\":"+itoa(ty->id)); Writeline(conn, ", \"type\":\""+string(ty->name)+"\""); } } if(use_json)// && (verbosity==verbose||verbosity==shorter))// lol // just name Writeline(conn, ", \"kind\":"+itoa(node->kind)); if((use_json)&&!showExcludes&&node->statementCount>1 && getImage(node)!="") Writeline(", \"image\":\""+replace_all(replace_all(getImage(node,150,/*thumb*/true),"'","%27"),"\"","%22")+"\""); // if((use_json)&&getText(node)[0]!=0) // Writeline(", \"description\":\""+string(getText(node))+"\""); Statement* s = 0; if (format==csv|| verbosity == verbose || verbosity == longer|| verbosity == alle || showExcludes || ( all.size() == 1 && !(verbosity == shorter))) { int count=0; // Writeline(",image:\""+getImage(node->name)+"\""); if (use_json)Writeline(conn, ",\n\t \"statements\":[\n"); // sortStatements( deque<Statement*> statements;// sort while ((s = nextStatement(node, s))&&count++<lookupLimit){// resultLimit if (!checkStatement(s))break; // if(!got_topic &&( s->predicate==_Type|| s->predicate==_SuperClass)){ // addStatementToNode(node, s->id(), true);// next time // } if(get_topic &&!got_topic && verbosity != verbose && (s->predicate>100 || s->predicate<-100)) continue;// only important stuff here! // filter statements if(s->object==0)continue; // if(eq(s->Predicate()->name,"Offizielle Website") && !contains(s->Object()->name,"www")) // continue; if (s->subject==node->id and s->predicate!=4)//_instance statements.push_front(s); else statements.push_back(s); } // if(get_topic && verbosity!=shorter){ // NV topics=getTopics(node); // N s=topics[0]; // for (int j = 0; j < topics.size() && j<=resultLimit; j++) { // N s=topics[j]; // Temporary statement (node,topic,s) // statements.push_front(s); // } // } int good=0; for (int j = 0; j < statements.size() && j<=resultLimit; j++) { s=statements.at(j); // while ((s = nextStatement(node, s))&&count++<resultLimit) { if(format==csv&&all.size()>1)break;// entities vs statements p(s); if(verbosity!=alle&&checkHideStatement(s)){warnings++;continue;} fixLabels(s); if(!(verbosity==verbose||verbosity==alle) && (s->Predicate()==Instance||s->Predicate()==Type))continue; if(use_json && good>0)Writeline(conn, ",\n"); char* objectName=s->Object()->name; if(s->Predicate()==Instance){ N type=findProperty(s->Object(),Type->name,0,50); if( checkNode(type)) objectName=(char*)(concat(concat(objectName, ": "),type->name)); } sprintf(buff, statement_format, s->id(), s->Subject()->name, s->Predicate()->name, objectName, s->Subject()->id, s->Predicate()->id, s->Object()->id); Writeline(conn, buff); good++; } if (use_json)Writeline(conn, "]"); } if (format == xml)Writeline(conn, "</entity>\n"); // string img=getImage(node->name); // if(img!="")Writeline(conn,"<img src=\""+img+"\"/>"); } if (use_json || format == html || format == js)Writeline(conn,good>0?"}\n]}":"]}"); if (format == xml)Writeline(conn, "</results>\n"); if(format == js)Writeline(conn, ")");// jsonp const char* html_end=";\n</script>\n<script src='http://pannous.net/netbase.js'></script></body></html>\n"; if(format == html)Writeline(conn, html_end); // sprintf(buff, "<script src='/js/%s'></script>",q0); // Writeline(conn, buff); // } pf("Warnings/excluded: %d\n",warnings); return 0;// 0K }
void FLineEdit::editingFinishedSlot() { m_readOnly = true; emit editable(false); setCursor(Qt::IBeamCursor); }