void schedulePlaceRemoval(int index);
void cancelPlaceRemoval(int index);
QMimeData *createMimeData(const QList<int> &indexes) const;
+ void increaseIndexIfNeeded(int &index) const;
QTemporaryDir m_tempHomeDir;
};
return mimeData;
}
+void PlacesItemModelTest::increaseIndexIfNeeded(int &index) const
+{
+ if (m_hasDesktopFolder) {
+ index++;
+ }
+ if (m_hasDocumentsFolder) {
+ index++;
+ }
+ if (m_hasDownloadsFolder) {
+ index++;
+ }
+}
+
void PlacesItemModelTest::init()
{
m_model = new PlacesItemModel();
{
const auto groups = m_model->groups();
int expectedRemoteIndex = 2;
- if (m_hasDesktopFolder) {
- expectedRemoteIndex++;
- }
- if (m_hasDocumentsFolder) {
- expectedRemoteIndex++;
- }
- if (m_hasDownloadsFolder) {
- expectedRemoteIndex++;
- }
+ increaseIndexIfNeeded(expectedRemoteIndex);
QCOMPARE(groups.size(), 6);
PlacesItemModel *model = new PlacesItemModel();
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
// create a new place
createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
void PlacesItemModelTest::testSystemItems()
{
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
QCOMPARE(m_model->count(), m_expectedModelCount);
for (int r = 0; r < m_model->count(); r++) {
void PlacesItemModelTest::testEditBookmark()
{
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
QScopedPointer<PlacesItemModel> other(new PlacesItemModel());
void PlacesItemModelTest::testEditAfterCreation()
{
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
void PlacesItemModelTest::testEditMetadata()
{
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
void PlacesItemModelTest::testRefresh()
{
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
void PlacesItemModelTest::testDragAndDrop()
{
int lastIndex = 1; // last index of places group
- if (m_hasDesktopFolder) {
- lastIndex++;
- }
- if (m_hasDocumentsFolder) {
- lastIndex++;
- }
- if (m_hasDownloadsFolder) {
- lastIndex++;
- }
+ increaseIndexIfNeeded(lastIndex);
QList<QVariant> args;
KItemRangeList range;
void PlacesItemModelTest::renameAfterCreation()
{
int tempDirIndex = 2;
- if (m_hasDesktopFolder) {
- tempDirIndex++;
- }
- if (m_hasDocumentsFolder) {
- tempDirIndex++;
- }
- if (m_hasDownloadsFolder) {
- tempDirIndex++;
- }
+ increaseIndexIfNeeded(tempDirIndex);
const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QStringList urls = initialUrls();