Rows with the same topic but in different letter case can be reordered

c++11
Stanislav Bas 10 years ago
parent ced4e237a8
commit 21f0b586ec

@ -97,7 +97,8 @@ bool CSMWorld::InfoCollection::reorderRows (int baseIndex, const std::vector<int
return false; return false;
// Check that topics match // Check that topics match
if (getRecord (baseIndex).get().mTopicId!=getRecord (lastIndex).get().mTopicId) if (!Misc::StringUtils::ciEqual(getRecord(baseIndex).get().mTopicId,
getRecord(lastIndex).get().mTopicId))
return false; return false;
// reorder // reorder

@ -9,6 +9,8 @@
#include <QString> #include <QString>
#include <QtCore/qnamespace.h> #include <QtCore/qnamespace.h>
#include <components/misc/stringops.hpp>
#include "../../model/doc/document.hpp" #include "../../model/doc/document.hpp"
#include "../../model/world/data.hpp" #include "../../model/world/data.hpp"
@ -128,17 +130,24 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
{ {
int row = mProxyModel->mapToSource ( int row = mProxyModel->mapToSource (
mProxyModel->index (selectedRows.begin()->row(), 0)).row(); mProxyModel->index (selectedRows.begin()->row(), 0)).row();
QString curData = mModel->data(mModel->index(row, column)).toString();
if (row>0 && mModel->data (mModel->index (row, column))== if (row > 0)
mModel->data (mModel->index (row-1, column)))
{ {
menu.addAction (mMoveUpAction); QString prevData = mModel->data(mModel->index(row - 1, column)).toString();
if (Misc::StringUtils::ciEqual(curData.toStdString(), prevData.toStdString()))
{
menu.addAction(mMoveUpAction);
}
} }
if (row<mModel->rowCount()-1 && mModel->data (mModel->index (row, column))== if (row < mModel->rowCount() - 1)
mModel->data (mModel->index (row+1, column)))
{ {
menu.addAction (mMoveDownAction); QString nextData = mModel->data(mModel->index(row + 1, column)).toString();
if (Misc::StringUtils::ciEqual(curData.toStdString(), nextData.toStdString()))
{
menu.addAction(mMoveDownAction);
}
} }
} }
} }

Loading…
Cancel
Save