1
/***************************************************************************
2
* Copyright (C) 2001-2002 by Bernd Gehrmann *
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
***************************************************************************/
12
#include "filegroupspart.h"
13
#include "filegroupspart.moc"
15
#include <qwhatsthis.h>
20
#include <kiconloader.h>
22
#include <kdevgenericfactory.h>
23
#include <kdialogbase.h>
26
#include "kdevproject.h"
27
#include "kdevmainwindow.h"
28
#include "kdevplugininfo.h"
30
#include "filegroupswidget.h"
31
#include "filegroupsconfigwidget.h"
33
#define FILEGROUPS_OPTIONS 1
35
typedef KDevGenericFactory<FileGroupsPart> FileGroupsFactory;
36
static const KDevPluginInfo data("kdevfilegroups");
37
K_EXPORT_COMPONENT_FACTORY( libkdevfilegroups, FileGroupsFactory( data ) )
39
FileGroupsPart::FileGroupsPart(QObject *parent, const char *name, const QStringList &)
40
: KDevPlugin(&data, parent, name ? name : "FileGroupsPart")
42
deleteRequested = false;
43
setInstance(FileGroupsFactory::instance());
45
m_filegroups = new FileGroupsWidget(this);
46
m_filegroups->setCaption(i18n("File Group View"));
47
m_filegroups->setIcon(SmallIcon( info()->icon() ) );
48
QWhatsThis::add(m_filegroups, i18n("<b>File group view</b><p>"
49
"The file group viewer shows all files of the project, "
50
"in groups which can be configured in project settings dialog, <b>File Groups</b> tab."));
51
mainWindow()->embedSelectView(m_filegroups, i18n("File Groups"), i18n("File groups in the project directory"));
53
_configProxy = new ConfigWidgetProxy( core() );
54
_configProxy->createProjectConfigPage( i18n("File Groups"), FILEGROUPS_OPTIONS, info()->icon() );
55
connect( _configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )),
56
this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )) );
60
connect( project(), SIGNAL(addedFilesToProject(const QStringList&)),
61
m_filegroups, SLOT(addFiles(const QStringList&)) );
62
connect( project(), SIGNAL(removedFilesFromProject(const QStringList&)),
63
m_filegroups, SLOT(removeFiles(const QStringList&)) );
64
/* connect( project(), SIGNAL(addedFileToProject(const QString&)),
65
m_filegroups, SLOT(addFile(const QString&)) );
66
connect( project(), SIGNAL(removedFileFromProject(const QString&)),
67
m_filegroups, SLOT(removeFile(const QString&)) );*/
68
m_filegroups->refresh();
71
FileGroupsPart::~FileGroupsPart()
73
deleteRequested = true;
75
mainWindow()->removeView(m_filegroups);
80
void FileGroupsPart::refresh()
84
// This method may be called from m_filetree's slot,
85
// so we make sure not to modify the list view during
86
// the execution of the slot
87
QTimer::singleShot(0, m_filegroups, SLOT(refresh()));
90
void FileGroupsPart::insertConfigWidget( const KDialogBase * dlg, QWidget * page, unsigned int pagenumber )
92
if ( pagenumber == FILEGROUPS_OPTIONS )
94
FileGroupsConfigWidget *w = new FileGroupsConfigWidget(this, page, "file groups config widget");
95
connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) );