/trunk/ClassEditor/classeditor.ui |
---|
103,7 → 103,7 |
</rect> |
</property> |
<property name="text"> |
<string>Удалить поле</string> |
<string>Удалить выделенные поля</string> |
</property> |
</widget> |
<widget class="QCheckBox" name="checkBox"> |
152,7 → 152,7 |
<x>0</x> |
<y>0</y> |
<width>983</width> |
<height>25</height> |
<height>27</height> |
</rect> |
</property> |
<widget class="QMenu" name="menu"> |
/trunk/ClassEditor/delegateforclassestable.cpp |
---|
5,7 → 5,9 |
QItemDelegate(parent) |
{ |
items.append(tr("CHAR(10)")); |
items.append(tr("CHAR(30)")); |
items.append(tr("INT(10)")); |
items.append(tr("DATA")); |
} |
QWidget *DelegateForClassesTable::createEditor(QWidget *parent, |
const QStyleOptionViewItem &/* option */, |
47,6 → 49,9 |
QComboBox *comboBox = static_cast<QComboBox*>(editor); |
int curr_index = items.indexOf(value); |
if (curr_index!= -1) comboBox->setCurrentIndex(curr_index); |
else { |
} |
/* |
if (value == "0") comboBox->setCurrentIndex(0); |
if (value == "1") comboBox->setCurrentIndex(1); |
59,7 → 64,7 |
if (value == "8") comboBox->setCurrentIndex(8); |
if (value == "9") comboBox->setCurrentIndex(9); |
*/ |
comboBox->setEditable(true); |
comboBox->setEditable(false); |
//comboBox->setItemText(0, value); |
92,3 → 97,10 |
editor->setGeometry(option.rect); |
} |
//! [4] |
void DelegateForClassesTable::setItems(QStringList new_items){ |
DelegateForClassesTable::items = new_items; |
} |
/trunk/ClassEditor/classeditor.cpp |
---|
433,15 → 433,31 |
QModelIndex model_index; |
QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
QModelIndexList indexes = selectionModel->selectedIndexes(); |
QModelIndexList indexes_fo_first_col; // èíäåêñû äëÿ ïåðâîãî ñòîëáöà (èìåíà êëàññîâ) |
//model_index = mymodel->selec; |
//modelList = ui->tableView->SelectItems; |
i = indexes.size(); |
QList<int> selectedRows; |
indexes_fo_first_col.clear(); |
foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
} |
selectedRows.clear(); |
foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
if (!selectedRows.contains(model_index.row())) selectedRows.append(model_index.row()); |
if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
} |
qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå |
for (int m =0; m < selectedRows.size(); ++m){ |
modelForDescription->removeRow(selectedRows.at(m)); |
} |
i = selectedRows.size(); |
if (i > 0) model_index = indexes.at(0); |
/trunk/ClassEditor/delegateforclassestable.h |
---|
24,6 → 24,8 |
void updateEditorGeometry(QWidget *editor, |
const QStyleOptionViewItem &option, const QModelIndex &index) const; |
void setItems(QStringList new_items); // äîáàâëÿåì íîâûå ïóíêòû â äåëåãàò |
private: |
QStringList items; |