summaryrefslogtreecommitdiffstats
path: root/shemov.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2012-03-18 01:47:21 +0100
committerArno <am@disconnect.de>2012-03-18 01:47:21 +0100
commit3e784fed0148c4ec24aa8b2b8ca53f2d9d9bc543 (patch)
treeae756b5b493aacb6c486a13b3e4fd0d9a0e4d801 /shemov.cpp
parent1e14ae6748f271265dd719ac0766a2da3501a21f (diff)
downloadSheMov-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 'shemov.cpp')
-rw-r--r--shemov.cpp37
1 files changed, 10 insertions, 27 deletions
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("<span style=\"color:#000000\">%1</span>")).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(){