1
/***************************************************************************
2
* Copyright (C) 2007 by Andreas Pakulat *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
***************************************************************************/
13
#include "selectnewfilesdialog.h"
15
#include <qlistview.h>
16
#include <klistview.h>
18
#include <qstringlist.h>
21
#include "selectnewfilesdialogbase.h"
23
SelectNewFilesDialog::SelectNewFilesDialog( QStringList paths, QWidget* parent, const char* name )
24
: KDialogBase( parent, name, true, i18n("Add newly created files to project"), KDialogBase::Ok|KDialogBase::Cancel )
26
m_widget = new SelectNewFilesDialogBase(this);
27
m_widget->fileView->header()->hide();
28
m_widget->fileView->addColumn(i18n("Path") );
29
for( QStringList::const_iterator it = paths.begin(); it != paths.end(); ++it)
33
setMainWidget( m_widget );
37
SelectNewFilesDialog::~SelectNewFilesDialog()
40
void SelectNewFilesDialog::slotCancel()
44
KDialogBase::slotCancel();
47
void SelectNewFilesDialog::checkItem( QCheckListItem* item, const QString& curpath )
52
QString path = curpath + item->text();
53
if( item->state() != QCheckListItem::Off )
57
if( item->firstChild() )
59
checkItem( static_cast<QCheckListItem*>(item->firstChild()), path+"/" );
61
if( item->nextSibling() )
63
checkItem( static_cast<QCheckListItem*>(item->nextSibling()), curpath );
67
void SelectNewFilesDialog::slotOk()
69
QCheckListItem* item = static_cast<QCheckListItem*> (m_widget->fileView->firstChild());
70
checkItem( item, "" );
71
kdDebug(9025) << "Inc List:" << includePaths << endl;
72
kdDebug(9025) << "Exc List:" << excludePaths << endl;
73
KDialogBase::slotOk();
76
void SelectNewFilesDialog::addPath( QCheckListItem* item, const QString& path )
81
QStringList parts = QStringList::split("/", path );
82
QString name = parts.first();
84
QCheckListItem* i = createItem( item, name, parts.size() );
85
i->setState( QCheckListItem::On );
86
i->setTristate( true );
87
addPath(i, parts.join("/") );
90
QCheckListItem* SelectNewFilesDialog::createItem( QCheckListItem* parent, const QString& name, int count )
92
QCheckListItem::Type t = QCheckListItem::CheckBox;
94
t = QCheckListItem::CheckBoxController;
98
QListViewItem* item = m_widget->fileView->firstChild();
101
if( item->text( 0 ) == name )
102
return static_cast<QCheckListItem*>(item);
103
item = item->nextSibling();
105
return new QCheckListItem( m_widget->fileView, name, t );
108
QListViewItem* item = parent->firstChild();
111
if( item->text( 0 ) == name )
112
return static_cast<QCheckListItem*>(item);
113
item = item->nextSibling();
115
return new QCheckListItem( parent, name, t );
119
QStringList SelectNewFilesDialog::excludedPaths() const
124
QStringList SelectNewFilesDialog::includedPaths() const
129
#include "selectnewfilesdialog.moc"
131
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on