void HistoryContentsWidget::showContextMenu(const QPoint &point) { const qint64 entry = getEntry(m_ui->historyView->indexAt(point)); QMenu menu(this); if (entry >= 0) { menu.addAction(Utils::getIcon(QLatin1String("document-open")), tr("Open"), this, SLOT(openEntry())); menu.addAction(tr("Open in New Tab"), this, SLOT(openEntry()))->setData(NewTabOpen); menu.addAction(tr("Open in New Background Tab"), this, SLOT(openEntry()))->setData(NewTabBackgroundOpen); menu.addSeparator(); menu.addAction(tr("Open in New Window"), this, SLOT(openEntry()))->setData(NewWindowOpen); menu.addAction(tr("Open in New Background Window"), this, SLOT(openEntry()))->setData(NewWindowBackgroundOpen); menu.addSeparator(); menu.addAction(tr("Add to Bookmarks..."), this, SLOT(bookmarkEntry())); menu.addAction(tr("Copy Link to Clipboard"), this, SLOT(copyEntryLink())); menu.addSeparator(); menu.addAction(tr("Remove Entry"), this, SLOT(removeEntry())); menu.addAction(tr("Remove All Entries from This Domain"), this, SLOT(removeDomainEntries())); menu.addSeparator(); } menu.addAction(ActionsManager::getAction(QLatin1String("ClearHistory"))); menu.exec(m_ui->historyView->mapToGlobal(point)); }
void WebCache::getEntryImpl() { if (!m_cacheBackend) { int code = m_cache->GetBackend(&m_cacheBackend, &m_openEntryCallback); if (code == ERR_IO_PENDING) return; else if (code != OK) { onGetEntryDone(0 /*unused*/); return; } } openEntry(0 /*unused*/); }
void MlCache::setCachedSlices(const std::string & name) { openEntry(name); HBase * p = getNamedEntry(name); int nf = p->numChildren(); unsigned csize = entrySize(name); for(int i = 0; i < nf; i++) { if(p->isChildData(i)) setCached(name, p->getChildName(i), csize); } closeEntry(name); }
CacheContentsWidget::CacheContentsWidget(Window *window) : ContentsWidget(window), m_model(new QStandardItemModel(this)), m_isLoading(true), m_ui(new Ui::CacheContentsWidget) { m_ui->setupUi(this); m_ui->previewLabel->hide(); QTimer::singleShot(100, this, SLOT(populateCache())); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterCache(QString))); connect(m_ui->cacheView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openEntry(QModelIndex))); connect(m_ui->cacheView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeDomainEntriesOrEntry())); }
bool MlCache::doRead(const std::string & name) { if(!HFile::doRead(name)) return false; openEntry("/info"); HBase *info = getNamedEntry("/info"); if(info->hasNamedAttr(".scene")) info->readStringAttr(".scene", m_sceneName); if(info->hasNamedAttr(".range")) info->readIntAttr(".range", m_bakeRange); closeEntry("/info"); setCachedSlices("/p"); setCachedSlices("/tang"); setCachedSlices("/ang"); return true; }
HistoryContentsWidget::HistoryContentsWidget(Window *window) : ContentsWidget(window), m_model(new QStandardItemModel(this)), m_isLoading(true), m_ui(new Ui::HistoryContentsWidget) { m_ui->setupUi(this); QStringList groups; groups << tr("Today") << tr("Yesterday") << tr("Earlier This Week") << tr("Previous Week") << tr("Earlier This Month") << tr("Earlier This Year") << tr("Older"); for (int i = 0; i < groups.count(); ++i) { m_model->appendRow(new QStandardItem(Utils::getIcon(QLatin1String("inode-directory")), groups.at(i))); } QStringList labels; labels << tr("Address") << tr("Title") << tr("Date"); m_model->setHorizontalHeaderLabels(labels); m_model->setSortRole(Qt::DisplayRole); m_ui->historyView->setModel(m_model); m_ui->historyView->setItemDelegate(new ItemDelegate(this)); m_ui->historyView->header()->setTextElideMode(Qt::ElideRight); m_ui->historyView->header()->setSectionResizeMode(0, QHeaderView::Stretch); m_ui->historyView->expand(m_model->index(0, 0)); QTimer::singleShot(100, this, SLOT(populateEntries())); connect(HistoryManager::getInstance(), SIGNAL(cleared()), this, SLOT(populateEntries())); connect(HistoryManager::getInstance(), SIGNAL(entryAdded(qint64)), this, SLOT(addEntry(qint64))); connect(HistoryManager::getInstance(), SIGNAL(entryUpdated(qint64)), this, SLOT(updateEntry(qint64))); connect(HistoryManager::getInstance(), SIGNAL(entryRemoved(qint64)), this, SLOT(removeEntry(qint64))); connect(HistoryManager::getInstance(), SIGNAL(dayChanged()), this, SLOT(populateEntries())); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterHistory(QString))); connect(m_ui->historyView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openEntry(QModelIndex))); connect(m_ui->historyView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); }
bool MlCache::doCopy(const std::string & name) { std::cout<<"copy cache to "<<name; useDocument(); openEntry("/ang"); int nang = entrySize("/ang"); if(nang < 1) return false; std::vector<std::string> sliceNames; unsigned numSlices = cacheSliceNames("/ang", sliceNames); std::cout<<" n slice "<<numSlices<<"in /ang\n"; if(numSlices < 2) return false; openEntry("/tang"); int tsize = entrySize("/tang"); openEntry("/p"); int ptsize = entrySize("/p"); MlCache tgt; if(!tgt.create(name)) return false; tgt.useDocument(); tgt.openEntry("/info"); HBase *info = tgt.getNamedEntry("/info"); info->addStringAttr(".scene", m_sceneName.size()); info->writeStringAttr(".scene", m_sceneName); info->addIntAttr(".range", 2); info->writeIntAttr(".range", m_bakeRange); tgt.closeEntry("/info"); tgt.openEntry("/ang"); tgt.saveEntrySize("/ang", nang); tgt.openEntry("/tang"); tgt.saveEntrySize("/tang", tsize); tgt.openEntry("/p"); tgt.saveEntrySize("/p", ptsize); const unsigned blockL = 4096; float * b = new float[blockL]; Vector3F * bp = new Vector3F[blockL]; Matrix33F * bm = new Matrix33F[blockL]; BoundingBox box; Vector3F center; unsigned i, j, start, count; for(i = 0; i < sliceNames.size(); i++) { std::string aslice = HObject::PartialPath("/ang", sliceNames[i]); if(aslice == "-9999") continue; useDocument(); openSliceFloat("/ang", aslice); openSliceVector3("/p", aslice); openSliceMatrix33("/tang", aslice); tgt.useDocument(); tgt.openSliceFloat("/ang", aslice); tgt.openSliceVector3("/p", aslice); tgt.openSliceMatrix33("/tang", aslice); start = 0; count = blockL; for(j = 0; j <= nang/blockL; j++) { if(j== nang/blockL) count = nang%blockL; start = j * blockL; useDocument(); readSliceFloat("/ang", aslice, start, count, b); tgt.useDocument(); tgt.writeSliceFloat("/ang", aslice, start, count, b); } start = 0; count = blockL; for(j = 0; j <= tsize/blockL; j++) { if(j== tsize/blockL) count = tsize%blockL; start = j * blockL; useDocument(); readSliceVector3("/p", aslice, start, count, bp); readSliceMatrix33("/tang", aslice, start, count, bm); tgt.useDocument(); tgt.writeSliceVector3("/p", aslice, start, count, bp); tgt.writeSliceMatrix33("/tang", aslice, start, count, bm); } useDocument(); closeSlice("/ang", aslice); closeSlice("/tang", aslice); closeSlice("/p", aslice); tgt.useDocument(); tgt.closeSlice("/ang", aslice); tgt.closeSlice("/tang", aslice); tgt.closeSlice("/p", aslice); getBounding(aslice, box); getTranslation(aslice, center); tgt.setBounding(aslice, box); tgt.setTranslation(aslice, center); tgt.flush(); } delete[] b; delete[] bp; delete[] bm; useDocument(); closeEntry("/ang"); closeEntry("/tang"); closeEntry("/p"); tgt.useDocument(); tgt.closeEntry("/ang"); tgt.closeEntry("/tang"); tgt.closeEntry("/p"); tgt.close(); return true; }