Thanks detlev for your suggestion.. Could you please give me any example code snippet?. Bcoz. i&#39;m totally new to model/view programming and pyqt.<br><br><div class="gmail_quote">On Sun, Jan 17, 2010 at 5:03 PM, detlev <span dir="ltr">&lt;<a href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
how about using a QSortFilterProxy model to filter the excluded ones?<br>
<br>
Detlev<br>
<div><div></div><div class="h5"><br>
On Samstag, 16. Januar 2010, Jebagnana Das wrote:<br>
&gt; Hello all,<br>
&gt;         Greetings.. After a spending a long time for googling i found the<br>
&gt; way to list the contents of a particular directory. Thanks to QDirModel.<br>
&gt;<br>
&gt;        My aim here is to allow the user to exclude specific directories<br>
&gt; within the chosen directory.. After adding a particular directory to the<br>
&gt; exclusion list(on the right side)the selected directory and it&#39;s<br>
&gt;  descendents should be removed(or hidden)from the tree view so that the<br>
&gt;  user is not allowed to select the same folder again..<br>
&gt;<br>
&gt;       Given here the minimal example needed for my app.. In this example<br>
&gt; when the user presses add to exclude list push button the folder is added<br>
&gt;  to the exclude folders listwidget..<br>
&gt;<br>
&gt; from PyQt4 import QtCore, QtGui<br>
&gt;<br>
&gt; class Ui_Dialog(QtGui.QDialog):<br>
&gt;<br>
&gt;     def __init__(self,parent=None):<br>
&gt;         QtGui.QDialog.__init__(self,parent)<br>
&gt;         self.resize(600, 500)<br>
&gt;<br>
&gt;         self.model = QtGui.QDirModel()<br>
&gt;         self.tree = QtGui.QTreeView(self)<br>
&gt;         self.tree.setModel(self.model)<br>
&gt;         self.model.setFilter(QtCore.QDir.Dirs|QtCore.QDir.NoDotAndDotDot)<br>
&gt;         self.tree.setSortingEnabled(True)<br>
&gt;<br>
&gt; self.tree.setRootIndex(self.model.index(&quot;/home/jebagnanadasa/Python-3.1.1&quot;)<br>
&gt; )<br>
&gt;<br>
&gt;         self.tree.hideColumn(1)<br>
&gt;         self.tree.setWindowTitle(&quot;Dir View&quot;)<br>
&gt;         self.tree.resize(400, 480)<br>
&gt;         self.tree.setColumnWidth(0,150)<br>
&gt;         self.tree.show()<br>
&gt;<br>
&gt;         self.pushButton = QtGui.QPushButton(self)<br>
&gt;         self.pushButton.setGeometry(QtCore.QRect(420, 30, 151, 28))<br>
&gt;         self.listWidget = QtGui.QListWidget(self)<br>
&gt;         self.listWidget.setGeometry(QtCore.QRect(410, 80, 171, 231))<br>
&gt;<br>
&gt;         QtCore.QObject.connect(self.tree,<br>
&gt; QtCore.SIGNAL(&quot;clicked(QModelIndex)&quot;), self.test)<br>
&gt;<br>
&gt; QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL(&#39;clicked()&#39;),self.addT<br>
</div></div>&gt; oList) QtCore.QMetaObject.connectSlotsByName(self)<br>
<div><div></div><div class="h5">&gt;<br>
&gt;         self.setWindowTitle(QtGui.QApplication.translate(&quot;Dialog&quot;,<br>
&gt;  &quot;Dialog&quot;, None, QtGui.QApplication.UnicodeUTF8))<br>
&gt;         self.pushButton.setText(QtGui.QApplication.translate(&quot;Dialog&quot;, &quot;Add<br>
&gt; to Exclude List&quot;, None, QtGui.QApplication.UnicodeUTF8))<br>
&gt;<br>
&gt;     def test(self,index):<br>
&gt;<br>
&gt;         if self.model.data(index.parent())==&quot;jebagnanadasa&quot;:<br>
&gt;             self.selectedDirectoryPath=self.model.data(index)<br>
&gt;             print(self.selectedDirectoryPath)<br>
&gt;         else:<br>
&gt;             dirHierarchy=[]<br>
&gt;             dirHierarchy.insert(0,self.model.data(index))<br>
&gt;             while (self.model.data(index.parent())!=&quot;jebagnanadasa&quot;):<br>
&gt;                 index=index.parent()<br>
&gt;                 dirHierarchy.insert(0,self.model.data(index))<br>
&gt;             self.selectedDirectoryPath=&quot;/&quot;.join(dirHierarchy)<br>
&gt;             print(self.selectedDirectoryPath)<br>
&gt;<br>
&gt;         #self.model.removeRow(0,index)<br>
&gt;<br>
&gt;     def addToList(self):<br>
&gt;         self.listWidget.addItem(self.selectedDirectoryPath)<br>
&gt;<br>
&gt;<br>
&gt; if __name__ == &quot;__main__&quot;:<br>
&gt;     import sys<br>
&gt;     app = QtGui.QApplication(sys.argv)<br>
&gt;     ui = Ui_Dialog()<br>
&gt;     ui.show()<br>
&gt;     sys.exit(app.exec_())<br>
&gt;<br>
&gt; See the screenshot also..<br>
&gt;<br>
&gt; [image:<br>
&gt; ?ui=2&amp;view=att&amp;th=12637fd44b798078&amp;attid=0.1&amp;disp=attd&amp;realattid=ii_12637fd<br>
&gt; 44b798078&amp;zw]<br>
&gt;<br>
&gt; Is there a way that i can make the excluded directories to be ignored when<br>
&gt; displaying the contents of the directory on consecutive startup(since it<br>
&gt;  was already on the exclusion list)?<br>
&gt;<br>
&gt; Any help would be much appreciated.. Thanks..<br>
&gt;<br>
&gt; P.S: remove() and rmdir() is not recommended since it deletes the<br>
&gt; directories entirely from the file System!<br>
&gt;<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Detlev Offenbach<br>
<a href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a><br>
</font></blockquote></div><br>