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

List:       kde-core-devel
Subject:    KFileDialog, KFileTreeView, KDirLister, something's broken
From:       Neil Stevens <neil () qualityassistant ! com>
Date:       2002-01-31 10:23:33
[Download RAW message or body]

If you use a KFileDialog to get a directory, then pass that directory to a 
KFileTreeView, the KFileTreeView gets no items.  Can anyone help me figure 
out what's wrong?

Attached is a simple test case, which is only very slightly modified from 
the (working) kfiletreeviewtest already in cvs.

thanks,
-- 
Neil Stevens
neil@qualityassistant.com

Don't think of a bug as a problem.  Think of it as a call to action.

["kfiletreeviewtest.cpp" (text/x-c)]

/* This file is part of the KDE libraries
    Copyright (C) 2001 Klaas Freitag <freitag@suse.de>

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

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <kmainwindow.h>
#include <kapp.h>
#include <kurl.h>
#include <kdebug.h>
#include <kstatusbar.h>
#include <kfiledialog.h>

#include <kfiletreeview.h>

class testFrame: public KMainWindow
{
public:
   testFrame();
   void showPath( KURL & );

private:
   KFileTreeView *treeView;
};


testFrame::testFrame():KMainWindow(0,"Test FileTreeView")
{
   treeView = new KFileTreeView( this );

   /* Connect to see the status bar */
   KStatusBar* sta = statusBar();
   connect( treeView, SIGNAL( onItem( const QString& )),
	    sta, SLOT( message( const QString& )));
   
   
   treeView->addColumn( "Column1" );
   
   setCentralWidget( treeView );
}

void testFrame::showPath( KURL &url )
{
   QString fname = url.fileName ();
   KFileTreeBranch *nb = treeView->addBranch( url, fname );
   treeView->populateBranch( nb );
}



int main(int argc, char **argv)
{
    KApplication a(argc, argv, "kfiletreeviewtest");
    QString name1;
    QStringList names;

    QString argv1;
    testFrame *tf;

    tf =  new testFrame();
    tf->show();
    a.setMainWidget( tf );

	KURL url = KFileDialog::getExistingDirectory();
	if(!url.isEmpty())
	{
		tf->showPath(url);
	}

    int ret = a.exec();
    return( ret );
}


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

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