X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fflag.cpp;h=662a6d02d56df89ada5671e4d4b62fe61c8da967;hb=d8d053b6e51abf651ca31d0d4822035c06fb7f9b;hp=53b0feefa07b77c4ecce071b99358490a4fe6012;hpb=8914fe790fb677c56194a3ae4da06ba671fca78a;p=pulseview.git
diff --git a/pv/view/flag.cpp b/pv/view/flag.cpp
index 53b0fee..662a6d0 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,26 +23,30 @@
#include
#include
#include
+#include
-#include
+#include
#include
+using std::enable_shared_from_this;
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)
{
}
Flag::Flag(const Flag &flag) :
- TimeMarker(flag.view_, FillColour, flag.time_)
+ TimeMarker(flag.view_, FillColour, flag.time_),
+ enable_shared_from_this(flag)
{
}
@@ -59,7 +62,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);
@@ -73,11 +81,34 @@ 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()));
+}
+
void Flag::on_text_changed(const QString &text)
{
text_ = text;
view_.time_item_appearance_changed(true, false);
}
-} // namespace view
+} // namespace TraceView
+} // namespace views
} // namespace pv