MCPcopy Create free account
hub / github.com/AncientLysine/BiliLocal / PoolEditor

Class PoolEditor

src/Editor.cpp:428–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426};
427
428class PoolEditor:public QWidget
429{
430public:
431 explicit PoolEditor(QWidget *parent=0):
432 QWidget(parent)
433 {
434 setMinimumWidth(100*logicalDpiX()/96);
435 manager=new QNetworkAccessManager(this);
436 Config::setManager(manager);
437
438 scroll=new MScroll(this);
439 scroll->setSingleStep(20);
440 connect(scroll,&QScrollBar::valueChanged,[this](int value){
441 value=-value;
442 for(QObject *c:widget->children()){
443 qobject_cast<QWidget *>(c)->move(0,value);
444 value+=100*logicalDpiY()/96;
445 }
446 });
447
448 widget=new QWidget(this);
449 widget->setContextMenuPolicy(Qt::CustomContextMenu);
450 connect(widget,&QWidget::customContextMenuRequested,[this](QPoint point){
451 Track *c=dynamic_cast<Track *>(childAt(point));
452 if(!c){
453 return;
454 }
455 QMenu menu(this);
456 Load *load=Load::instance();
457 auto &p=Danmaku::instance()->getPool();
458 auto &r=c->getRecord();
459 QAction *fullA=menu.addAction(Editor::tr("Full"));
460 fullA->setEnabled(load->canFull(&r));
461 connect(fullA,&QAction::triggered,[=,&r](){
462 load->fullDanmaku(&r);
463 });
464 menu.addSeparator();
465 connect(menu.addAction(Editor::tr("History")),&QAction::triggered,[=,&r](){
466 Calendar history(window());
467 QMap<QDate,int> count;
468 QDate c=r.limit==0?QDate::currentDate().addDays(1):QDateTime::fromTime_t(r.limit).date();
469 history.setCurrentDate(c);
470 if(!load->canHist(&r)){
471 for(const Comment &c:r.danmaku){
472 ++count[QDateTime::fromTime_t(c.date).date()];
473 }
474 count[QDate::currentDate().addDays(1)]=0;
475 count.remove(count.firstKey());
476 history.setCount(count);
477 history.setCurrentPage(c);
478 }
479 else{
480 QString cid=QFileInfo(r.source).baseName();
481 QString api("http://comment.%1/rolldate,%2");
482 api=api.arg(Utils::customUrl(Utils::Bilibili));
483 QNetworkReply *reply=manager->get(QNetworkRequest(api.arg(cid)));
484 connect(reply,&QNetworkReply::finished,[&](){
485 QMap<QDate,int> count;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected