summaryrefslogtreecommitdiffstats
path: root/src/app/Panel/krpreviewpopup.cpp
blob: 1a65540a190a8e92eac63dc34e2a2eaba20a2115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/***************************************************************************
                          krpreviewpopup.cpp  -  description
                             -------------------
    begin                : Sun Dec 29 2002
    copyright            : (C) 2002 by Shie Erlich & Rafi Yanai
    web site             : http://krusader.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <tdeio/previewjob.h>
#include "krpreviewpopup.h"
#include <kdebug.h>
#include <tdelocale.h>
#include <keditcl.h>
#include "../KViewer/krviewer.h"
#include "../krusader.h"

KrPreviewPopup::KrPreviewPopup(): id(1),noPreview(true){
	connect(this,TQ_SIGNAL(activated(int)),this,TQ_SLOT(view(int)));
}

void KrPreviewPopup::setUrls(const KURL::List* urls){
	//insertItem(i18n("Configure preview"),0);
	insertItem(i18n("Preview not available"),0);

	TDEIO::PreviewJob* pjob;
	TQStringList plugins = TDEIO::PreviewJob::availablePlugins();

	for( unsigned int i=0; i< urls->count(); ++i){
		KFileItem* kfi = new KFileItem(KFileItem::Unknown,KFileItem::Unknown,*(urls->at(i)));
		files.append(kfi);
	}

	pjob = new TDEIO::PreviewJob(files,200,200,200,1,true,true,0);
	connect(pjob,TQ_SIGNAL(gotPreview(const KFileItem*,const TQPixmap&)),
          this,TQ_SLOT(addPreview(const KFileItem*,const TQPixmap&)));
}

KrPreviewPopup::~KrPreviewPopup(){}

void KrPreviewPopup::addPreview(const KFileItem* file,const TQPixmap& preview){
	if(noPreview){
		removeItem(0);
		noPreview = false;
	}
	insertItem(preview,id);
  insertItem(file->text(),id++);
	insertSeparator();
	availablePreviews.append(file->url());
}

void KrPreviewPopup::view(int id){
	if( id==0 ) return;
	else {
		KURL url = *(availablePreviews.at(id-1));
		KrViewer::view(url);
	}
}

#include "krpreviewpopup.moc"