21 #include "kmetaprops.h"
24 #include <tdefilemetainfowidget.h>
25 #include <tdefilemetainfo.h>
26 #include <tdeglobal.h>
27 #include <tdeglobalsettings.h>
28 #include <tdelocale.h>
29 #include <kprotocolinfo.h>
31 #include <tqvalidator.h>
34 #include <tqfileinfo.h>
35 #include <tqdatetime.h>
36 #include <tqstylesheet.h>
37 #include <tqvgroupbox.h>
41 class MetaPropsScrollView :
public TQScrollView
44 MetaPropsScrollView(TQWidget* parent = 0,
const char* name = 0)
45 : TQScrollView(parent, name)
47 setFrameStyle(TQFrame::NoFrame);
48 m_frame =
new TQFrame(viewport(),
"MetaPropsScrollView::m_frame");
49 m_frame->setFrameStyle(TQFrame::NoFrame);
50 addChild(m_frame, 0, 0);
53 TQFrame* frame() {
return m_frame;};
56 virtual void viewportResizeEvent(TQResizeEvent* ev)
58 TQScrollView::viewportResizeEvent(ev);
59 m_frame->resize( kMax(m_frame->sizeHint().width(), ev->size().width()),
60 kMax(m_frame->sizeHint().height(), ev->size().height()));
67 class KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate
70 KFileMetaPropsPluginPrivate() {}
71 ~KFileMetaPropsPluginPrivate() {}
74 TQGridLayout* m_framelayout;
77 TQPtrList<KFileMetaInfoWidget> m_editWidgets;
83 d =
new KFileMetaPropsPluginPrivate;
86 kdDebug(250) <<
"KFileMetaPropsPlugin constructor" << endl;
88 d->m_info = fileitem->metaInfo();
89 if (!d->m_info.isValid())
92 fileitem->setMetaInfo(d->m_info);
108 void KFileMetaPropsPlugin::createLayout()
112 kdDebug(250) <<
"KFileMetaPropsPlugin::createLayout" << endl;
115 if ( !d->m_info.isValid() || (d->m_info.preferredKeys()).isEmpty() )
119 KFileMetaInfoProvider* prov = KFileMetaInfoProvider::self();
120 TQStringList groupList = d->m_info.preferredGroups();
122 const KFileMimeTypeInfo* mtinfo = prov->mimeTypeInfo(d->m_info.mimeType());
125 kdDebug(7034) <<
"no mimetype info there\n";
130 TQFrame* topframe =
properties->addPage(i18n(
"&Meta Info"));
131 topframe->setFrameStyle(TQFrame::NoFrame);
132 TQVBoxLayout* tmp =
new TQVBoxLayout(topframe);
135 MetaPropsScrollView* view =
new MetaPropsScrollView(topframe);
137 tmp->addWidget(view);
139 d->m_frame = view->frame();
141 TQVBoxLayout *toplayout =
new TQVBoxLayout(d->m_frame);
142 toplayout->setSpacing(KDialog::spacingHint());
144 for (TQStringList::Iterator git=groupList.begin();
145 git!=groupList.end(); ++git)
147 kdDebug(7033) << *git << endl;
149 TQStringList itemList = d->m_info.group(*git).preferredKeys();
150 if (itemList.isEmpty())
153 TQGroupBox *groupBox =
new TQGroupBox(2, TQt::Horizontal,
154 TQStyleSheet::escape(mtinfo->groupInfo(*git)->translatedName()),
157 toplayout->addWidget(groupBox);
159 TQValueList<KFileMetaInfoItem> readItems;
160 TQValueList<KFileMetaInfoItem> editItems;
162 for (TQStringList::Iterator iit = itemList.begin();
163 iit!=itemList.end(); ++iit)
165 KFileMetaInfoItem item = d->m_info[*git][*iit];
166 if ( !item.isValid() )
continue;
168 bool editable = file_info.isWritable() && item.isEditable();
171 editItems.append( item );
173 readItems.append( item );
178 for (TQValueList<KFileMetaInfoItem>::Iterator iit= editItems.begin();
179 iit!=editItems.end(); ++iit)
181 TQLabel* l =
new TQLabel((*iit).translatedKey() +
":", groupBox);
182 l->setAlignment( AlignAuto | AlignTop | ExpandTabs );
183 TQValidator* val = mtinfo->createValidator(*git, (*iit).key());
184 if (!val) kdDebug(7033) <<
"didn't get a validator for " << *git <<
"/" << (*iit).key() << endl;
186 d->m_editWidgets.append( w );
187 connect(w, TQ_SIGNAL(valueChanged(
const TQVariant&)),
this, TQ_SIGNAL(
changed()));
191 for (TQValueList<KFileMetaInfoItem>::Iterator iit= readItems.begin();
192 iit!=readItems.end(); ++iit)
194 TQLabel* l =
new TQLabel((*iit).translatedKey() +
":", groupBox);
195 l->setAlignment( AlignAuto | AlignTop | ExpandTabs );
200 toplayout->addStretch(1);
240 KFileMetaPropsPlugin::~KFileMetaPropsPlugin()
248 #warning TODO: Add support for more than one item
250 if (KExecPropsPlugin::supports(_items) || KURLPropsPlugin::supports(_items))
253 bool metaDataEnabled = TDEGlobalSettings::showFilePreview(_items.first()->url());
254 return _items.count() == 1 && metaDataEnabled;
259 kdDebug(250) <<
"applying changes" << endl;
262 TQPtrListIterator<KFileMetaInfoWidget> it( d->m_editWidgets );
264 for (; (w = it.current()); ++it) w->apply();
268 #include "kmetaprops.moc"
The main properties dialog class.
KFileItemList items() const
const KURL & kurl() const
The URL of the file that has its properties being displayed.
A Plugin in the Properties dialog This is an abstract class.
void changed()
Emit this signal when the user changed anything in the plugin's tabs.
KPropertiesDialog * properties
Pointer to the dialog.