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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/***************************************************************************
copyright : (C) 2003 by Arnold Krille
email : arnold@arnoldarts.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License. *
* *
***************************************************************************/
#include "krecglobal.h"
#include "krecglobal.moc"
#include "krecexport_template.h"
#include <tdeconfig.h>
#include <tqwidget.h>
#include <kapplication.h>
#include <kstatusbar.h>
#include <ktrader.h>
#include <tdeparts/componentfactory.h>
#include <tqvaluelist.h>
#include <kservice.h>
#include <kdebug.h>
KRecGlobal::KRecGlobal( TQObject* p, const char* n )
: TQObject( p,n )
, _qwidget( 0 )
, _statusbar( 0 )
, _timeformatcache( -1 )
, _framebasecache( -1 )
{
//kdDebug( 60005 ) << k_funcinfo << endl;
_exports = new TQDict<KRecExportItem>;
}
KRecGlobal::~KRecGlobal() {
//kdDebug( 60005 ) << k_funcinfo << endl;
}
KRecGlobal* KRecGlobal::the() {
//kdDebug( 60005 ) << k_funcinfo << endl;
static KRecGlobal* object = new KRecGlobal();
return object;
}
void KRecGlobal::setMainWidget( TQWidget* n ) { _qwidget = n; }
TQWidget* KRecGlobal::mainWidget() { return _qwidget; }
TDEConfig* KRecGlobal::tdeconfig() { return kapp->config(); }
void KRecGlobal::setStatusBar( KStatusBar *bar ) { _statusbar = bar; }
void KRecGlobal::message( const TQString &text ) { if ( _statusbar ) _statusbar->message( text, 2000 ); }
bool KRecGlobal::registerExport( KRecExportItem* item ) {
//kdDebug( 60005 ) << k_funcinfo << "About to register ExportItem for \"" << item->exportFormat() << "\" extensions:\"" << item->extensions() << "\"" << endl;
if ( !the()->_exports->find( item->exportFormat() ) ) {
the()->_exports->insert( item->exportFormat(), item );
the()->_exportformats << item->exportFormat();
}
return true;
}
KRecExportItem* KRecGlobal::getExportItem( const TQString &exportFormat ) {
KRecExportItem *tmp = _exports->find( exportFormat );
return tmp->newItem();
}
TQStringList KRecGlobal::exportFormats() const {
return _exportformats;
}
TQString KRecGlobal::exportFormatEndings() const {
TQString out;
TDETrader::OfferList offers = TDETrader::self()->query( "KRec/exportplugin" );
TDETrader::OfferList::iterator it = offers.begin();
while ( it!=offers.end() ) {
out += " *.";
out += ( *it )->property( "X-TDE-ExportSuffix" ).toStringList().join( " *." );
++it;
}
return out;
}
KRecExportItem* KRecGlobal::getExportItemForEnding( const TQString &ending ) {
TDETrader::OfferList offers = TDETrader::self()->query( "KRec/exportplugin" );
TDETrader::OfferList::iterator it = offers.begin();
while ( it!=offers.end() ) {
kdDebug(60005) << ( *it )->property( "X-TDE-ExportSuffix" ).toStringList() << endl;
if ( ( *it )->property( "X-TDE-ExportSuffix" ).toStringList().grep( ending ).count() ) {
kdDebug(60005) << "Ending(" << ending << ") found" << endl;
return KParts::ComponentFactory::createInstanceFromService<KRecExportItem>( ( *it ), this, "exportplugin" );
} else kdDebug(60005) << "Doesn't contain " << ending << endl;
++it;
}
return 0;
}
int KRecGlobal::timeFormatMode() {
if ( _timeformatcache < 0 ) {
kapp->config()->setGroup( "General" );
_timeformatcache = kapp->config()->readNumEntry( "TimeFormat", 0 );
}
return _timeformatcache;
}
void KRecGlobal::setTimeFormatMode( int n ) {
kapp->config()->setGroup( "General" );
kapp->config()->writeEntry( "TimeFormat", n );
_timeformatcache = n;
}
int KRecGlobal::frameBase() {
if ( _framebasecache < 0 ) {
kapp->config()->setGroup( "General" );
_framebasecache = kapp->config()->readNumEntry( "FrameBase", 25 );
}
return _framebasecache;
}
void KRecGlobal::setFrameBase( int n ) {
kapp->config()->setGroup( "General" );
kapp->config()->writeEntry( "FrameBase", n );
_framebasecache = n;
}
|