[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kross/ui
From: Robert Knight <robertknight () gmail ! com>
Date: 2007-05-18 15:10:20
Message-ID: 1179501020.520318.18691.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 666022 by knight:
Fix Kross model index() method, Qt expects that repeated calls to index() with the \
same parent,row and column will return a QModelIndex with the same internal pointer. \
Fixes a crash in KOffice and also double-click invocation of scripts in the script \
docker. Also use more approriate icons for script related buttons. Using the \
'eject' icon to open the settings dialog was quite confusing.
M +35 -2 model.cpp
M +3 -3 view.cpp
--- trunk/KDE/kdelibs/kross/ui/model.cpp #666021:666022
@@ -44,6 +44,7 @@
Action* action;
ActionCollection* collection;
};
+ QVector<ActionCollectionModelItem*> children;
const QModelIndex parent;
explicit ActionCollectionModelItem(Action* a, const QModelIndex& p = \
QModelIndex(), ActionCollectionModelItem* parentitem = 0) @@ -64,6 +65,13 @@
ActionCollection* collection;
ActionCollectionModelItem* item;
Mode mode;
+
+ template <class T>
+ ActionCollectionModelItem* childItem(ActionCollectionModelItem* item,
+ const QModelIndex& parent,
+ int row,
+ int column,
+ T value);
};
}
@@ -118,6 +126,27 @@
return 0;
}
+template <class T>
+ActionCollectionModelItem* ActionCollectionModel::Private::childItem( \
ActionCollectionModelItem* item , + const \
QModelIndex& parent, + int row,
+ int /*column*/,
+ T value )
+{
+ ActionCollectionModelItem* childItem = 0;
+ if ( row < item->children.count() &&
+ item->children.at(row) != 0 ) {
+ childItem = item->children.at(row);
+ }
+ else {
+ childItem = new ActionCollectionModelItem(value,parent,item);
+
+ item->children.resize(row+1);
+ item->children[row] = childItem;
+ }
+ return childItem;
+}
+
QModelIndex ActionCollectionModel::index(int row, int column, const QModelIndex& \
parent) const {
ActionCollectionModelItem* item = parent.isValid() ? \
static_cast<ActionCollectionModelItem*>(parent.internalPointer()) : d->item; @@ \
-126,13 +155,17 @@ if( row < count ) {
Action* action = dynamic_cast< Action* >( \
item->collection->actions().value(row) ); if( action )
- return createIndex(row, column, new ActionCollectionModelItem(action, \
parent, item)); + {
+ return createIndex(row, \
column,d->childItem(item,parent,row,column,action)); + }
}
else {
QString name = item->collection->collections().value(row - count);
ActionCollection* collection = item->collection->collection(name);
if( collection )
- return createIndex(row, column, new \
ActionCollectionModelItem(collection, parent, item)); + {
+ return createIndex(row, \
column,d->childItem(item,parent,row,column,collection)); + }
}
return QModelIndex();
}
--- trunk/KDE/kdelibs/kross/ui/view.cpp #666021:666022
@@ -299,14 +299,14 @@
d->collection = new KActionCollection(this);
- KAction* runaction = new KAction(KIcon("media-playback-start"), i18n("Run"), \
this); + KAction* runaction = new KAction(KIcon("launch"), i18n("Run"), this);
runaction->setObjectName("run");
runaction->setToolTip( i18n("Execute the selected script.") );
runaction->setEnabled(false);
d->collection->addAction("run", runaction);
connect(runaction, SIGNAL(triggered()), this, SLOT(slotRun()));
- KAction* stopaction = new KAction(KIcon("media-playback-stop"), i18n("Stop"), \
this); + KAction* stopaction = new KAction(KIcon("process-stop"), i18n("Stop"), \
this); stopaction->setObjectName("stop");
stopaction->setToolTip( i18n("Stop execution of the selected script.") );
stopaction->setEnabled(false);
@@ -343,7 +343,7 @@
//i18n("About"), i18n("Configure")
- KAction* manageraction = new KAction(KIcon("media-eject"), i18n("Script \
Manager"), this); + KAction* manageraction = new KAction(KIcon("configure"), \
i18n("Script Manager"), this); manageraction->setObjectName("manager");
manageraction->setToolTip( i18n("Script Manager to configure scripts.") );
d->collection->addAction("manager", manageraction);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic