Well, it did work, but after fiddling around with some voodoo. The current code I have is:
void NamingConvention::moveCurrentItemDown()
{
int currentRow = this->lstOrder->currentRow();
int nextRow = currentRow + 1;
this->lstOrder->takeItem( currentRow + 1);
this->lstOrder->takeItem( nextRow + 2 );
this->lstOrder->insertItem( currentRow, itemTwo );
this->lstOrder->insertItem( nextRow, itemOne );
updateLabel();
}
void NamingConvention::moveCurrentItemDown()
{
int currentRow = this->lstOrder->currentRow();
int nextRow = currentRow + 1;
QListWidgetItem* itemOne = this->lstOrder->item( currentRow );
QListWidgetItem* itemTwo = this->lstOrder->item( nextRow );
this->lstOrder->takeItem( currentRow + 1);
this->lstOrder->takeItem( nextRow + 2 );
this->lstOrder->insertItem( currentRow, itemTwo );
this->lstOrder->insertItem( nextRow, itemOne );
updateLabel();
}
To copy to clipboard, switch view to plain text mode
I had trouble with the takeItem part, and the only way I could make it work was to add the +1 and +2 to the rows in question for it to work properly, otherwise it would make one or two of the items disappear. I cant understand why though, as I understand takeItem returns a 0 if it was unsuccessful (something I personally dont agree with, returning -1 would be a better option in my opinion), so you'd need to pass in a 1 to literally get the first row, which I understand alright, but then I need to take the next item and it wont work unless I have the +2 in there, if I have what would logically be there (+1) it would just make the selected item disappear. I would greatly appreciate someone explaining why this is to my rather slow mind.
Thanks again though stampede, what I do have does work.
Bookmarks