Permalink
Browse files

Fixed image loading two times at startup

  • Loading branch information...
1 parent 6399605 commit cb480500ad328806247c648bc18abf7c3e8bddc0 @nikola-kocic committed Jan 29, 2012
Showing with 21 additions and 22 deletions.
  1. +0 −13 main.cpp
  2. +1 −1 main_window.cpp
  3. +8 −3 picture_loader.cpp
  4. +12 −5 view_files.cpp
View
@@ -10,19 +10,6 @@ int main(int argc, char *argv[])
app.setApplicationVersion("0.2");
MainWindow w;
-
-#ifdef WIN32
- QStringList l_libPaths;
- /* Build plugins path */
- QDir l_pluginsPath(QApplication::applicationDirPath());
- l_pluginsPath.mkdir("plugins");
- l_pluginsPath.cd("plugins");
-
- /* Set library paths */
- l_libPaths << l_pluginsPath.path() << QApplication::applicationDirPath();
- QApplication::setLibraryPaths(l_libPaths);
-#endif
-
w.showMaximized();
return app.exec();
}
View
@@ -570,7 +570,7 @@ void MainWindow::deleteBookmark()
void MainWindow::on_filesView_currentChanged(const FileInfo &info)
{
#ifdef DEBUG_MAIN_WINDOW
- qDebug() << "MainWindow::on_filesView_currentChanged" << info.getDebugInfo();
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "MainWindow::on_filesView_currentChanged" << info.getDebugInfo();
#endif
m_act_dirUp->setEnabled(!info.isContainerRoot());
this->setWindowTitle(m_view_files->getCurrentFileInfo().getContainerName() + " - " + QApplication::applicationName() + " " + QApplication::applicationVersion());
View
@@ -69,7 +69,9 @@ QImage PictureLoader::styleThumbnail(const QImage &img, const QSize &thumb_size)
QImage PictureLoader::getImageFromFile(const ThumbnailInfo &thumb_info)
{
QImageReader image_reader(thumb_info.getFileInfo().getPath());
- // qDebug() << image_reader.format();
+#ifdef DEBUG_PICTURE_LOADER
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << thumb_info.getFileInfo().getPath() << image_reader.format() << image_reader.supportedImageFormats();
+#endif
if (!thumb_info.getThumbSize().isEmpty())
{
if (image_reader.size().height() > thumb_info.getThumbSize().height() || image_reader.size().width() > thumb_info.getThumbSize().width())
@@ -95,7 +97,7 @@ QImage PictureLoader::getImageFromZip(const ThumbnailInfo &thumb_info)
{
return QImage(0, 0);
#ifdef DEBUG_PICTURE_LOADER
- qDebug() << "PictureLoader::getImageFromZip setCurrentFile failed" << thumb_info.getFileInfo().zipImagePath();
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "PictureLoader::getImageFromZip setCurrentFile failed" << thumb_info.getFileInfo().zipImagePath();
#endif
}
@@ -126,9 +128,12 @@ QImage PictureLoader::getImageFromZip(const ThumbnailInfo &thumb_info)
}
out.close();
#ifdef DEBUG_PICTURE_LOADER
- qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "PictureLoader::getImageFromZip" << "finished reading from zip";
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "PictureLoader::getImageFromZip" << "finished reading from zip" << thumb_info.getFileInfo().getPath();
#endif
QImageReader image_reader(&out);
+#ifdef DEBUG_PICTURE_LOADER
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << image_reader.format() << image_reader.supportedImageFormats();
+#endif
if (!thumb_info.getThumbSize().isEmpty())
{
if (image_reader.size().height() > thumb_info.getThumbSize().height() || image_reader.size().width() > thumb_info.getThumbSize().width())
View
@@ -369,27 +369,34 @@ void ViewFiles::on_archiveDirsView_currentRowChanged(const QModelIndex &current,
{
return;
}
- m_fileinfo_current = FileInfo(current.data(QFileSystemModel::FilePathRole).toString());
m_view_current->setRootIndex(m_proxy_file_list->mapFromSource(m_proxy_archive_dirs->mapToSource(current)));
m_view_current->selectionModel()->clear();
showThumbnails();
+ if (m_flag_opening)
+ return;
+
+ m_fileinfo_current = FileInfo(current.data(QFileSystemModel::FilePathRole).toString());
emit currentFileChanged(m_fileinfo_current);
}
void ViewFiles::on_FilesView_currentRowChanged(const QModelIndex &current, const QModelIndex &previous)
{
Q_UNUSED(previous);
- if (!current.isValid()) return;
+ if (!current.isValid())
+ return;
+
m_view_current->scrollTo(current);
- m_fileinfo_current = FileInfo(current.data(QFileSystemModel::FilePathRole).toString(), false); // Pass 'false' for 'IsContainer' because item is only selected
+ if (m_flag_opening)
+ return;
#ifdef DEBUG_VIEW_FILES
- qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "ViewFiles::currentChanged" << m_fileinfo_current.getDebugInfo();
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "ViewFiles::on_FilesView_currentRowChanged" << m_fileinfo_current.getDebugInfo();
#endif
+ m_fileinfo_current = FileInfo(current.data(QFileSystemModel::FilePathRole).toString(), false); // Pass 'false' for 'IsContainer' because item is only selected
emit currentFileChanged(m_fileinfo_current);
}
@@ -525,7 +532,7 @@ void ViewFiles::on_rows_inserted(const QModelIndexList &indexes)
{
#ifdef DEBUG_VIEW_FILES
- qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "ViewFiles::on_rows_inserted" << m_show_thumbnails;
+ qDebug() << QDateTime::currentDateTime().toString(Qt::ISODate) << "ViewFiles::on_rows_inserted" << "thumbnails?" << m_show_thumbnails;
#endif
if (!m_show_thumbnails)
{

0 comments on commit cb48050

Please sign in to comment.