From kde-commits Tue Aug 31 21:25:20 2010 From: Stephane Mankowski Date: Tue, 31 Aug 2010 21:25:20 +0000 To: kde-commits Subject: extragear/office/skrooge Message-Id: <20100831212520.34B14AC857 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128328970110027 SVN commit 1170432 by smankowski: FEATURE: Addition of file as property by drag and drop M +1 -0 CHANGELOG M +0 -3 skg_bookmark/skgbookmarkplugindockwidget_base.ui M +26 -7 skgbasegui/skgobjectmodelbase.cpp M +32 -0 skgbasemodeler/skgdocument.cpp M +15 -0 skgbasemodeler/skgdocument.h M +5 -0 skgbasemodeler/skgobjectbase.cpp M +11 -0 skgbasemodeler/skgobjectbase.h M +1 -4 skrooge_bank/skgbankpluginwidget_base.ui M +3 -0 skrooge_calculator/skgcalculatorpluginwidget_base.ui M +3 -8 skrooge_operation/skgoperationpluginwidget_base.ui M +3 -3 skrooge_scheduled/skgscheduledpluginwidget_base.ui M +3 -3 skrooge_search/skgsearchpluginwidget_base.ui M +3 -3 skrooge_tracker/skgtrackerpluginwidget_base.ui M +2 -8 skrooge_unit/skgunitpluginwidget_base.ui --- trunk/extragear/office/skrooge/CHANGELOG #1170431:1170432 @@ -17,6 +17,7 @@ *New feature: Context in a toolbar (useful for small screen) *New feature: Advice widget in dashboard *New feature: Full screen (useful for small screen) + *New feature: Addition of file as property by drag and drop -- maintainer Stephane MANKOWSKI xxx --- trunk/extragear/office/skrooge/skg_bookmark/skgbookmarkplugindockwidget_base.ui #1170431:1170432 @@ -23,9 +23,6 @@ - - true - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> --- trunk/extragear/office/skrooge/skgbasegui/skgobjectmodelbase.cpp #1170431:1170432 @@ -532,12 +532,11 @@ { _SKGTRACEIN(10, "SKGObjectModelBase::flags"); - Qt::ItemFlags flags=QAbstractItemModel::flags(index); + Qt::ItemFlags flags=QAbstractItemModel::flags(index)| Qt::ItemIsDropEnabled; if (nodeTable) { flags|=Qt::ItemIsEditable; - if (index.isValid()) flags|=Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; - else flags|=Qt::ItemIsDropEnabled; + if (index.isValid()) flags|=Qt::ItemIsDragEnabled; } if (index.column() == 0) flags|=Qt::ItemIsUserCheckable; return flags; @@ -571,13 +570,14 @@ Qt::DropActions SKGObjectModelBase::supportedDropActions() const { - return (nodeTable ? Qt::MoveAction : Qt::IgnoreAction); + return Qt::MoveAction; } QStringList SKGObjectModelBase::mimeTypes() const { QStringList types; types << "application/skg."+getRealTable()+".ids"; + types << "text/uri-list"; return types; } @@ -609,14 +609,33 @@ { Q_UNUSED(row); if (action == Qt::IgnoreAction) return true; - if (!data || !data->hasFormat("application/skg.node.ids")) return false; + if (!data || !(data->hasFormat("application/skg.node.ids") || data->hasUrls())) return false; if (column > 0) return false; + SKGError err; + //Drop files + if (data->hasUrls() && parent.isValid() && getRealTable()!="node") + { + QList urls=data->urls(); + int nb=urls.count(); + { + SKGObjectBase obj=getObject(parent); + + SKGBEGINPROGRESSTRANSACTION(*getDocument(), i18nc("Noun, name of the user action", "Property creation"), err, nb); + for (int i=0; err.isSucceeded() && istepForward(i+1); + } + } + } + //Drop nodes + else if (data->hasFormat ( "application/skg.node.ids" )) + { QByteArray encodedData = data->data("application/skg.node.ids"); QDataStream stream(&encodedData, QIODevice::ReadOnly); QStringList newItems; - SKGError err; SKGNodeObject parentNode; if (parent.isValid()) { @@ -667,7 +686,7 @@ if (err.isSucceeded()) err=child.save(); } } - + } SKGMainPanel::displayErrorMessage(err); return err.isSucceeded(); } --- trunk/extragear/office/skrooge/skgbasemodeler/skgdocument.cpp #1170431:1170432 @@ -1499,6 +1499,38 @@ return output; } +SKGError SKGDocument::setParameter(const QString& iName, const QString& iValue, const QString& iFileName, const QString& iParentUUID, SKGPropertyObject* oObjectCreated) +{ + SKGError err; + SKGTRACEINRC(10, "SKGDocument::setParameter", err); + SKGTRACEL(10) << "Input parameter [iName] =[" << iName << ']' << endl; + SKGTRACEL(10) << "Input parameter [iValue] =[" << iValue << ']' << endl; + SKGTRACEL(10) << "Input parameter [iFileName]=[" << iFileName << ']' << endl; + QVariant blob; + QString value=iValue; + QFile file(iFileName); + if (file.exists()) { + //Open file + if (!file.open(QIODevice::ReadOnly)) { + err=SKGError(ERR_INVALIDARG, i18nc("Error message", "Open file '%1' failed", iFileName)); + } else { + QByteArray blob_bytes=file.readAll(); + if (!blob_bytes.count()) { + err=SKGError(ERR_INVALIDARG, i18nc("Error message", "Open file '%1' failed", iFileName)); + } else { + blob=blob_bytes; + value=QFileInfo(iFileName).fileName(); + } + + //close file + file.close(); + } + } + + if (err.isSucceeded()) err=setParameter(iName, value, blob, iParentUUID, oObjectCreated); + return err; +} + SKGError SKGDocument::setParameter(const QString& iName, const QString& iValue, const QVariant& iBlob, const QString& iParentUUID, SKGPropertyObject* oObjectCreated) { SKGError err; --- trunk/extragear/office/skrooge/skgbasemodeler/skgdocument.h #1170431:1170432 @@ -370,6 +370,21 @@ * @see beginTransaction * @param iName the parameter unique identifier. * @param iValue the parameter value. + * @param iFileName the file name. + * @param iParentUUID the unique identifier of the object owning this parameter. + * @param oObjectCreated the parameter object created + * @return an object managing the error. + * @see SKGError + */ + virtual SKGError setParameter(const QString& iName, const QString& iValue, const QString& iFileName, + const QString& iParentUUID="document", SKGPropertyObject* oObjectCreated=NULL); + + /** + * Set a parameter. + * WARNING: This method must be used in a transaction. + * @see beginTransaction + * @param iName the parameter unique identifier. + * @param iValue the parameter value. * @param iBlob the parameter blob. * @param iParentUUID the unique identifier of the object owning this parameter. * @param oObjectCreated the parameter object created --- trunk/extragear/office/skrooge/skgbasemodeler/skgobjectbase.cpp #1170431:1170432 @@ -450,6 +450,11 @@ return getDocument()->getParameterBlob(iName, getUniqueID()); } +SKGError SKGObjectBase::setProperty(const QString& iName, const QString& iValue, const QString& iFileName, SKGPropertyObject* oObjectCreated) +{ + return getDocument()->setParameter(iName, iValue, iFileName, getUniqueID(), oObjectCreated); +} + SKGError SKGObjectBase::setProperty(const QString& iName, const QString& iValue, const QVariant& iBlob, SKGPropertyObject* oObjectCreated) { return getDocument()->setParameter(iName, iValue, iBlob, getUniqueID(), oObjectCreated); --- trunk/extragear/office/skrooge/skgbasemodeler/skgobjectbase.h #1170431:1170432 @@ -279,6 +279,17 @@ * Set the value for a property * @param iName the property name * @param iValue the property value + * @param iFileName the file name. + * @param oObjectCreated the property object created + * @return an object managing the property + * @see SKGError + */ + virtual SKGError setProperty(const QString& iName, const QString& iValue, const QString& iFileName, SKGPropertyObject* oObjectCreated=NULL); + + /** + * Set the value for a property + * @param iName the property name + * @param iValue the property value * @param iBlob the property blob * @param oObjectCreated the property object created * @return an object managing the property --- trunk/extragear/office/skrooge/skrooge_bank/skgbankpluginwidget_base.ui #1170431:1170432 @@ -87,7 +87,7 @@ - QAbstractItemView::NoDragDrop + QAbstractItemView::DropOnly true @@ -95,9 +95,6 @@ QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows - true --- trunk/extragear/office/skrooge/skrooge_calculator/skgcalculatorpluginwidget_base.ui #1170431:1170432 @@ -192,6 +192,9 @@ Parameters for interest computation + + QAbstractItemView::DropOnly + true --- trunk/extragear/office/skrooge/skrooge_operation/skgoperationpluginwidget_base.ui #1170431:1170432 @@ -160,6 +160,9 @@ + + true + list of operations @@ -172,9 +175,6 @@ QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows - true @@ -1490,11 +1490,6 @@
kfilterproxysearchline.h
- KSqueezedTextLabel - QLabel -
ksqueezedtextlabel.h
-
- KTitleWidget QWidget
ktitlewidget.h
--- trunk/extragear/office/skrooge/skrooge_scheduled/skgscheduledpluginwidget_base.ui #1170431:1170432 @@ -71,15 +71,15 @@ List of recurrent operations + + QAbstractItemView::DropOnly + true QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows - true --- trunk/extragear/office/skrooge/skrooge_search/skgsearchpluginwidget_base.ui #1170431:1170432 @@ -66,15 +66,15 @@ List of searches and processes + + QAbstractItemView::DropOnly + true QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows -
--- trunk/extragear/office/skrooge/skrooge_tracker/skgtrackerpluginwidget_base.ui #1170431:1170432 @@ -84,15 +84,15 @@ list of trackers + + QAbstractItemView::DropOnly + true QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows - true --- trunk/extragear/office/skrooge/skrooge_unit/skgunitpluginwidget_base.ui #1170431:1170432 @@ -75,7 +75,7 @@ List of units - QAbstractItemView::NoDragDrop + QAbstractItemView::DropOnly true @@ -83,9 +83,6 @@ QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows - true @@ -114,7 +111,7 @@ List of quotes for selected unit - QAbstractItemView::NoDragDrop + QAbstractItemView::DropOnly true @@ -122,9 +119,6 @@ QAbstractItemView::ExtendedSelection - - QAbstractItemView::SelectRows - false