summaryrefslogtreecommitdiffstats
path: root/buildtools/custommakefiles/custommanagerwidget.cpp
blob: 85f77d52f6c7f68d8992234483bf39e59223c28d (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
/***************************************************************************
 *   Copyright (C) 2007 by Andreas Pakulat                                 *
 *   apaku@gmx.de                                                          *
 *                                                                         *
 *   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 "custommanagerwidget.h"

#include <tqstringlist.h>
#include <tqlayout.h>
#include <tqlistbox.h>
#include <tqwhatsthis.h>
#include <tqtooltip.h>

#include <ktextedit.h>
#include <kurlrequester.h>
#include <kurlcompletion.h>
#include <tdefiledialog.h>
#include <keditlistbox.h>
#include <tdelocale.h>
#include <kdebug.h>

#include "customprojectpart.h"
#include "domutil.h"

CustomManagerWidget::CustomManagerWidget( CustomProjectPart* part, TQWidget* parent )
        : CustomManagerWidgetBase( parent ), m_part( part), m_dom( *part->projectDom() )
{
    m_filetypes->insertStringList( DomUtil::readListEntry( m_dom, "kdevcustomproject/filetypes", "filetype" ) );
    KURLRequester* urlselector = new KURLRequester( );
    urlselector->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
    urlselector->setURL( TQString() );
    urlselector->completionObject() ->setDir( part->projectDirectory() );
    urlselector->fileDialog() ->setURL( KURL( part->projectDirectory() ) );
    m_blacklistBox = new KEditListBox( i18n("blacklisted files and directories are not"
                         " considered part of the project, even if they fit one of "
                         "the wildcard patterns in the project file list",
                         "Blacklisted files/dirs"), urlselector->customEditor(), this);
    m_blacklistBox->setButtons( KEditListBox::Add | KEditListBox::Remove );
    m_blacklistBox->insertStringList( DomUtil::readListEntry( m_dom, "kdevcustomproject/blacklist","path") );
    grid->addWidget( m_blacklistBox, 0, 1 );
    connect(m_blacklistBox, TQT_SIGNAL(added(const TQString&)), this, TQT_SLOT(checkUrl(const TQString&)));
}

void CustomManagerWidget::checkUrl(const TQString& url)
{
    kdDebug(9025) << "got file:" << url << endl;
    if( !TQFileInfo(url).isRelative() )
    {
        kdDebug(9025) << "seems to be non-relative" << endl;
        TQString relpath = m_part->relativeToProject( url );
        TQListBoxItem* item = m_blacklistBox->listBox()->findItem( url );
        m_blacklistBox->listBox()->takeItem( item );
        kdDebug(9025) << "relative path:" << relpath << endl;
        if( !relpath.isEmpty() )
            m_blacklistBox->insertItem( relpath );
    }
}

CustomManagerWidget::~CustomManagerWidget()
{
}

void CustomManagerWidget::accept()
{
    DomUtil::writeListEntry( m_dom, "kdevcustomproject/filetypes", "filetype",
                            m_filetypes->items() );
    DomUtil::writeListEntry( m_dom, "kdevcustomproject/blacklist", "path",
                            m_blacklistBox->items() );
}


#include "custommanagerwidget.moc"

// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on