1
////////////////////////////////////////////////////////////////////////////////
2
/*! @file NetWidgets.cpp Простенькие виджеты для работы с объектами RANet.
3
- Part of RAGUI - Research Assistant Graphical User Interface.
4
- Uses QtGui v.4.6 - http://qt.nokia.com/
5
- Uses RANet - Research Assistant Net Library (based on ANSI C++).
6
- Copyright(C) 2010, Viktor E. Bursian, St.Petersburg, Russia.
7
Viktor.Bursian@mail.ioffe.ru
8
*///////////////////////////////////////////////////////////////////////////////
9
#include "NetWidgets.h"
11
#include "GeneralGUI.h"
12
#include "Net2TreeEvolution.h"
13
#include <QMessageBox>
16
//------------------------------------------------------------------------------
17
//---------------------------------------------------------- sDropNodeWidget ---
19
sDropNodeWidget::sDropNodeWidget (QWidget * parent)
21
,Prompt(QString2sString(tr("drop datanet node here")))
23
SetValue(sNodePtr(NULL));
24
setStyleSheet("QLabel {background: white; "
25
"border: 1px solid grey; border-radius: 4px; padding: 2px;}");
27
setMinimumWidth(height());
31
void sDropNodeWidget::Clear ()
33
SetValue(sNodePtr(NULL));
37
void sDropNodeWidget::SetValue (sNodePtr V)
39
bool ValueChanged = ! (V == Value);
43
setToolTip(sString2QString(Prompt));
45
sString T(Value->Text(HTML));
46
setText(sString2QString(T));
47
/*! @todo{UI trifles} show ToolTip if text goes out of the borders*/
48
if( T.Length() > 20 ){
49
setToolTip(sString2QString(T));
51
setToolTip(QString());
54
if( ValueChanged ) emit Changed();
58
void sDropNodeWidget::mouseReleaseEvent (QMouseEvent * event)
60
if( event->button() == Qt::LeftButton )
61
QMessageBox::information(parentWidget()
62
,tr("Link to a datanet node")
63
,tr("This field may (or should) contain a link to "
64
"another element of data. \n\n")
65
+sString2QString(Prompt));
69
void sDropNodeWidget::contextMenuEvent (QContextMenuEvent * event)
71
QMenu PopupMenu(parentWidget());
72
PopupMenu.addAction("Clear",this,SLOT(Clear()));
73
PopupMenu.exec(event->globalPos());
77
void sDropNodeWidget::dragEnterEvent (QDragEnterEvent * event)
80
->hasFormat(sString2QString(sNet2TreeEvolution::sItem::MimeType)) ){
81
event->setDropAction(Qt::LinkAction);
87
void sDropNodeWidget::dropEvent (QDropEvent * event)
90
->hasFormat(sString2QString(sNet2TreeEvolution::sItem::MimeType)) ){
91
event->setDropAction(Qt::LinkAction);
93
SetValue(sNet2TreeEvolution::sItem::DraggedItem->AttrValue());
97
//------------------------------------------------------------------------------