00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "kateprojectdirview.h"
00022
#include "kateprojectdirview.moc"
00023
00024
#include <kdialogbase.h>
00025
#include <kicontheme.h>
00026
#include <klocale.h>
00027
00028
class KateProjectDirViewDialog :
public KDialogBase
00029 {
00030
public:
00031 KateProjectDirViewDialog (
Kate::Project *project,
const QString &dir, QWidget *parent);
00032 ~KateProjectDirViewDialog ();
00033
00034
int exec();
00035
00036
private:
00037
Kate::Project *m_project;
00038 QString m_dir;
00039 KateProjectDirView *m_view;
00040 };
00041
00042 KateProjectDirView::KateProjectDirView (
Kate::Project *project,
const QString &dir, QWidget *parent) : KFileIconView (parent, "projectdirview")
00043 {
00044 m_project = project;
00045 m_relDir = dir;
00046 m_dir = KURL (m_project->dir() + QString (
"/") + m_relDir);
00047 m_dirs = m_project->
dirs (dir);
00048 m_files = m_project->files (dir);
00049
00050 setSelectionMode (KFile::Extended);
00051 setIconSize( KIcon::SizeMedium );
00052
00053 m_listJob = KIO::listDir (m_dir,
false,
true);
00054 connect (m_listJob, SIGNAL(entries( KIO::Job *,
const KIO::UDSEntryList&)),
this, SLOT(entries( KIO::Job *,
const KIO::UDSEntryList&)));
00055 }
00056
00057 KateProjectDirView::~KateProjectDirView ()
00058 {
00059 }
00060
00061
void KateProjectDirView::entries( KIO::Job *,
const KIO::UDSEntryList& list)
00062 {
00063
for (uint z=0; z < list.count(); z++)
00064 {
00065 KFileItem *item =
new KFileItem (list[z], m_dir,
true,
true);
00066
00067
if (item->isDir())
00068 {
00069
if ((item->name() != QString (
".")) && (item->name() != QString (
"..")) && (m_dirs.findIndex (item->name()) == -1))
00070 insertItem (item);
00071 }
00072
else
00073 {
00074
if (m_files.findIndex (item->name()) == -1)
00075 insertItem (item);
00076 }
00077 }
00078 }
00079
00080
void KateProjectDirView::addDialog (
Kate::Project *project,
const QString &dir, QWidget *parent)
00081 {
00082 KateProjectDirViewDialog* dlg =
new KateProjectDirViewDialog (project, dir, parent);
00083 dlg->exec();
00084
delete dlg;
00085 }
00086
00087 KateProjectDirViewDialog::KateProjectDirViewDialog (
Kate::Project *project,
const QString &dir, QWidget *parent) : KDialogBase (parent, "dirviewdialog", true, i18n ("Add Directories/Files to Project"), KDialogBase::Ok|KDialogBase::Cancel)
00088 {
00089 m_project = project;
00090 m_dir = dir;
00091 m_view =
new KateProjectDirView (project, dir,
this);
00092 setMainWidget(m_view);
00093 }
00094
00095 KateProjectDirViewDialog::~KateProjectDirViewDialog ()
00096 {
00097 }
00098
00099
int KateProjectDirViewDialog::exec()
00100 {
00101
int n = 0;
00102
00103
if ((n = KDialogBase::exec()))
00104 {
00105 QStringList dirs, files;
00106
for (KFileItem *item = m_view->firstFileItem(); item != 0; item = m_view->nextItem (item))
00107 {
00108
if (m_view->isSelected (item))
00109 {
00110
if (item->isDir())
00111 dirs.push_back (item->name());
00112
else
00113 files.push_back (item->name());
00114 }
00115 }
00116
00117 m_project->addDirs (m_dir, dirs);
00118 m_project->addFiles (m_dir, files);
00119 }
00120
00121
return n;
00122 }