14#include <QStringListModel>
26#include <boost/scope_exit.hpp>
52base::base ( std::shared_ptr<editor_data_state> editordata,
53 QWidget * parent,
bool owned )
129 setWindowTitle ( QString (
"Edit Relationship: %1" ).arg ( Virtue.
p_name.c_str() ) );
130 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
131 ComboBox->setHidden (
true );
154 SaveButton->setHidden (
true );
155 RemoveButton->setHidden (
true );
163 if(
dynamic_cast<QListWidget*
>(Target)) {
164 auto decode = [
this] (
const QMimeData *
const data) -> QPair<bool, QStringList>
167 QStringList newItems;
169 if(data->hasFormat(
"application/vnd.text.list") ==
true) {
170 QByteArray encodedData = data->data(
"application/vnd.text.list");
171 QDataStream stream(&encodedData, QIODevice::ReadOnly);
175 while(!stream.atEnd()) {
179 const QString& obj_id = text.at(0);
180 const QString& obj_class = text.at(1);
182 if((obj_class.toStdString() == referenceClass) ||
185 newItems.append(obj_id);
194 return qMakePair(allGood, newItems);
197 if(Event->type() == QEvent::DragEnter) {
198 QDragEnterEvent *tDropEvent =
static_cast<QDragEnterEvent *
>(Event);
200 const QMimeData *
const data = tDropEvent->mimeData();
201 const auto& decodedData = decode(data);
202 if((decodedData.first ==
true) && (decodedData.second.size() > 0)) {
203 tDropEvent->acceptProposedAction();
209 if(Event->type() == QEvent::Drop) {
210 QDropEvent *tDropEvent =
static_cast<QDropEvent *
>(Event);
212 const QMimeData *
const data = tDropEvent->mimeData();
213 for(
const QString& o : decode(data).second) {
218 tDropEvent->acceptProposedAction();
222 }
else if(QComboBox * Box =
dynamic_cast<QComboBox *
>(Target)) {
223 if(Event->type() == QEvent::Wheel) {
227 if(Event->type() == QEvent::KeyPress) {
228 QKeyEvent * KeyEvent =
dynamic_cast<QKeyEvent *
>(Event);
230 if(KeyEvent->key() == Qt::Key_Up || KeyEvent->key() == Qt::Key_Down) {
237 if(Event->type() == QEvent::FocusOut) {
238 QWidget * popup = Box->findChild<QFrame *>();
239 QWidget * popup1 = Box->lineEdit()->findChild<QFrame *>();
241 if(popup != popup1 and not popup->isHidden()) {
247 FirstItem =
new QListWidgetItem(
"Type here");
250 FirstItem =
new QListWidgetItem(
"No Object");
259 FirstItem->setBackground(Qt::GlobalColor::lightGray);
260 FirstItem->setForeground(QColor(0, 0, 0, 127));
264 }
else if(
FirstItem->listWidget() == ListWidget && ListWidget->itemWidget(
FirstItem) != 0) {
265 ListWidget->takeItem(ListWidget->row(
FirstItem));
266 ListWidget->setItemWidget(
FirstItem,
nullptr);
270 FirstItem =
new QListWidgetItem(
"Type here");
273 FirstItem =
new QListWidgetItem(
"No Object");
282 FirstItem->setBackground(Qt::GlobalColor::lightGray);
283 FirstItem->setForeground(QColor(0, 0, 0, 127));
291 }
else if(QLineEdit* le =
dynamic_cast<QLineEdit *
>(Target)) {
292 if(Event->type() == QEvent::MouseButtonDblClick) {
293 const QString& value = le->text();
296 if((value.isEmpty() ==
false) && (value !=
"Type here") && (value !=
"No Object")) {
317 ListWidget->setAcceptDrops (
true );
318 ListWidget->installEventFilter (
this );
323 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
324 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
325 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
340 std::vector<tref>
const & related
345 for (
tref const & o : related )
347 result.append ( QString::fromStdString ( o.UID() ) );
361 ComboBox->addItems ( ListOfObjects );
373 connect ( SaveButton, SIGNAL ( clicked() ),
this, SLOT (
EndSignal() ) );
380 connect ( ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
382 connect ( ListWidget, SIGNAL ( itemDoubleClicked ( QListWidgetItem * ) ),
this,
384 connect ( ListWidget->model(), SIGNAL ( layoutChanged() ),
this, SLOT (
DummyMovement() ) );
385 connect ( ListWidget, SIGNAL ( itemPressed ( QListWidgetItem * ) ),
this,
397 FirstItem =
new QListWidgetItem (
"Type here" );
403 FirstItem =
new QListWidgetItem (
"No Object" );
416 FirstItem->setBackground ( Qt::GlobalColor::lightGray );
417 FirstItem->setForeground ( QColor ( 0, 0, 0, 127 ) );
427 QString (
"Relationship Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
428 " Type: %1 \n" ).arg ( Virtue.
p_type.c_str() )
429 + QString (
" Cardinality: %1 \n" ).arg (
432 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
439 QString oname = QString::fromStdString ( obj.full_name() );
441 for ( QWidget * editor : QApplication::allWidgets() )
445 if ( ( w->objectName() ).compare ( oname ) == 0 )
448 w->setVisible (
true );
465 std::string
const & ouid =
Item->data ( Qt::DisplayRole ).toString().toStdString();
475 MoveTop =
new QAction ( tr (
"Move Top" ),
this );
476 MoveTop->setShortcutContext ( Qt::WidgetShortcut );
480 MoveBottom =
new QAction ( tr (
"Move Bottom" ),
this );
481 MoveBottom->setShortcutContext ( Qt::WidgetShortcut );
485 MoveUp =
new QAction ( tr (
"Move Up" ),
this );
486 MoveUp->setShortcutContext ( Qt::WidgetShortcut );
490 MoveDown =
new QAction ( tr (
"Move Down" ),
this );
491 MoveDown->setShortcutContext ( Qt::WidgetShortcut );
497 EditAction =
new QAction ( tr (
"Edit" ),
this );
498 EditAction->setShortcutContext ( Qt::WidgetShortcut );
503 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
508 if ( (
CurrentItem = ListWidget->itemAt ( pos ) ) )
512 (
ContextMenu->actions() ).at ( 0 )->setVisible (
true );
513 (
ContextMenu->actions() ).at ( 1 )->setVisible (
true );
514 (
ContextMenu->actions() ).at ( 2 )->setVisible (
true );
515 (
ContextMenu->actions() ).at ( 3 )->setVisible (
true );
516 (
ContextMenu->actions() ).at ( 4 )->setVisible (
true );
517 (
ContextMenu->actions() ).at ( 5 )->setVisible (
false );
518 (
ContextMenu->actions() ).at ( 6 )->setVisible (
true );
520 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
525 (
ContextMenu->actions() ).at ( 0 )->setVisible (
false );
526 (
ContextMenu->actions() ).at ( 1 )->setVisible (
false );
527 (
ContextMenu->actions() ).at ( 2 )->setVisible (
false );
528 (
ContextMenu->actions() ).at ( 3 )->setVisible (
false );
529 (
ContextMenu->actions() ).at ( 4 )->setVisible (
true );
530 (
ContextMenu->actions() ).at ( 5 )->setVisible (
true );
531 (
ContextMenu->actions() ).at ( 6 )->setVisible (
true );
533 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
545 int ItemPosition = ListWidget->row (
CurrentItem );
557 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
558 ListWidget->setCurrentRow ( index );
565 int ItemPosition = ListWidget->row (
CurrentItem );
577 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
578 ListWidget->setCurrentRow ( index );
585 int ItemPosition = ListWidget->row (
CurrentItem );
588 if ( ItemPosition != 0 )
590 this_data.swapItemsAt ( ItemPosition, ItemPosition - 1 );
598 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
599 ListWidget->setCurrentRow ( index );
607 int ItemPosition = ListWidget->row (
CurrentItem );
610 if ( ItemPosition != (
this_data.size() - 1 ) )
612 this_data.swapItemsAt ( ItemPosition, ItemPosition + 1 );
620 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
621 ListWidget->setCurrentRow ( index );
629 if ( QComboBox * ComboBox =
dynamic_cast<QComboBox *
> ( ListWidget->itemWidget (
633 ComboBox->lineEdit()->setFocus();
643 QString
const & editorname = QString::fromStdString ( obj.full_name() );
645 for ( QWidget * editor :
646 QApplication::allWidgets()
651 if ( ( w->objectName() ).compare ( editorname ) == 0 )
654 w->setVisible (
true );
678 QStringList ListOfObjects;
680 for (
int i = 0; i < ComboBox->count(); ++i )
682 ListOfObjects.append ( ComboBox->itemText ( i ) );
685 QComboBox * NewComboBox =
new QComboBox (
this );
687 NewComboBox->setLineEdit (
new QLineEdit() );
689 NewComboBox->addItems ( ListOfObjects );
691 QCompleter * Completer =
new QCompleter ( ListOfObjects );
692 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
693 Completer->setFilterMode(Qt::MatchContains);
695 NewComboBox->lineEdit()->setCompleter ( Completer );
697 NewComboBox->setEditable (
true );
699 NewComboBox->setEditText (
Item->text() );
701 if ( ListOfObjects.size() > 0 )
703 NewComboBox->lineEdit()->selectAll();
708 NewComboBox->setEnabled (
false );
711 QVariant VariantFromList ( ListOfObjects );
713 NewComboBox->setValidator ( MyCustomValidator );
714 NewComboBox->installEventFilter (
this );
716 connect ( NewComboBox, SIGNAL ( activated (
const QString & ) ),
this,
719 NewComboBox->lineEdit()->installEventFilter(
this);
721 ListWidget->setItemWidget (
FirstItem, NewComboBox );
726 if (
IsMultiValue and ListWidget->item ( 0 )->text() ==
"Type here"
737 for (
int i = 0; i != ListWidget->count(); ++i )
739 QListWidgetItem *
Item = ListWidget->item ( i );
740 QString
const & val =
Item->text();
742 if ( val !=
"Type here" and val !=
"No Object" )
777 int index =
this_data.indexOf ( DataValue );
778 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
779 ListWidget->setCurrentRow ( index );
783 FirstItem =
new QListWidgetItem (
"Type here" );
787 FirstItem =
new QListWidgetItem ( DataValue.toStdString().c_str() );
794 FirstItem->setBackground ( Qt::GlobalColor::lightGray );
795 FirstItem->setForeground ( QColor ( 0, 0, 0, 127 ) );
808 QList<QListWidgetItem *> items;
812 items = ListWidget->selectedItems();
820 if ( items.size() > 0 )
823 for ( QListWidgetItem * item : items )
825 QString text = item->text();
827 if ( text !=
"Type here" )
831 if ( QListWidgetItem * toremove = ListWidget->takeItem ( ListWidget->row ( item ) ) )
839 if ( QComboBox * editbox =
dynamic_cast<QComboBox *
> ( ListWidget->itemWidget (
843 editbox->lineEdit()->clear();
844 editbox->lineEdit()->clearFocus();
861 for (
int i = 0; i < ListWidget->count(); ++i )
863 QString
const & value = ListWidget->item ( i )->text();
865 if ( value !=
"No Object" and value !=
"Type here" )
867 values.append ( value );
873 if ( values.size() > 0 )
876 ListWidget->setPalette ( QApplication::palette (
this ) );
923 StringLineEdit->installEventFilter(
this);
924 StringLineEdit->setTabChangesFocus(
true);
926 setWindowTitle ( QString (
"Edit Attr : %1" ).arg ( virtue.
p_name.c_str() ) );
927 AttributeNameLabel->setText ( QString ( virtue.
p_name.c_str() ) +
" : " );
929 AttributeNameLabel->setHidden (
true );
937 OkButton->setDisabled (
true );
947 StringLineEdit->setPalette ( QApplication::palette (
this ) );
950 OkButton->setHidden (
true );
954 connect ( StringLineEdit, SIGNAL ( StringValidated() ),
this, SLOT (
AddToDataList() ),
955 Qt::UniqueConnection );
956 OkButton->setHidden (
true );
964 AttributeNameLabel->setFocus();
980 StringLineEdit->setText (
this_data.value ( 0 ) );
987 return StringLineEdit;
992 StringLineEdit->SetNullCheck ( Check );
997 StringLineEdit->SetMultiCheck ( Multi );
1002 StringLineEdit->SetCheckDefault ( Default );
1007 StringLineEdit->selectAll();
1012 if (target == StringLineEdit)
1014 if (evt->type() == QEvent::FocusIn)
1018 else if (evt->type() == QEvent::KeyPress)
1020 QKeyEvent *kevt =
static_cast<QKeyEvent*
>(evt);
1021 switch (kevt->key())
1024 case Qt::Key_Return:
1026 if ( kevt->modifiers() == Qt::AltModifier)
1028 kevt->setModifiers(Qt::NoModifier);
1032 StringLineEdit->parentWidget()->setFocus(Qt::FocusReason::TabFocusReason);
1056 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
1057 " Type: %1 \n" ).arg (
1059 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
1060 + QString (
" Format: %1 \n" ).arg (
1062 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
1064 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
1065 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
1076 connect ( StringLineEdit, SIGNAL ( textChanged ( ) ),
this, SLOT (
UpdateActions ( ) ), Qt::UniqueConnection );
1078 connect ( OkButton, SIGNAL ( clicked() ),
this, SLOT (
AddToDataList() ), Qt::UniqueConnection );
1084 StringLineEdit->SetDefaultValue ( ValueDefault );
1093 PopUpButton->fontMetrics().boundingRect (
"..." ).width() + 15 );
1095 Qt::UniqueConnection );
1116 OkButton->setEnabled (
true );
1122 OkButton->setEnabled (
true );
1129 QString NewValue = StringLineEdit->toPlainText();
1133 StringLineEdit->setToolTip ( QString (
"The set value is : %1" ).arg ( NewValue ) );
1157 QVBoxLayout * Layout =
new QVBoxLayout();
1160 Dialog->setWindowTitle ( QString (
"Edit Attr : %1" ).arg ( Virtue.
p_name.c_str() ) );
1165 Dialog->setLayout ( Layout );
1166 Dialog->setModal (
true );
1169 Qt::UniqueConnection );
1171 Qt::UniqueConnection );
1175 TextEditDialog->insertPlainText ( StringLineEdit->toPlainText() );
1181 StringLineEdit->clear();
1214 setWindowTitle ( QString (
"Edit Attribute: %1" ).arg ( Virtue.
p_name.c_str() ) );
1215 LineEdit->SetPopupMenu();
1224 LineEdit->SetNullCheck (
false );
1232 FormatBox->setCurrentIndex ( 2 );
1238 FormatBox->setCurrentIndex ( 0 );
1244 FormatBox->setCurrentIndex ( 1 );
1258 AttributeName->setText ( QString ( Virtue.
p_name.c_str() ) +
" : " );
1259 AttributeName->setHidden (
true );
1262 QString Dummy (
"Dummy" );
1289 if ( not
this_data.value ( 0 ).startsWith (
"0x" ) )
1291 LineEdit->setText (
"0x" +
this_data.value ( 0 ) );
1295 LineEdit->setText (
this_data.value ( 0 ) );
1302 LineEdit->setText (
"0" +
this_data.value ( 0 ) );
1306 LineEdit->setText (
this_data.value ( 0 ) );
1311 LineEdit->setText (
this_data.value ( 0 ) );
1320 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
1321 " Type: %1 \n" ).arg (
1323 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
1324 + QString (
" Format: %1 \n" ).arg (
1326 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
1328 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
1329 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
1340 connect ( LineEdit, SIGNAL ( DecChange() ),
this, SLOT (
ChangeFormatDec() ) );
1341 connect ( LineEdit, SIGNAL ( OctChange() ),
this, SLOT (
ChangeFormatOct() ) );
1342 connect ( LineEdit, SIGNAL ( HexChange() ),
this, SLOT (
ChangeFormatHex() ) );
1344 connect ( FormatBox, SIGNAL ( currentIndexChanged (
int ) ),
1345 this, SLOT (
ChangeFormat (
int ) ), Qt::UniqueConnection );
1347 connect ( LineEdit, SIGNAL ( editingFinished() ),
1348 this, SLOT (
AddToList() ), Qt::UniqueConnection );
1349 connect ( LineEdit, SIGNAL ( textChanged ( QString ) ),
1350 this, SLOT (
UpdateActions ( QString ) ), Qt::UniqueConnection );
1351 connect ( LineEdit, SIGNAL ( returnPressed () ),
1362 QString Message = QString (
"The value for attribute %1 is in the wrong format" ).arg (
1367 QString RangeMex = QString (
" - The value should be in the range : %1" ).arg ( Range );
1368 Message.append (
"\n\n" + RangeMex );
1373 Message.append ( QString (
"\n\n - The value should be formatted as a %1." ).arg (
1377 QMessageBox::warning (
this, tr (
"Wrong value" ), Message );
1383 auto checkInteger = [
this, text]()
1387 bool convert_to_defined_base;
1389 qlonglong NewLongLong{0};
1390 qulonglong NewULongLong{0};
1392 auto check_convert = [
this, &convert_to_defined_base]()
1396 if ( not convert_to_defined_base )
1422 NewULongLong = text.toULongLong ( &convert_to_defined_base,
this_base );
1424 if ( not check_convert() )
1450 max_u = ULONG_LONG_MAX;
1457 if ( min_u <= NewULongLong and NewULongLong <= max_u )
1462 ShowWarning (
"", QString (
"[%1 - %2]" ).arg ( min_u ).arg ( max_u ) );
1466 NewLongLong = text.toLongLong ( &convert_to_defined_base,
this_base );
1468 if ( not check_convert() )
1493 min_s = - ( LONG_LONG_MAX ) - 1;
1494 max_s = LONG_LONG_MAX;
1501 if ( min_s <= NewLongLong and NewLongLong <= max_s )
1506 ShowWarning (
"", QString (
"[%1 - %2]" ).arg ( min_s ).arg ( max_s ) );
1519 QString Range = QString::fromStdString ( Virtue.
p_range );
1521 if ( Range.isEmpty() )
1526 QStringList ValueList = Range.split (
"," );
1528 QList<QPair<QString, QString>> RangeList;
1530 for ( QString & RangeValue : ValueList )
1532 if ( RangeValue.contains (
".." ) )
1534 QStringList Ranges = RangeValue.split (
".." );
1535 RangeList.append ( QPair<QString, QString> ( Ranges.at ( 0 ), Ranges.at ( 1 ) ) );
1536 ValueList.removeOne ( RangeValue );
1540 if ( ValueList.contains ( Value ) )
1545 for ( QPair<QString, QString> & ValuePair : RangeList )
1547 if ( ValuePair.first ==
"*" )
1549 if ( Value.toDouble() <= ValuePair.second.toDouble() )
1559 else if ( ValuePair.second ==
"*" )
1561 if ( Value.toDouble() >= ValuePair.first.toDouble() )
1573 if ( ( Value.toDouble() >= ValuePair.first.toDouble() ) &&
1574 ( Value.toDouble() <= ValuePair.second.toDouble() ) )
1592 bool validValue =
true;
1606 Value.toDouble(&ok);
1624 if (
this_data.contains(LineEdit->text()) ) {
1633 if (
this_data.contains(LineEdit->text()) ) {
1637 auto convert_to_proper_base = [
this] (
const QString& value) -> QString {
1647 if(Unsigned ==
true) {
1655 if(cnvrtd.startsWith(
"0") ==
false) {
1656 cnvrtd.insert(0,
"0");
1658 LineEdit->EmitOctSlot();
1660 LineEdit->EmitDecSlot();
1662 if(cnvrtd.startsWith(
"0x", Qt::CaseInsensitive) ==
false) {
1663 cnvrtd.insert(0,
"0x");
1665 LineEdit->EmitHexSlot();
1677 LineEdit->blockSignals (
true );
1679 BOOST_SCOPE_EXIT(this_)
1681 this_->LineEdit->blockSignals (
false );
1683 BOOST_SCOPE_EXIT_END
1685 bool isValid =
true;
1687 QString input = LineEdit->text();
1707 this_data.append ( convert_to_proper_base(input) );
1711 if(isValid ==
true) {
1712 QString Dummy (
"Dummy" );
1722 if(isValid ==
true) {
1739 QString CurrentString = LineEdit->text();
1741 if ( CurrentString.isEmpty() )
1765 QString ConvertedString;
1771 bool OkConversion =
false;
1779 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 10 );
1783 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 10 );
1794 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 8 );
1798 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 8 );
1801 ConvertedString.insert(0,
"0");
1810 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 16 );
1814 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 16 );
1817 ConvertedString.insert(0,
"0x");
1821 if ( !OkConversion )
1831 Format =
"HEX-DECIMAL";
1835 Format =
"OCT-DECIMAL";
1843 if ( !ConvertedString.isEmpty() )
1846 LineEdit->setText ( ConvertedString );
1895 Combo->setFocusPolicy ( Qt::ClickFocus );
1896 Combo->installEventFilter (
this );
1898 if ( Combo->lineEdit() !=
nullptr )
1900 Combo->lineEdit()->installEventFilter (
this );
1907 Combo->setEditable (
true );
1913 if ( Data.isEmpty() )
1918 int Index = Combo->findText ( Data.value ( 0 ) );
1922 Combo->setCurrentIndex ( Index );
1923 Combo->setEditText ( Data.value ( 0 ) );
1930 Combo->addItems ( Data );
1932 QCompleter * Completer =
new QCompleter ( Combo->model(), Combo );
1933 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
1934 Completer->setCompletionMode ( QCompleter::PopupCompletion );
1935 Completer->setFilterMode(Qt::MatchContains);
1937 Combo->setCompleter ( Completer );
1941 QVariant VarFromList ( Data );
1943 if ( AcceptNoMatch )
1946 Combo->setValidator ( TmpValidator );
1952 Combo->setValidator ( TmpValidator );
1970 {
"true",
"false" };
1975 QString rangename = virt.
p_range.c_str();
1976 QStringList range = rangename.split (
"," );
1997 if ( Target == Combo->lineEdit() && Event->type() == QEvent::MouseButtonRelease )
1999 if ( !Combo->lineEdit()->hasSelectedText() )
2001 Combo->lineEdit()->selectAll();
2006 if ( Event->type() == QEvent::Wheel )
2022 connect ( Combo, SIGNAL ( editTextChanged (
const QString & ) ),
this,
2023 SLOT (
TryValidate (
const QString & ) ), Qt::UniqueConnection );
2024 connect ( Combo, SIGNAL ( activated (
const QString & ) ),
this,
2025 SLOT (
ChangeDetected (
const QString & ) ), Qt::UniqueConnection );
2026 connect ( Combo, SIGNAL ( currentIndexChanged (
int ) ),
this,
2028 Qt::UniqueConnection );
2035 if ( Combo->validator() !=
nullptr )
2037 if ( Combo->validator()->validate ( tmp, index ) == QValidator::Acceptable )
2048 Combo->setPalette ( QApplication::palette (
this ) );
2052 else if ( Combo->validator()->validate ( tmp, index ) == QValidator::Intermediate )
2067 Combo->setPalette ( QApplication::palette (
this ) );
2074 Q_UNUSED ( StringChange )
2081 Q_UNUSED ( DefaultIndex )
2124 setWindowTitle ( QString (
"Edit Attribute : %1" ).arg ( Virtue.
p_name.c_str() ) );
2125 QVBoxLayout * MainLayout =
new QVBoxLayout (
this );
2126 MainLayout->setSpacing ( 0 );
2127 MainLayout->setMargin ( 0 );
2128 MainLayout->setContentsMargins ( 0, 0, 0, 0 );
2129 QHBoxLayout * ButtonLayout =
new QHBoxLayout();
2131 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
2142 MainLayout->addWidget ( Combo );
2143 connect ( Combo->Combo, SIGNAL ( activated (
const QString & ) ),
this,
2144 SLOT (
AddToDataList (
const QString & ) ), Qt::UniqueConnection );
2164 MainLayout->addWidget ( Numeric );
2166 Qt::UniqueConnection );
2167 connect ( Numeric, SIGNAL ( signal_value_duplicated() ),
this, SLOT (
LineValueChanged() ),
2168 Qt::UniqueConnection );
2172 Numeric->
GetLineEdit()->setPlaceholderText (
"Type Here" );
2173 Numeric->setStyleSheet (
2174 "QLineEdit { background: #c0c0c0;} QLineEdit:focus {background: white;}" );
2176 ListWidget->setFrameStyle ( QFrame::NoFrame );
2187 String->SetMultiCheck (
true );
2188 MainLayout->addWidget ( String );
2190 Qt::UniqueConnection );
2193 String->GetLineEdit()->setFrameStyle(QFrame::NoFrame);
2195 String->setStyleSheet (
"QLineEdit { background: #c0c0c0;} "
2196 "QLineEdit:focus {background: white;}" );
2199 ListWidget->setFrameStyle ( QFrame::NoFrame );
2207 OkButton =
new QPushButton ( tr (
"Apply" ) );
2209 ButtonLayout->addWidget (
OkButton );
2214 connect (
ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
2218 MainLayout->addLayout ( ButtonLayout );
2222 setLayout ( MainLayout );
2238 QFontMetrics FontMetrics ( Font );
2240 2 * FontMetrics.horizontalAdvance ( QString (
"Edit Relationship: %1" ).arg ( Virtue.
p_name.c_str() ) )
2242 setMinimumHeight ( 100 );
2255 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
2258 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
2259 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
2261 for (
int i = 0; i <
ListWidget->count(); ++i )
2263 QListWidgetItem * widget =
ListWidget->item ( i );
2265 Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled
2266 | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled );
2270 connect (
ListWidget, SIGNAL ( itemChanged ( QListWidgetItem * ) ),
this,
2280 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
2281 " Type: %1 \n" ).arg (
2283 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
2284 + QString (
" Format: %1 \n" ).arg (
2286 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
2288 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
2289 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
2301 StatusBar->setSizeGripEnabled (
false );
2303 StatusBar->setAutoFillBackground (
true );
2317 if ( Data.isEmpty() )
2326 StatusBar->showMessage ( QString (
"Item %1 was added." ).arg ( Data ) );
2337 for ( QListWidgetItem * widget :
widgets )
2339 int index =
this_data.indexOf ( widget->text() );
2348 if ( QListWidgetItem * w =
ListWidget->takeItem ( r ) )
2357 StatusBar->showMessage (
"The selected items were removed." );
2381 StatusBar->showMessage (
"Attribute can not be null." );
2391 StatusBar->showMessage (
"Attribute is set." );
2392 ListWidget->setPalette ( QApplication::palette (
this ) );
2412 if ( (!Data.isEmpty()) &&
BaseWidget->dataeditor()->is_valid())
2421 QString newtext = changed->text();
2426 StatusBar->showMessage ( QString (
"Item %1 was modified." ).arg ( oldtext ) );
2433 Q_UNUSED ( IndexList )
2437 for (
int i = 0; i <
ListWidget->count(); ++i )
2447 for (
int i = 0; i <
ListWidget->count(); ++i )
2471 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
2473 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_state(bool isvalid, bool isnotnull, bool isobligatory)
editor_data(T const &virtue)
static configobject::tref get(dbe::cokey const &desc)
inner::configobject::tref tref
config_object_description dref
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