X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fflag.cpp;h=95cee716de453e6e288a4b1a2b1cce807b52ee88;hp=2ee8ced4972413439d67ba938014c2dee5617e46;hb=efdec55aec1a137460fa362a381ed1904182bfed;hpb=dbfae3f1b55b984c7ee7e619a8da53b77db98c90 diff --git a/pv/view/flag.cpp b/pv/view/flag.cpp index 2ee8ced4..95cee716 100644 --- a/pv/view/flag.cpp +++ b/pv/view/flag.cpp @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include "timemarker.hpp" @@ -24,19 +23,21 @@ #include #include #include +#include -#include +#include #include using std::shared_ptr; namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor Flag::FillColour(0x73, 0xD2, 0x16); -Flag::Flag(View &view, double time, const QString &text) : +Flag::Flag(View &view, const pv::util::Timestamp& time, const QString &text) : TimeMarker(view, FillColour, time), text_(text) { @@ -44,7 +45,7 @@ Flag::Flag(View &view, double time, const QString &text) : Flag::Flag(const Flag &flag) : TimeMarker(flag.view_, FillColour, flag.time_), - std::enable_shared_from_this(flag) + std::enable_shared_from_this(flag) { } @@ -60,7 +61,12 @@ QString Flag::get_text() const pv::widgets::Popup* Flag::create_popup(QWidget *parent) { - pv::widgets::Popup *const popup = TimeMarker::create_popup(parent); + using pv::widgets::Popup; + + Popup *const popup = TimeMarker::create_popup(parent); + popup->set_position(parent->mapToGlobal( + point(parent->rect())), Popup::Bottom); + QFormLayout *const form = (QFormLayout*)popup->layout(); QLineEdit *const text_edit = new QLineEdit(popup); @@ -74,7 +80,24 @@ pv::widgets::Popup* Flag::create_popup(QWidget *parent) return popup; } +QMenu* Flag::create_context_menu(QWidget *parent) +{ + QMenu *const menu = new QMenu(parent); + + QAction *const del = new QAction(tr("Delete"), this); + del->setShortcuts(QKeySequence::Delete); + connect(del, SIGNAL(triggered()), this, SLOT(on_delete())); + menu->addAction(del); + + return menu; +} + void Flag::delete_pressed() +{ + on_delete(); +} + +void Flag::on_delete() { view_.remove_flag(shared_ptr(shared_from_this())); } @@ -85,5 +108,6 @@ void Flag::on_text_changed(const QString &text) view_.time_item_appearance_changed(true, false); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv