void computeBoundingBox (double& xmin, double& ymin, double& xmax, double& ymax, const RecordList& rl, double maxrange) { xmin = ymin = MAXDOUBLE; xmax = ymax = -MAXDOUBLE; const LaserRecord* lastLaser = 0; for (RecordList::const_iterator it = rl.begin(); it != rl.end(); it++) { const LaserRecord* lr = dynamic_cast<const LaserRecord*> (*it); if (lr) { lastLaser = lr; continue; } const ScanMatchRecord* smr = dynamic_cast<const ScanMatchRecord*> (*it); if (smr && lastLaser) { for (std::vector<OrientedPoint>::const_iterator pit = smr->poses.begin(); pit != smr->poses.end(); pit++) { computeBoundingBox (xmin, ymin, xmax, ymax, *lastLaser, *pit, maxrange); } } } }
void pa5functions::BinSort( RecordList& recordList, RecordList* bucketList ){ for( RecordList::iterator it = recordList.begin(); it != recordList.end(); ++ it ){ bucketList[it->testScore].push_back( (*it) ); } }
//----[ load ]------------------------------------------------------------- bool dcResourceStorage::load(const std::string& owner_name, dcGenericResource* resource) { typedef std::queue<dcGenericResource*> LoadingQueue; LoadingQueue loading_queue; loading_queue.push(resource); std::string root_path = owner_name + dc::dcGenericResource::PATH_SEPARATOR; do { dcGenericResource* resource = loading_queue.front(); // Load members of the current resource RecordList members; if (!read(root_path + resource->getPathString(), &members)) return false; RecordList::iterator i; for (i = members.begin(); i != members.end(); ++i) { dcGenericResource* member = resource->acquireMember( i->member_name.c_str(), i->resource_type.c_str(), 0); if (member) { member->interpret(i->value.c_str()); loading_queue.push(member); } } // We're done loading this resource, so remove it from the queue loading_queue.pop(); } while (!loading_queue.empty()); return true; }
void CmdInterface::show(const RecordList & lst) { cIter i = lst.begin(); for ( ; i != lst.end(); i++) CmdInterface::show(*i); }
void ProjectReserveView::refresh() { RecordList records; QSqlQuery q = Database::current()->exec( "select project.keyelement, project_slots_current.arsenalslotreserve, sum from project_slots_current join project on project.name=project_slots_current.name;" ); while( q.next() ) records.append( Record( new RecordImp( projectReserveTable(), q ) ) ); model()->setRootList( records ); }
RecordList PhoneBook::searchByName(const string & name) { Iter i = _records.begin(), j; RecordList ret; while ((j=searchName(name, i++)) != _records.end()) ret.push_back(*j); return ret; }
void FieldCheckBox::slotRecordListChanged() { if( mProxy && !mField.isEmpty() ){ RecordList rl = mProxy->records(); QList<QVariant> vals = rl.getValue( mField ); QList<bool> boolVals; foreach( QVariant v, vals ) { boolVals.append( v.toBool() ); }
void CmdInterface::show(const RecordList & lst) { if (lst.size() > 0) { cIter i = lst.begin(); for ( ; i != lst.end(); i++) CmdInterface::show(*i); } else println("empty."); }
void init(){ screenSleep(); chatRecord.add("Renge: 初、初次见面……请、请告诉我你的名字……>///<\n"); char tmp[1000]={0}; cin >> tmp; user.changeName(tmp); sprintf(tmp,"你:%s\n",user.name); chatRecord.add(tmp); screenSleep(); sprintf(tmp,"Renge: %s……吗?好漂亮的名字呢=v=\n",user.name); chatRecord.add(tmp); }
int main (int argc, const char * const * argv){ if (argc<3){ cout << "usage gfs2log [-err] [-neff] [-part] [-odom] <infilename> <outfilename>" << endl; cout << " -odom : dump raw odometry in ODOM message instead of inpolated corrected one" << endl; return -1; } bool err=0; bool neff=0; bool part=0; bool odom=0; // int particle_num; unsigned int c=1; if (!strcmp(argv[c],"-err")){ err=true; c++; } if (!strcmp(argv[c],"-neff")){ neff=true; c++; } if (!strcmp(argv[c],"-part")){ part=true; c++; } if (!strcmp(argv[c],"-odom")){ odom=true; c++; } ifstream is(argv[c]); if (!is){ cout << "could read file "<< endl; return -1; } c++; RecordList rl; rl.read(is); unsigned int bestidx=rl.getBestIdx(); cout << endl << "best index = " << bestidx<< endl; ofstream os(argv[c]); if (! os){ cout << "could write file "<< endl; return -1; } rl.printPath(os,bestidx,err,odom); if(part) rl.printLastParticles(os); os.close(); return 0; }
void commandExit(){ screenSleep(); chatRecord.add("Renge: 下、下次再见……\n"); screenSleep(); screenSleep(); shutdown(); }
void BinexReadWrite_T :: init( void ) { TestUtil testUtil; string dataFilePath = gpstk::getPathData(); //---------------------------------------- // Full file paths //---------------------------------------- string inputFile = dataFilePath + gpstk::getFileSep() + "test_input_binex_readwrite.txt"; if (verboseLevel > 0) { cout << " Reading test input . . ." << endl; } readNums(inputFile); if (verboseLevel > 0) { cout << " " << numList.size() << " numbers" << endl; cout << " Creating BINEX records . . ." << endl; } createRecs(); if (verboseLevel > 0) { cout << " " << testRecords.size() << " records" << endl; } }
int main(int argc, char ** argv) { if (argc<2) { cout << "usage gfs2stat <infilename> <outfilename>" << endl; return 0; } ifstream is(argv[1]); if (!is) { cout << "no file found: " << argv[1] << endl; return 0; } ofstream os(argv[2]); if (!os) { cout << "cannot open file: " << argv[1] << endl; return 0; } cout << "loading... "<< flush; RecordList rl; rl.read(is); cout << " done" << endl; int count=-1; for (RecordList::const_iterator it=rl.begin(); it!=rl.end(); it++) { count++; const ScanMatchRecord* rec=dynamic_cast<const ScanMatchRecord*>(*it); if (!rec) continue; Gaussian3 gaussian; /* vector<double> nweights; cout << "N"<< flush; back_insert_iterator< vector<double> > out(nweights); toNormalForm(out,rec->weights.begin(), rec->weights.end()); cout << "G"<< flush; gaussian.computeFromSamples(rec->poses, nweights); */ gaussian.computeFromSamples(rec->poses); cout << "E"<< flush; os << count <<" "; os << gaussian.mean.x <<" "; os << gaussian.mean.y <<" "; os << gaussian.mean.theta <<" "; os << gaussian.covariance.eval[0] <<" "; os << gaussian.covariance.eval[1] <<" "; os << gaussian.covariance.eval[2] <<endl; } os.close(); }
void startupfunc(){ user.input(); char tmp[1000]; screenSleep(); sprintf(tmp,"Renge: 欢、欢迎回来……%s……\n",user.name); chatRecord.add(tmp); answers.init(); }
void ScheduleDialog::accept() { RecordList assetSelection = mAssetTree->selection(); Element e = assetSelection.isEmpty() ? Element(mProject) : Element(assetSelection[0]); if( mSchedule.isRecord() ) { Database::current()->beginTransaction( "Modify Schedule" ); mSchedule.setDuration( Interval().addHours(mHoursSpin->value()) ); mSchedule.setElement( e ); mSchedule.setAssetType( mAssetType ); mSchedule.setUser( mEmployee ); mSchedule.setDate( mDateStartEdit->date() ); mSchedule.setCreatedByUser( User::currentUser() ); mSchedule.commit(); Database::current()->commitTransaction(); } else { Database::current()->beginTransaction( "Create Schedule" ); ScheduleList toCommit; QDate start = mDateStartEdit->date(); QDate end = mDateEndEdit->date(); while( start <= end ) { Schedule s; s.setUser( mEmployee ); s.setElement( e ); s.setAssetType( mAssetType ); s.setDate( start ); s.setDuration( Interval().addHours(mHoursSpin->value()) ); s.setCreatedByUser( User::currentUser() ); toCommit += s; start = start.addDays( 1 ); } toCommit.commit(); if( !e.users().contains( mEmployee ) ) { ElementUser eu; eu.setElement( e ); eu.setUser( mEmployee ); eu.commit(); } Database::current()->commitTransaction(); } QDialog::accept(); }
void process(){ char tmp[1000]; cin.getline(tmp,1000,'\n'); if(strlen(tmp)==0){ chatRecord.output(); return; } if(tmp[0]!='/'){ char tmp2[1000]; sprintf(tmp2,"%s: %s\n",user.name,tmp); chatRecord.add(tmp2); answers.answer(tmp,chatRecord); }else if(strhead(tmp,"/exit ")||strcmp(tmp,"/exit")==0) commandExit(); else if(strhead(tmp,"/clear ")||strcmp(tmp,"/clear")==0) commandClear(); else if(strhead(tmp,"/teach ")||strcmp(tmp,"/teach")==0) commandTeach(); else if(strhead(tmp,"/help ")||strcmp(tmp,"/help")==0) commandHelp(); else commandNotFound(); }
void commandTeach(){ char tmp1[1000],tmp2[1000],tmp3[1000]; chatRecord.add("Renge: 喵?要教我些什么……?\n"); cin.getline(tmp1,1000,'\n'); while(strlen(tmp1)==0){ chatRecord.output(); cin.getline(tmp1,1000,'\n'); } sprintf(tmp3,"Renge: “%s”么……?我该怎么回答?\n",tmp1); chatRecord.add(tmp3); cin.getline(tmp2,1000,'\n'); while(strlen(tmp2)==0){ chatRecord.output(); cin.getline(tmp2,1000,'\n'); } sprintf(tmp3,"Renge: “%s”……我记住了……\n",tmp2); chatRecord.add(tmp3); answers.teach(tmp1,tmp2); }
void RecordUndoOperation::undo() { if( mType == INSERT || mType == DELETE ) { RecordList temp = mRecords.reversed(); if( mType == INSERT ) { temp.remove(); } else { // Clear the DELETED state st_foreach( RecordIter, it, temp ) it.imp()->mState = RecordImp::NEWRECORD | RecordImp::COMMIT_ALL_FIELDS; temp.commit( false ); } } else if( mType == UPDATE ) { RecordList list = mRecords; Record oldvals( mRecords[0].imp()->copy(), false ); mRecords[1].commit(); mRecords[1] = oldvals; } }
void HostListsDialog::showMenu( const QPoint & pos, const Record &, RecordList list ) { QMenu * menu = new QMenu( this ); QAction * del = menu->addAction( "Delete" ); QAction * result = menu->exec( pos ); if( result ) { if( result == del ) { list.remove(); } } delete menu; }
void ScheduleDialog::updateAssets() { if( mDisableUpdates ) return; bool en = mAssetType.isRecord() && mProject.isRecord(); mAssetTree->setEnabled( en ); mAssets.clear(); if( !en ) return; mAssets = Element::recordsByProject( mProject ); if( mTypeFilterAssetsCheck->isChecked() ) mAssets = mAssets.filter( "assettype", mAssetType.key() ); //LOG_5( "TimeEntryDialog::updateAssets: Got " + QString::number( list.size() ) + " assets" ); /* st_foreach( ElementIter, it, list ) { Element e(*it); QVariant v = e.getValue( "allowTime" ); if( (v.isNull() && e.children().isEmpty()) || (!v.isNull() && v.toBool()) ) mAssets += e; } */ RecordList sel = mAssetTree->selection(); mAssetModel->setRootList( TimeEntryDialog::filterAssets( mAssets, mAssetFilterEdit->text() ) ); if( !sel.isEmpty() ) { mAssetTree->setSelection( sel ); mAssetTree->scrollTo( sel ); } }
void pa5functions::ReadInputFile( const char* inputFile, RecordList& recordList ){ // File validation std::fstream fin( inputFile ); if( !fin ){ throw pa5_exception( "Invalid input file." ); } // Parse the file line by line and tokenize std::string currentLine; std::list<std::string> currentTokens; std::list<std::string>::iterator tokenIter; while( !fin.eof() ){ currentLine.clear(); currentTokens.clear(); getline( fin, currentLine ); // Handle poorly formed, but not invalid input input if( currentLine.size() == 0 ){ continue; } TokenizeString( currentLine, currentTokens, ',' ); if( currentTokens.size() != 3 ){ throw pa5_exception( "Invalid input file - format or data error." ); } tokenIter = currentTokens.begin(); StudentRecord record; record.name = *(tokenIter); record.ssn = *(++tokenIter); record.testScore = atoi((*(++tokenIter)).c_str()); // Normalize string length. record.name = record.name.substr(0,12); record.ssn = record.ssn.substr(0,9); recordList.push_back( record ); } fin.close(); }
//--------------------------------------------------------------------------- void BinexReadWriteTest::process() throw() { if (verboseLevel > 0) { cout << "Creating BINEX records . . ." << endl; } for (short recNum = 0; recNum < 10; recNum++) { BinexData record(recNum); TestDataList recordData; size_t offset = 0; for (short dataNum = 0; dataNum < 80; dataNum++) { TestDataType whichType = (TestDataType)(rand() % (eMGFZI + 1) ); void *value = NULL; switch (whichType) { case eChar: { char c = (char)(rand() % 0x100); record.updateMessageData(offset, c, sizeof(c) ); value = new char(c); break; } case eShort: { short s = (short)(rand() % 10000); record.updateMessageData(offset, s, sizeof(s) ); value = new short(s); break; } case eLong: { long l = (long)(lrand48() ); record.updateMessageData(offset, l, sizeof(l) ); value = new long(l); break; } case eUBNXI: { BinexData::UBNXI u( (unsigned long)(abs(lrand48() ) ) % BinexData::UBNXI::MAX_VALUE); record.updateMessageData(offset, u); value = new BinexData::UBNXI(u); break; } case eMGFZI: { BinexData::MGFZI m( (long long)(lrand48() ) ); record.updateMessageData(offset, m); value = new BinexData::MGFZI(m); break; } default: // Internal error exit(1); } if (value != NULL) { recordData.push_back(TestData(whichType, value) ); } } testData.push_back(recordData); testRecords.push_back(record); } if (verboseLevel > 0) { cout << "Verifying BINEX records . . ." << endl; } TestDataListList::iterator dataListIter = testData.begin(); RecordList::iterator recordIter = testRecords.begin(); bool more = true; while ( (dataListIter != testData.end() ) && (recordIter != testRecords.end() ) ) { TestDataList dataList = *dataListIter; BinexData record = *recordIter; try { size_t offset = 0; TestDataList::iterator dataIter = (*dataListIter).begin(); while (dataIter != (*dataListIter).end() ) { switch ( (*dataIter).first) { case eChar: { string desc = "Comparing character record message data"; char c; record.extractMessageData(offset, c, sizeof(c) ); if (memcmp( (void*)&c, (*dataIter).second, sizeof(c) ) ) { report(desc, false); cout << " Actual: " << c << endl; cout << " Expected: " << *( (char*)(*dataIter).second) << endl; } else { report(desc, true); } break; } case eShort: { string desc = "Comparing short record message data"; short s; record.extractMessageData(offset, s, sizeof(s) ); if (memcmp( (void*)&s, (*dataIter).second, sizeof(s) ) ) { report(desc, false); cout << " Actual: " << s << endl; cout << " Expected: " << *( (char*)(*dataIter).second) << endl; } else { report(desc, true); } break; } case eLong: { string desc = "Comparing long record message data"; long l; record.extractMessageData(offset, l, sizeof(l) ); if (memcmp( (void*)&l, (*dataIter).second, sizeof(l) ) ) { report(desc, false); cout << " Actual: " << l << endl; cout << " Expected: " << *( (char*)(*dataIter).second) << endl; } else { report(desc, true); } break; } case eUBNXI: { string desc = "Comparing UBNXI record message data"; BinexData::UBNXI u; record.extractMessageData(offset, u); if (u == *( (BinexData::UBNXI*)(*dataIter).second) ) { report(desc, true); } else { report(desc, false); cout << " Actual: " << (unsigned long)u << endl; cout << " Expected: " << (unsigned long)*( (BinexData::UBNXI*)(*dataIter).second) << endl; } break; } case eMGFZI: { string desc = "Comparing MGFZI record message data"; BinexData::MGFZI m; record.extractMessageData(offset, m); if (m == *( (BinexData::MGFZI*)(*dataIter).second) ) { report(desc, true); } else { report(desc, false); cout << " Actual: " << (long long)m << endl; cout << " Expected: " << (long long)*( (BinexData::MGFZI*)(*dataIter).second) << endl; } break; } default: // Internal error exit(1); } dataIter++; } } catch (FFStreamError e) { cout << " FFStreamError reading record." << endl; } catch (...) { cout << " Unknown error reading record." << endl; } dataListIter++; recordIter++; } if (verboseLevel > 0) { cout << "Writing BINEX file . . ." << endl; } BinexStream outStream("test.out", std::ios::out | std::ios::binary); outStream.exceptions(ios_base::failbit | ios_base::badbit); recordIter = testRecords.begin(); while (recordIter != testRecords.end() ) { try { (*recordIter).putRecord(outStream); } catch(...) { cout << " Error writing record." << endl; } recordIter++; } outStream.close(); if (verboseLevel > 0) { cout << "Reading BINEX file . . ." << endl; } BinexStream inStream("test.out", std::ios::in | std::ios::binary); inStream.exceptions(ios_base::failbit); recordIter = testRecords.begin(); while (inStream.good() && (EOF != inStream.peek() ) ) { if (recordIter == testRecords.end() ) { cout << "Stored records exhausted before file records - exiting." << endl; break; } BinexData record; try { record.getRecord(inStream); if (record == *recordIter) { report("Reading and comparing BINEX record", true); } else { report("Reading and comparing BINEX record", false); cout << "Actual record:" << endl; (*recordIter).dump(cout); cout << "Expected record:" << endl; record.dump(cout); } } catch (FFStreamError e) { cout << e << endl; } catch (...) { cout << " Unknown error reading record." << endl; } recordIter++; } inStream.close(); }
int main (int argc, char** argv) { QApplication app (argc, argv); double maxrange = 50; double delta = 0.1; int scanSkip = 5; const char* filename = 0; const char* format = "PNG"; CMD_PARSE_BEGIN (1, argc) parseDouble ("-maxrange", maxrange); parseDouble ("-delta", delta); parseInt ("-skip", scanSkip); parseString ("-filename", filename); parseString ("-format", format); CMD_PARSE_END double maxUrange = maxrange; if (! filename) { cout << " supply a gfs file, please" << endl; cout << " usage gfs2img [options] -filename <gfs_file>" << endl; cout << " [options]:" << endl; cout << " -maxrange <range>" << endl; cout << " -delta <map cell size>" << endl; cout << " -skip <frames to skip among images>" << endl; cout << " -format <image format in capital letters>" << endl; return -1; } ifstream is (filename); if (!is) { cout << " supply an EXISTING gfs file, please" << endl; return -1; } RecordList rl; rl.read (is); int particles = 0; int beams = 0; for (RecordList::const_iterator it = rl.begin(); it != rl.end(); it++) { const OdometryRecord* odometry = dynamic_cast<const OdometryRecord*> (*it); if (odometry) { particles = odometry->dim; } const LaserRecord* s = dynamic_cast<const LaserRecord*> (*it); if (s) { beams = s->readings.size(); } if (particles && beams) break; } cout << "Particles from gfs=" << particles << endl; if (! particles) { cout << "no particles found, terminating" << endl; return -1; } cout << "Laser beams from gfs=" << beams << endl; if (! beams) { cout << "0 beams found, terminating" << endl; return -1; } double laserBeamStep = 0; if (beams == 180 || beams == 181) { laserBeamStep = M_PI / 180; } else if (beams == 360 || beams == 361) { laserBeamStep = M_PI / 360; } cout << "Laser beam step" << laserBeamStep << endl; if (laserBeamStep == 0) { cout << "Invalid Beam Step, terminating" << endl; return -1; } double laserAngles[MAX_LASER_BEAMS]; double theta = -M_PI / 2; for (int i = 0; i < beams; i++) { laserAngles[i] = theta; theta += laserBeamStep; } ScanMatcher matcher; matcher.setLaserParameters (beams, laserAngles, OrientedPoint (0, 0, 0)); matcher.setlaserMaxRange (maxrange); matcher.setusableRange (maxUrange); matcher.setgenerateMap (true); double xmin, ymin, xmax, ymax; cout << "computing bounding box" << endl; computeBoundingBox (xmin, ymin, xmax, ymax, rl, maxrange); cout << "DONE" << endl << "BBOX= " << xmin << " " << ymin << " " << xmax << " " << ymax << endl; Point center; center.x = (xmin + xmax) / 2.; center.y = (ymin + ymax) / 2.; cout << "computing paths" << endl; unsigned int frame = 0; int scanCount = 0; for (RecordList::const_iterator it = rl.begin(); it != rl.end(); it++) { const ScanMatchRecord* s = dynamic_cast<const ScanMatchRecord*> (*it); if (!s) continue; scanCount++; if (scanCount % scanSkip) continue; cout << "Frame " << frame << " "; std::vector<RecordList> paths (particles); int bestIdx = 0; double bestWeight = -MAXDOUBLE; for (int p = 0; p < particles; p++) { paths[p] = rl.computePath (p, it); double w = rl.getLogWeight (p, it); if (w > bestWeight) { bestWeight = w; bestIdx = p; } } cout << "bestIdx=" << bestIdx << " bestWeight=" << bestWeight << endl; cout << "computing best map" << endl; ScanMatcherMap smap (center, xmin, ymin, xmax, ymax, delta); int count = 0; for (RecordList::const_iterator mt = paths[bestIdx].begin(); mt != paths[bestIdx].end(); mt++) { const LaserRecord* s = dynamic_cast<const LaserRecord*> (*mt); if (s) { double rawreadings[MAX_LASER_BEAMS]; for (uint i = 0; i < s->readings.size(); i++) rawreadings[i] = s->readings[i]; matcher.invalidateActiveArea(); matcher.computeActiveArea (smap, s->pose, rawreadings); // matcher.allocActiveArea(smap, s->pose, rawreadings); matcher.registerScan (smap, s->pose, rawreadings); count++; } } cout << "DONE " << count << endl; QPixmap pixmap (smap.getMapSizeX(), smap.getMapSizeY()); pixmap.fill (QColor (200, 200, 255)); QPainter painter (&pixmap); for (int x = 0; x < smap.getMapSizeX(); x++) for (int y = 0; y < smap.getMapSizeY(); y++) { double v = smap.cell (x, y); if (v >= 0) { int grayValue = 255 - (int) (255.*v); painter.setPen (QColor (grayValue, grayValue, grayValue)); painter.drawPoint (x, smap.getMapSizeY() - y - 1); } } /* cout << "painting trajectories" << endl; for (int p=0; p<particles; p++){ painter.setPen(QColor(Qt::red)); if (p==bestIdx) continue; bool first=true; IntPoint oldPoint(0,0); for (RecordList::const_iterator mt=paths[p].begin(); mt!=paths[p].end(); mt++){ const LaserRecord* s=dynamic_cast<const LaserRecord*>(*mt); if (s){ IntPoint ip=smap.world2map(s->pose); ip.y=smap.getMapSizeY()-ip.y-1; if (!first){ painter.drawLine( oldPoint.x, oldPoint.y, ip.x, ip.y); } oldPoint=ip; first=false; } } paths[p].destroyReferences();; } painter.setPen(QColor(Qt::black)); bool first=true; IntPoint oldPoint(0,0); for (RecordList::const_iterator mt=paths[bestIdx].begin(); mt!=paths[bestIdx].end(); mt++){ const LaserRecord* s=dynamic_cast<const LaserRecord*>(*mt); if (s){ IntPoint ip=smap.world2map(s->pose); ip.y=smap.getMapSizeY()-ip.y-1; if (!first){ painter.drawLine( oldPoint.x, oldPoint.y, ip.x, ip.y); } oldPoint=ip; first=false; } } paths[bestIdx].destroyReferences();; */ cout << " DONE" << endl; cout << "writing image" << endl; QImage img = pixmap.convertToImage(); char ofilename[MAX_FILENAME]; sprintf (ofilename, "%s-%.4d.%s", filename, frame, format); cout << ofilename << endl; img.save (QString (ofilename), format, 0); frame++; } cout << "For Cyrill: \"The Evil is Outside\"" << endl; }
void commandClear(){ clearScreen(); chatRecord.clear(); }
//------------------------------------------------------------------------------------------------- void BachAssetListView::dropEvent( QDropEvent * event ) { if ( !mShowingCollection || !bach_editor_mode ) return; DEBG( "dropEvent 1!" ); if ( event->source() == this && mCurrentDropTarget.isValid() && mCurrentCollection.isValid() ) { DEBG( "dropEvent 2.2!" ); if ( !RecordDrag::canDecode( event->mimeData() ) ) return; BachAssetList bal; GetAssets( mCurrentCollection, mShowExcluded, bal ); RecordList dropped; RecordDrag::decode( event->mimeData(), &dropped ); BachAssetIter it = bal.begin(); // first, do all the items UP to the item into which it should be inserted before int position = 0; for( ; it != bal.end() ; ++it ) { BachAsset ba = (*it); if ( mCurrentDropTarget == ba ) break; if ( dropped.contains( ba ) ) continue; BachBucketMap bbm = BachBucketMap::recordByBucketAndAsset( mCurrentCollection, ba ); DEBG( "Position1:"+QString::number(position)+":"+ba.path() ); bbm.setPosition( position ); bbm.commit(); ++position; } // then do all the dropped ones for ( RecordIter it = dropped.begin() ; it != dropped.end() ; ++it ) { BachAsset ba = *it; // find the map used BachBucketMap bbm = BachBucketMap::recordByBucketAndAsset( mCurrentCollection, ba ); DEBG( "Position2:"+QString::number(position)+":"+bbm.bachAsset().path() ); bbm.setPosition( position ); bbm.commit(); ++position; } // then do all the ones past the end for( ; it != bal.end() ; ++it ) { BachAsset ba = (*it); if ( dropped.contains( ba ) ) continue; BachBucketMap bbm = BachBucketMap::recordByBucketAndAsset( mCurrentCollection, ba ); DEBG( "Position3:"+QString::number(position)+":"+ba.path() ); bbm.setPosition( position ); bbm.commit(); ++position; } BachAssetList bal1; GetAssets( mCurrentCollection, mShowExcluded, bal1 ); model()->updateRecords( BachAssetList() ); model()->append( bal1 ); event->acceptProposedAction(); } }
void NotificationRouteDialog::slotRemoveRoute() { RecordList sel = mNotificationRouteView->selection(); sel.remove(); mNotificationRouteView->model()->remove(sel); }
void commandNotFound(){ screenSleep(); chatRecord.add("Renge: ……?大概可以用/help和/?来查看帮助……\n"); }
void commandHelp(){ screenSleep(); chatRecord.add("Renge: 嗯……/exit可以用来退出=w=还有/clear用于清屏什么的……/teach的话就可以教窝说话啰~~\n"); }
void NotificationRouteDialog::routeSelectionChanged( RecordList rl ) { mRemoveButton->setEnabled( bool(rl.size()) ); }
void debug(){ char tmp[1000]; sprintf(tmp,"%d %d\n",answers.debug1(),answers.debug2()); chatRecord.add(tmp); }