OSDN Git Service

Better workaround for "ResizeToContents not updating" bug.
authorlordmulder <mulder2@gmx.de>
Tue, 23 Aug 2011 15:01:11 +0000 (17:01 +0200)
committerlordmulder <mulder2@gmx.de>
Tue, 23 Aug 2011 15:01:11 +0000 (17:01 +0200)
src/Config.h
src/Dialog_MainWindow.cpp
src/Dialog_MainWindow.h
src/Dialog_Processing.cpp
src/Dialog_Processing.h

index 85ed0b6..c85863d 100644 (file)
@@ -30,7 +30,7 @@
 #define VER_LAMEXP_MINOR_LO                                    3
 #define VER_LAMEXP_TYPE                                                Alpha
 #define VER_LAMEXP_PATCH                                       15
-#define VER_LAMEXP_BUILD                                       660
+#define VER_LAMEXP_BUILD                                       662
 
 ///////////////////////////////////////////////////////////////////////////////
 // Tools versions
index 846020f..82c8241 100644 (file)
@@ -132,6 +132,8 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
        connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged()));
        connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
        connect(sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint)));
+       connect(sourceFileView->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
+       connect(sourceFileView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
        connect(m_showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked()));
        connect(m_previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered()));
        connect(m_findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered()));
@@ -862,10 +864,6 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
                        break;
                }
        }
-       else if(obj == sourceFileView->viewport())
-       {
-               sourceFileView ->resizeColumnToContents(0);
-       }
 
        return false;
 }
@@ -1864,6 +1862,15 @@ void MainWindow::sourceFilesContextMenu(const QPoint &pos)
 }
 
 /*
+ * Scrollbar of source files moved
+ */
+void MainWindow::sourceFilesScrollbarMoved(int)
+{
+       qDebug("sourceFileView->resizeColumnToContents(0);");
+       sourceFileView->resizeColumnToContents(0);
+}
+
+/*
  * Open selected file in external player
  */
 void MainWindow::previewContextActionTriggered(void)
index 6d96b1b..d593dc0 100644 (file)
@@ -118,6 +118,7 @@ private slots:
        void showFolderContextActionTriggered(void);
        void showRenameMacros(const QString &text);
        void sourceFilesContextMenu(const QPoint &pos);
+       void sourceFilesScrollbarMoved(int);
        void sourceModelChanged(void);
        void styleActionActivated(QAction *action);
        void tabActionActivated(QAction *action);
index 703faf3..8fb2b53 100644 (file)
@@ -135,6 +135,7 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
        connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
        connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
        connect(view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
+       connect(view_log->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(logViewSectionSizeChanged(int,int,int)));
 
        //Create context menu
        m_contextMenu = new QMenu();
@@ -264,10 +265,6 @@ bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event)
                        QDesktopServices::openUrl(url);
                }
        }
-       else if(obj == view_log->viewport())
-       {
-               view_log->resizeColumnToContents(1);
-       }
 
        return false;
 }
@@ -482,6 +479,18 @@ void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
        }
 }
 
+void ProcessingDialog::logViewSectionSizeChanged(int logicalIndex, int oldSize, int newSize)
+{
+       qDebug("sectionResized");
+       if(logicalIndex == 1)
+       {
+               if(QHeaderView *hdr = view_log->horizontalHeader())
+               {
+                       hdr->setMinimumSectionSize(max(hdr->minimumSectionSize(), hdr->sectionSize(1)));
+               }
+       }
+}
+
 void ProcessingDialog::contextMenuTriggered(const QPoint &pos)
 {
        QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
index 44ad371..13eb76f 100644 (file)
@@ -52,6 +52,7 @@ private slots:
        void processFinished(const QUuid &jobId, const QString &outFileName, bool success);
        void progressModelChanged(void);
        void logViewDoubleClicked(const QModelIndex &index);
+       void logViewSectionSizeChanged(int, int, int);
        void contextMenuTriggered(const QPoint &pos);
        void contextMenuDetailsActionTriggered(void);
        void contextMenuShowFileActionTriggered(void);