diff options
author | Arno <am@disconnect.de> | 2012-03-18 01:47:21 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-03-18 01:47:21 +0100 |
commit | 3e784fed0148c4ec24aa8b2b8ca53f2d9d9bc543 (patch) | |
tree | ae756b5b493aacb6c486a13b3e4fd0d9a0e4d801 /pictureswidget.cpp | |
parent | 1e14ae6748f271265dd719ac0766a2da3501a21f (diff) | |
download | SheMov-3e784fed0148c4ec24aa8b2b8ca53f2d9d9bc543.tar.gz SheMov-3e784fed0148c4ec24aa8b2b8ca53f2d9d9bc543.tar.bz2 SheMov-3e784fed0148c4ec24aa8b2b8ca53f2d9d9bc543.zip |
Fix some severe braindamage
It started as a buxfix session, but the more I dug into some ancient
code, the more I had to change.
Well, first and foremost, this fixes a crash in PicturesWidget. Trying
to display the mappings of the selected picture in a different color
never was a good idea. Show them in the statusbar instead.
While looking at the statusBar code, make PictureWidget emit signals to
show the total size and number of selected items. Then I noticed some
really, really braindamaged connection madness in the Shemov
constructor. Instead of doing all the work in SheMov itself, have the
widgets emit signals.
This should have been several commits, but one lead to another...
Diffstat (limited to 'pictureswidget.cpp')
-rw-r--r-- | pictureswidget.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/pictureswidget.cpp b/pictureswidget.cpp index b420309..95e8a60 100644 --- a/pictureswidget.cpp +++ b/pictureswidget.cpp @@ -35,7 +35,6 @@ PicturesWidget::PicturesWidget(QWidget *parent) : QWidget(parent), mWindowTitleB connect(mMappingTree, SIGNAL(mappingChanged(int)), mPictureView, SLOT(mappingChanged(int))); //change window title when mapping selection changes connect(mMappingTree, SIGNAL(mappingChanged(int)), this, SLOT(constructWindowTitle())); - connect(mPictureView, SIGNAL(newFileMappigs()), this, SLOT(setMappingColors())); connect(mPictureView, SIGNAL(editPicsMappings()), this, SLOT(editMappings())); connect(mPictureView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(showInPicViewer(QModelIndex))); splitter->addWidget(mMappingTree); @@ -58,11 +57,6 @@ void PicturesWidget::showPicViewer(bool toggled){ mPicViewer->setVisible(toggled); } -void PicturesWidget::setMappingColors(){ - MappingTreeModel *mtm = static_cast<MappingTreeModel*>(SmGlobals::instance()->model("MappingTree")); - mtm->setSelectedMappings(mPictureView->fileMappings()); -} - void PicturesWidget::editMappings(){ QList<int> currentMappings = mPictureView->fileMappings(); mEditDialog->editWidget()->setMappings(currentMappings); @@ -106,12 +100,13 @@ void PicturesWidget::showInPicViewer(const QModelIndex &idx){ } PictureView::PictureView(QWidget *parent) : QTreeView(parent) { - //setup model + //setup models mModel = new PicFilesModel(QStringList() << tr("Filename") << tr("SizeNum") << tr("Format") << tr("Full Path") << tr("Id") << tr("Added") << tr("Md5Sum") << tr("Size"), this); mProxy = new QSortFilterProxyModel(this); mProxy->setSourceModel(mModel); setModel(mProxy); - connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(setFileMappings())); + connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectedFilesChanged())); + mMappingTreeModel = static_cast<MappingTreeModel*>(SmGlobals::instance()->model("MappingTree")); //read settings QSettings s; @@ -237,17 +232,33 @@ void PictureView::contextMenuEvent(QContextMenuEvent *e){ ctxMenu.exec(e->globalPos()); } -void PictureView::setFileMappings(){ +void PictureView::selectedFilesChanged(){ QModelIndexList sel = selectionModel()->selectedRows(); if(sel.isEmpty()){ return; } + //file mappings QList<QVariant> fileIds; + qint64 selSize = 0; foreach(QModelIndex i, sel){ fileIds << i.data(PicFilesModel::IdRole); + selSize += i.data(PicFilesModel::SizeRole).toInt(); } mFilesMappings = mModel->mappingIds(fileIds); - emit newFileMappigs(); + QStringList mappings; + foreach(int m, mFilesMappings){ + MappingData mapping = mMappingTreeModel->mappingDataFromId(m); + if(!mappings.contains(mapping.name)){ + mappings << mapping.name; + } + } + qSort(mappings); + QString mappingMsg = QString(tr("Mappings: %1")).arg(mappings.join(",")); + emit newMappings(mappingMsg); + + //selected items + emit numSelected(sel.size()); + emit selectedSize(selSize); } PicFilesModel::PicFilesModel(const QStringList &headers, QObject *parent) : SmTreeModel(headers, parent) { |