1
/***************************************************************************
2
* Copyright (C) 2001-2002 by Bernd Gehrmann *
4
* Copyright (C) 2003 by Mario Scalas *
5
* mario.scalas@libero.it *
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. *
12
***************************************************************************/
14
#include "fileviewpart.h"
16
#include <qwhatsthis.h>
18
#include <qtoolbutton.h>
20
#include <kcombobox.h>
24
#include <kiconloader.h>
26
#include <kdevgenericfactory.h>
27
#include <kdialogbase.h>
30
#include "kdevproject.h"
31
#include "kdevmainwindow.h"
33
#include "partwidget.h"
35
#include "filetreewidget.h"
36
#include "vcscolorsconfigwidget.h"
37
#include "kdevversioncontrol.h"
38
#include "kdevplugininfo.h"
40
#define FILETREE_OPTIONS 1
42
///////////////////////////////////////////////////////////////////////////////
44
///////////////////////////////////////////////////////////////////////////////
46
VCSColors FileViewPart::vcsColors;
48
///////////////////////////////////////////////////////////////////////////////
50
///////////////////////////////////////////////////////////////////////////////
52
typedef KDevGenericFactory<FileViewPart> FileViewFactory;
53
static const KDevPluginInfo data("kdevfileview");
54
K_EXPORT_COMPONENT_FACTORY( libkdevfileview, FileViewFactory( data ) )
56
///////////////////////////////////////////////////////////////////////////////
57
// class FileTreeWidget
58
///////////////////////////////////////////////////////////////////////////////
60
FileViewPart::FileViewPart(QObject *parent, const char *name, const QStringList &)
61
: KDevPlugin(&data, parent, name ? name : "FileViewPart"),
64
setInstance( FileViewFactory::instance() );
65
// setXMLFile("kdevfileview.rc");
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 )) );
72
QTimer::singleShot( 1000, this, SLOT(init()) );
75
///////////////////////////////////////////////////////////////////////////////
77
void FileViewPart::init( )
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") );
85
m_widget->showProjectFiles();
88
///////////////////////////////////////////////////////////////////////////////
90
FileViewPart::~FileViewPart()
93
mainWindow()->removeView( m_widget );
101
///////////////////////////////////////////////////////////////////////////////
103
void FileViewPart::loadSettings()
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 );
115
KConfig *cfg = instance()->config();
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 );
129
///////////////////////////////////////////////////////////////////////////////
131
void FileViewPart::storeSettings()
133
KConfig *cfg = instance()->config();
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 );
147
void FileViewPart::insertConfigWidget( const KDialogBase* dlg, QWidget * page, unsigned int pagenumber )
149
if ( pagenumber == FILETREE_OPTIONS )
151
VCSColorsConfigWidget *w = new VCSColorsConfigWidget( this, vcsColors, page, "vcscolorsconfigwidget" );
152
connect( dlg, SIGNAL(okClicked()), w, SLOT(slotAccept()) );
156
KDevVersionControl *FileViewPart::versionControl()
158
return extension<KDevVersionControl>("KDevelop/VersionControl");
161
#include "fileviewpart.moc"