Re: Thumbnail Bar

"Ilya Konkov" <[email protected]> Fri, 28 Mar 2008 22:01:23 +0500
Newsgroups gmane.comp.kde.gwenview
Message-ID <[email protected]>
Hello.

1. Scrollbar's arrows.
Seems that I have to specify url for image. How and into what dir
should I put images of arrows?

2. Hiding dirs/archives.
I tried to make proxy model on top of existed SortedDirModel, but
there were problems with syncing thumbnail views.
So I added mime exclude filter to existed model. "Exclude" because it
feels to be faster, but not sure -- it's just feeling.

--
Ilya Konkov

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________
Gwenview-general mailing list
Gwenview-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/gwenview-general
mimefilter.patch (text/x-patch, 2.1 KB)
Index: app/mainwindow.cpp
===================================================================
--- app/mainwindow.cpp	(revision 791046)
+++ app/mainwindow.cpp	(working copy)
@@ -733,6 +733,8 @@
 void MainWindow::setActiveViewModeAction(QAction* action) {
 	if (action == d->mViewAction) {
 		// Switching to view mode
+		QStringList mimeFilter = MimeTypeUtils::dirMimeTypes() + ArchiveUtils::mimeTypes();
+		d->mDirModel->setMimeExcludeFilter(mimeFilter);
 		d->mViewStackedWidget->setCurrentWidget(d->mDocumentView);
 		if (d->mDocumentView->isEmpty()) {
 			openSelectedDocument();
@@ -750,6 +752,7 @@
 			// his image back.
 			d->mDocumentView->reset();
 		}
+		d->mDirModel->setMimeExcludeFilter(QStringList());
 	}
 
 	emit viewModeChanged();
Index: lib/sorteddirmodel.cpp
===================================================================
--- lib/sorteddirmodel.cpp	(revision 791046)
+++ lib/sorteddirmodel.cpp	(working copy)
@@ -31,6 +31,7 @@
 
 struct SortedDirModelPrivate {
 	KDirModel* mSourceModel;
+	QStringList mMimeFilter;
 };
 
 
@@ -82,4 +83,25 @@
 }
 
 
+void SortedDirModel::setMimeExcludeFilter(const QStringList &mimeList) {
+	if (d->mMimeFilter == mimeList) {
+		return;
+	}
+	d->mMimeFilter = mimeList;
+	invalidateFilter();
+}
+
+
+bool SortedDirModel::filterAcceptsRow(int row, const QModelIndex& parent) const {
+	if (!d->mMimeFilter.isEmpty()) {
+		QModelIndex index = d->mSourceModel->index(row, 0, parent);
+		QString mimeType = d->mSourceModel->itemForIndex(index).mimetype();
+		if (d->mMimeFilter.contains(mimeType)) {
+			return false;
+		} 
+	}
+	return KDirSortFilterProxyModel::filterAcceptsRow(row, parent);
+}
+
+
 } //namespace
Index: lib/sorteddirmodel.h
===================================================================
--- lib/sorteddirmodel.h	(revision 791046)
+++ lib/sorteddirmodel.h	(working copy)
@@ -45,6 +45,11 @@
 	QModelIndex indexForItem(const KFileItem& item) const;
 	QModelIndex indexForUrl(const KUrl& url) const;
 
+	virtual void setMimeExcludeFilter(const QStringList &mimeList);
+
+protected:
+	bool filterAcceptsRow(int row, const QModelIndex& parent) const;
+
 private:
 	SortedDirModelPrivate * const d;
 };