summaryrefslogtreecommitdiffstats
path: root/languages/cpp/pcsimporter/customimporter/settingsdialog.cpp
blob: 9994dcdd7e97097db22e0c4d18227c04d1a050dd (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/***************************************************************************
*   Copyright (C) 2003 by Roberto Raggi                                   *
*   roberto@kdevelop.org                                                  *
*                                                                         *
*   Copyright (C) 2006 by Jens Dagerbo                                    *
*   jens.dagerbo@swipnet.se                                               *
*                                                                         *
*   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 <tqdir.h>

#include <klistbox.h>
#include <kcombobox.h>
#include <kurlrequester.h>
#include <kdeversion.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <klineedit.h>

#include <keditlistbox.h>

// should be included after possible KEditListBox redefinition
#include "settingsdialog.h"

#include <tqfile.h>
#include <tqregexp.h>
#include <tqlayout.h>
#include <tqcheckbox.h>

#include <cstdlib>

SettingsDialog::SettingsDialog( TQWidget* parent, const char* name, WFlags fl )
		: SettingsDialogBase( parent, name, fl )
{
	KURLRequester * req = new KURLRequester( this );
	req->setMode( KFile::Directory );
	KEditListBox::CustomEditor pCustomEditor;
	pCustomEditor = req->customEditor();
	elb = new KEditListBox( i18n( "Directories to Parse" ), pCustomEditor, this );

	grid->addMultiCellWidget( elb, 3, 3, 0, grid->numCols() );

	//	connect( dbName_edit, TQT_SIGNAL( textChanged( const TQString& ) ), this, TQT_SLOT( validate() ) );
	connect( elb->addButton(), TQT_SIGNAL( clicked() ), this, TQT_SLOT( validate() ) );
	connect( elb->removeButton(), TQT_SIGNAL( clicked() ), this, TQT_SLOT( validate() ) );
	connect( elb, TQT_SIGNAL( added( const TQString& ) ), this, TQT_SLOT( validateDirectory( const TQString& ) ) );
}

SettingsDialog::~SettingsDialog()
{}

TQString SettingsDialog::dbName( ) const
{
	return TQString();
// 	return dbName_edit->text();
}

TQStringList SettingsDialog::dirs( ) const
{
	return elb->items();
}

TQString SettingsDialog::filePattern( ) const
{
	return pattern_edit->text();
}

bool SettingsDialog::recursive( ) const
{
	return recursive_box->isChecked();
}

void SettingsDialog::validate()
{
// 	emit enabled( !dbName_edit->text().isEmpty() && elb->listBox() ->count() > 0 );
 	emit enabled( elb->listBox()->count() > 0 );
}

void SettingsDialog::validateDirectory( const TQString & dir )
{
	TQDir d( dir, TQString(), TQDir::DefaultSort, TQDir::Dirs );
	if ( !d.exists() )
	{
		elb->lineEdit() ->setText( dir );

		if ( TQListBoxItem * item = elb->listBox() ->findItem( dir, TQt::ExactMatch ) )
		{
			elb->listBox() ->removeItem( elb->listBox() ->index( item ) );
		}

		TQString errormsg = TQString( "<qt><b>%1</b> is not a directory</qt>" ).tqarg( dir );
		KMessageBox::error( 0, errormsg, "Couldn't find directory" );
	}
	emit enabled( elb->listBox()->count() > 0 );
}

#include "settingsdialog.moc" 
//kate: indent-mode csands; tab-width 4; space-indent off;