summaryrefslogtreecommitdiffstats
path: root/keep/app/includeexcludedialog.cpp
blob: c55eb6c1aa0ce4c3eb876e3fe7bd6159aebaa6be (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
/* This file is part of the Keep project
   Copyright (C) 2006 Jean-Rémy Falleri <jr.falleri@laposte.net>

   Keep 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.

   Keep 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 General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Keep; if not, write to the
   Free Software Foundation, Inc.,
   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.           */

#include "includeexcludedialog.h"

#include <tdelocale.h>
#include <tqlayout.h>
#include <kurl.h>
#include <dcopref.h>
#include <kdebug.h>
#include <kactivelabel.h>
#include <kmimetype.h>
#include <tqpixmap.h>
#include <tdeapplication.h>
#include <kpushbutton.h>
#include <kiconloader.h>
#include <tqstringlist.h>
#include <tdeactionselector.h>
#include <tdelistview.h>
#include <kurlrequester.h>

#include "includeexcludeitem.h"

IncludeExcludeDialog::IncludeExcludeDialog(TQWidget *parent):KDialogBase(Plain, i18n("Inclusion/Exclusion Configuration"),
	Help|Ok, Ok, parent, "includeExcludeDialog", true, false)
{
	TQGridLayout *topLayout = new TQGridLayout(plainPage());
	m_view = new IncludeExcludeView(plainPage());

	topLayout->addWidget( m_view,0,0 );

	TDEIconLoader *icons = TDEGlobal::iconLoader();
	m_view->remove->setPixmap(icons->loadIcon("remove",TDEIcon::Toolbar,22));

	m_view->includeExcludeList->setSorting(-1);

	connect(m_view->include,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotInclude()));
	connect(m_view->exclude,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotExclude()));
	connect(m_view->remove,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotRemove()));

	resize( TQSize(450,450).expandedTo(minimumSizeHint()) );
}

TQStringList IncludeExcludeDialog::includeExcludeList()
{
	TQStringList includeExcludeList;
	TQListViewItemIterator it( m_view->includeExcludeList );
	while ( it.current() ) {
		TQListViewItem *item = it.current();
		IncludeExcludeItem *includeExcludeItem = static_cast<IncludeExcludeItem*>(item);
		includeExcludeList.append(includeExcludeItem->includeExclude());
		++it;
	}
	return includeExcludeList;
}

void IncludeExcludeDialog::setIncludeExcludeList(TQStringList includeExcludeList)
{
	m_view->includeExcludeList->clear();
	TQStringList::iterator it;
	IncludeExcludeItem *lastItem;
	for ( it = includeExcludeList.begin(); it != includeExcludeList.end(); ++it )
	{
		if ( it == includeExcludeList.begin() )
			lastItem = new IncludeExcludeItem(m_view->includeExcludeList,*it);
		else
		{
			IncludeExcludeItem *item = new IncludeExcludeItem(m_view->includeExcludeList,lastItem,*it);
			lastItem = item;
		}
		
	}
}

void IncludeExcludeDialog::slotInclude()
{
	IncludeExcludeItem *item = new IncludeExcludeItem( m_view->includeExcludeList,"I" + m_view->itemURL->url() );
}

void IncludeExcludeDialog::slotExclude()
{
	IncludeExcludeItem *item = new IncludeExcludeItem( m_view->includeExcludeList,"E" + m_view->itemURL->url() );
}


void IncludeExcludeDialog::slotRemove()
{
	m_view->includeExcludeList->takeItem(m_view->includeExcludeList->selectedItem());
}

#include "includeexcludedialog.moc"