9#include <QStringListModel>
21#include <boost/scope_exit.hpp>
36 this_virtue ( virtue )
47base::base ( std::shared_ptr<editor_data_state> editordata,
48 QWidget * parent,
bool owned )
51 p_data_editor ( editordata ),
52 this_is_owned ( owned ),
53 this_value_changed ( false ),
54 this_initial_load ( false )
109 IsMultiValue ( false ),
110 StatusBar ( nullptr ),
111 ContextMenu ( nullptr ),
112 RemoveAction ( nullptr ),
114 MoveBottom ( nullptr ),
116 MoveDown ( nullptr ),
117 EditAction ( nullptr ),
118 CurrentItem ( nullptr )
124 setWindowTitle ( QString (
"Edit Relationship: %1" ).arg ( Virtue.
p_name.c_str() ) );
125 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
126 ComboBox->setHidden (
true );
149 SaveButton->setHidden (
true );
150 RemoveButton->setHidden (
true );
158 if(
dynamic_cast<QListWidget*
>(Target)) {
159 auto decode = [
this] (
const QMimeData *
const data) -> QPair<bool, QStringList>
162 QStringList newItems;
164 if(data->hasFormat(
"application/vnd.text.list") ==
true) {
165 QByteArray encodedData = data->data(
"application/vnd.text.list");
166 QDataStream stream(&encodedData, QIODevice::ReadOnly);
170 while(!stream.atEnd()) {
174 const QString& obj_id = text.at(0);
175 const QString& obj_class = text.at(1);
177 if((obj_class.toStdString() == referenceClass) ||
180 newItems.append(obj_id);
189 return qMakePair(allGood, newItems);
192 if(Event->type() == QEvent::DragEnter) {
193 QDragEnterEvent *tDropEvent =
static_cast<QDragEnterEvent *
>(Event);
195 const QMimeData *
const data = tDropEvent->mimeData();
196 const auto& decodedData = decode(data);
197 if((decodedData.first ==
true) && (decodedData.second.size() > 0)) {
198 tDropEvent->acceptProposedAction();
204 if(Event->type() == QEvent::Drop) {
205 QDropEvent *tDropEvent =
static_cast<QDropEvent *
>(Event);
207 const QMimeData *
const data = tDropEvent->mimeData();
208 for(
const QString& o : decode(data).second) {
213 tDropEvent->acceptProposedAction();
217 }
else if(QComboBox * Box =
dynamic_cast<QComboBox *
>(Target)) {
218 if(Event->type() == QEvent::Wheel) {
222 if(Event->type() == QEvent::KeyPress) {
223 QKeyEvent * KeyEvent =
dynamic_cast<QKeyEvent *
>(Event);
225 if(KeyEvent->key() == Qt::Key_Up || KeyEvent->key() == Qt::Key_Down) {
232 if(Event->type() == QEvent::FocusOut) {
233 QWidget * popup = Box->findChild<QFrame *>();
234 QWidget * popup1 = Box->lineEdit()->findChild<QFrame *>();
236 if(popup != popup1 and not popup->isHidden()) {
242 FirstItem =
new QListWidgetItem(
"Type here");
245 FirstItem =
new QListWidgetItem(
"No Object");
254 FirstItem->setBackgroundColor(Qt::GlobalColor::lightGray);
255 FirstItem->setTextColor(QColor(0, 0, 0, 127));
259 }
else if(
FirstItem->listWidget() == ListWidget && ListWidget->itemWidget(
FirstItem) != 0) {
260 ListWidget->takeItem(ListWidget->row(
FirstItem));
261 ListWidget->setItemWidget(
FirstItem,
nullptr);
265 FirstItem =
new QListWidgetItem(
"Type here");
268 FirstItem =
new QListWidgetItem(
"No Object");
277 FirstItem->setBackgroundColor(Qt::GlobalColor::lightGray);
278 FirstItem->setTextColor(QColor(0, 0, 0, 127));
286 }
else if(QLineEdit* le =
dynamic_cast<QLineEdit *
>(Target)) {
287 if(Event->type() == QEvent::MouseButtonDblClick) {
288 const QString& value = le->text();
291 if((value.isEmpty() ==
false) && (value !=
"Type here") && (value !=
"No Object")) {
312 ListWidget->setAcceptDrops (
true );
313 ListWidget->installEventFilter (
this );
318 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
319 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
320 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
335 std::vector<tref>
const & related
340 for (
tref const & o : related )
342 result.append ( QString::fromStdString ( o.UID() ) );
356 ComboBox->addItems ( ListOfObjects );
368 connect ( SaveButton, SIGNAL ( clicked() ),
this, SLOT (
EndSignal() ) );
375 connect ( ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
377 connect ( ListWidget, SIGNAL ( itemDoubleClicked ( QListWidgetItem * ) ),
this,
379 connect ( ListWidget->model(), SIGNAL ( layoutChanged() ),
this, SLOT (
DummyMovement() ) );
380 connect ( ListWidget, SIGNAL ( itemPressed ( QListWidgetItem * ) ),
this,
392 FirstItem =
new QListWidgetItem (
"Type here" );
398 FirstItem =
new QListWidgetItem (
"No Object" );
411 FirstItem->setBackgroundColor ( Qt::GlobalColor::lightGray );
412 FirstItem->setTextColor ( QColor ( 0, 0, 0, 127 ) );
422 QString (
"Relationship Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
423 " Type: %1 \n" ).arg ( Virtue.
p_type.c_str() )
424 + QString (
" Cardinality: %1 \n" ).arg (
427 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
434 QString oname = QString::fromStdString ( obj.full_name() );
436 for ( QWidget * editor : QApplication::allWidgets() )
440 if ( ( w->objectName() ).compare ( oname ) == 0 )
443 w->setVisible (
true );
460 std::string
const & ouid =
Item->data ( Qt::DisplayRole ).toString().toStdString();
470 MoveTop =
new QAction ( tr (
"Move Top" ),
this );
471 MoveTop->setShortcutContext ( Qt::WidgetShortcut );
475 MoveBottom =
new QAction ( tr (
"Move Bottom" ),
this );
476 MoveBottom->setShortcutContext ( Qt::WidgetShortcut );
480 MoveUp =
new QAction ( tr (
"Move Up" ),
this );
481 MoveUp->setShortcutContext ( Qt::WidgetShortcut );
485 MoveDown =
new QAction ( tr (
"Move Down" ),
this );
486 MoveDown->setShortcutContext ( Qt::WidgetShortcut );
492 EditAction =
new QAction ( tr (
"Edit" ),
this );
493 EditAction->setShortcutContext ( Qt::WidgetShortcut );
498 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
503 if ( (
CurrentItem = ListWidget->itemAt ( pos ) ) )
507 (
ContextMenu->actions() ).at ( 0 )->setVisible (
true );
508 (
ContextMenu->actions() ).at ( 1 )->setVisible (
true );
509 (
ContextMenu->actions() ).at ( 2 )->setVisible (
true );
510 (
ContextMenu->actions() ).at ( 3 )->setVisible (
true );
511 (
ContextMenu->actions() ).at ( 4 )->setVisible (
true );
512 (
ContextMenu->actions() ).at ( 5 )->setVisible (
false );
513 (
ContextMenu->actions() ).at ( 6 )->setVisible (
true );
515 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
520 (
ContextMenu->actions() ).at ( 0 )->setVisible (
false );
521 (
ContextMenu->actions() ).at ( 1 )->setVisible (
false );
522 (
ContextMenu->actions() ).at ( 2 )->setVisible (
false );
523 (
ContextMenu->actions() ).at ( 3 )->setVisible (
false );
524 (
ContextMenu->actions() ).at ( 4 )->setVisible (
true );
525 (
ContextMenu->actions() ).at ( 5 )->setVisible (
true );
526 (
ContextMenu->actions() ).at ( 6 )->setVisible (
true );
528 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
540 int ItemPosition = ListWidget->row (
CurrentItem );
552 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
553 ListWidget->setCurrentRow ( index );
560 int ItemPosition = ListWidget->row (
CurrentItem );
572 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
573 ListWidget->setCurrentRow ( index );
580 int ItemPosition = ListWidget->row (
CurrentItem );
583 if ( ItemPosition != 0 )
585 this_data.swap ( ItemPosition, ItemPosition - 1 );
593 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
594 ListWidget->setCurrentRow ( index );
602 int ItemPosition = ListWidget->row (
CurrentItem );
605 if ( ItemPosition != (
this_data.size() - 1 ) )
607 this_data.swap ( ItemPosition, ItemPosition + 1 );
615 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
616 ListWidget->setCurrentRow ( index );
624 if ( QComboBox * ComboBox =
dynamic_cast<QComboBox *
> ( ListWidget->itemWidget (
628 ComboBox->lineEdit()->setFocus();
638 QString
const & editorname = QString::fromStdString ( obj.full_name() );
640 for ( QWidget * editor :
641 QApplication::allWidgets()
646 if ( ( w->objectName() ).compare ( editorname ) == 0 )
649 w->setVisible (
true );
673 QStringList ListOfObjects;
675 for (
int i = 0; i < ComboBox->count(); ++i )
677 ListOfObjects.append ( ComboBox->itemText ( i ) );
680 QComboBox * NewComboBox =
new QComboBox (
this );
682 NewComboBox->setLineEdit (
new QLineEdit() );
684 NewComboBox->addItems ( ListOfObjects );
686 QCompleter * Completer =
new QCompleter ( ListOfObjects );
687 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
688 Completer->setFilterMode(Qt::MatchContains);
690 NewComboBox->lineEdit()->setCompleter ( Completer );
692 NewComboBox->setEditable (
true );
694 NewComboBox->setEditText (
Item->text() );
696 if ( ListOfObjects.size() > 0 )
698 NewComboBox->lineEdit()->selectAll();
703 NewComboBox->setEnabled (
false );
706 QVariant VariantFromList ( ListOfObjects );
708 NewComboBox->setValidator ( MyCustomValidator );
709 NewComboBox->installEventFilter (
this );
711 connect ( NewComboBox, SIGNAL ( activated (
const QString & ) ),
this,
714 NewComboBox->lineEdit()->installEventFilter(
this);
716 ListWidget->setItemWidget (
FirstItem, NewComboBox );
721 if (
IsMultiValue and ListWidget->item ( 0 )->text() ==
"Type here"
732 for (
int i = 0; i != ListWidget->count(); ++i )
734 QListWidgetItem *
Item = ListWidget->item ( i );
735 QString
const & val =
Item->text();
737 if ( val !=
"Type here" and val !=
"No Object" )
772 int index =
this_data.indexOf ( DataValue );
773 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
774 ListWidget->setCurrentRow ( index );
778 FirstItem =
new QListWidgetItem (
"Type here" );
782 FirstItem =
new QListWidgetItem ( DataValue.toStdString().c_str() );
789 FirstItem->setBackgroundColor ( Qt::GlobalColor::lightGray );
790 FirstItem->setTextColor ( QColor ( 0, 0, 0, 127 ) );
803 QList<QListWidgetItem *> items;
807 items = ListWidget->selectedItems();
815 if ( items.size() > 0 )
818 for ( QListWidgetItem * item : items )
820 QString text = item->text();
822 if ( text !=
"Type here" )
826 if ( QListWidgetItem * toremove = ListWidget->takeItem ( ListWidget->row ( item ) ) )
834 if ( QComboBox * editbox =
dynamic_cast<QComboBox *
> ( ListWidget->itemWidget (
838 editbox->lineEdit()->clear();
839 editbox->lineEdit()->clearFocus();
856 for (
int i = 0; i < ListWidget->count(); ++i )
858 QString
const & value = ListWidget->item ( i )->text();
860 if ( value !=
"No Object" and value !=
"Type here" )
862 values.append ( value );
868 if ( values.size() > 0 )
871 ListWidget->setPalette ( QApplication::palette (
this ) );
910 PopUpButton ( nullptr ),
912 OkButtonDialog ( nullptr ),
913 TextEditDialog ( nullptr )
918 StringLineEdit->installEventFilter(
this);
919 StringLineEdit->setTabChangesFocus(
true);
921 setWindowTitle ( QString (
"Edit Attr : %1" ).arg ( virtue.
p_name.c_str() ) );
922 AttributeNameLabel->setText ( QString ( virtue.
p_name.c_str() ) +
" : " );
924 AttributeNameLabel->setHidden (
true );
932 OkButton->setDisabled (
true );
942 StringLineEdit->setPalette ( QApplication::palette (
this ) );
945 OkButton->setHidden (
true );
949 connect ( StringLineEdit, SIGNAL ( StringValidated() ),
this, SLOT (
AddToDataList() ),
950 Qt::UniqueConnection );
951 OkButton->setHidden (
true );
959 AttributeNameLabel->setFocus();
975 StringLineEdit->setText (
this_data.value ( 0 ) );
982 return StringLineEdit;
987 StringLineEdit->SetNullCheck ( Check );
992 StringLineEdit->SetMultiCheck ( Multi );
997 StringLineEdit->SetCheckDefault ( Default );
1002 StringLineEdit->selectAll();
1007 if (target == StringLineEdit)
1009 if (evt->type() == QEvent::FocusIn)
1013 else if (evt->type() == QEvent::KeyPress)
1015 QKeyEvent *kevt =
static_cast<QKeyEvent*
>(evt);
1016 switch (kevt->key())
1019 case Qt::Key_Return:
1021 if ( kevt->modifiers() == Qt::AltModifier)
1023 kevt->setModifiers(Qt::NoModifier);
1027 StringLineEdit->parentWidget()->setFocus(Qt::FocusReason::TabFocusReason);
1051 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
1052 " Type: %1 \n" ).arg (
1054 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
1055 + QString (
" Format: %1 \n" ).arg (
1057 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
1059 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
1060 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
1071 connect ( StringLineEdit, SIGNAL ( textChanged ( ) ),
this, SLOT (
UpdateActions ( ) ), Qt::UniqueConnection );
1073 connect ( OkButton, SIGNAL ( clicked() ),
this, SLOT (
AddToDataList() ), Qt::UniqueConnection );
1079 StringLineEdit->SetDefaultValue ( ValueDefault );
1088 PopUpButton->fontMetrics().boundingRect (
"..." ).width() + 15 );
1090 Qt::UniqueConnection );
1111 OkButton->setEnabled (
true );
1117 OkButton->setEnabled (
true );
1124 QString NewValue = StringLineEdit->toPlainText();
1128 StringLineEdit->setToolTip ( QString (
"The set value is : %1" ).arg ( NewValue ) );
1152 QVBoxLayout * Layout =
new QVBoxLayout();
1155 Dialog->setWindowTitle ( QString (
"Edit Attr : %1" ).arg ( Virtue.
p_name.c_str() ) );
1160 Dialog->setLayout ( Layout );
1161 Dialog->setModal (
true );
1164 Qt::UniqueConnection );
1166 Qt::UniqueConnection );
1170 TextEditDialog->insertPlainText ( StringLineEdit->toPlainText() );
1176 StringLineEdit->clear();
1204 this_native_base ( -1 )
1209 setWindowTitle ( QString (
"Edit Attribute: %1" ).arg ( Virtue.
p_name.c_str() ) );
1210 LineEdit->SetPopupMenu();
1219 LineEdit->SetNullCheck (
false );
1227 FormatBox->setCurrentIndex ( 2 );
1233 FormatBox->setCurrentIndex ( 0 );
1239 FormatBox->setCurrentIndex ( 1 );
1253 AttributeName->setText ( QString ( Virtue.
p_name.c_str() ) +
" : " );
1254 AttributeName->setHidden (
true );
1257 QString Dummy (
"Dummy" );
1284 if ( not
this_data.value ( 0 ).startsWith (
"0x" ) )
1286 LineEdit->setText (
"0x" +
this_data.value ( 0 ) );
1290 LineEdit->setText (
this_data.value ( 0 ) );
1297 LineEdit->setText (
"0" +
this_data.value ( 0 ) );
1301 LineEdit->setText (
this_data.value ( 0 ) );
1306 LineEdit->setText (
this_data.value ( 0 ) );
1315 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
1316 " Type: %1 \n" ).arg (
1318 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
1319 + QString (
" Format: %1 \n" ).arg (
1321 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
1323 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
1324 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
1335 connect ( LineEdit, SIGNAL ( DecChange() ),
this, SLOT (
ChangeFormatDec() ) );
1336 connect ( LineEdit, SIGNAL ( OctChange() ),
this, SLOT (
ChangeFormatOct() ) );
1337 connect ( LineEdit, SIGNAL ( HexChange() ),
this, SLOT (
ChangeFormatHex() ) );
1339 connect ( FormatBox, SIGNAL ( currentIndexChanged (
int ) ),
1340 this, SLOT (
ChangeFormat (
int ) ), Qt::UniqueConnection );
1342 connect ( LineEdit, SIGNAL ( editingFinished() ),
1343 this, SLOT (
AddToList() ), Qt::UniqueConnection );
1344 connect ( LineEdit, SIGNAL ( textChanged ( QString ) ),
1345 this, SLOT (
UpdateActions ( QString ) ), Qt::UniqueConnection );
1346 connect ( LineEdit, SIGNAL ( returnPressed () ),
1357 QString Message = QString (
"The value for attribute %1 is in the wrong format" ).arg (
1362 QString RangeMex = QString (
" - The value should be in the range : %1" ).arg ( Range );
1363 Message.append (
"\n\n" + RangeMex );
1368 Message.append ( QString (
"\n\n - The value should be formatted as a %1." ).arg (
1372 QMessageBox::warning (
this, tr (
"Wrong value" ), Message );
1378 auto checkInteger = [
this, text]()
1382 bool convert_to_defined_base;
1384 qlonglong NewLongLong{0};
1385 qulonglong NewULongLong{0};
1387 auto check_convert = [
this, &convert_to_defined_base]()
1391 if ( not convert_to_defined_base )
1417 NewULongLong = text.toULongLong ( &convert_to_defined_base,
this_base );
1419 if ( not check_convert() )
1445 max_u = ULONG_LONG_MAX;
1452 if ( min_u <= NewULongLong and NewULongLong <= max_u )
1457 ShowWarning (
"", QString (
"[%1 - %2]" ).arg ( min_u ).arg ( max_u ) );
1461 NewLongLong = text.toLongLong ( &convert_to_defined_base,
this_base );
1463 if ( not check_convert() )
1488 min_s = - ( LONG_LONG_MAX ) - 1;
1489 max_s = LONG_LONG_MAX;
1496 if ( min_s <= NewLongLong and NewLongLong <= max_s )
1501 ShowWarning (
"", QString (
"[%1 - %2]" ).arg ( min_s ).arg ( max_s ) );
1514 QString Range = QString::fromStdString ( Virtue.
p_range );
1516 if ( Range.isEmpty() )
1521 QStringList ValueList = Range.split (
"," );
1523 QList<QPair<QString, QString>> RangeList;
1525 for ( QString & RangeValue : ValueList )
1527 if ( RangeValue.contains (
".." ) )
1529 QStringList Ranges = RangeValue.split (
".." );
1530 RangeList.append ( QPair<QString, QString> ( Ranges.at ( 0 ), Ranges.at ( 1 ) ) );
1531 ValueList.removeOne ( RangeValue );
1535 if ( ValueList.contains ( Value ) )
1540 for ( QPair<QString, QString> & ValuePair : RangeList )
1542 if ( ValuePair.first ==
"*" )
1544 if ( Value.toDouble() <= ValuePair.second.toDouble() )
1554 else if ( ValuePair.second ==
"*" )
1556 if ( Value.toDouble() >= ValuePair.first.toDouble() )
1568 if ( ( Value.toDouble() >= ValuePair.first.toDouble() ) &&
1569 ( Value.toDouble() <= ValuePair.second.toDouble() ) )
1587 bool validValue =
true;
1601 Value.toDouble(&ok);
1619 if (
this_data.contains(LineEdit->text()) ) {
1628 if (
this_data.contains(LineEdit->text()) ) {
1632 auto convert_to_proper_base = [
this] (
const QString& value) -> QString {
1642 if(Unsigned ==
true) {
1650 if(cnvrtd.startsWith(
"0") ==
false) {
1651 cnvrtd.insert(0,
"0");
1653 LineEdit->EmitOctSlot();
1655 LineEdit->EmitDecSlot();
1657 if(cnvrtd.startsWith(
"0x", Qt::CaseInsensitive) ==
false) {
1658 cnvrtd.insert(0,
"0x");
1660 LineEdit->EmitHexSlot();
1672 LineEdit->blockSignals (
true );
1674 BOOST_SCOPE_EXIT(this_)
1676 this_->LineEdit->blockSignals (
false );
1678 BOOST_SCOPE_EXIT_END
1680 bool isValid =
true;
1682 QString input = LineEdit->text();
1702 this_data.append ( convert_to_proper_base(input) );
1706 if(isValid ==
true) {
1707 QString Dummy (
"Dummy" );
1717 if(isValid ==
true) {
1734 QString CurrentString = LineEdit->text();
1736 if ( CurrentString.isEmpty() )
1760 QString ConvertedString;
1766 bool OkConversion =
false;
1774 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 10 );
1778 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 10 );
1789 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 8 );
1793 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 8 );
1796 ConvertedString.insert(0,
"0");
1805 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 16 );
1809 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 16 );
1812 ConvertedString.insert(0,
"0x");
1816 if ( !OkConversion )
1826 Format =
"HEX-DECIMAL";
1830 Format =
"OCT-DECIMAL";
1838 if ( !ConvertedString.isEmpty() )
1841 LineEdit->setText ( ConvertedString );
1890 Combo->setFocusPolicy ( Qt::ClickFocus );
1891 Combo->installEventFilter (
this );
1893 if ( Combo->lineEdit() !=
nullptr )
1895 Combo->lineEdit()->installEventFilter (
this );
1902 Combo->setEditable (
true );
1908 if ( Data.isEmpty() )
1913 int Index = Combo->findText ( Data.value ( 0 ) );
1917 Combo->setCurrentIndex ( Index );
1918 Combo->setEditText ( Data.value ( 0 ) );
1925 Combo->addItems ( Data );
1927 QCompleter * Completer =
new QCompleter ( Combo->model(), Combo );
1928 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
1929 Completer->setCompletionMode ( QCompleter::PopupCompletion );
1930 Completer->setFilterMode(Qt::MatchContains);
1932 Combo->setCompleter ( Completer );
1936 QVariant VarFromList ( Data );
1938 if ( AcceptNoMatch )
1941 Combo->setValidator ( TmpValidator );
1947 Combo->setValidator ( TmpValidator );
1965 {
"true",
"false" };
1970 QString rangename = virt.
p_range.c_str();
1971 QStringList range = rangename.split (
"," );
1992 if ( Target == Combo->lineEdit() && Event->type() == QEvent::MouseButtonRelease )
1994 if ( !Combo->lineEdit()->hasSelectedText() )
1996 Combo->lineEdit()->selectAll();
2001 if ( Event->type() == QEvent::Wheel )
2017 connect ( Combo, SIGNAL ( editTextChanged (
const QString & ) ),
this,
2018 SLOT (
TryValidate (
const QString & ) ), Qt::UniqueConnection );
2019 connect ( Combo, SIGNAL ( activated (
const QString & ) ),
this,
2020 SLOT (
ChangeDetected (
const QString & ) ), Qt::UniqueConnection );
2021 connect ( Combo, SIGNAL ( currentIndexChanged (
int ) ),
this,
2023 Qt::UniqueConnection );
2030 if ( Combo->validator() !=
nullptr )
2032 if ( Combo->validator()->validate ( tmp, index ) == QValidator::Acceptable )
2043 Combo->setPalette ( QApplication::palette (
this ) );
2047 else if ( Combo->validator()->validate ( tmp, index ) == QValidator::Intermediate )
2062 Combo->setPalette ( QApplication::palette (
this ) );
2069 Q_UNUSED ( StringChange )
2076 Q_UNUSED ( DefaultIndex )
2110 StatusBar ( nullptr ),
2111 OkButton ( nullptr ),
2112 RemoveButton ( nullptr ),
2113 ListWidget ( nullptr ),
2114 ContextMenu ( nullptr ),
2115 RemoveAction ( nullptr )
2119 setWindowTitle ( QString (
"Edit Attribute : %1" ).arg ( Virtue.
p_name.c_str() ) );
2120 QVBoxLayout * MainLayout =
new QVBoxLayout (
this );
2121 MainLayout->setSpacing ( 0 );
2122 MainLayout->setMargin ( 0 );
2123 MainLayout->setContentsMargins ( 0, 0, 0, 0 );
2124 QHBoxLayout * ButtonLayout =
new QHBoxLayout();
2126 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
2137 MainLayout->addWidget ( Combo );
2138 connect ( Combo->Combo, SIGNAL ( activated (
const QString & ) ),
this,
2139 SLOT (
AddToDataList (
const QString & ) ), Qt::UniqueConnection );
2159 MainLayout->addWidget ( Numeric );
2161 Qt::UniqueConnection );
2162 connect ( Numeric, SIGNAL ( signal_value_duplicated() ),
this, SLOT (
LineValueChanged() ),
2163 Qt::UniqueConnection );
2167 Numeric->
GetLineEdit()->setPlaceholderText (
"Type Here" );
2168 Numeric->setStyleSheet (
2169 "QLineEdit { background: #c0c0c0;} QLineEdit:focus {background: white;}" );
2171 ListWidget->setFrameStyle ( QFrame::NoFrame );
2182 String->SetMultiCheck (
true );
2183 MainLayout->addWidget ( String );
2185 Qt::UniqueConnection );
2188 String->GetLineEdit()->setFrameStyle(QFrame::NoFrame);
2190 String->setStyleSheet (
"QLineEdit { background: #c0c0c0;} "
2191 "QLineEdit:focus {background: white;}" );
2194 ListWidget->setFrameStyle ( QFrame::NoFrame );
2202 OkButton =
new QPushButton ( tr (
"Apply" ) );
2204 ButtonLayout->addWidget (
OkButton );
2209 connect (
ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
2213 MainLayout->addLayout ( ButtonLayout );
2217 setLayout ( MainLayout );
2233 QFontMetrics FontMetrics ( Font );
2235 2 * FontMetrics.width ( QString (
"Edit Relationship: %1" ).arg ( Virtue.
p_name.c_str() ) )
2237 setMinimumHeight ( 100 );
2250 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
2253 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
2254 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
2256 for (
int i = 0; i <
ListWidget->count(); ++i )
2258 QListWidgetItem * widget =
ListWidget->item ( i );
2260 Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled
2261 | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled );
2265 connect (
ListWidget, SIGNAL ( itemChanged ( QListWidgetItem * ) ),
this,
2275 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
2276 " Type: %1 \n" ).arg (
2278 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
2279 + QString (
" Format: %1 \n" ).arg (
2281 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
2283 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
2284 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
2296 StatusBar->setSizeGripEnabled (
false );
2298 StatusBar->setAutoFillBackground (
true );
2312 if ( Data.isEmpty() )
2321 StatusBar->showMessage ( QString (
"Item %1 was added." ).arg ( Data ) );
2329 QList<QListWidgetItem *> widgets =
ListWidget->selectedItems();
2332 for ( QListWidgetItem * widget : widgets )
2334 int index =
this_data.indexOf ( widget->text() );
2343 if ( QListWidgetItem * w =
ListWidget->takeItem ( r ) )
2352 StatusBar->showMessage (
"The selected items were removed." );
2376 StatusBar->showMessage (
"Attribute can not be null." );
2386 StatusBar->showMessage (
"Attribute is set." );
2387 ListWidget->setPalette ( QApplication::palette (
this ) );
2416 QString newtext = changed->text();
2421 StatusBar->showMessage ( QString (
"Item %1 was modified." ).arg ( oldtext ) );
2428 Q_UNUSED ( IndexList )
2432 for (
int i = 0; i <
ListWidget->count(); ++i )
2442 for (
int i = 0; i <
ListWidget->count(); ++i )
2466 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
2468 Qt::UniqueConnection );
static QPalette AlertStatusBarPallete
static QPalette LoadedDefault
static QPalette WarningStatusBarPallete
static confaccessor & ref()
static bool derived(std::string const &fromclass, std::string const &aclass)
static std::vector< dbe::inner::configobject::tref > objects(std::string const &cname, bool const keep_inherited=true)
virtual ~editor_data_state()
editor_data(T const &virtue)
static configobject::tref get(dbe::cokey const &desc)
int_format_t p_int_format
std::string p_description
std::string p_default_value
static const char * type2str(type_t type)
static const char * format2str(int_format_t format)
cardinality_t p_cardinality
static const char * card2str(cardinality_t cardinality)
std::string p_description