Logo Search packages:      
Sourcecode: kallery version File versions  Download package

void KalleryFunctions::moveInListAndBox ( QListBox *  listBox,
QStringList &  itemList,
QValueList< OptionType::Description > *  descList,
int  delta,
int  special 
)

Move an item - the current one - up or down with delta position in a QStringList and the corresponding listbox.

Parameters:
listBox the listbox object
itemList the list of items
descList the list with descriptions of the items. Can be NULL.
delta the movement difference
special if special == -1, the item will be the first item, if special == 1, the item will became the last item.

Definition at line 61 of file kalleryfunctions.cpp.

Referenced by ImageThumbPage::slotModifyImageList(), SelectSourcePage::slotModifyImageSourceList(), and ImageThumbPage::slotModifyThumbList().

{
  int currentItem;
  QString currentText;
  QString currentItemText;
  OptionType::Description currentDescText;
  QStringList::Iterator it;
  QValueList<OptionType::Description>::Iterator descIt;

  currentItem = listBox->currentItem();
  currentText = listBox->currentText();
  it = itemList.at(currentItem);
  currentItemText = itemList[currentItem];

  switch (special)
  {
    case -1:
      delta = -currentItem;
      break;
    case 1:
      delta = (itemList.count() - currentItem -1);
      break;
  }

  if (descList !=0)
  {
    currentDescText = (*descList)[currentItem];
    descIt = descList->at(currentItem);
    descIt = descList->remove(descIt);
  }

  listBox->removeItem(currentItem);
  it = itemList.remove(it);

  if ( (currentItem+delta >= 0) && (currentItem + delta <= (int)listBox->count()) )
  {
    currentItem += delta;
    int i = 0;
    while (i != delta)
    {
      if (delta < 0)
      {
        it--;
        if (descList != 0)
          descIt--;
      }
      else
      {
        it++;
        if (descList != 0)
          descIt++;
      }
      i = (delta < 0) ? i-1 : i+1;
    }
  }

  if (descList != 0)
  {
    descList->insert(descIt,currentDescText);
  }
  itemList.insert(it,currentItemText);

  listBox->insertItem(currentText,currentItem);
  listBox->setSelected(currentItem,true);
}


Generated by  Doxygen 1.6.0   Back to index