/*========================================================================= refresh =========================================================================*/ void KFileBrowser::refresh (void) { setPath (this->path); }
void qml_node::resetNode() { if(m_was_destroyed) return; m_node.clear(); nodeChanged(m_node); const bool reading = m_device ? m_device->readPreset() : false; reset_parent(); // Creation may not have finished yet. if (m_parentNode && !m_parentNode->ossiaNode()) { m_parentNode->resetNode(); } if (m_device) { // Utility function to set-up a node. auto setup_valid_node = [&] { m_ossia_node->about_to_be_deleted .connect<&qml_node::on_node_deleted>(this); m_node = QString::fromStdString(m_ossia_node->get_name()); nodeChanged(m_node); setPath(QString::fromStdString( ossia::net::address_string_from_node(*m_ossia_node))); applyNodeAttributes(); }; std::string node_name; bool relative = false; // Naming logic if (m_userRequestedNode.isEmpty()) { if (auto par = this->parent()) { node_name = par->objectName().toStdString(); if (node_name.empty()) node_name = par->metaObject()->className(); } if (node_name.empty()) node_name = "Object"; relative = true; } else if (m_userRequestedNode[0] != '/') { relative = true; node_name = m_userRequestedNode.toStdString(); } else if (m_userRequestedNode == QStringLiteral("/")) { m_ossia_node = &m_device->device().get_root_node(); setup_valid_node(); return; } else { node_name = m_userRequestedNode.toStdString(); } // Find the node auto get_parent = [&]() -> ossia::net::node_base& { if (m_parentNode && m_parentNode->ossiaNode()) return *m_parentNode->ossiaNode(); if (relative) { return findClosestParent( this->parent(), m_device->device().get_root_node()); } else { return m_device->device().get_root_node(); } }; ossia::net::node_base& parent = get_parent(); if (reading) { m_ossia_node = ossia::net::find_node(parent, node_name); if (m_ossia_node) { setup_valid_node(); } else { setPath({}); } } else { m_ossia_node = &ossia::net::create_node(parent, node_name); setup_valid_node(); } return; } // In case something went wrong... setPath({}); }
/*code implements Greedy search*/ bool Design::greedy(int dest){ #if DEBUG==3 fprintf(debugfile_,"GREEDY"); fprintf(debugfile_,"dest: %d\n",dest); fflush(debugfile_); #endif MinHeap<SearchData> openlist; CloseStructure* closelist=new CloseStructure[map_.numvert()]; bool rc=false; Node<EdgeInfo>* currconnect; int nn; SearchData curr; SearchData tmp; curr.set(whichbox_,-1,0); //start at current node, parent is -1. //uniform cost so cost incurred so far is 0 bool done=false; bool found=false; float biggestcost=0; int numclosed=0; do{ #if DEBUG==3 fprintf(debugfile_,"curr.nodenum: %d\n",curr.nodenum()); fflush(debugfile_); #endif LList<EdgeInfo>& edgelist=map_.edges(curr.nodenum()); //get the conections to curr while(currconnect=edgelist.curr()){ //for each node connected to curr nn=currconnect->data().to(); if(!closelist[nn].closed_){ //if its not in the closed list #if DEBUG==3 fprintf(debugfile_,"add to openlist: %d\n",nn); fflush(debugfile_); #endif tmp.set(nn,curr.nodenum(),timeleft(currconnect,dest)); openlist.insert(tmp); } edgelist.gonext(); }//while closelist[curr.nodenum()].closed_=true; //add it to the close list closelist[curr.nodenum()].nodeinf_=curr; numclosed++; if(!openlist.isempty()){ //if there are still nodes to consider curr=openlist.remove();//remove lowest cost item from list #if DEBUG == 3 fprintf(debugfile_,"removed from openlist: %d\n",curr.nodenum()); fflush(debugfile_); #endif while(!openlist.isempty() && closelist[curr.nodenum()].closed_){ //if already encountered curr=openlist.remove();//remove lowest cost item from list //consider the next node } if(closelist[curr.nodenum()].closed_){ //only way to reach this part of code is if the open list is empty and //we have not found the next node to examine done=true; } else{ if(curr.nodenum()==dest){ found=true; //found a node to the destination... question is, is it the best. biggestcost=curr.cost(); } if(found && curr.cost() > biggestcost){ done=true; } }//else still have node }//if list is not empty else{ done=true; }//open list is empty }while(!done); if(found){ rc=true; setPath(closelist,dest); delete [] closelist; } return rc; }
LoginRequest::LoginRequest(QObject *parent) : Request(parent) , d(new Private) { setPath("/auth/api/v1/login/1/"); }
void PathChooser::slotBrowse() { emit beforeBrowsing(); QString predefined = path(); if ((predefined.isEmpty() || !QFileInfo(predefined).isDir()) && !d->m_initialBrowsePathOverride.isNull()) { predefined = d->m_initialBrowsePathOverride; if (!QFileInfo(predefined).isDir()) predefined.clear(); } // Prompt for a file/dir QString newPath; switch (d->m_acceptingKind) { case PathChooser::Directory: case PathChooser::ExistingDirectory: newPath = QFileDialog::getExistingDirectory(this, makeDialogTitle(tr("Choose Directory")), predefined); break; case PathChooser::ExistingCommand: case PathChooser::Command: newPath = QFileDialog::getOpenFileName(this, makeDialogTitle(tr("Choose Executable")), predefined, d->m_dialogFilter); break; case PathChooser::File: // fall through newPath = QFileDialog::getOpenFileName(this, makeDialogTitle(tr("Choose File")), predefined, d->m_dialogFilter); break; case PathChooser::SaveFile: newPath = QFileDialog::getSaveFileName(this, makeDialogTitle(tr("Choose File")), predefined, d->m_dialogFilter); break; case PathChooser::Any: { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::AnyFile); dialog.setWindowTitle(makeDialogTitle(tr("Choose File"))); QFileInfo fi(predefined); if (fi.exists()) dialog.setDirectory(fi.absolutePath()); // FIXME: fix QFileDialog so that it filters properly: lib*.a dialog.setNameFilter(d->m_dialogFilter); if (dialog.exec() == QDialog::Accepted) { // probably loop here until the *.framework dir match QStringList paths = dialog.selectedFiles(); if (!paths.isEmpty()) newPath = paths.at(0); } break; } default: break; } // Delete trailing slashes unless it is "/"|"\\", only if (!newPath.isEmpty()) { newPath = QDir::toNativeSeparators(newPath); if (newPath.size() > 1 && newPath.endsWith(QDir::separator())) newPath.truncate(newPath.size() - 1); setPath(newPath); } emit browsingFinished(); d->m_lineEdit->triggerChanged(); }
ImageStoreItem::ImageStoreItem(const QString& p) { setPath(p); }
CoilItem::CoilItem(SlotItem *fromSlot, SlotItem * toSlot, WindingItem *winding, int _turns, double _x1, double _y1) : KoilItem(winding){ pen = winding->getPen(); normalColor = pen.color().lighter(125); brushColor = normalColor; hoverColor = normalColor.lighter(150); selectedColor = normalColor.darker(200); x1 = _x1; y1 = _y1; slot2 = fromSlot; slot1 = toSlot; // slot1->setL2(negative); // slot2->setL1(positive); slot1->setL2(negative, winding->getPen()); slot2->setL1(positive, winding->getPen()); setFlags( ItemIsSelectable | ItemIsFocusable /*| ItemIsMovable*/); setAcceptHoverEvents ( true ); setZValue(-1); // The coil is behind the slots turns = _turns; // label = new QGraphicsTextItem(this); path = new QPainterPath(); QPointF P1 = slot1->P2(); // recover the outer layer of slot 1 xs1 = P1.x(); ys1 = P1.y(); QPointF P2 = slot2->P1(); // recover the inner layer of slot 2 xs2 = P2.x(); ys2 = P2.y(); width = sqrt((xs2-xs1)*(xs2-xs1)+(ys2-ys1)*(ys2-ys1)); if (x1<0) x1 = -width/2; // set the default values if (y1<0) y1 = -width/2; cp1 = new ControlPointItem(x1,y1,this); connect(cp1,SIGNAL(pointMoved(qreal,qreal)),this,SLOT(cp1Moved(qreal,qreal))); itemChange(ItemSelectedHasChanged, false); center.setX((xs1+xs2)/2); center.setY((ys2+ys1)/2); setPath(); // // move and rotate the coil on the two slots and rotate the label moveBy(center.x(),center.y()); angle = atan2(ys2-ys1,xs2-xs1)*180/pi; setRotation(angle); // //set the default incidence for the coil incidence = _pos; info = tr("Coil with %1 turns").arg(turns); }
Status InMatchExpression::init(StringData path) { return setPath(path); }