summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-08-17 19:26:56 +0200
committerArno <am@disconnect.de>2010-08-17 19:26:56 +0200
commit9c2ffa8c6a9b1683ea21ed43f2b44f62fda7964e (patch)
tree53d3ad1e3c2ee0f6ca32e93fbae5e088ead4b704
parent831a1031b14f4899905e54dd94fdff5d263eb609 (diff)
downloadSheMov-9c2ffa8c6a9b1683ea21ed43f2b44f62fda7964e.tar.gz
SheMov-9c2ffa8c6a9b1683ea21ed43f2b44f62fda7964e.tar.bz2
SheMov-9c2ffa8c6a9b1683ea21ed43f2b44f62fda7964e.zip
Fixed various bugs in NewMovieWizard
SmTreeModel had a serious bug: SmTreeItem would accept rows > mChildren.count() in SmTreeItem::child(int row). Do some sanity checks. This only happened when trying to edit the type of the last file in NewMovieWizard::MovieInfoPage, strangely enough. But this should fix it. While working on the Wizard I tried to figure out why mItemEdit->clear only sometimes worked. I guess it's because mItemEdit and the QCompleter were connected to the same QKeyEvent, the latter winning and doing the completion. "Fixed" this by removing the connection to the returnPressed() slot of mItemEdit and giving the "Add Item" button a shortcut. Don't really know if this is more annoying than pressing CTRL- Also fixed a small logic error in MappingTableItemModel::lowerBound(). Revert the logic if the sort order should be ascending.
-rw-r--r--mappingtablewidget.cpp5
-rw-r--r--newmoviewizard.cpp6
-rw-r--r--smtreeitem.cpp5
3 files changed, 10 insertions, 6 deletions
diff --git a/mappingtablewidget.cpp b/mappingtablewidget.cpp
index 85e0afb..03bfa75 100644
--- a/mappingtablewidget.cpp
+++ b/mappingtablewidget.cpp
@@ -41,12 +41,11 @@ MappingTableWidget::MappingTableWidget(const QString &table, QWidget *parent) :
l1->setBuddy(mItemEdit);
itemEditLayout->addWidget(l1);
itemEditLayout->addWidget(mItemEdit);
- connect(mItemEdit, SIGNAL(returnPressed()), this, SLOT(addItem()));
//buttons
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
- mAddItem = new QPushButton(tr("Add item"));
+ mAddItem = new QPushButton(tr("&Add item"));
mRemoveItem = new QPushButton(tr("Remove item"));
buttonLayout->addWidget(mAddItem);
buttonLayout->addWidget(mRemoveItem);
@@ -129,7 +128,7 @@ Qt::ItemFlags MappingTableItemModel::flags(const QModelIndex &index) const{
int MappingTableItemModel::lowerBound(const QString &value) const{
int retval = 0;
for(int i = 0; i < stringList().count(); ++i){
- if(value < stringList().at(i)){
+ if(stringList().at(i) < value){
++retval;
}else{
break;
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index 6d21a5b..81e0312 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -288,6 +288,7 @@ void MovieInfoPage::typeChanged(QString type){
}
QModelIndex item = selected.at(0);
QModelIndex typeIndex = mFileModel->index(item.row(), WizardTreeModel::FileType, item.parent());
+ QModelIndex oldParent = typeIndex.parent();
mFileModel->setData(typeIndex, newTypeId, Qt::EditRole);
QModelIndex newParent;
if(newTypeId == WizardTreeModel::Movie){
@@ -295,8 +296,9 @@ void MovieInfoPage::typeChanged(QString type){
}else{
newParent = mFileModel->find("Cover files");
}
- mFileModel->reparent(item, newParent);
-
+ if(oldParent != newParent){
+ mFileModel->reparent(item, newParent);
+ }
}
void MovieInfoPage::seriesPartChanged(int partNo){
diff --git a/smtreeitem.cpp b/smtreeitem.cpp
index a13e76a..5584319 100644
--- a/smtreeitem.cpp
+++ b/smtreeitem.cpp
@@ -36,7 +36,10 @@ void SmTreeItem::appendChild(SmTreeItem *child){
}
SmTreeItem *SmTreeItem::child(int row) const{
- return mChildren.at(row);
+ if(row > -1 && row < mChildren.count()){
+ return mChildren.at(row);
+ }
+ return 0;
}
int SmTreeItem::childCount() const{