Example #1
0
	void LocalCollection::RemoveRootPaths (const QStringList& paths)
	{
		int removed = 0;
		for (const auto& str : paths)
		{
			removed += RootPaths_.removeAll (str);
			FilesWatcher_->RemovePath (str);
		}

		if (removed)
			emit rootPathsChanged (RootPaths_);
	}
Example #2
0
	void LocalCollection::AddRootPaths (QStringList paths)
	{
		Q_FOREACH (const auto& path, RootPaths_)
			paths.removeAll (path);
		if (paths.isEmpty ())
			return;

		RootPaths_ << paths;
		emit rootPathsChanged (RootPaths_);

		std::for_each (paths.begin (), paths.end (),
				[this] (decltype (paths.front ()) item) { FilesWatcher_->AddPath (item); });
	}
	FSBrowserWidget::FSBrowserWidget (QWidget *parent)
	: QWidget (parent)
	, Player_ (0)
	, FSModel_ (new FSModel (this))
	, ColumnsBeenResized_ (false)
	{
		Ui_.setupUi (this);

		FSModel_->setReadOnly (true);
		FSModel_->setRootPath (QDir::rootPath ());
		Ui_.FSTree_->setModel (FSModel_);

		auto addToPlaylist = new QAction (tr ("Add to playlist"), this);
		addToPlaylist->setProperty ("ActionIcon", "list-add");
		connect (addToPlaylist,
				SIGNAL (triggered ()),
				this,
				SLOT (loadFromFSBrowser ()));
		Ui_.FSTree_->addAction (addToPlaylist);

		DirCollection_ = new QAction (QString (), this);
		DirCollection_->setProperty ("WatchActionIconChange", true);
		Ui_.FSTree_->addAction (DirCollection_);

		Ui_.FSTree_->addAction (Util::CreateSeparator (this));

		ViewProps_ = new QAction (tr ("Show track properties"), this);
		ViewProps_->setProperty ("ActionIcon", "document-properties");
		connect (ViewProps_,
				SIGNAL (triggered ()),
				this,
				SLOT (viewProps ()));
		Ui_.FSTree_->addAction (ViewProps_);

		connect (Ui_.FSTree_->selectionModel (),
				SIGNAL (currentRowChanged (QModelIndex, QModelIndex)),
				this,
				SLOT (handleItemSelected (QModelIndex)));

		connect (Core::Instance ().GetLocalCollection (),
				SIGNAL (rootPathsChanged (QStringList)),
				this,
				SLOT (handleCollectionChanged ()));
	}