You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.4 KiB
87 lines
2.4 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
* Copyright (C) 2002 Simon MacMullen
|
||
|
*
|
||
|
* 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.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; see the file COPYING. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include <config.h>
|
||
12 years ago
|
#include "tdefile_folder.h"
|
||
15 years ago
|
|
||
|
#include <kgenericfactory.h>
|
||
12 years ago
|
#include <tdeio/global.h>
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqfileinfo.h>
|
||
|
#include <tqdir.h>
|
||
15 years ago
|
|
||
|
typedef KGenericFactory<KFolderPlugin> KFolderFactory;
|
||
|
|
||
12 years ago
|
K_EXPORT_COMPONENT_FACTORY(tdefile_folder, KFolderFactory( "tdefile_folder" ))
|
||
15 years ago
|
|
||
13 years ago
|
KFolderPlugin::KFolderPlugin(TQObject *parent, const char *name,
|
||
15 years ago
|
const TQStringList &args)
|
||
15 years ago
|
|
||
13 years ago
|
: KFilePlugin(parent, name, args)
|
||
15 years ago
|
{
|
||
|
KFileMimeTypeInfo* info = addMimeTypeInfo( "inode/directory" );
|
||
|
|
||
|
KFileMimeTypeInfo::GroupInfo* group = 0L;
|
||
|
|
||
|
group = addGroupInfo(info, "FolderInfo", i18n("Folder Information"));
|
||
|
|
||
|
KFileMimeTypeInfo::ItemInfo* item;
|
||
|
|
||
15 years ago
|
item = addItemInfo(group, "Items", i18n("Items"), TQVariant::Int);
|
||
|
item = addItemInfo(group, "Size", i18n("Size"), TQVariant::Int);
|
||
15 years ago
|
setUnit(item, KFileMimeTypeInfo::Bytes);
|
||
|
}
|
||
|
|
||
|
bool KFolderPlugin::readInfo( KFileMetaInfo& info, uint /*what*/)
|
||
|
{
|
||
|
KFileMetaInfoGroup group = appendGroup(info, "FolderInfo");
|
||
|
|
||
|
if (info.path().isEmpty())
|
||
|
return false;
|
||
|
|
||
15 years ago
|
TQDir dir;
|
||
15 years ago
|
if ( !dir.cd(info.path()) )
|
||
|
return false;
|
||
|
|
||
15 years ago
|
const TQPtrList<TQFileInfo> *fileList = dir.entryInfoList();
|
||
15 years ago
|
if (!fileList)
|
||
|
return false;
|
||
|
|
||
15 years ago
|
TQPtrListIterator<TQFileInfo> list = TQPtrListIterator<TQFileInfo>(*fileList);
|
||
15 years ago
|
|
||
15 years ago
|
TQFileInfo* file;
|
||
15 years ago
|
int items = 0;
|
||
12 years ago
|
TDEIO::filesize_t bytes = 0;
|
||
15 years ago
|
|
||
|
while ( (file = list.current()) != 0 ) {
|
||
|
++list;
|
||
|
if (!file->fileName().startsWith(".")) {
|
||
|
items++;
|
||
|
bytes += file->size();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
appendItem(group, "Items", items);
|
||
|
appendItem(group, "Size", bytes);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
12 years ago
|
#include "tdefile_folder.moc"
|