| 66 | } |
| 67 | |
| 68 | void SearchComboBox::ShowDlg(QWidget *editline) |
| 69 | { |
| 70 | if (_bShow) |
| 71 | return; |
| 72 | |
| 73 | _bShow = true; |
| 74 | |
| 75 | int w = 350; |
| 76 | int h = 550; |
| 77 | int eh = 20; |
| 78 | |
| 79 | if (editline != NULL){ |
| 80 | w = editline->width(); |
| 81 | } |
| 82 | |
| 83 | this->setFixedSize(w, h); |
| 84 | |
| 85 | QVBoxLayout *grid = new QVBoxLayout(this); |
| 86 | this->setLayout(grid); |
| 87 | grid->setContentsMargins(0,0,0,0); |
| 88 | grid->setAlignment(Qt::AlignTop); |
| 89 | grid->setSpacing(2); |
| 90 | |
| 91 | QLineEdit *edit = new QLineEdit(this); |
| 92 | edit->setMaximumWidth(this->width()); |
| 93 | grid->addWidget(edit); |
| 94 | eh = edit->height(); |
| 95 | |
| 96 | QWidget *panel= new QWidget(this); |
| 97 | panel->setContentsMargins(0,0,0,0); |
| 98 | panel->setFixedSize(w, h - eh); |
| 99 | grid->addWidget(panel); |
| 100 | |
| 101 | QWidget *listPanel = new QWidget(panel); |
| 102 | QVBoxLayout *listLay = new QVBoxLayout(listPanel); |
| 103 | listLay->setContentsMargins(2, 2, 20, 2); |
| 104 | listLay->setSpacing(0); |
| 105 | listLay->setAlignment(Qt::AlignTop); |
| 106 | |
| 107 | QFont font = this->font(); |
| 108 | font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); |
| 109 | |
| 110 | for(auto o : _items) |
| 111 | { |
| 112 | ComboButtonItem *bt = new ComboButtonItem(panel, this, o); |
| 113 | bt->setText(o->_name); |
| 114 | bt->setObjectName("flat"); |
| 115 | bt->setMaximumWidth(w - 20); |
| 116 | bt->setMinimumWidth(w - 20); |
| 117 | o->_control = bt; |
| 118 | bt->setFont(font); |
| 119 | |
| 120 | listLay->addWidget(bt); |
| 121 | } |
| 122 | |
| 123 | _scroll = new QScrollArea(panel); |
| 124 | _scroll->setWidget(listPanel); |
| 125 | _scroll->setStyleSheet("QScrollArea{border:none;}"); |
no test coverage detected