Commit 0d402134 authored by Srikanth Tiyyagura's avatar Srikanth Tiyyagura

Modified the two functions importResourceFilename() and...

Modified the two functions importResourceFilename() and loadingResourceFileName()  to decrease the code, changed the icons of GHNS tool bar and also added my name in the license
parent 1b345dec
......@@ -3,6 +3,7 @@
* Copyright (c) 2009 Sven Langkamp <sven.langkamp@gmail.com>
* Copyright (c) 2010 Cyrille Berger <cberger@cberger.net>
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
* Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
*
* 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
......
......@@ -5,6 +5,7 @@
* Copyright (c) 2009-2011 Sven Langkamp (sven.langkamp@gmail.com)
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
* Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
* Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
*
* 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
......
/*
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
*
* 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
......
/*
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
*
* 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
......
......@@ -2,6 +2,7 @@
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2009 Sven Langkamp <sven.langkamp@gmail.com>
* Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
* Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
*
* 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
......
......@@ -2,6 +2,7 @@
Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
Copyright (c) 2007 Jan Hambrecht <jaham@gmx.net>
Copyright (c) 2007 Sven Langkamp <sven.langkamp@gmail.com>
Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -71,21 +72,21 @@ KoResourceItemChooser::KoResourceItemChooser( KoAbstractResourceServerAdapter *
layout->addWidget( d->view, 0, 0, 1, 5 );
QPushButton *button = new QPushButton( this );
button->setIcon( SmallIcon( "list-add" ) );
button->setIcon( SmallIcon( "document-open" ) );
button->setToolTip( i18n("Import") );
button->setEnabled( true );
d->buttonGroup->addButton( button, Button_Import );
layout->addWidget( button, 1, 0 );
button = new QPushButton( this );
button->setIcon( SmallIcon( "list-remove" ) );
button->setIcon( SmallIcon( "trash-empty" ) );
button->setToolTip( i18n("Delete") );
button->setEnabled( false );
d->buttonGroup->addButton( button, Button_Remove );
layout->addWidget( button, 1, 1 );
button = new QPushButton( this );
button->setIcon( SmallIcon( "bookmarks" ) );
button->setIcon( SmallIcon( "download" ) );
button->setToolTip( i18n("Download") );
button->setEnabled( true );
button->hide();
......@@ -93,7 +94,7 @@ KoResourceItemChooser::KoResourceItemChooser( KoAbstractResourceServerAdapter *
layout->addWidget( button, 1, 3 );
button = new QPushButton( this );
button->setIcon( SmallIcon( "download" ) );
button->setIcon( SmallIcon( "go-up" ) );
button->setToolTip( i18n("Share") );
button->setEnabled( false );
button->hide();
......@@ -156,7 +157,7 @@ void KoResourceItemChooser::slotButtonClicked( int button )
foreach( const QString &file, e.installedFiles() ) {
QFileInfo fi(file);
d->model->resourceServerAdapter()->loadingResourceFile( fi.absolutePath()+"/"+fi.fileName() );
d->model->resourceServerAdapter()->importResourceFile( fi.absolutePath()+"/"+fi.fileName() , false );
}
foreach( const QString &file, e.uninstalledFiles() ) {
......
......@@ -3,6 +3,7 @@
Copyright (c) 2007 Jan Hambrecht <jaham@gmx.net>
Copyright (c) 2007 Sven Langkamp <sven.langkamp@gmail.com>
Copyright (c) 2010 Boudewijn Rempt <boud@valdyas.org>
Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......
......@@ -4,6 +4,7 @@
Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
Copyright (c) 2005 Sven Langkamp <sven.langkamp@gmail.com>
Copyright (c) 2007 Jan Hambrecht <jaham@gmx.net>
Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -259,8 +260,9 @@ public:
* Creates a new resourcea from a given file and adds them to the resource server
* The base implementation does only load one resource per file, override to implement collections
* @param filename file name of the resource file to be imported
* @param fileCreation decides whether to create the file in the saveLocation() directory
*/
virtual void importResourceFile( const QString & filename ) {
virtual void importResourceFile( const QString & filename , bool fileCreation=true) {
QFileInfo fi( filename );
if( fi.exists() == false )
return;
......@@ -273,35 +275,19 @@ public:
return;
}
Q_ASSERT(!resource->defaultFileExtension().isEmpty());
Q_ASSERT(!saveLocation().isEmpty());
if( fileCreation ) {
Q_ASSERT(!resource->defaultFileExtension().isEmpty());
Q_ASSERT(!saveLocation().isEmpty());
QString newFilename = saveLocation() + fi.baseName() + resource->defaultFileExtension();
QFileInfo fileInfo(newFilename);
QString newFilename = saveLocation() + fi.baseName() + resource->defaultFileExtension();
QFileInfo fileInfo(newFilename);
int i = 1;
while (fileInfo.exists()) {
fileInfo.setFile(saveLocation() + fi.baseName() + QString("%1").arg(i) + resource->defaultFileExtension());
i++;
}
resource->setFilename(fileInfo.filePath());
if(!addResource(resource)) {
delete resource;
}
}
/// loads the resource file into the resource server after it is downloaded using GHNS
virtual void loadingResourceFile( const QString & filename ) {
QFileInfo fi( filename );
if( fi.exists() == false )
return;
T* resource = createResource( filename );
resource->load();
if(!resource->valid()){
kWarning(30009) << "Import failed! Resource is not valid";
delete resource;
return;
int i = 1;
while (fileInfo.exists()) {
fileInfo.setFile(saveLocation() + fi.baseName() + QString("%1").arg(i) + resource->defaultFileExtension());
i++;
}
resource->setFilename(fileInfo.filePath());
}
if(!addResource(resource)) {
......
/* This file is part of the KDE project
Copyright (c) 2007 Sven Langkamp <sven.langkamp@gmail.com>
Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -37,9 +38,8 @@ public:
virtual QList<KoResource*> resources() = 0;
virtual bool addResource(KoResource* resource) = 0;
virtual bool removeResource(KoResource* resource) = 0;
virtual void loadingResourceFile( const QString & filename ) = 0;
virtual void removeResourceFile( const QString & filename ) = 0;
virtual void importResourceFile( const QString & filename ) = 0;
virtual void importResourceFile( const QString & filename , bool fileCreation=true) = 0;
virtual QString extensions() = 0;
signals:
......@@ -116,19 +116,11 @@ public:
return false;
}
void loadingResourceFile( const QString & filename )
void importResourceFile( const QString & filename , bool fileCreation=true )
{
if( ! m_resourceServer )
return;
m_resourceServer->loadingResourceFile(filename);
}
void importResourceFile( const QString & filename )
{
if( ! m_resourceServer )
return;
m_resourceServer->importResourceFile(filename);
m_resourceServer->importResourceFile( filename, fileCreation );
}
void removeResourceFile( const QString & filename )
......
......@@ -3,6 +3,7 @@
Copyright (c) 1999 Matthias Elter <elter@kde.org>
Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
Copyright (c) 2005 Sven Langkamp <sven.langkamp@gmail.com>
Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment