m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged,
this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
+ connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged,
+ this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
+ connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested,
+ this, &DolphinViewContainer::slotUrlSelectionRequested);
connect(m_view, &DolphinView::writeStateChanged,
this, &DolphinViewContainer::writeStateChanged);
connect(m_view, &DolphinView::requestItemInfo,
}
urlNavigator->setActive(isActive());
- connect(m_view, &DolphinView::urlChanged,
- urlNavigator, &DolphinUrlNavigator::setLocationUrl);
+ // Url changes are still done via m_urlNavigator.
connect(urlNavigator, &DolphinUrlNavigator::urlChanged,
- this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
- connect(urlNavigator, &DolphinUrlNavigator::activated,
- this, &DolphinViewContainer::activate);
- connect(urlNavigator, &DolphinUrlNavigator::urlAboutToBeChanged,
- this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
- connect(urlNavigator, &DolphinUrlNavigator::urlSelectionRequested,
- this, &DolphinViewContainer::slotUrlSelectionRequested);
+ m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
connect(urlNavigator, &DolphinUrlNavigator::urlsDropped,
this, [=](const QUrl &destination, QDropEvent *event) {
m_view->dropUrls(destination, event, urlNavigator->dropWidget());
});
+ // Aside from these, only visual things need to be connected.
+ connect(m_view, &DolphinView::urlChanged,
+ urlNavigator, &DolphinUrlNavigator::setLocationUrl);
+ connect(urlNavigator, &DolphinUrlNavigator::activated,
+ this, &DolphinViewContainer::activate);
m_urlNavigatorConnected = urlNavigator;
}
return;
}
+ disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged,
+ m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
+ disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped,
+ this, nullptr);
disconnect(m_view, &DolphinView::urlChanged,
m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
- disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged,
- this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated,
this, &DolphinViewContainer::activate);
- disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlAboutToBeChanged,
- this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
- disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlSelectionRequested,
- this, &DolphinViewContainer::slotUrlSelectionRequested);
- disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped,
- this, nullptr);
m_urlNavigatorVisualState = m_urlNavigatorConnected->visualState();
m_urlNavigatorConnected = nullptr;
bool m_hasDesktopFolder = false;
bool m_hasDocumentsFolder = false;
bool m_hasDownloadsFolder = false;
+ bool m_hasMusicFolder = false;
+ bool m_hasPicturesFolder = false;
+ bool m_hasVideosFolder = false;
void setBalooEnabled(bool enabled);
int indexOf(const QUrl &url);
void schedulePlaceRemoval(int index);
void cancelPlaceRemoval(int index);
QMimeData *createMimeData(const QList<int> &indexes) const;
+ void increaseIndexIfNeeded(int &index) const;
QTemporaryDir m_tempHomeDir;
};
urls << QDir::homePath() + QStringLiteral("/Downloads");
}
+ if (m_hasMusicFolder) {
+ urls << QDir::homePath() + QStringLiteral("/Music");
+ }
+
+ if (m_hasPicturesFolder) {
+ urls << QDir::homePath() + QStringLiteral("/Pictures");
+ }
+
+ if (m_hasVideosFolder) {
+ urls << QDir::homePath() + QStringLiteral("/Videos");
+ }
+
urls << QStringLiteral("trash:/")
<< QStringLiteral("remote:/")
<< QStringLiteral("/media/nfs");
return mimeData;
}
+void PlacesItemModelTest::increaseIndexIfNeeded(int &index) const
+{
+ if (m_hasDesktopFolder) {
+ index++;
+ }
+ if (m_hasDocumentsFolder) {
+ index++;
+ }
+ if (m_hasDownloadsFolder) {
+ index++;
+ }
+ if (m_hasMusicFolder) {
+ index++;
+ }
+ if (m_hasPicturesFolder) {
+ index++;
+ }
+ if (m_hasVideosFolder) {
+ index++;
+ }
+}
+
void PlacesItemModelTest::init()
{
m_model = new PlacesItemModel();
m_expectedModelCount++;
}
+ if (QDir(QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).exists()) {
+ m_hasMusicFolder = true;
+ m_expectedModelCount++;
+ }
+
+ if (QDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)).exists()) {
+ m_hasPicturesFolder = true;
+ m_expectedModelCount++;
+ }
+
+ if (QDir(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)).exists()) {
+ m_hasVideosFolder = true;
+ m_expectedModelCount++;
+ }
+
qRegisterMetaType<KItemRangeList>();
qRegisterMetaType<KItemRange>();
}
{
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();