Skip to content

Commit

Permalink
Fixed image loading two times at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-kocic committed Jan 29, 2012
1 parent 6399605 commit cb48050
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
13 changes: 0 additions & 13 deletions main.cpp
Expand Up @@ -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();
}
2 changes: 1 addition & 1 deletion main_window.cpp
Expand Up @@ -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());
Expand Down
11 changes: 8 additions & 3 deletions picture_loader.cpp
Expand Up @@ -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())
Expand All @@ -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
}

Expand Down Expand Up @@ -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())
Expand Down
17 changes: 12 additions & 5 deletions view_files.cpp
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit cb48050

Please sign in to comment.