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
107
108
|
#include "fileselector_part.h"
#include <tqwhatsthis.h>
#include <tqpushbutton.h>
#include <tqcheckbox.h>
#include <tqslider.h>
#include <tqvbox.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <tdeapplication.h>
#include <kstandarddirs.h>
#include <ktextbrowser.h>
#include <tdeconfig.h>
#include <tdefileitem.h>
#include <kdevgenericfactory.h>
#include <tdediroperator.h>
#include <kdialogbase.h>
#include <tdemessagebox.h>
#include <kdevapi.h>
#include <kdevcore.h>
#include <kdevproject.h>
#include <kdevmainwindow.h>
#include <kdevpartcontroller.h>
#include <kdevplugininfo.h>
#include <kdevcreatefile.h>
#include <ktip.h>
#include "fileselector_widget.h"
typedef KDevGenericFactory<FileSelectorPart> FileSelectorFactory;
static const KDevPluginInfo pluginData("kdevfileselector");
K_EXPORT_COMPONENT_FACTORY( libkdevfileselector, FileSelectorFactory( pluginData ) )
FileSelectorPart::FileSelectorPart(TQObject *parent, const char *name, const TQStringList &)
: KDevPlugin(&pluginData, parent, name ? name : "FileSelectorPart")
{
setInstance(FileSelectorFactory::instance());
m_filetree = new KDevFileSelector( this, mainWindow(), partController(), 0, "fileselectorwidget" );
connect( m_filetree->dirOperator(), TQT_SIGNAL(fileSelected(const KFileItem*)),
this, TQT_SLOT(fileSelected(const KFileItem*)));
connect( core(), TQT_SIGNAL(projectOpened()), this, TQT_SLOT(slotProjectOpened()) );
connect( core(), TQT_SIGNAL(configWidget(KDialogBase*)), this, TQT_SLOT(slotConfigWidget(KDialogBase*)) );
m_filetree->setCaption( i18n("File Selector") );
m_filetree->setIcon( SmallIcon( info()->icon() ) );
mainWindow()->embedSelectView( m_filetree, i18n("File Selector"), i18n("File selector") );
TQWhatsThis::add(m_filetree, i18n("<b>File selector</b><p>This file selector lists directory contents and provides some file management functions."));
m_filetree->readConfig( instance()->config(), "fileselector" );
m_newFileAction = new TDEAction(i18n("New File..."), CTRL+ALT+SHIFT+Key_N, this, TQT_SLOT(newFile()), this, "new_file");
}
FileSelectorPart::~FileSelectorPart()
{
if (m_filetree){
mainWindow()->removeView( m_filetree );
}
delete (KDevFileSelector*) m_filetree;
}
void FileSelectorPart::fileSelected( const KFileItem * file )
{
KURL u(file->url());
partController()->editDocument( u );
}
void FileSelectorPart::slotProjectOpened()
{
KURL u;
u.setPath( project()->projectDirectory() );
m_filetree->setDir( u );
}
void FileSelectorPart::slotConfigWidget( KDialogBase * dlg )
{
TQVBox* vbox = dlg->addVBoxPage( i18n("File Selector"), i18n("File Selector"), BarIcon( info()->icon(), TDEIcon::SizeMedium) );
KFSConfigPage* page = new KFSConfigPage( vbox, 0, m_filetree );
connect( dlg, TQT_SIGNAL( okClicked( ) ), page, TQT_SLOT( apply( ) ) );
// ### implement reload
}
void FileSelectorPart::newFile()
{
KDevCreateFile *creator = extension<KDevCreateFile>("TDevelop/CreateFile");
if (creator)
{
KDevCreateFile::CreatedFile file = creator->createNewFile("",
m_filetree->dirOperator()->url().path());
if (file.status == KDevCreateFile::CreatedFile::STATUS_NOTCREATED)
KMessageBox::error(0, i18n("Cannot create file. Check whether the directory and filename are valid."));
else if (file.status != KDevCreateFile::CreatedFile::STATUS_CANCELED)
{
partController()->editDocument(KURL::fromPathOrURL(
file.dir + "/" + file.filename));
}
}
}
#include "fileselector_part.moc"
|