[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdemultimedia/noatun/modules/splitplaylist
From:       Stefan Gehn <mETz81 () web ! de>
Date:       2007-02-25 18:32:45
Message-ID: 1172428365.301294.12504.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 637192 by metz:

- Remove obsolete/annoying paint/resize code from splitplaylist
- try to guess mimetype for added files by looking at the url before trying stupid \
KIO::MimeTypeJob, it always seems to fetch the WHOLE file :(


 M  +26 -59    view.cpp  
 M  +0 -2      view.h  


--- trunk/KDE/kdemultimedia/noatun/modules/splitplaylist/view.cpp #637191:637192
@@ -230,30 +230,15 @@
 
 void SafeListViewItem::modified()
 {
-	bool widthChangeNeeded = false;
+	PlaylistItem pli = SPL->item(new ItemData(SPL, this));
+	const QString titlestring = SPL->Plugin::global()->player()->title(pli);
 
-	PlaylistItem pli(SPL->item(new ItemData(SPL, this)));
-	QString titlestring = SPL->Plugin::global()->player()->title(pli);
+	setText(0, titlestring);
+	setText(1, pli.lengthString());
 
-	if (text(0) != titlestring)
-	{
-		setText(0, titlestring);
-		widthChangeNeeded = true;
-	}
-
-	if (pli.length()!=-1 && text(1)!=pli.lengthString())
-	{
-		setText(1, pli.lengthString());
-		widthChangeNeeded = true;
-	}
-
-	if (widthChangeNeeded)
-		widthChanged(-1);
-
 	pli.modified(SPL->Plugin::global());
 }
 
-
 void SafeListViewItem::stateChange(bool s)
 {
 	// if you uncheck this, uncheck the others that
@@ -273,26 +258,6 @@
 	}
 }
 
-
-void SafeListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int \
                width, int align)
-{
-	Q3CheckListItem::paintCell(p, cg, column, width, align);
-
-	ItemData *item = SPL->item(SPL->current());
-	if (item && item->item() == this)
-	{
-		kDebug(66666) << k_funcinfo << "for current item" << endl;
-		p->save();
-
-		// p->setRasterOp(XorROP); // TODO KDE4 XXX
-		p->setOpacity(0.5);
-		p->fillRect(0, 0, width, height(), Qt::white);
-
-		p->restore();
-	}
-}
-
-
 void SafeListViewItem::remove()
 {
 	kDebug(66666) << k_funcinfo << "For item " << text(0) << endl;
@@ -318,18 +283,7 @@
 
 void SafeListViewItem::showPlaying(bool p)
 {
-	if (p)
-	{
-		setPixmap(0, ::SmallIcon("player_play"));
-	}
-	else
-	{
-		setPixmap(0, QPixmap());
-	}
-
-	QRect rect(listView()->itemRect(this));
-	rect.setWidth(listView()->viewport()->width());
-	listView()->viewport()->update(rect);
+	setPixmap(0, (p ? ::SmallIcon("player_play") : QPixmap()));
 }
 
 
@@ -344,7 +298,8 @@
 	setDragEnabled(true);
 	setItemsMovable(true);
 	setSelectionMode(Q3ListView::Extended);
-	connect(this, SIGNAL(dropped(QDropEvent*, Q3ListViewItem*)), \
SLOT(dropEvent(QDropEvent*, Q3ListViewItem*))); +	connect(this, \
SIGNAL(dropped(QDropEvent*, Q3ListViewItem*)), +		SLOT(dropEvent(QDropEvent*, \
Q3ListViewItem*)));  connect(this, SIGNAL(moved()), SLOT(move()));
 	connect(this, SIGNAL(aboutToMove()), parent, SLOT(setNoSorting()));
 	connect(this, SIGNAL(deleteCurrentItem()), parent, SLOT(deleteSelected()));
@@ -486,19 +441,26 @@
 Q3ListViewItem *List::addFile(const KUrl& url, bool play, Q3ListViewItem *after)
 {
 	// when a new item is added, we don't want to sort anymore
-	//SPL->view->setNoSorting();
 	static_cast<View*>(parent())->setNoSorting();
 	Q3ListViewItem *currentItem = 0;
+	QString mimeType;
 
-	QString mimetype = KIO::NetAccess::mimetype(url, 0);
+	mimeType = KMimeType::findByUrl(url, 0 /*mode*/,
+		url.isLocalFile() /*is local*/, false /*fast mode*/)->name();
+	if (mimeType == "application/octet-stream")
+	{
+		kDebug(66666) << "COULD NOT DETERMINE MIMETYPE FOR URL, ASKING KIO" << endl;
+		mimeType = KIO::NetAccess::mimetype(url, 0);
+	}
+	kDebug(66666) << "==> Found MimeType " << mimeType << endl;
 
-	kDebug(66666) << "mimetype: " << mimetype << endl;
 
-	if (PlaylistSaver::loadableMimeTypes().contains(mimetype))
+	if (PlaylistSaver::loadableMimeTypes().contains(mimeType))
 	{
+		kDebug(66666) << "Passed KUrl ist supported by PlaylistSaver" << endl;
 		// it's a playlist
 		NoatunSaver saver(this, after);
-		if (saver.load(url))
+		if (saver.load(url, mimeType))
 		{
 			// return the first item added from this playlist
 			// that way noatun can start playing the first item
@@ -509,12 +471,13 @@
 				currentItem = saver.getAfter();
 		}
 	}
-	else // check player()->mimeTypes()
+	else if (SPL->Plugin::global()->player()->mimeTypes().contains(mimeType))
 	{
+		kDebug(66666) << "Passed KUrl ist supported by Player" << endl;
 		if (!after)
 			after = lastItem();
 
-		KFileItem fileItem(KFileItem::Unknown,KFileItem::Unknown,url);
+		KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown,url);
 		if (fileItem.isDir())
 		{
 			addDirectoryRecursive(url, after);
@@ -525,6 +488,10 @@
 			currentItem = new SafeListViewItem(this, after, url);
 		}
 	}
+	else
+	{
+		kDebug(66666) << "Passed KUrl ist unsupported by Noatun" << endl;
+	}
 
 	if (play && currentItem)
 		SPL->listItemSelected(currentItem);
--- trunk/KDE/kdemultimedia/noatun/modules/splitplaylist/view.h #637191:637192
@@ -62,8 +62,6 @@
 	virtual void modified();
 	virtual void stateChange(bool s);
 
-	void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int \
                align);
-
 private:
 	struct Property
 	{


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic