mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Press Alt-B while selecting in daily view to add bookmark.
This commit is contained in:
parent
eb4ba53b08
commit
df122db7a4
@ -675,6 +675,16 @@ double gGraph::currentTime() const
|
||||
{
|
||||
return m_graphview->currentTime();
|
||||
}
|
||||
double gGraph::screenToTime(int xpos)
|
||||
{
|
||||
double w = m_rect.width() - left - right;
|
||||
double xx = m_blockzoom ? rmax_x - rmin_x : max_x - min_x;
|
||||
double xmult = xx / w;
|
||||
double x = xpos - m_rect.left() - left;
|
||||
double res = xmult * x;
|
||||
res += m_blockzoom ? rmin_x : min_x;
|
||||
return res;
|
||||
}
|
||||
|
||||
void gGraph::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
@ -850,7 +860,6 @@ void gGraph::mousePressEvent(QMouseEvent *event)
|
||||
//qDebug() << m_title << "Clicked" << x << y << left << right << top << bottom << m_width << m_height;
|
||||
}
|
||||
|
||||
|
||||
void gGraph::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
|
@ -247,6 +247,8 @@ class gGraph : public QObject
|
||||
//! \brief Asks the main gGraphView to redraw after ms milliseconds
|
||||
void timedRedraw(int ms);
|
||||
|
||||
double screenToTime(int xpos);
|
||||
|
||||
//! \brief Sets the margins for the four sides of this graph.
|
||||
void setMargins(short left, short right, short top, short bottom) {
|
||||
m_marginleft = left;
|
||||
@ -314,6 +316,11 @@ class gGraph : public QObject
|
||||
//! \brief Key Pressed event
|
||||
virtual void keyReleaseEvent(QKeyEvent *event);
|
||||
|
||||
void cancelSelection() {
|
||||
m_selecting_area = false;
|
||||
m_selection = QRect(0,0,0,0);
|
||||
}
|
||||
|
||||
void dumpInfo();
|
||||
|
||||
//! \brief Change the current selected time boundaries by mult, from origin position origin_px
|
||||
|
@ -1923,10 +1923,43 @@ void gGraphView::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void gGraphView::getSelectionTimes(qint64 & start, qint64 & end)
|
||||
{
|
||||
if (m_graph_index >= 0) {
|
||||
gGraph *g = m_graphs[m_graph_index];
|
||||
if (!g) {
|
||||
start = 0;
|
||||
end = 0;
|
||||
return;
|
||||
}
|
||||
int x1 = qMin(m_point_clicked.x(), m_point_released.x());
|
||||
int x2 = qMax(m_point_clicked.x(), m_point_released.x());
|
||||
start = g->screenToTime(x1);
|
||||
end = g->screenToTime(x2);
|
||||
}
|
||||
}
|
||||
|
||||
void gGraphView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
// bool meta = m_metaselect;
|
||||
m_metaselect = event->modifiers() & Qt::AltModifier;
|
||||
if (m_metaselect && ((event->key() == Qt::Key_B) || (event->key() == 8747))) {
|
||||
if (mainwin->getDaily()->graphView() == this) {
|
||||
if (m_graph_index >= 0) {
|
||||
m_metaselect=false;
|
||||
qint64 start,end;
|
||||
getSelectionTimes(start,end);
|
||||
QDateTime d1 = QDateTime::fromMSecsSinceEpoch(start);
|
||||
// QDateTime d2 = QDateTime::fromMSecsSinceEpoch(end);
|
||||
|
||||
mainwin->getDaily()->addBookmark(start, end, QString("Bookmark at %1").arg(d1.time().toString("HH:mm:ss")));
|
||||
m_graphs[m_graph_index]->cancelSelection();
|
||||
m_graph_index = -1;
|
||||
timedRedraw(0);
|
||||
}
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_metaselect) && (event->key() >= Qt::Key_0) && (event->key() <= Qt::Key_9)) {
|
||||
int bk = (int)event->key()-Qt::Key_0;
|
||||
|
@ -385,6 +385,8 @@ class gGraphView
|
||||
void dumpInfo();
|
||||
void resetMouse() { m_mouse = QPoint(0,0); }
|
||||
|
||||
void getSelectionTimes(qint64 & start, qint64 & end);
|
||||
|
||||
// for profiling purposes, a count of lines drawn in a single frame
|
||||
int lines_drawn_this_frame;
|
||||
int quads_drawn_this_frame;
|
||||
|
@ -70,6 +70,10 @@ void Session::TrashEvents()
|
||||
QHash<ChannelID, QVector<EventList *> >::iterator i;
|
||||
QHash<ChannelID, QVector<EventList *> >::iterator i_end=eventlist.end();
|
||||
|
||||
if (s_changed) {
|
||||
// Save first..
|
||||
}
|
||||
|
||||
for (i = eventlist.begin(); i != i_end; ++i) {
|
||||
j_end=i.value().end();
|
||||
for (j = i.value().begin(); j != j_end; ++j) {
|
||||
|
@ -1888,7 +1888,7 @@ Session * Daily::CreateJournalSession(QDate date)
|
||||
} else {
|
||||
QDateTime dt(date,QTime(20,0));
|
||||
st=qint64(dt.toTime_t())*1000L;
|
||||
et=st+3600000;
|
||||
et=st+3600000L;
|
||||
}
|
||||
sess->set_first(st);
|
||||
sess->set_last(et);
|
||||
@ -2133,15 +2133,13 @@ void Daily::on_bookmarkTable_itemClicked(QTableWidgetItem *item)
|
||||
GraphView->redraw();
|
||||
}
|
||||
|
||||
void Daily::on_addBookmarkButton_clicked()
|
||||
void Daily::addBookmark(qint64 st, qint64 et, QString text)
|
||||
{
|
||||
qint64 st,et;
|
||||
ui->bookmarkTable->blockSignals(true);
|
||||
GraphView->GetXBounds(st,et);
|
||||
QDateTime d=QDateTime::fromTime_t(st/1000L);
|
||||
int row=ui->bookmarkTable->rowCount();
|
||||
ui->bookmarkTable->insertRow(row);
|
||||
QTableWidgetItem *tw=new QTableWidgetItem(tr("Bookmark at %1").arg(d.time().toString("HH:mm:ss")));
|
||||
QTableWidgetItem *tw=new QTableWidgetItem(text);
|
||||
QTableWidgetItem *dw=new QTableWidgetItem(d.time().toString("HH:mm:ss"));
|
||||
dw->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
|
||||
ui->bookmarkTable->setItem(row,0,dw);
|
||||
@ -2160,8 +2158,15 @@ void Daily::on_addBookmarkButton_clicked()
|
||||
update_Bookmarks();
|
||||
mainwin->updateFavourites();
|
||||
|
||||
//ui->bookmarkTable->setItem(row,2,new QTableWidgetItem(QString::number(st)));
|
||||
//ui->bookmarkTable->setItem(row,3,new QTableWidgetItem(QString::number(et)));
|
||||
}
|
||||
|
||||
void Daily::on_addBookmarkButton_clicked()
|
||||
{
|
||||
qint64 st,et;
|
||||
GraphView->GetXBounds(st,et);
|
||||
QDateTime d=QDateTime::fromTime_t(st/1000L);
|
||||
|
||||
addBookmark(st,et, tr("Bookmark at %1").arg(d.time().toString("HH:mm:ss")));
|
||||
}
|
||||
void Daily::update_Bookmarks()
|
||||
{
|
||||
|
@ -142,6 +142,7 @@ public:
|
||||
void setSidebarVisible(bool visible);
|
||||
void setCalendarVisible(bool visible);
|
||||
|
||||
void addBookmark(qint64 st, qint64 et, QString text);
|
||||
|
||||
private slots:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user