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

« back to all changes in this revision

Viewing changes to parts/fileview/fileviewpart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

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
 
 *   Copyright (C) 2003 by Mario Scalas                                    *
5
 
 *   mario.scalas@libero.it                                                *
6
 
 *                                                                         *
7
 
 *   This program is free software; you can redistribute it and/or modify  *
8
 
 *   it under the terms of the GNU General Public License as published by  *
9
 
 *   the Free Software Foundation; either version 2 of the License, or     *
10
 
 *   (at your option) any later version.                                   *
11
 
 *                                                                         *
12
 
 ***************************************************************************/
13
 
 
14
 
#include "fileviewpart.h"
15
 
 
16
 
#include <qwhatsthis.h>
17
 
#include <qvbox.h>
18
 
#include <qtoolbutton.h>
19
 
#include <qdom.h>
20
 
#include <kcombobox.h>
21
 
#include <qtimer.h>
22
 
#include <kaction.h>
23
 
#include <kdebug.h>
24
 
#include <kiconloader.h>
25
 
#include <klocale.h>
26
 
#include <kdevgenericfactory.h>
27
 
#include <kdialogbase.h>
28
 
 
29
 
#include "kdevcore.h"
30
 
#include "kdevproject.h"
31
 
#include "kdevmainwindow.h"
32
 
 
33
 
#include "partwidget.h"
34
 
#include "domutil.h"
35
 
#include "filetreewidget.h"
36
 
#include "vcscolorsconfigwidget.h"
37
 
#include "kdevversioncontrol.h"
38
 
#include "kdevplugininfo.h"
39
 
 
40
 
#define FILETREE_OPTIONS 1
41
 
 
42
 
///////////////////////////////////////////////////////////////////////////////
43
 
// static members
44
 
///////////////////////////////////////////////////////////////////////////////
45
 
 
46
 
VCSColors FileViewPart::vcsColors;
47
 
 
48
 
///////////////////////////////////////////////////////////////////////////////
49
 
// class factory
50
 
///////////////////////////////////////////////////////////////////////////////
51
 
 
52
 
typedef KDevGenericFactory<FileViewPart> FileViewFactory;
53
 
static const KDevPluginInfo data("kdevfileview");
54
 
K_EXPORT_COMPONENT_FACTORY( libkdevfileview, FileViewFactory( data ) )
55
 
 
56
 
///////////////////////////////////////////////////////////////////////////////
57
 
// class FileTreeWidget
58
 
///////////////////////////////////////////////////////////////////////////////
59
 
 
60
 
FileViewPart::FileViewPart(QObject *parent, const char *name, const QStringList &)
61
 
        : KDevPlugin(&data, parent, name ? name : "FileViewPart"),
62
 
    m_widget( 0 )
63
 
{
64
 
    setInstance( FileViewFactory::instance() );
65
 
    //    setXMLFile("kdevfileview.rc");
66
 
 
67
 
        _configProxy = new ConfigWidgetProxy( core() );
68
 
        _configProxy->createProjectConfigPage( i18n("File Tree"), FILETREE_OPTIONS, info()->icon() );
69
 
        connect( _configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )),
70
 
                this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )) );
71
 
 
72
 
        QTimer::singleShot( 1000, this, SLOT(init()) );
73
 
}
74
 
 
75
 
///////////////////////////////////////////////////////////////////////////////
76
 
 
77
 
void FileViewPart::init( )
78
 
{
79
 
        m_widget = new PartWidget( this );
80
 
        m_widget->setIcon( SmallIcon( info()->icon() ) );
81
 
        mainWindow()->embedSelectView( m_widget, i18n("File Tree"), i18n("File tree view in the project directory") );
82
 
 
83
 
        loadSettings();
84
 
 
85
 
        m_widget->showProjectFiles();
86
 
}
87
 
 
88
 
///////////////////////////////////////////////////////////////////////////////
89
 
 
90
 
FileViewPart::~FileViewPart()
91
 
{
92
 
    if (m_widget)
93
 
        mainWindow()->removeView( m_widget );
94
 
    delete m_widget;
95
 
 
96
 
    storeSettings();
97
 
 
98
 
        delete _configProxy;
99
 
}
100
 
 
101
 
///////////////////////////////////////////////////////////////////////////////
102
 
 
103
 
void FileViewPart::loadSettings()
104
 
{
105
 
    const QColor added = QColor( "#CCFF99" ),
106
 
        updated = QColor( "#FFFFCC" ),
107
 
        modified = QColor( "#CCCCFF" ),
108
 
        conflict = QColor( "#FF6666" ),
109
 
        sticky = QColor( "#FFCCCC" ),
110
 
        needsPatch = QColor( "#FFCCFF" ),
111
 
        needsCheckout = QColor( "#FFCCFF" ),
112
 
        unknown = QColor( white ),
113
 
        defaultColor = QColor( white );
114
 
 
115
 
    KConfig *cfg = instance()->config();
116
 
 
117
 
    KConfigGroupSaver gs( cfg, "VCS Colors" );
118
 
    vcsColors.added = cfg->readColorEntry( "FileAddedColor", &added );
119
 
    vcsColors.updated = cfg->readColorEntry( "FileUpdatedColor", &updated );
120
 
    vcsColors.sticky = cfg->readColorEntry( "FileStickyColor", &sticky );
121
 
    vcsColors.modified = cfg->readColorEntry( "FileModifiedColor", &modified );
122
 
    vcsColors.conflict = cfg->readColorEntry( "FileConflictColor", &conflict );
123
 
    vcsColors.needsPatch = cfg->readColorEntry( "FileNeedsPatchColor", &needsPatch );
124
 
    vcsColors.needsCheckout = cfg->readColorEntry( "FileNeedsCheckoutColor", &needsCheckout );
125
 
    vcsColors.unknown = cfg->readColorEntry( "FileUnknownColor", &unknown );
126
 
    vcsColors.defaultColor = cfg->readColorEntry( "DefaultColor", &defaultColor );
127
 
}
128
 
 
129
 
///////////////////////////////////////////////////////////////////////////////
130
 
 
131
 
void FileViewPart::storeSettings()
132
 
{
133
 
    KConfig *cfg = instance()->config();
134
 
    // VCS colors
135
 
    KConfigGroupSaver gs( cfg, "VCS Colors" );
136
 
    cfg->writeEntry( "FileAddedColor", vcsColors.added );
137
 
    cfg->writeEntry( "FileUpdatedColor", vcsColors.updated );
138
 
    cfg->writeEntry( "FileStickyColor", vcsColors.sticky );
139
 
    cfg->writeEntry( "FileModifiedColor", vcsColors.modified );
140
 
    cfg->writeEntry( "FileConflictColor", vcsColors.conflict );
141
 
    cfg->writeEntry( "FileNeedsPatchColor", vcsColors.needsPatch );
142
 
    cfg->writeEntry( "FileNeedsCheckoutColor", vcsColors.needsCheckout );
143
 
    cfg->writeEntry( "FileUnknownColor", vcsColors.unknown );
144
 
    cfg->writeEntry( "DefaultColor", vcsColors.defaultColor );
145
 
}
146
 
 
147
 
void FileViewPart::insertConfigWidget( const KDialogBase* dlg, QWidget * page, unsigned int pagenumber )
148
 
{
149
 
        if ( pagenumber == FILETREE_OPTIONS )
150
 
        {
151
 
                VCSColorsConfigWidget *w = new VCSColorsConfigWidget( this, vcsColors, page, "vcscolorsconfigwidget" );
152
 
                connect( dlg, SIGNAL(okClicked()), w, SLOT(slotAccept()) );
153
 
        }
154
 
}
155
 
 
156
 
KDevVersionControl *FileViewPart::versionControl()
157
 
{
158
 
   return extension<KDevVersionControl>("KDevelop/VersionControl");
159
 
}
160
 
 
161
 
#include "fileviewpart.moc"