/* * This file Copyright (C) Mnemosyne LLC * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * $Id: utils.cc 12697 2011-08-20 05:19:27Z jordan $ */ #include #include #include #include #include #include #include #include #include #include #include #include // tr_formatter #include "utils.h" /*** **** ***/ QString Utils :: remoteFileChooser( QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local ) { QString path; if( local ) { if( dir ) path = QFileDialog::getExistingDirectory( parent, title, myPath ); else path = QFileDialog::getOpenFileName( parent, title, myPath ); } else path = QInputDialog::getText( parent, title, tr( "Enter a location:" ), QLineEdit::Normal, myPath, NULL ); return path; } void Utils :: toStderr( const QString& str ) { std::cerr << qPrintable(str) << std::endl; } const QIcon& Utils :: guessMimeIcon( const QString& filename ) { enum { DISK, DOCUMENT, PICTURE, VIDEO, ARCHIVE, AUDIO, APP, TYPE_COUNT }; static QIcon fallback; static QIcon fileIcons[TYPE_COUNT]; static QSet suffixes[TYPE_COUNT]; if( fileIcons[0].isNull( ) ) { fallback = QApplication::style()->standardIcon( QStyle :: SP_FileIcon ); suffixes[DISK] << QString::fromAscii("iso"); fileIcons[DISK]= QIcon::fromTheme( QString::fromAscii("media-optical"), fallback ); const char * doc_types[] = { "abw", "csv", "doc", "dvi", "htm", "html", "ini", "log", "odp", "ods", "odt", "pdf", "ppt", "ps", "rtf", "tex", "txt", "xml" }; for( int i=0, n=sizeof(doc_types)/sizeof(doc_types[0]); i