From 3e784fed0148c4ec24aa8b2b8ca53f2d9d9bc543 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 18 Mar 2012 01:47:21 +0100 Subject: 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... --- shemov.cpp | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'shemov.cpp') diff --git a/shemov.cpp b/shemov.cpp index 77c9a98..8a8ff57 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -76,16 +76,19 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla mATree = new ArchiveTreeView; mTab->addTab(mATree, "Archive"); connect(mATree->filesWidget(), SIGNAL(statusMessage(QString)), this, SLOT(statusbarMessage(QString))); - connect(mATree->filesWidget(), SIGNAL(sizeChanged(qint64)), this, SLOT(setSize(qint64))); connect(mATree, SIGNAL(needWindowTitleChange(QString)), this, SLOT(setWindowTitle(QString))); - connect(mATree->filesWidget()->filesTree()->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateSelectionCount(const QItemSelection &, const QItemSelection &))); - connect(mATree->seriesWidget()->seriesTree()->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateSelectionCount(QItemSelection,QItemSelection))); + connect(mATree->filesWidget(), SIGNAL(numSelected(int)), this, SLOT(updateSelectedCount(int))); + connect(mATree->filesWidget(), SIGNAL(selectedSize(qint64)), this, SLOT(setSize(qint64))); + connect(mATree->filesWidget(), SIGNAL(statusMessage(QString)), this, SLOT(statusbarMessage(QString))); connect(this, SIGNAL(configChanged()), mATree, SLOT(readSettings())); //pictures mPicWidget = new PicturesWidget; mTab->addTab(mPicWidget, tr("Pictures")); connect(mPicWidget, SIGNAL(needWindowTitleChange(QString)), this, SLOT(setWindowTitle(QString))); + connect(mPicWidget->picView(), SIGNAL(newMappings(QString)), this, SLOT(statusbarMessage(QString))); + connect(mPicWidget->picView(), SIGNAL(numSelected(int)), this, SLOT(updateSelectedCount(int))); + connect(mPicWidget->picView(), SIGNAL(selectedSize(qint64)), this, SLOT(setSize(qint64))); //newmoviewizard + dbanalyzer mNewMovieWizard = new NewMovieWizard(this); @@ -103,7 +106,8 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla createToolBar(); setFsFree(); - connect(mFSWidget->fileView()->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateSelectionCount(const QItemSelection &, const QItemSelection &))); + connect(mFSWidget->fileView(), SIGNAL(selectedSize(qint64)), this, SLOT(setSize(qint64))); + connect(mFSWidget->fileView(), SIGNAL(numSelected(int)), this, SLOT(updateSelectedCount(int))); connect(mFSWidget, SIGNAL(windowTitle(QString)), this, SLOT(setWindowTitle(QString))); connect(mFSWidget->fileView(), SIGNAL(statusbarMessage(const QString &)), this, SLOT(statusbarMessage(const QString &))); connect(mFSWidget, SIGNAL(statusbarMessage(const QString &)), this, SLOT(statusbarMessage(const QString &))); @@ -142,28 +146,8 @@ void SheMov::closeEvent(QCloseEvent *event){ event->accept(); } -void SheMov::updateSelectionCount(const QItemSelection & /* sel */, const QItemSelection & /* prev */){ - QLocale l; - switch (mTab->currentIndex()) { - case 0: { - int selCount = mFSWidget->fileView()->selectionModel()->selectedRows().count(); - mSelectedItems->setText(QString::number(selCount)); - qint64 selSize(0); - foreach(QModelIndex idx, mFSWidget->fileView()->selectionModel()->selectedRows()){ - QModelIndex real = mFSWidget->fileProxy()->mapToSource(idx); - if(real.isValid()){ - QFileInfo fi = mFSWidget->dirModel()->fileInfo(real); - selSize += fi.size(); - } - } - mSelectedSize->setText(QString(tr("%1")).arg(l.toString((selSize)))); - break; - } - case 1: { - int selCount = mATree->filesWidget()->filesTree()->selectionModel()->selectedRows().count(); - mSelectedItems->setText(QString::number(selCount)); - } - } +void SheMov::updateSelectedCount(int count){ + mSelectedItems->setText(QString::number(count)); } void SheMov::statusbarMessage(const QString &message){ @@ -196,7 +180,6 @@ void SheMov::tabChanged(int newTab){ mShowTreeGroup->setEnabled(newTab == 1); mPicActionGroup->setEnabled(newTab == 2); mFilterFavoritesA->setEnabled(newTab == 1); - updateSelectionCount(QItemSelection(), QItemSelection()); } void SheMov::setFsFree(){ -- cgit v1.2.3-70-g09d2