~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to parts/fileview/filegroupspart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2001-2002 by Bernd Gehrmann                             *
 
3
 *   bernd@kdevelop.org                                                    *
 
4
 *                                                                         *
 
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.                                   *
 
9
 *                                                                         *
 
10
 ***************************************************************************/
 
11
 
 
12
#include "filegroupspart.h"
 
13
#include "filegroupspart.moc"
 
14
 
 
15
#include <qwhatsthis.h>
 
16
#include <qvbox.h>
 
17
#include <qtimer.h>
 
18
#include <kaction.h>
 
19
#include <kdebug.h>
 
20
#include <kiconloader.h>
 
21
#include <klocale.h>
 
22
#include <kdevgenericfactory.h>
 
23
#include <kdialogbase.h>
 
24
 
 
25
#include "kdevcore.h"
 
26
#include "kdevproject.h"
 
27
#include "kdevmainwindow.h"
 
28
#include "kdevplugininfo.h"
 
29
 
 
30
#include "filegroupswidget.h"
 
31
#include "filegroupsconfigwidget.h"
 
32
 
 
33
#define FILEGROUPS_OPTIONS 1
 
34
 
 
35
typedef KDevGenericFactory<FileGroupsPart> FileGroupsFactory;
 
36
static const KDevPluginInfo data("kdevfilegroups");
 
37
K_EXPORT_COMPONENT_FACTORY( libkdevfilegroups, FileGroupsFactory( data ) )
 
38
 
 
39
FileGroupsPart::FileGroupsPart(QObject *parent, const char *name, const QStringList &)
 
40
    : KDevPlugin(&data, parent, name ? name : "FileGroupsPart")
 
41
{
 
42
    deleteRequested = false;
 
43
    setInstance(FileGroupsFactory::instance());
 
44
 
 
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"));
 
52
 
 
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 )) );
 
57
 
 
58
 
 
59
    // File groups
 
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();
 
69
}
 
70
 
 
71
FileGroupsPart::~FileGroupsPart()
 
72
{
 
73
    deleteRequested = true;
 
74
    if (m_filegroups)
 
75
        mainWindow()->removeView(m_filegroups);
 
76
    delete m_filegroups;
 
77
        delete _configProxy;
 
78
}
 
79
 
 
80
void FileGroupsPart::refresh()
 
81
{
 
82
    if (deleteRequested)
 
83
        return;
 
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()));
 
88
}
 
89
 
 
90
void FileGroupsPart::insertConfigWidget( const KDialogBase * dlg, QWidget * page, unsigned int pagenumber )
 
91
{
 
92
        if ( pagenumber == FILEGROUPS_OPTIONS )
 
93
        {
 
94
                FileGroupsConfigWidget *w = new FileGroupsConfigWidget(this, page, "file groups config widget");
 
95
                connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) );
 
96
        }
 
97
}