Permalink
Browse files

Sort indexList by row before sorting

  • Loading branch information...
1 parent 3331b7f commit bebac11f06a67568f07f780118516484cca62acd @hluk committed May 16, 2012
Showing with 6 additions and 2 deletions.
  1. +2 −1 src/action.cpp
  2. +4 −1 src/clipboardmodel.cpp
View
3 src/action.cpp
@@ -17,9 +17,10 @@
along with CopyQ. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <QAction>
#include "action.h"
+#include <QAction>
+
Action::Action(const QString &cmd, const QStringList &args,
const QByteArray &input, bool outputItems,
const QString &itemSeparator,
View
5 src/clipboardmodel.cpp
@@ -295,19 +295,22 @@ void ClipboardModel::sortItems(const QModelIndexList &indexList,
{
ComparisonItem a, b;
QList< QPair<int, ClipboardItem*> > list;
+ QList<int> rows;
for (int i = 0; i < indexList.length(); ++i) {
int row = indexList[i].row();
if ( row >= m_clipboardList.length() )
return;
list.append( qMakePair(row, m_clipboardList[row]) );
+ rows.append(row);
}
+ qSort(rows);
qSort( list.begin(), list.end(), compare );
for (int i = 0; i < list.length(); ++i ) {
int row1 = list[i].first;
- int row2 = indexList[i].row();
+ int row2 = rows[i];
if (row1 != row2) {
m_clipboardList[row2] = list[i].second;
QModelIndex ind = index(row2);

0 comments on commit bebac11

Please sign in to comment.