summaryrefslogtreecommitdiffstats
path: root/krusader/GUI/dirhistoryqueue.cpp
blob: a66d47f54cdcbee7f2b162a83e6412a89de39fe2 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/***************************************************************************
                         dirhistoryqueue.cpp  -  description
                            -------------------
   begin                : Thu Jan 1 2004
   copyright            : (C) 2004 by Shie Erlich & Rafi Yanai
   email                : 
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 "dirhistoryqueue.h"
#include "../Panel/listpanel.h"

#include <kdebug.h>

DirHistoryQueue::DirHistoryQueue( ListPanel* p ) {
	panel = p;

	connect( panel, SIGNAL( pathChanged( ListPanel* ) ), this, SLOT( slotPathChanged( ListPanel* ) ) );
}
DirHistoryQueue::~DirHistoryQueue() {}

/** No descriptions */
void DirHistoryQueue::slotPathChanged( ListPanel* p ) {
	KURL url = p->virtualPath();
	// already in the queue ?
	if(  urlQueue.findIndex( url ) >= 0 ){
		// remove it !
		urlQueue.remove( url );
	}
	// do we have room for another ?
	if ( urlQueue.size() > 12 ) {
		// no room - remove the oldest entry
		urlQueue.pop_back();	
	}
	
	urlQueue.push_front( url );
}

#if 0
void DirHistoryQueue::addUrl(const KURL& url){
	if ( pathQueue.findIndex( path ) == -1 ) {
		if ( pathQueue.size() > 12 ) {
			// remove the oldest entry
			pathQueue.pop_back();
		}
	} else {
		pathQueue.remove( path );
	}

	pathQueue.push_front( path );
}

void DirHistoryQueue::RemovePath( const QString& path ) {
	QStringList::iterator it;
	it = pathQueue.find( path );
	if ( it != pathQueue.end() ) {
		pathQueue.remove( it );
	}
}

bool DirHistoryQueue::checkPath( const QString& path ) {
	KURL url( path );

	QString p = url.path();
	//  kdDebug() << "url:" << p <<  ", file: " << url.fileName() << ", dir: " << url.directory() <<  endl;
	if ( url.protocol() == "file" ) {
		QDir dir( path );
		if ( !dir.exists() ) {
			RemovePath( path );
			return false;
		}
	}

	return true;

}
#endif

#include "dirhistoryqueue.moc"