14#include <QStringListModel>
26#include <boost/scope_exit.hpp>
52base::base ( std::shared_ptr<editor_data_state> editordata,
53 QWidget * parent,
bool owned )
109 bool owned,
bool readonly )
130 setWindowTitle ( QString (
"Edit Relationship: %1" ).arg ( Virtue.
p_name.c_str() ) );
131 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
132 ComboBox->setHidden (
true );
155 SaveButton->setHidden (
true );
156 RemoveButton->setHidden (
true );
164 if(
dynamic_cast<QListWidget*
>(Target)) {
165 auto decode = [
this] (
const QMimeData *
const data) -> QPair<bool, QStringList>
168 QStringList newItems;
170 if(data->hasFormat(
"application/vnd.text.list") ==
true) {
171 QByteArray encodedData = data->data(
"application/vnd.text.list");
172 QDataStream stream(&encodedData, QIODevice::ReadOnly);
176 while(!stream.atEnd()) {
180 const QString& obj_id = text.at(0);
181 const QString& obj_class = text.at(1);
183 if((obj_class.toStdString() == referenceClass) ||
186 newItems.append(obj_id);
195 return qMakePair(allGood, newItems);
198 if(Event->type() == QEvent::DragEnter) {
199 QDragEnterEvent *tDragEvent =
static_cast<QDragEnterEvent *
>(Event);
201 const QMimeData *
const data = tDragEvent->mimeData();
202 const auto& decodedData = decode(data);
203 if((decodedData.first ==
true) && (decodedData.second.size() > 0)) {
204 tDragEvent->acceptProposedAction();
210 if(Event->type() == QEvent::Drop) {
211 QDropEvent *tDropEvent =
static_cast<QDropEvent *
>(Event);
213 const QMimeData *
const data = tDropEvent->mimeData();
214 for(
const QString& o : decode(data).second) {
220 tDropEvent->acceptProposedAction();
224 }
else if(QComboBox * Box =
dynamic_cast<QComboBox *
>(Target)) {
225 if(Event->type() == QEvent::Wheel) {
229 if(Event->type() == QEvent::KeyPress) {
230 QKeyEvent * KeyEvent =
dynamic_cast<QKeyEvent *
>(Event);
232 if(KeyEvent->key() == Qt::Key_Up || KeyEvent->key() == Qt::Key_Down) {
239 if(Event->type() == QEvent::FocusOut) {
240 QWidget * popup = Box->findChild<QFrame *>();
241 QWidget * popup1 = Box->lineEdit()->findChild<QFrame *>();
243 if(popup != popup1 and not popup->isHidden()) {
249 ListWidget->itemWidget(
FirstItem) != 0) {
250 ListWidget->takeItem(ListWidget->row(
FirstItem));
251 ListWidget->setItemWidget(
FirstItem,
nullptr);
256 std::cout <<
"Do we ever get here? FirstItem is not null but other conditions not met!\n";
260 }
else if(QLineEdit* le =
dynamic_cast<QLineEdit *
>(Target)) {
261 if(Event->type() == QEvent::MouseButtonDblClick) {
262 const QString& value = le->text();
287 ListWidget->setAcceptDrops (
true );
288 ListWidget->installEventFilter (
this );
294 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
295 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
296 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
311 std::vector<tref>
const & related
316 for (
tref const & o : related )
318 result.append ( QString::fromStdString ( o.full_name() ) );
333 ComboBox->addItems ( ListOfObjects );
345 connect ( SaveButton, SIGNAL ( clicked() ),
this, SLOT (
EndSignal() ) );
352 connect ( ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
354 connect ( ListWidget, SIGNAL ( itemDoubleClicked ( QListWidgetItem * ) ),
this,
356 connect ( ListWidget->model(), SIGNAL ( layoutChanged() ),
this, SLOT (
DummyMovement() ) );
357 connect ( ListWidget, SIGNAL ( itemPressed ( QListWidgetItem * ) ),
this,
380 FirstItem->setBackground ( Qt::GlobalColor::lightGray );
381 FirstItem->setForeground ( QColor ( 0, 0, 0, 127 ) );
406 QString (
"Relationship Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
407 " Type: %1 \n" ).arg ( Virtue.
p_type.c_str() )
408 + QString (
" Cardinality: %1 \n" ).arg (
411 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
418 QString oname = QString::fromStdString ( obj.full_name() );
420 for ( QWidget * editor : QApplication::allWidgets() )
424 if ( ( w->objectName() ).compare ( oname ) == 0 )
427 w->setVisible (
true );
444 std::string
const & ouid =
Item->data ( Qt::DisplayRole ).toString().toStdString();
454 MoveTop =
new QAction ( tr (
"Move Top" ),
this );
455 MoveTop->setShortcutContext ( Qt::WidgetShortcut );
459 MoveBottom =
new QAction ( tr (
"Move Bottom" ),
this );
460 MoveBottom->setShortcutContext ( Qt::WidgetShortcut );
464 MoveUp =
new QAction ( tr (
"Move Up" ),
this );
465 MoveUp->setShortcutContext ( Qt::WidgetShortcut );
469 MoveDown =
new QAction ( tr (
"Move Down" ),
this );
470 MoveDown->setShortcutContext ( Qt::WidgetShortcut );
476 EditAction =
new QAction ( tr (
"Edit" ),
this );
477 EditAction->setShortcutContext ( Qt::WidgetShortcut );
482 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
491 (
ContextMenu->actions() ).at ( 0 )->setVisible (
true );
492 (
ContextMenu->actions() ).at ( 1 )->setVisible (
true );
493 (
ContextMenu->actions() ).at ( 2 )->setVisible (
true );
494 (
ContextMenu->actions() ).at ( 3 )->setVisible (
true );
495 (
ContextMenu->actions() ).at ( 4 )->setVisible (
true );
496 (
ContextMenu->actions() ).at ( 5 )->setVisible (
false );
497 (
ContextMenu->actions() ).at ( 6 )->setVisible (
true );
499 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
504 (
ContextMenu->actions() ).at ( 0 )->setVisible (
false );
505 (
ContextMenu->actions() ).at ( 1 )->setVisible (
false );
506 (
ContextMenu->actions() ).at ( 2 )->setVisible (
false );
507 (
ContextMenu->actions() ).at ( 3 )->setVisible (
false );
508 (
ContextMenu->actions() ).at ( 4 )->setVisible (
true );
509 (
ContextMenu->actions() ).at ( 5 )->setVisible (
true );
510 (
ContextMenu->actions() ).at ( 6 )->setVisible (
true );
512 ContextMenu->exec ( ListWidget->mapToGlobal ( pos ) );
524 int ItemPosition = ListWidget->row (
CurrentItem );
536 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
537 ListWidget->setCurrentRow ( index );
544 int ItemPosition = ListWidget->row (
CurrentItem );
556 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
557 ListWidget->setCurrentRow ( index );
564 int ItemPosition = ListWidget->row (
CurrentItem );
567 if ( ItemPosition != 0 )
569 this_data.swapItemsAt ( ItemPosition, ItemPosition - 1 );
577 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
578 ListWidget->setCurrentRow ( index );
586 int ItemPosition = ListWidget->row (
CurrentItem );
589 if ( ItemPosition != (
this_data.size() - 1 ) )
591 this_data.swapItemsAt ( ItemPosition, ItemPosition + 1 );
599 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
600 ListWidget->setCurrentRow ( index );
608 if ( QComboBox * ComboBox =
dynamic_cast<QComboBox *
> ( ListWidget->itemWidget (
612 ComboBox->lineEdit()->setFocus();
622 QString
const & editorname = QString::fromStdString ( obj.full_name() );
624 for ( QWidget * editor :
625 QApplication::allWidgets()
630 if ( ( w->objectName() ).compare ( editorname ) == 0 )
633 w->setVisible (
true );
657 QStringList ListOfObjects;
659 for (
int i = 0; i < ComboBox->count(); ++i )
661 ListOfObjects.append ( ComboBox->itemText ( i ) );
664 QComboBox * NewComboBox =
new QComboBox (
this );
666 NewComboBox->setLineEdit (
new QLineEdit() );
668 NewComboBox->addItems ( ListOfObjects );
670 QCompleter * Completer =
new QCompleter ( ListOfObjects );
671 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
672 Completer->setFilterMode(Qt::MatchContains);
674 NewComboBox->lineEdit()->setCompleter ( Completer );
676 NewComboBox->setEditable (
true );
678 NewComboBox->setEditText (
Item->text() );
680 if ( ListOfObjects.size() > 0 )
682 NewComboBox->lineEdit()->selectAll();
687 NewComboBox->setEnabled (
false );
690 QVariant VariantFromList ( ListOfObjects );
692 NewComboBox->setValidator ( MyCustomValidator );
693 NewComboBox->installEventFilter (
this );
695 connect ( NewComboBox, SIGNAL ( activated (
const QString & ) ),
this,
698 NewComboBox->lineEdit()->installEventFilter(
this);
700 ListWidget->setItemWidget (
FirstItem, NewComboBox );
716 for (
int i = 0; i != ListWidget->count(); ++i )
718 QListWidgetItem *
Item = ListWidget->item ( i );
719 QString
const & val =
Item->text();
756 int index =
this_data.indexOf ( DataValue );
757 ListWidget->scrollTo ( ListWidget->model()->index ( index, 0 ) );
758 ListWidget->setCurrentRow ( index );
766 FirstItem =
new QListWidgetItem ( DataValue.toStdString().c_str() );
773 FirstItem->setBackground ( Qt::GlobalColor::lightGray );
774 FirstItem->setForeground ( QColor ( 0, 0, 0, 127 ) );
787 QList<QListWidgetItem *> items;
791 items = ListWidget->selectedItems();
799 if ( items.size() > 0 )
802 for ( QListWidgetItem * item : items )
804 QString text = item->text();
810 if ( QListWidgetItem * toremove = ListWidget->takeItem ( ListWidget->row ( item ) ) )
818 if ( QComboBox * editbox =
dynamic_cast<QComboBox *
> ( ListWidget->itemWidget (
822 editbox->lineEdit()->clear();
823 editbox->lineEdit()->clearFocus();
840 for (
int i = 0; i < ListWidget->count(); ++i )
842 QString
const & value = ListWidget->item ( i )->text();
846 values.append ( value );
852 if ( values.size() > 0 )
855 ListWidget->setPalette ( QApplication::palette (
this ) );
889 bool owned,
bool readonly )
904 StringLineEdit->setReadOnly(
true);
907 StringLineEdit->installEventFilter(
this);
909 StringLineEdit->setTabChangesFocus(
true);
911 setWindowTitle ( QString (
"Edit Attr : %1" ).arg ( virtue.
p_name.c_str() ) );
912 AttributeNameLabel->setText ( QString ( virtue.
p_name.c_str() ) +
" : " );
914 AttributeNameLabel->setHidden (
true );
922 OkButton->setDisabled (
true );
932 StringLineEdit->setPalette ( QApplication::palette (
this ) );
935 OkButton->setHidden (
true );
939 connect ( StringLineEdit, SIGNAL ( StringValidated() ),
this, SLOT (
AddToDataList() ),
940 Qt::UniqueConnection );
941 OkButton->setHidden (
true );
949 AttributeNameLabel->setFocus();
965 StringLineEdit->setText (
this_data.value ( 0 ) );
972 return StringLineEdit;
977 StringLineEdit->SetNullCheck ( Check );
982 StringLineEdit->SetMultiCheck ( Multi );
987 StringLineEdit->SetCheckDefault ( Default );
992 StringLineEdit->selectAll();
997 if (target == StringLineEdit)
999 if (evt->type() == QEvent::FocusIn)
1003 else if (evt->type() == QEvent::KeyPress)
1005 QKeyEvent *kevt =
static_cast<QKeyEvent*
>(evt);
1006 switch (kevt->key())
1009 case Qt::Key_Return:
1011 if ( kevt->modifiers() == Qt::AltModifier)
1013 kevt->setModifiers(Qt::NoModifier);
1017 StringLineEdit->parentWidget()->setFocus(Qt::FocusReason::TabFocusReason);
1041 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
1042 " Type: %1 \n" ).arg (
1044 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
1045 + QString (
" Format: %1 \n" ).arg (
1047 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
1049 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
1050 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
1062 connect ( StringLineEdit, SIGNAL ( textChanged ( ) ),
this, SLOT (
UpdateActions ( ) ), Qt::UniqueConnection );
1064 connect ( OkButton, SIGNAL ( clicked() ),
this, SLOT (
AddToDataList() ), Qt::UniqueConnection );
1071 StringLineEdit->SetDefaultValue ( ValueDefault );
1080 PopUpButton->fontMetrics().boundingRect (
"..." ).width() + 15 );
1082 Qt::UniqueConnection );
1103 OkButton->setEnabled (
true );
1109 OkButton->setEnabled (
true );
1116 QString NewValue = StringLineEdit->toPlainText();
1120 StringLineEdit->setToolTip ( QString (
"The set value is : %1" ).arg ( NewValue ) );
1144 QVBoxLayout * Layout =
new QVBoxLayout();
1147 Dialog->setWindowTitle ( QString (
"Edit Attr : %1" ).arg ( Virtue.
p_name.c_str() ) );
1152 Dialog->setLayout ( Layout );
1153 Dialog->setModal (
true );
1156 Qt::UniqueConnection );
1158 Qt::UniqueConnection );
1162 TextEditDialog->insertPlainText ( StringLineEdit->toPlainText() );
1168 StringLineEdit->clear();
1192 bool owned,
bool readonly )
1202 setWindowTitle ( QString (
"Edit Attribute: %1" ).arg ( Virtue.
p_name.c_str() ) );
1204 LineEdit->setReadOnly(
true);
1207 LineEdit->SetPopupMenu();
1216 LineEdit->SetNullCheck (
false );
1224 FormatBox->setCurrentIndex ( 2 );
1230 FormatBox->setCurrentIndex ( 0 );
1236 FormatBox->setCurrentIndex ( 1 );
1250 AttributeName->setText ( QString ( Virtue.
p_name.c_str() ) +
" : " );
1251 AttributeName->setHidden (
true );
1254 QString Dummy (
"Dummy" );
1281 if ( not
this_data.value ( 0 ).startsWith (
"0x" ) )
1283 LineEdit->setText (
"0x" +
this_data.value ( 0 ) );
1287 LineEdit->setText (
this_data.value ( 0 ) );
1294 LineEdit->setText (
"0" +
this_data.value ( 0 ) );
1298 LineEdit->setText (
this_data.value ( 0 ) );
1303 LineEdit->setText (
this_data.value ( 0 ) );
1312 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
1313 " Type: %1 \n" ).arg (
1315 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
1316 + QString (
" Format: %1 \n" ).arg (
1318 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
1320 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
1321 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
1332 connect ( LineEdit, SIGNAL ( DecChange() ),
this, SLOT (
ChangeFormatDec() ) );
1333 connect ( LineEdit, SIGNAL ( OctChange() ),
this, SLOT (
ChangeFormatOct() ) );
1334 connect ( LineEdit, SIGNAL ( HexChange() ),
this, SLOT (
ChangeFormatHex() ) );
1336 connect ( FormatBox, SIGNAL ( currentIndexChanged (
int ) ),
1337 this, SLOT (
ChangeFormat (
int ) ), Qt::UniqueConnection );
1339 connect ( LineEdit, SIGNAL ( editingFinished() ),
1340 this, SLOT (
AddToList() ), Qt::UniqueConnection );
1341 connect ( LineEdit, SIGNAL ( textChanged ( QString ) ),
1342 this, SLOT (
UpdateActions ( QString ) ), Qt::UniqueConnection );
1343 connect ( LineEdit, SIGNAL ( returnPressed () ),
1354 QString Message = QString (
"The value for attribute %1 is in the wrong format" ).arg (
1359 QString RangeMex = QString (
" - The value should be in the range : %1" ).arg ( Range );
1360 Message.append (
"\n\n" + RangeMex );
1365 Message.append ( QString (
"\n\n - The value should be formatted as a %1." ).arg (
1369 QMessageBox::warning (
this, tr (
"Wrong value" ), Message );
1375 auto checkInteger = [
this, text]()
1379 bool convert_to_defined_base;
1381 qlonglong NewLongLong{0};
1382 qulonglong NewULongLong{0};
1384 auto check_convert = [
this, &convert_to_defined_base]()
1388 if ( not convert_to_defined_base )
1414 NewULongLong = text.toULongLong ( &convert_to_defined_base,
this_base );
1416 if ( not check_convert() )
1442 max_u = ULONG_LONG_MAX;
1449 if ( min_u <= NewULongLong and NewULongLong <= max_u )
1454 ShowWarning (
"", QString (
"[%1 - %2]" ).arg ( min_u ).arg ( max_u ) );
1458 NewLongLong = text.toLongLong ( &convert_to_defined_base,
this_base );
1460 if ( not check_convert() )
1485 min_s = - ( LONG_LONG_MAX ) - 1;
1486 max_s = LONG_LONG_MAX;
1493 if ( min_s <= NewLongLong and NewLongLong <= max_s )
1498 ShowWarning (
"", QString (
"[%1 - %2]" ).arg ( min_s ).arg ( max_s ) );
1511 QString Range = QString::fromStdString ( Virtue.
p_range );
1513 if ( Range.isEmpty() )
1518 QStringList ValueList = Range.split (
"," );
1520 QList<QPair<QString, QString>> RangeList;
1522 for ( QString & RangeValue : ValueList )
1524 if ( RangeValue.contains (
".." ) )
1526 QStringList Ranges = RangeValue.split (
".." );
1527 RangeList.append ( QPair<QString, QString> ( Ranges.at ( 0 ), Ranges.at ( 1 ) ) );
1528 ValueList.removeOne ( RangeValue );
1532 if ( ValueList.contains ( Value ) )
1537 for ( QPair<QString, QString> & ValuePair : RangeList )
1539 if ( ValuePair.first ==
"*" )
1541 if ( Value.toDouble() <= ValuePair.second.toDouble() )
1551 else if ( ValuePair.second ==
"*" )
1553 if ( Value.toDouble() >= ValuePair.first.toDouble() )
1565 if ( ( Value.toDouble() >= ValuePair.first.toDouble() ) &&
1566 ( Value.toDouble() <= ValuePair.second.toDouble() ) )
1584 bool validValue =
true;
1598 Value.toDouble(&ok);
1616 if (
this_data.contains(LineEdit->text()) ) {
1625 if (
this_data.contains(LineEdit->text()) ) {
1629 auto convert_to_proper_base = [
this] (
const QString& value) -> QString {
1639 if(Unsigned ==
true) {
1647 if(cnvrtd.startsWith(
"0") ==
false) {
1648 cnvrtd.insert(0,
"0");
1650 LineEdit->EmitOctSlot();
1652 LineEdit->EmitDecSlot();
1654 if(cnvrtd.startsWith(
"0x", Qt::CaseInsensitive) ==
false) {
1655 cnvrtd.insert(0,
"0x");
1657 LineEdit->EmitHexSlot();
1669 LineEdit->blockSignals (
true );
1671 BOOST_SCOPE_EXIT(this_)
1673 this_->LineEdit->blockSignals (
false );
1675 BOOST_SCOPE_EXIT_END
1677 bool isValid =
true;
1679 QString input = LineEdit->text();
1699 this_data.append ( convert_to_proper_base(input) );
1703 if(isValid ==
true) {
1704 QString Dummy (
"Dummy" );
1714 if(isValid ==
true) {
1731 QString CurrentString = LineEdit->text();
1733 if ( CurrentString.isEmpty() )
1757 QString ConvertedString;
1763 bool OkConversion =
false;
1771 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 10 );
1775 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 10 );
1786 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 8 );
1790 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 8 );
1793 ConvertedString.insert(0,
"0");
1802 ConvertedString.setNum ( CurrentString.toULongLong ( &OkConversion, 0 ), 16 );
1806 ConvertedString.setNum ( CurrentString.toLongLong ( &OkConversion, 0 ), 16 );
1809 ConvertedString.insert(0,
"0x");
1813 if ( !OkConversion )
1823 Format =
"HEX-DECIMAL";
1827 Format =
"OCT-DECIMAL";
1835 if ( !ConvertedString.isEmpty() )
1838 LineEdit->setText ( ConvertedString );
1879 bool owned,
bool readonly )
1888 Combo->setFocusPolicy ( Qt::ClickFocus );
1890 Combo->setEditable (
false);
1891 if ( Combo->lineEdit() !=
nullptr ) {
1892 Combo->lineEdit()->setReadOnly(
true);
1893 Combo->lineEdit()->hide();
1897 Combo->installEventFilter (
this );
1898 if ( Combo->lineEdit() !=
nullptr ) {
1899 Combo->lineEdit()->installEventFilter (
this );
1904 Combo->setEditable (
true );
1911 if ( Data.isEmpty() )
1916 int Index = Combo->findText ( Data.value ( 0 ) );
1920 Combo->setCurrentIndex ( Index );
1921 Combo->setEditText ( Data.value ( 0 ) );
1928 Combo->addItems ( Data );
1930 if (Combo->isEditable()) {
1931 QCompleter * Completer =
new QCompleter ( Combo->model(), Combo );
1932 Completer->setCaseSensitivity ( Qt::CaseInsensitive );
1933 Completer->setCompletionMode ( QCompleter::PopupCompletion );
1934 Completer->setFilterMode(Qt::MatchContains);
1935 Combo->setCompleter ( Completer );
1939 QVariant VarFromList ( Data );
1941 if ( AcceptNoMatch )
1944 Combo->setValidator ( TmpValidator );
1949 Combo->setValidator ( TmpValidator );
1967 {
"true",
"false" };
1972 QString rangename = virt.
p_range.c_str();
1973 QStringList range = rangename.split (
"," );
1995 if (
dynamic_cast<QLineEdit*
>(Target) !=
nullptr) {
1996 std::cout <<
"cast to QLineEdit\n";
1998 if ( Target == Combo && Combo->lineEdit() !=
nullptr) {
1999 if (Event->type() < 100) {
2001 if (Event->type() == QEvent::FocusOut) {
2002 if (Combo->lineEdit()->text().isEmpty()) {
2007 if (Event->type() == QEvent::FocusIn) {
2008 if (!Combo->lineEdit()->hasSelectedText() ) {
2009 Combo->lineEdit()->selectAll();
2013 if(Event->type() == QEvent::KeyPress) {
2014 QKeyEvent * KeyEvent =
dynamic_cast<QKeyEvent *
>(Event);
2015 if(KeyEvent->key() == Qt::Key_Up || KeyEvent->key() == Qt::Key_Down) {
2023 if ( Event->type() == QEvent::Wheel )
2039 connect ( Combo, SIGNAL ( editTextChanged (
const QString & ) ),
this,
2040 SLOT (
TryValidate (
const QString & ) ), Qt::UniqueConnection );
2041 connect ( Combo, SIGNAL ( activated (
const QString & ) ),
this,
2042 SLOT (
ChangeDetected (
const QString & ) ), Qt::UniqueConnection );
2048 Combo->lineEdit()->setPalette ( QApplication::palette (
this ) );
2052 if (Combo->validator() !=
nullptr )
2054 if ( Combo->validator()->validate ( tmp, index ) == QValidator::Acceptable )
2065 Combo->lineEdit()->setPalette ( QApplication::palette (
this ) );
2069 else if ( Combo->validator()->validate ( tmp, index ) == QValidator::Intermediate )
2084 Combo->setPalette ( QApplication::palette (
this ) );
2091 Q_UNUSED ( StringChange )
2098 Q_UNUSED ( DefaultIndex )
2128 bool owned,
bool readonly )
2142 setWindowTitle ( QString (
"Edit Attribute : %1" ).arg ( Virtue.
p_name.c_str() ) );
2143 QVBoxLayout * MainLayout =
new QVBoxLayout (
this );
2144 MainLayout->setSpacing ( 0 );
2145 MainLayout->setMargin ( 0 );
2146 MainLayout->setContentsMargins ( 0, 0, 0, 0 );
2147 QHBoxLayout * ButtonLayout =
new QHBoxLayout();
2149 ListWidget->setContextMenuPolicy ( Qt::CustomContextMenu );
2161 MainLayout->addWidget ( Combo );
2162 connect ( Combo->Combo, SIGNAL ( activated (
const QString & ) ),
this,
2163 SLOT (
AddToDataList (
const QString & ) ), Qt::UniqueConnection );
2165 Combo->setStyleSheet (
"QLineEdit { background: #c0c0c0;} "
2166 "QLineEdit:focus {background: white;}" );
2184 MainLayout->addWidget ( Numeric );
2186 Qt::UniqueConnection );
2187 connect ( Numeric, SIGNAL ( signal_value_duplicated() ),
this, SLOT (
LineValueChanged() ),
2188 Qt::UniqueConnection );
2194 Numeric->setStyleSheet (
2195 "QLineEdit { background: #c0c0c0;} QLineEdit:focus {background: white;}" );
2197 ListWidget->setFrameStyle ( QFrame::NoFrame );
2207 String->SetMultiCheck (
true );
2208 MainLayout->addWidget ( String );
2210 Qt::UniqueConnection );
2213 String->GetLineEdit()->setReadOnly(
m_readonly);
2214 String->GetLineEdit()->setFrameStyle(QFrame::NoFrame);
2216 String->setStyleSheet (
"QLineEdit { background: #c0c0c0;} "
2217 "QLineEdit:focus {background: white;}" );
2220 ListWidget->setFrameStyle ( QFrame::NoFrame );
2228 OkButton =
new QPushButton ( tr (
"Apply" ) );
2230 ButtonLayout->addWidget (
OkButton );
2235 connect (
ListWidget, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
2238 MainLayout->addLayout ( ButtonLayout );
2242 setLayout ( MainLayout );
2258 QFontMetrics FontMetrics ( Font );
2260 2 * FontMetrics.horizontalAdvance ( QString (
"Edit Relationship: %1" ).arg ( Virtue.
p_name.c_str() ) )
2262 setMinimumHeight ( 100 );
2275 ListWidget->setSelectionMode ( QAbstractItemView::ExtendedSelection );
2278 ListWidget->setEditTriggers ( QAbstractItemView::DoubleClicked );
2279 ListWidget->setDragDropMode ( QAbstractItemView::InternalMove );
2281 for (
int i = 0; i <
ListWidget->count(); ++i )
2283 QListWidgetItem * widget =
ListWidget->item ( i );
2285 Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled
2286 | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled );
2289 connect (
ListWidget, SIGNAL ( itemChanged ( QListWidgetItem * ) ),
this,
2299 QString (
"Attribute Name: %1 \n" ).arg ( Virtue.
p_name.c_str() ) + QString (
2300 " Type: %1 \n" ).arg (
2302 + QString (
" Range: %1 \n" ).arg ( Virtue.
p_range.c_str() )
2303 + QString (
" Format: %1 \n" ).arg (
2305 + QString (
" Not Null: %1 \n" ).arg ( Virtue.
p_is_not_null )
2307 + QString (
" Default Value: %1 \n" ).arg ( Virtue.
p_default_value.c_str() )
2308 + QString (
" Description: %1 \n" ).arg ( Virtue.
p_description.c_str() ) );
2320 StatusBar->setSizeGripEnabled (
false );
2322 StatusBar->setAutoFillBackground (
true );
2336 if ( Data.isEmpty() )
2345 StatusBar->showMessage ( QString (
"Item %1 was added." ).arg ( Data ) );
2356 for ( QListWidgetItem * widget :
widgets )
2358 int index =
this_data.indexOf ( widget->text() );
2367 if ( QListWidgetItem * w =
ListWidget->takeItem ( r ) )
2376 StatusBar->showMessage (
"The selected items were removed." );
2400 StatusBar->showMessage (
"Attribute can not be null." );
2410 StatusBar->showMessage (
"Attribute is set." );
2411 ListWidget->setPalette ( QApplication::palette (
this ) );
2431 if ( (!Data.isEmpty()) &&
BaseWidget->dataeditor()->is_valid())
2440 QString newtext = changed->text();
2445 StatusBar->showMessage ( QString (
"Item %1 was modified." ).arg ( oldtext ) );
2452 Q_UNUSED ( IndexList )
2456 for (
int i = 0; i <
ListWidget->count(); ++i )
2466 for (
int i = 0; i <
ListWidget->count(); ++i )
2490 RemoveAction->setShortcutContext ( Qt::WidgetShortcut );
2492 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