//================================================================================
//! Перемещение элементов из одного списка в другой
//================================================================================
void FieldSettings::listMove( int id )
{
QList<QListWidgetItem *> itemList1 = list1->selectedItems();
QList<QListWidgetItem *> itemList2 = list2->selectedItems();
switch (id)
{
// вправо
case 0:
for (register int i = 0; i < itemList1.count(); ++i)
{
list1->setCurrentItem( itemList1.at(i) );
QListWidgetItem *it0 = new QListWidgetItem( list2 );
it0->setText( itemList1.at(i)->data( Qt::DisplayRole ).toString() );
it0->setData( Qt::UserRole, itemList1.at(i)->data( Qt::UserRole ).toInt() );
QListWidgetItem *it = list1->takeItem( list1->currentRow() );
list1->removeItemWidget( it );
}
list2->sortItems();
break;
// влево
case 1:
for (register int i = 0; i < itemList2.count(); ++i)
{
list2->setCurrentItem( itemList2.at(i) );
QListWidgetItem *it0 = new QListWidgetItem( list1 );
it0->setText( itemList2.at(i)->data( Qt::DisplayRole ).toString() );
it0->setData( Qt::UserRole, itemList2.at(i)->data( Qt::UserRole ).toInt() );
QListWidgetItem *it = list2->takeItem( list2->currentRow() );
list2->removeItemWidget( it );
}
list1->sortItems();
break;
// вправо все
case 2:
for (register int i = list1->count() - 1; i >= 0; --i)
{
list1->setCurrentItem( list1->item(i) );
QListWidgetItem *it0 = new QListWidgetItem( list2 );
it0->setText( list1->item(i)->data( Qt::DisplayRole ).toString() );
it0->setData( Qt::UserRole, list1->item(i)->data( Qt::UserRole ).toInt() );
QListWidgetItem *it = list1->takeItem( list1->currentRow() );
list1->removeItemWidget( it );
}
list2->sortItems();
break;
// влево все
case 3:
for (register int i = list2->count() - 1; i >= 0; --i)
{
list2->setCurrentItem( list2->item(i) );
QListWidgetItem *it0 = new QListWidgetItem( list1 );
it0->setText( list2->item(i)->data( Qt::DisplayRole ).toString() );
it0->setData( Qt::UserRole, list2->item(i)->data( Qt::UserRole ).toInt() );
QListWidgetItem *it = list2->takeItem( list2->currentRow() );
list2->removeItemWidget( it );
}
list1->sortItems();
break;
}
}
//================================================================================