// This can happen after openUrl returns, or directly from m_image->ref() void KHTMLImage::notifyFinished( khtml::CachedObject *o ) { if ( !m_image || o != m_image ) return; //const QPixmap &pix = m_image->pixmap(); QString caption; KMimeType::Ptr mimeType; if ( !m_mimeType.isEmpty() ) mimeType = KMimeType::mimeType(m_mimeType, KMimeType::ResolveAliases); if ( mimeType ) { if ( !m_image->suggestedTitle().isEmpty() ) { caption = i18n( "%1 (%2 - %3x%4 Pixels)", m_image->suggestedTitle(), mimeType->comment(), m_image->pixmap_size().width(), m_image->pixmap_size().height() ); } else { caption = i18n( "%1 - %2x%3 Pixels" , mimeType->comment() , m_image->pixmap_size().width() , m_image->pixmap_size().height() ); } } else { if ( !m_image->suggestedTitle().isEmpty() ) { caption = i18n( "%1 (%2x%3 Pixels)" , m_image->suggestedTitle(), m_image->pixmap_size().width() , m_image->pixmap_size().height() ); } else { caption = i18n( "Image - %1x%2 Pixels" , m_image->pixmap_size().width() , m_image->pixmap_size().height() ); } } emit setWindowCaption( caption ); emit completed(); emit setStatusBarText(i18n("Done.")); }
void KMMimePartTreeItem::setIconAndTextForType( const QString & mime ) { QString mimetype = mime.lower(); if ( mimetype.startsWith( "multipart/" ) ) { setText( 1, mimetype ); setPixmap( 0, SmallIcon("folder") ); } else if ( mimetype == "application/octet-stream" ) { setText( 1, i18n("Unspecified Binary Data") ); // don't show "Unknown"... setPixmap( 0, SmallIcon("unknown") ); } else { KMimeType::Ptr mtp = KMimeType::mimeType( mimetype ); setText( 1, (mtp && !mtp->comment().isEmpty()) ? mtp->comment() : mimetype ); setPixmap( 0, mtp ? mtp->pixmap( KIcon::Small) : SmallIcon("unknown") ); } }
void KFileFilterCombo::setMimeFilter(const QStringList &types, const QString &defaultType) { clear(); filters.clear(); QString delim = QString::fromLatin1(", "); d->hasAllSupportedFiles = false; m_allTypes = defaultType.isEmpty() && (types.count() > 1); QString allComments, allTypes; int i = 0; for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it, ++i) { if(m_allTypes && it != types.begin()) { allComments += delim; allTypes += ' '; } kdDebug(kfile_area) << *it << endl; KMimeType::Ptr type = KMimeType::mimeType(*it); filters.append(type->name()); if(m_allTypes) { allTypes += type->name(); allComments += type->comment(); } insertItem(type->comment()); if(type->name() == defaultType) setCurrentItem(i); } if(m_allTypes) { if(i < 3) // show the mime-comments of at max 3 types insertItem(allComments, 0); else { insertItem(i18n("All Supported Files"), 0); d->hasAllSupportedFiles = true; } filters.prepend(allTypes); } d->lastFilter = currentText(); d->isMimeFilter = true; }
QString KFileItem::mimeComment() const { const QString displayType = d->m_entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_TYPE ); if (!displayType.isEmpty()) return displayType; KMimeType::Ptr mType = determineMimeType(); bool isLocalUrl; KUrl url = mostLocalUrl(isLocalUrl); KMimeType::Ptr mime = mimeTypePtr(); // This cannot move to kio_file (with UDS_DISPLAY_TYPE) because it needs // the mimetype to be determined, which is done here, and possibly delayed... if (isLocalUrl && mime->is("application/x-desktop")) { KDesktopFile cfg( url.toLocalFile() ); QString comment = cfg.desktopGroup().readEntry( "Comment" ); if (!comment.isEmpty()) return comment; } QString comment = mType->comment( url ); //kDebug() << "finding comment for " << url.url() << " : " << d->m_pMimeType->name(); if (!comment.isEmpty()) return comment; else return mType->name(); }
void KMimeTypeTest::testByName() { KMimeType::Ptr s0 = KMimeType::mimeType("application/x-zerosize"); QVERIFY(s0); QCOMPARE(s0->name(), QString::fromLatin1("application/x-zerosize")); QCOMPARE(s0->comment(), QString::fromLatin1("empty document")); KMimeType::Ptr s0Again = KMimeType::mimeType("application/x-zerosize"); QCOMPARE(s0Again->name(), s0->name()); QVERIFY(s0Again != s0); KMimeType::Ptr s1 = KMimeType::mimeType("text/plain"); QVERIFY(s1); QCOMPARE(s1->name(), QString::fromLatin1("text/plain")); //qDebug("Comment is %s", qPrintable(s1->comment()) ); KMimeType::Ptr krita = KMimeType::mimeType("application/x-krita"); QVERIFY(krita); // Test <comment> parsing with application/rdf+xml which has the english comment after the other ones KMimeType::Ptr rdf = KMimeType::mimeType("application/rdf+xml"); QVERIFY(rdf); QCOMPARE(rdf->comment(), QString::fromLatin1("RDF file")); KMimeType::Ptr bzip2 = KMimeType::mimeType("application/x-bzip2"); QVERIFY(bzip2); QCOMPARE(bzip2->comment(), QString::fromLatin1("Bzip archive")); KMimeType::Ptr defaultMime = KMimeType::mimeType("application/octet-stream"); QVERIFY(defaultMime); QVERIFY(defaultMime->isDefault()); }
void URLGrabber::matchingMimeActions(const QString& clipData) { KUrl url(clipData); KConfigGroup cg(KGlobal::config(), "Actions"); if(!cg.readEntry("EnableMagicMimeActions",true)) { //kDebug() << "skipping mime magic due to configuration"; return; } if(!url.isValid()) { //kDebug() << "skipping mime magic due to invalid url"; return; } if(url.isRelative()) { //openinng a relative path will just not work. what path should be used? //kDebug() << "skipping mime magic due to relative url"; return; } if(url.isLocalFile()) { if ( clipData == "//") { //kDebug() << "skipping mime magic due to C++ comment //"; return; } if(!QFile::exists(url.toLocalFile())) { //kDebug() << "skipping mime magic due to nonexistent localfile"; return; } } // try to figure out if clipData contains a filename KMimeType::Ptr mimetype = KMimeType::findByUrl( url, 0, false, true /*fast mode*/ ); // let's see if we found some reasonable mimetype. // If we do we'll populate menu with actions for apps // that can handle that mimetype // first: if clipboard contents starts with http, let's assume it's "text/html". // That is even if we've url like "http://www.kde.org/somescript.pl", we'll // still treat that as html page, because determining a mimetype using kio // might take a long time, and i want this function to be quick! if ( ( clipData.startsWith( QLatin1String("http://") ) || clipData.startsWith( QLatin1String("https://") ) ) && mimetype->name() != "text/html" ) { // use a fake path to create a mimetype that corresponds to "text/html" mimetype = KMimeType::findByPath( "/tmp/klipper.html", 0, true /*fast mode*/ ); } if ( !mimetype->isDefault() ) { ClipAction* action = new ClipAction( QString(), mimetype->comment() ); KService::List lst = KMimeTypeTrader::self()->query( mimetype->name(), "Application" ); foreach( const KService::Ptr &service, lst ) { QHash<QChar,QString> map; map.insert( 'i', "--icon " + service->icon() ); map.insert( 'c', service->name() ); QString exec = service->exec(); exec = KMacroExpander::expandMacros( exec, map ).trimmed(); action->addCommand( ClipCommand( exec, service->name(), true, service->icon() ) ); }
//=========================================================== // void ImportWizard::setupIntro() { m_introPage = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(m_introPage, KDialog::marginHint()); QLabel *lblIntro = new QLabel(m_introPage); lblIntro->setAlignment( Qt::AlignTop | Qt::AlignLeft | Qt::WordBreak ); QString msg; if (m_predefinedConnectionData) { //predefined import: server source msg = i18n("<qt>Database Importing wizard is about to import \"%1\" database " "<nobr>(connection %2)</nobr> into a Kexi database.</qt>") .arg(m_predefinedDatabaseName).arg(m_predefinedConnectionData->serverInfoString()); } else if (!m_predefinedDatabaseName.isEmpty()) { //predefined import: file source //! @todo this message is currently ok for files only KMimeType::Ptr mimeTypePtr = KMimeType::mimeType(m_predefinedMimeType); msg = i18n("<qt>Database Importing wizard is about to import <nobr>\"%1\"</nobr> file " "of type \"%2\" into a Kexi database.</qt>") .arg(QDir::convertSeparators(m_predefinedDatabaseName)).arg(mimeTypePtr->comment()); } else { msg = i18n("Database Importing wizard allows you to import an existing database " "into a Kexi database."); } lblIntro->setText(msg+"\n\n" +i18n("Click \"Next\" button to continue or \"Cancel\" button to exit this wizard.")); vbox->addWidget( lblIntro ); addPage(m_introPage, i18n("Welcome to the Database Importing Wizard")); }
QString typeForContent( KMime::Content *content ) { if ( !content->contentType( false ) ) return QString(); KMimeType::Ptr mimeType = KMimeType::mimeType( QString::fromLatin1( content->contentType()->mimeType() ) ); if ( mimeType.isNull() ) return QString::fromLatin1( content->contentType()->mimeType() ); return mimeType->comment(); }
static void printMimeTypes( const TDECmdLineArgs *args ) { for ( int i = 0; i < args->count(); i++ ) { KURL url = args->url( i ); KMimeType::Ptr mt = KMimeType::findByURL( url ); cout << args->arg(i) << ": " << mt->comment().local8Bit().data() << " (" << mt->name().local8Bit().data() << ")" << endl; } }
QString KFileItem::mimeComment() { KMimeType::Ptr mType = determineMimeType(); bool isLocalURL; KURL url = mostLocalURL(isLocalURL); QString comment = mType->comment( url, isLocalURL ); //kdDebug() << "finding comment for " << url.url() << " : " << m_pMimeType->name() << endl; if (!comment.isEmpty()) return comment; else return mType->name(); }
void RenderPartObject::slotPartLoadingErrorNotify() { #if APPLE_CHANGES // FIXME: What are we going to do for this case? #else // First we need to find out the servicetype - again - this code is too duplicated ! HTMLEmbedElementImpl *embed = 0; QString serviceType; if( element()->id()==ID_OBJECT ) { // check for embed child object HTMLObjectElementImpl *o = static_cast<HTMLObjectElementImpl *>(element()); serviceType = o->serviceType; NodeImpl *child = o->firstChild(); while ( child ) { if ( child->id() == ID_EMBED ) embed = static_cast<HTMLEmbedElementImpl *>( child ); child = child->nextSibling(); } } else if( element()->id()==ID_EMBED ) { embed = static_cast<HTMLEmbedElementImpl *>(element()); } if ( embed ) serviceType = embed->serviceType; KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part(); KParts::BrowserExtension *ext = part->browserExtension(); if( embed && !embed->pluginPage.isEmpty() && ext ) { // Prepare the mimetype to show in the question (comment if available, name as fallback) QString mimeName = serviceType; KMimeType::Ptr mime = KMimeType::mimeType(serviceType); if ( mime->name() != KMimeType::defaultMimeType() ) mimeName = mime->comment(); // Prepare the URL to show in the question (host only if http, to make it short) KURL pluginPageURL( embed->pluginPage ); QString shortURL = pluginPageURL.protocol() == "http" ? pluginPageURL.host() : pluginPageURL.prettyURL(); int res = KMessageBox::questionYesNo( m_view, i18n("No plugin found for '%1'.\nDo you want to download one from %2?").arg(mimeName).arg(shortURL), i18n("Missing plugin"), QString::null, QString::null, QString("plugin-")+serviceType); if ( res == KMessageBox::Yes ) { // Display vendor download page ext->createNewWindow( pluginPageURL ); } } #endif // APPLE_CHANGES }
KoFilterChooser::KoFilterChooser(QWidget *parent, const QStringList &mimeTypes, const QString &nativeFormat, const KUrl &url) : KDialog(parent), m_mimeTypes(mimeTypes) { setObjectName("kofilterchooser"); setInitialSize(QSize(300, 350)); setButtons(KDialog::Ok|KDialog::Cancel); setDefaultButton(KDialog::Ok); setCaption(i18n("Choose Filter")); setModal(true); QWidget *page = new QWidget(this); setMainWidget(page); QVBoxLayout *layout = new QVBoxLayout(page); if (url.isValid()) { KSqueezedTextLabel *l = new KSqueezedTextLabel(url.path(), page); layout->addWidget(l); } m_filterList = new QListWidget(page); layout->addWidget(m_filterList); page->setLayout(layout); Q_ASSERT(!m_mimeTypes.isEmpty()); for (QStringList::ConstIterator it = m_mimeTypes.constBegin(); it != m_mimeTypes.constEnd(); it++) { KMimeType::Ptr mime = KMimeType::mimeType(*it); const QString name = mime ? mime->comment() : *it; if (! name.isEmpty()) m_filterList->addItem(name); } if (nativeFormat == "application/x-kword") { const int index = m_mimeTypes.indexOf("text/plain"); if (index > -1) m_filterList->setCurrentRow(index); } if (m_filterList->currentRow() == -1) m_filterList->setCurrentRow(0); m_filterList->setFocus(); connect(m_filterList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(accept())); resize(QSize(520, 400));//.expandedTo(minimumSizeHint())); }
void Wizard::installExtraMimes(QString baseName, QStringList globs) { QString mimefile = baseName; mimefile.replace('/', '-'); KMimeType::Ptr mime = KMimeType::mimeType(baseName); if (!mime) { kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found"; } else { QStringList extensions = mime->patterns(); QString comment = mime->comment(); foreach(const QString &glob, globs) { if (!extensions.contains(glob)) extensions << glob; } kDebug() << "EXTS: " << extensions; QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml"); kDebug() << "INSTALLING NEW MIME TO: " << packageFileName; QFile packageFile(packageFileName); if (!packageFile.open(QIODevice::WriteOnly)) { kError() << "Couldn't open" << packageFileName << "for writing"; return; } QXmlStreamWriter writer(&packageFile); writer.setAutoFormatting(true); writer.writeStartDocument(); const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info"; writer.writeDefaultNamespace(nsUri); writer.writeStartElement("mime-info"); writer.writeStartElement(nsUri, "mime-type"); writer.writeAttribute("type", baseName); if (!comment.isEmpty()) { writer.writeStartElement(nsUri, "comment"); writer.writeCharacters(comment); writer.writeEndElement(); // comment } foreach(const QString& pattern, extensions) { writer.writeStartElement(nsUri, "glob"); writer.writeAttribute("pattern", pattern); writer.writeEndElement(); // glob } writer.writeEndElement(); // mime-info writer.writeEndElement(); // mime-type writer.writeEndDocument(); }
static KIO::CopyJob *chooseAndPaste(const KURL &u, QMimeSource *data, const QValueVector< QCString > &formats, const QString &text, QWidget *widget, bool clipboard) { QStringList formatLabels; for(uint i = 0; i < formats.size(); ++i) { const QCString &fmt = formats[i]; KMimeType::Ptr mime = KMimeType::mimeType(fmt); if(mime != KMimeType::defaultMimeTypePtr()) formatLabels.append(i18n("%1 (%2)").arg(mime->comment()).arg(fmt)); else formatLabels.append(fmt); } QString dialogText(text); if(dialogText.isEmpty()) dialogText = i18n("Filename for clipboard content:"); KIO::PasteDialog dlg(QString::null, dialogText, QString::null, formatLabels, widget, clipboard); if(dlg.exec() != KDialogBase::Accepted) return 0; if(clipboard && dlg.clipboardChanged()) { KMessageBox::sorry(widget, i18n("The clipboard has changed since you used 'paste': " "the chosen data format is no longer applicable. " "Please copy again what you wanted to paste.")); return 0; } const QString result = dlg.lineEditText(); const QCString chosenFormat = formats[dlg.comboItem()]; kdDebug() << " result=" << result << " chosenFormat=" << chosenFormat << endl; KURL new_url(u); new_url.addPath(result); // if "data" came from QClipboard, then it was deleted already - by a nice 0-seconds timer // In that case, get it again. Let's hope the user didn't copy something else meanwhile :/ if(clipboard) { data = QApplication::clipboard()->data(); } const QByteArray ba = data->encodedData(chosenFormat); return pasteDataAsyncTo(new_url, ba); }
bool ArkViewer::viewInInternalViewer(const QString& fileName, const KMimeType::Ptr& mimeType) { const KUrl fileUrl(fileName); setCaption(fileUrl.fileName()); restoreDialogSize(KGlobal::config()->group("Viewer")); QFrame *header = new QFrame(m_widget); QHBoxLayout *headerLayout = new QHBoxLayout(header); QLabel *iconLabel = new QLabel(header); headerLayout->addWidget(iconLabel); iconLabel->setPixmap(KIconLoader::global()->loadMimeTypeIcon(mimeType->iconName(), KIconLoader::Desktop)); iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); KVBox *headerRight = new KVBox(header); headerLayout->addWidget(headerRight); new QLabel(QString(QLatin1String( "<qt><b>%1</b></qt>" )) .arg(fileUrl.fileName()), headerRight ); new QLabel(mimeType->comment(), headerRight); header->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); m_part = KMimeTypeTrader::self()->createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType->name(), m_widget, this); if (!m_part.data()) { return false; } if (m_part.data()->browserExtension()) { connect(m_part.data()->browserExtension(), SIGNAL(openUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), SLOT(slotOpenUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments))); } m_part.data()->openUrl(fileUrl); return true; }
void removeExistingExtensions( QString &extension ) { QStringList filtered; const QStringList exts = extension.split( ',' ); for ( QStringList::const_iterator it=exts.constBegin(); it!=exts.constEnd(); ++it ) { QString ext = (*it).trimmed(); if ( ext == "*" ) // some plugins have that, but we don't want to associate a mimetype with *.*! continue; KMimeType::Ptr mime = KMimeType::findByUrl( KUrl("file:///foo."+ext ), 0, true, true ); if( mime->isDefault() || mime->comment().startsWith("Netscape") ) { kDebug() << "accepted"; filtered.append( ext ); } } extension = filtered.join( "," ); }
void Nepomuk::QueryClientWrapper::slotNewEntries(const QList<Nepomuk::Query::Result>& results) { QList<Plasma::QueryMatch> matches; foreach(const Query::Result& result, results) { Plasma::QueryMatch match(m_runner); match.setType(Plasma::QueryMatch::PossibleMatch); match.setRelevance(normalizeScore(result.score())); Nepomuk::Resource res = result.resource(); QString type; QString iconName; KMimeType::Ptr mimetype; if (res.hasProperty(Nepomuk::Vocabulary::NIE::mimeType())) { mimetype = KMimeType::mimeType(res.property(Nepomuk::Vocabulary::NIE::mimeType()).toString()); } if (!mimetype && res.isFile() && res.toFile().url().isLocalFile()) { const KUrl url(res.toFile().url()); mimetype = KMimeType::findByUrl(url); } if (mimetype) { type = mimetype->comment(); iconName = mimetype->iconName(); } if (type.isEmpty() ) { type = Nepomuk::Types::Class(res.resourceType()).label(); iconName = res.genericIcon(); } match.setText(res.genericLabel()); match.setSubtext(type); match.setIcon(KIcon(iconName.isEmpty() ? QString::fromLatin1("nepomuk") : iconName)); match.setData(qVariantFromValue(res)); match.setId(KUrl(res.resourceUri()).url()); matches << match; }
void KHTMLImage::updateWindowCaption() { if ( !m_khtml ) return; DOM::HTMLDocumentImpl *impl = dynamic_cast<DOM::HTMLDocumentImpl *>( m_khtml->document().handle() ); if ( !impl ) return; DOM::HTMLElementImpl *body = impl->body(); if ( !body ) return; DOM::NodeImpl *image = body->firstChild(); if ( !image ) return; khtml::RenderImage *renderImage = dynamic_cast<khtml::RenderImage *>( image->renderer() ); if ( !renderImage ) return; QPixmap pix = renderImage->pixmap(); QString caption; KMimeType::Ptr mimeType; if ( !m_mimeType.isEmpty() ) mimeType = KMimeType::mimeType( m_mimeType ); if ( mimeType ) caption = i18n( "%1 - %2x%3 Pixels" ).arg( mimeType->comment() ) .arg( pix.width() ).arg( pix.height() ); else caption = i18n( "Image - %2x%3 Pixels" ).arg( pix.width() ).arg( pix.height() ); emit setWindowCaption( caption ); emit completed(); emit setStatusBarText(i18n("Done.")); }
void AttachPropertyDialog::setAttachment(KTNEFAttach *attach) { QString s = (attach->fileName().isEmpty() ? attach->name() : attach->fileName()); filename_->setText("<b>"+s+"</b>"); setCaption(s); display_->setText(attach->displayName()); mime_->setText(attach->mimeTag()); s.setNum(attach->size()); s.append(" bytes"); size_->setText(s); KMimeType::Ptr mimetype = KMimeType::mimeType(attach->mimeTag()); QPixmap pix = loadRenderingPixmap( attach, colorGroup().background() ); if ( !pix.isNull() ) icon_->setPixmap( pix ); else icon_->setPixmap(mimetype->pixmap(KIcon::Small)); description_->setText(mimetype->comment()); s.setNum(attach->index()); index_->setText(s); formatPropertySet( attach, properties_ ); m_attach = attach; }
LinkItem::LinkItem( DOM::Element link ) : m_valid( false ) { DOM::NamedNodeMap attrs = link.attributes(); DOM::Node href = attrs.getNamedItem( "href" ); // Load source address of images too DOM::Node src = attrs.getNamedItem( "src" ); if ( href.nodeValue().string().isEmpty() && !src.nodeValue().string().isEmpty() ) href = src; // qDebug("*** href: %s", href.nodeValue().string().latin1() ); QString urlString = link.ownerDocument().completeURL( href.nodeValue() ).string(); if ( urlString.isEmpty() ) return; url = KUrl( urlString ); if ( !KProtocolManager::supportsReading( url ) ) return; // somehow getElementsByTagName("#text") doesn't work :( DOM::NodeList children = link.childNodes(); for ( uint i = 0; i < children.length(); i++ ) { DOM::Node node = children.item( i ); if ( node.nodeType() == DOM::Node::TEXT_NODE ) text.append( node.nodeValue().string() ); } // force "local file" mimetype determination KMimeType::Ptr mt = KMimeType::findByUrl( url, 0, true, true); icon = mt->iconName(); mimeType = mt->comment(); m_valid = true; }
void KGetLinkView::showLinks( const QList<QString>& links ) { QStandardItemModel *model = new QStandardItemModel(0, 5, this); model->setHeaderData(0, Qt::Horizontal, i18n("Auxiliary header")); model->setHeaderData(1, Qt::Horizontal, i18n("File Name")); model->setHeaderData(2, Qt::Horizontal, i18n("Description")); model->setHeaderData(3, Qt::Horizontal, i18nc("list header: type of file", "File Type")); model->setHeaderData(4, Qt::Horizontal, i18n("Location (URL)")); foreach (const QString &linkitem, links) { KUrl url(linkitem); QString file = url.fileName(); if (file.isEmpty()) { file = QString(url.host()); } KMimeType::Ptr mt = KMimeType::findByUrl(linkitem, 0, true, true); QList<QStandardItem*> items; QStandardItem *item = new QStandardItem(file); item->setIcon(KIcon(mt->iconName())); item->setCheckable(true); item->setData(QVariant(url.fileName()), Qt::DisplayRole); item->setData(QVariant(mt->name()), Qt::UserRole); // used for filtering DownloadFilterType items << new QStandardItem(QString::number(model->rowCount())); items << item; items << new QStandardItem(); items << new QStandardItem(mt->comment()); items << new QStandardItem(url.prettyUrl()); model->insertRow(model->rowCount(), items); }
bool operator()(const KMimeType::Ptr& lhs, const KMimeType::Ptr& rhs) const { return lhs->comment() < rhs->comment(); }
KfindTabWidget::KfindTabWidget(QWidget *parent) : KTabWidget( parent ), regExpDialog(0) { // This validator will be used for all numeric edit fields //KDigitValidator *digitV = new KDigitValidator(this); // ************ Page One ************ pages[0] = new QWidget; pages[0]->setObjectName( QLatin1String( "page1" ) ); nameBox = new KComboBox(pages[0]); nameBox->setEditable( true ); nameBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); // allow smaller than widest entry QLabel * namedL = new QLabel(i18nc("this is the label for the name textfield","&Named:"), pages[0]); namedL->setBuddy( nameBox ); namedL->setObjectName( QLatin1String( "named" ) ); namedL->setToolTip( i18n("You can use wildcard matching and \";\" for separating multiple names") ); dirBox = new KUrlComboBox(KUrlComboBox::Directories, pages[0]); dirBox->setEditable( true ); dirBox->setCompletionObject(new KUrlCompletion(KUrlCompletion::DirCompletion)); dirBox->setAutoDeleteCompletionObject(true); dirBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); // allow smaller than widest entry QLabel * lookinL = new QLabel(i18n("Look &in:"), pages[0]); lookinL->setBuddy( dirBox ); lookinL->setObjectName( QLatin1String( "lookin" ) ); subdirsCb = new QCheckBox(i18n("Include &subfolders"), pages[0]); caseSensCb = new QCheckBox(i18n("Case s&ensitive search"), pages[0]); browseB = new QPushButton(i18n("&Browse..."), pages[0]); useLocateCb = new QCheckBox(i18n("&Use files index"), pages[0]); hiddenFilesCb = new QCheckBox(i18n("Show &hidden files"), pages[0]); // Setup subdirsCb->setChecked(true); caseSensCb->setChecked(false); useLocateCb->setChecked(false); hiddenFilesCb->setChecked(false); if(KStandardDirs::findExe(QLatin1String("locate")).isEmpty()) useLocateCb->setEnabled(false); nameBox->setDuplicatesEnabled(false); nameBox->setFocus(); dirBox->setDuplicatesEnabled(false); nameBox->setInsertPolicy(QComboBox::InsertAtTop); dirBox->setInsertPolicy(QComboBox::InsertAtTop); const QString nameWhatsThis = i18n("<qt>Enter the filename you are looking for. <br />" "Alternatives may be separated by a semicolon \";\".<br />" "<br />" "The filename may contain the following special characters:" "<ul>" "<li><b>?</b> matches any single character</li>" "<li><b>*</b> matches zero or more of any characters</li>" "<li><b>[...]</b> matches any of the characters between the braces</li>" "</ul>" "<br />" "Example searches:" "<ul>" "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>" "<li><b>go[dt]</b> finds god and got</li>" "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", " "having one character in between</li>" "<li><b>My Document.kwd</b> finds a file of exactly that name</li>" "</ul></qt>"); nameBox->setWhatsThis(nameWhatsThis); namedL->setWhatsThis(nameWhatsThis); const QString whatsfileindex = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> " "package to speed-up the search; remember to update the index from time to time " "(using <i>updatedb</i>)." "</qt>"); useLocateCb->setWhatsThis(whatsfileindex); // Layout QGridLayout *grid = new QGridLayout( pages[0] ); grid->setMargin( KDialog::marginHint() ); grid->setSpacing( KDialog::spacingHint() ); QVBoxLayout *subgrid = new QVBoxLayout(); grid->addWidget( namedL, 0, 0 ); grid->addWidget( nameBox, 0, 1, 1, 3 ); grid->addWidget( lookinL, 1, 0 ); grid->addWidget( dirBox, 1, 1 ); grid->addWidget( browseB, 1, 2); grid->setColumnStretch(1,1); grid->addLayout( subgrid, 2, 1, 1, 2 ); QHBoxLayout * layoutOne = new QHBoxLayout(); layoutOne->addWidget( subdirsCb ); layoutOne->addWidget( hiddenFilesCb ); QHBoxLayout * layoutTwo = new QHBoxLayout(); layoutTwo->addWidget( caseSensCb); layoutTwo->addWidget( useLocateCb ); subgrid->addLayout( layoutOne ); subgrid->addLayout( layoutTwo ); subgrid->addStretch(1); // Signals connect(browseB, &QPushButton::clicked, this, &KfindTabWidget::getDirectory); connect(nameBox, static_cast<void (KComboBox::*)()>(&KComboBox::returnPressed), this, &KfindTabWidget::startSearch); connect(dirBox, static_cast<void (KUrlComboBox::*)()>(&KUrlComboBox::returnPressed), this, &KfindTabWidget::startSearch); // ************ Page Two pages[1] = new QWidget; pages[1]->setObjectName( QLatin1String( "page2" ) ); findCreated = new QCheckBox(i18n("Find all files created or &modified:"), pages[1]); bg = new QButtonGroup(); rb[0] = new QRadioButton(i18n("&between"), pages[1] ); rb[1] = new QRadioButton(pages[1]); // text set in updateDateLabels andL = new QLabel(i18n("and"), pages[1]); andL->setObjectName( QLatin1String( "and" ) ); betweenType = new KComboBox( pages[1] ); betweenType->setObjectName( QLatin1String( "comboBetweenType" ) ); betweenType->addItems(QVector<QString>(5).toList()); // texts set in updateDateLabels betweenType->setCurrentIndex(1); updateDateLabels(1, 1); QDate dt = KLocale::global()->calendar()->addYears(QDate::currentDate(), -1); fromDate = new KDateCombo(dt, pages[1] ); fromDate->setObjectName( QLatin1String( "fromDate" ) ); toDate = new KDateCombo(pages[1] ); toDate->setObjectName( QLatin1String( "toDate" ) ); timeBox = new KIntSpinBox( pages[1] ); timeBox->setRange( 1, 60 ); timeBox->setSingleStep( 1 ); timeBox->setObjectName( QLatin1String( "timeBox" ) ); sizeBox =new KComboBox( pages[1] ); sizeBox->setObjectName( QLatin1String( "sizeBox" ) ); QLabel * sizeL =new QLabel(i18n("File &size is:"), pages[1]); sizeL->setBuddy( sizeBox ); sizeEdit=new KIntSpinBox(pages[1] ); sizeEdit->setRange( 0, INT_MAX ); sizeEdit->setSingleStep( 1 ); sizeEdit->setObjectName( QLatin1String( "sizeEdit" ) ); sizeEdit->setValue(1); sizeUnitBox =new KComboBox( pages[1] ); sizeUnitBox->setObjectName( QLatin1String( "sizeUnitBox" ) ); m_usernameBox = new KComboBox( pages[1] ); m_usernameBox->setEditable( true ); m_usernameBox->setObjectName( QLatin1String( "m_combo1" )); QLabel *usernameLabel= new QLabel(i18n("Files owned by &user:"******"m_combo2" ) ); QLabel *groupLabel= new QLabel(i18n("Owned by &group:"),pages[1]); groupLabel->setBuddy( m_groupBox ); sizeBox ->addItem( i18nc("file size isn't considered in the search","(none)") ); sizeBox ->addItem( i18n("At Least") ); sizeBox ->addItem( i18n("At Most") ); sizeBox ->addItem( i18n("Equal To") ); sizeUnitBox ->addItem( i18np("Byte", "Bytes", 1) ); sizeUnitBox ->addItem( i18n("KiB") ); sizeUnitBox ->addItem( i18n("MiB") ); sizeUnitBox ->addItem( i18n("GiB") ); sizeUnitBox ->setCurrentIndex(1); int tmp = sizeEdit->fontMetrics().width(QLatin1String(" 000000000 ")); sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height()); m_usernameBox->setDuplicatesEnabled(false); m_groupBox->setDuplicatesEnabled(false); m_usernameBox->setInsertPolicy(QComboBox::InsertAtTop); m_groupBox->setInsertPolicy(QComboBox::InsertAtTop); // Setup rb[0]->setChecked(true); bg->addButton( rb[0] ); bg->addButton( rb[1] ); // Layout QGridLayout *grid1 = new QGridLayout( pages[1] ); grid1->setMargin( KDialog::marginHint() ); grid1->setSpacing( KDialog::spacingHint() ); grid1->addWidget(findCreated, 0, 0, 1, 3 ); grid1->addItem( new QSpacerItem(KDialog::spacingHint(), 0), 0, 0 ); grid1->addWidget(rb[0], 1, 1 ); grid1->addWidget(fromDate, 1, 2 ); grid1->addWidget(andL, 1, 3, Qt::AlignHCenter ); grid1->addWidget(toDate, 1, 4 ); grid1->addWidget(rb[1], 2, 1 ); grid1->addWidget(timeBox, 2, 2, 1, 2); grid1->addWidget(betweenType, 2, 4 ); grid1->addWidget(sizeL,3,0,1,2); grid1->addWidget(sizeBox,3,2); grid1->addWidget(sizeEdit,3,3); grid1->addWidget(sizeUnitBox,3,4); grid1->addWidget(usernameLabel,4,0,1,2); grid1->addWidget(m_usernameBox,4,2); grid1->addWidget(groupLabel,4,3); grid1->addWidget(m_groupBox,4,4); for (int c=1; c<=4; c++) grid1->setColumnStretch(c,1); grid1->setRowStretch(6,1); // Connect connect(findCreated, &QCheckBox::toggled, this, &KfindTabWidget::fixLayout); connect(bg, static_cast<void (QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), this, &KfindTabWidget::fixLayout); connect(sizeBox, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &KfindTabWidget::slotSizeBoxChanged); connect(timeBox, static_cast<void (KIntSpinBox::*)(int)>(&KIntSpinBox::valueChanged), this, &KfindTabWidget::slotUpdateDateLabelsForNumber); connect(betweenType, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &KfindTabWidget::slotUpdateDateLabelsForType); connect(sizeEdit, static_cast<void (KIntSpinBox::*)(int)>(&KIntSpinBox::valueChanged), this, &KfindTabWidget::slotUpdateByteComboBox); // ************ Page Three pages[2] = new QWidget; pages[2]->setObjectName( QLatin1String( "page3" ) ); typeBox =new KComboBox( pages[2] ); typeBox->setObjectName( QLatin1String( "typeBox" ) ); typeBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); // allow smaller than widest entry QLabel * typeL =new QLabel( i18nc("label for the file type combobox","File &type:"), pages[2] ); typeL->setBuddy( typeBox ); textEdit=new KLineEdit(pages[2]); textEdit->setClearButtonShown(true); textEdit->setObjectName( QLatin1String( "textEdit" ) ); QLabel * textL =new QLabel(i18n("C&ontaining text:"), pages[2]); textL->setBuddy( textEdit ); connect(textEdit, &KLineEdit::returnPressed, this, &KfindTabWidget::startSearch); const QString containingtext = i18n("<qt>If specified, only files that contain this text" " are found. Note that not all file types from the list" " above are supported. Please refer to the documentation" " for a list of supported file types." "</qt>"); textEdit->setToolTip(containingtext); textL->setWhatsThis(containingtext); caseContextCb =new QCheckBox(i18n("Case s&ensitive"), pages[2]); binaryContextCb =new QCheckBox(i18n("Include &binary files"), pages[2]); regexpContentCb =new QCheckBox(i18n("Regular e&xpression"), pages[2]); const QString binaryTooltip = i18n("<qt>This lets you search in any type of file, " "even those that usually do not contain text (for example " "program files and images).</qt>"); binaryContextCb->setToolTip(binaryTooltip); QPushButton* editRegExp = 0; if ( !KServiceTypeTrader::self()->query(QStringLiteral("KRegExpEditor/KRegExpEditor")).isEmpty() ) { // The editor is available, so lets use it. editRegExp = new QPushButton(i18n("&Edit..."), pages[2]); editRegExp->setObjectName( QLatin1String( "editRegExp" ) ); } metainfokeyEdit=new KLineEdit(pages[2]); metainfoEdit=new KLineEdit(pages[2]); QLabel * textMetaInfo = new QLabel(i18nc("as in search for", "fo&r:"), pages[2]); textMetaInfo->setBuddy( metainfoEdit ); QLabel * textMetaKey = new QLabel(i18n("Search &metainfo sections:"), pages[2]); textMetaKey->setBuddy( metainfokeyEdit ); // Setup typeBox->addItem(i18n("All Files & Folders")); typeBox->addItem(i18n("Files")); typeBox->addItem(i18n("Folders")); typeBox->addItem(i18n("Symbolic Links")); typeBox->addItem(i18n("Special Files (Sockets, Device Files, ...)")); typeBox->addItem(i18n("Executable Files")); typeBox->addItem(i18n("SUID Executable Files")); typeBox->addItem(i18n("All Images")); typeBox->addItem(i18n("All Video")); typeBox->addItem(i18n("All Sounds")); initMimeTypes(); initSpecialMimeTypes(); for ( KMimeType::List::ConstIterator it = m_types.constBegin(); it != m_types.constEnd(); ++it ) { KMimeType::Ptr typ = *it; // TODO: needs to move to thread (increases startup time to bizzare amount) // and replaced with a better concept 16x16 icons don't cut the cheese // typeBox->addItem(KIconLoader::global()->loadMimeTypeIcon( typ->iconName(), KIconLoader::Small ), typ->comment()); typeBox->addItem(typ->comment()); } if ( editRegExp ) { // The editor was available, so lets use it. connect(regexpContentCb, &QCheckBox::toggled, editRegExp, &QPushButton::setEnabled); editRegExp->setEnabled(false); connect(editRegExp, &QPushButton::clicked, this, &KfindTabWidget::slotEditRegExp); } else regexpContentCb->hide(); // Layout tmp = sizeEdit->fontMetrics().width(QLatin1String(" 00000 ")); sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height()); QGridLayout *grid2 = new QGridLayout( pages[2] ); grid2->setMargin( KDialog::marginHint() ); grid2->setSpacing( KDialog::spacingHint() ); grid2->addWidget( typeL, 0, 0 ); grid2->addWidget( textL, 1, 0 ); grid2->addWidget( typeBox, 0, 1, 1, 3 ); grid2->addWidget( textEdit, 1, 1, 1, 3 ); grid2->addWidget( regexpContentCb, 2, 2); grid2->addWidget( caseContextCb, 2, 1 ); grid2->addWidget( binaryContextCb, 3, 1); grid2->addWidget( textMetaKey, 4, 0 ); grid2->addWidget( metainfokeyEdit, 4, 1 ); grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter ); grid2->addWidget( metainfoEdit, 4, 3 ); metainfokeyEdit->setText(QLatin1String("*")); if ( editRegExp ) { // The editor was available, so lets use it. grid2->addWidget( editRegExp, 2, 3 ); } addTab( pages[0], i18n("Name/&Location") ); addTab( pages[2], i18nc("tab name: search by contents","C&ontents") ); addTab( pages[1], i18n("&Properties") ); // Setup const QString whatsmetainfo = i18n("<qt>Search within files' specific comments/metainfo<br />" "These are some examples:<br />" "<ul>" "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>" "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>" "</ul>" "</qt>"); const QString whatsmetainfokey = i18n("<qt>If specified, search only in this field<br />" "<ul>" "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>" "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>" "</ul>" "</qt>"); textMetaInfo->setWhatsThis(whatsmetainfo); metainfoEdit->setToolTip(whatsmetainfo); textMetaKey->setWhatsThis(whatsmetainfokey); metainfokeyEdit->setToolTip(whatsmetainfokey); fixLayout(); loadHistory(); }
void KoDocumentInfoDlg::initAboutTab() { KoDocument* doc = dynamic_cast< KoDocument* >(d->m_info->parent()); if (!doc) return; d->m_aboutUi->filePathLabel->setText(doc->localFilePath()); d->m_aboutUi->leTitle->setText(d->m_info->aboutInfo("title")); d->m_aboutUi->leSubject->setText(d->m_info->aboutInfo("subject")); d->m_aboutUi->leKeywords->setToolTip(i18n("Use ';' (Example: Office;KDE;KOffice)")); if (!d->m_info->aboutInfo("keyword").isEmpty()) d->m_aboutUi->leKeywords->setText(d->m_info->aboutInfo("keyword")); d->m_aboutUi->meComments->setPlainText(d->m_info->aboutInfo("comments")); if (!doc->mimeType().isEmpty()) { KMimeType::Ptr docmime = KMimeType::mimeType(doc->mimeType()); if (docmime) d->m_aboutUi->lblType->setText(docmime->comment()); } if (!d->m_info->aboutInfo("creation-date").isEmpty()) { QDateTime t = QDateTime::fromString(d->m_info->aboutInfo("creation-date"), Qt::ISODate); QString s = KGlobal::locale()->formatDateTime(t); d->m_aboutUi->lblCreated->setText(s + ", " + d->m_info->aboutInfo("initial-creator")); } if (!d->m_info->aboutInfo("date").isEmpty()) { QDateTime t = QDateTime::fromString(d->m_info->aboutInfo("date"), Qt::ISODate); QString s = KGlobal::locale()->formatDateTime(t); d->m_aboutUi->lblModified->setText(s + ", " + d->m_info->authorInfo("creator")); } d->m_aboutUi->lblRevision->setText(d->m_info->aboutInfo("editing-cycles")); if ( doc->supportedSpecialFormats() & KoDocument::SaveEncrypted ) { if (doc->specialOutputFlag() == KoDocument::SaveEncrypted) { if (d->m_toggleEncryption) { QPixmap p = KIconLoader::global()->loadIcon("object-unlocked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document will be decrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("Do not decrypt")); } else { QPixmap p = KIconLoader::global()->loadIcon("object-locked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document is encrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("D&ecrypt")); } } else { if (d->m_toggleEncryption) { QPixmap p = KIconLoader::global()->loadIcon("object-locked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document will be encrypted.")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("Do not encrypt")); } else { QPixmap p = KIconLoader::global()->loadIcon("object-unlocked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document is not encrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("&Encrypt")); } } } else { d->m_aboutUi->lblEncrypted->setText(i18n("This document does not support encryption")); d->m_aboutUi->pbEncrypt->setEnabled( false ); } connect(d->m_aboutUi->pbReset, SIGNAL(clicked()), this, SLOT(slotResetMetaData())); connect(d->m_aboutUi->pbEncrypt, SIGNAL(clicked()), this, SLOT(slotToggleEncryption())); }
KfindTabWidget::KfindTabWidget(TQWidget *parent, const char *name) : TQTabWidget( parent, name ), regExpDialog(0) { // This validator will be used for all numeric edit fields //KDigitValidator *digitV = new KDigitValidator(this); // ************ Page One ************ pages[0] = new TQWidget( this, "page1" ); nameBox = new KComboBox(TRUE, pages[0], "combo1"); nameBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // allow smaller than widest entry TQLabel * namedL = new TQLabel(nameBox, i18n("&Named:"), pages[0], "named"); TQToolTip::add( namedL, i18n("You can use wildcard matching and \";\" for separating multiple names") ); dirBox = new KComboBox(TRUE, pages[0], "combo2"); dirBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // allow smaller than widest entry TQLabel * lookinL = new TQLabel(dirBox, i18n("Look &in:"), pages[0], "named"); subdirsCb = new TQCheckBox(i18n("Include &subfolders"), pages[0]); caseSensCb = new TQCheckBox(i18n("Case s&ensitive search"), pages[0]); browseB = new TQPushButton(i18n("&Browse..."), pages[0]); useLocateCb = new TQCheckBox(i18n("&Use files index"), pages[0]); // Setup subdirsCb->setChecked(true); caseSensCb->setChecked(false); useLocateCb->setChecked(false); if(TDEStandardDirs::findExe("locate")==NULL) useLocateCb->setEnabled(false); nameBox->setDuplicatesEnabled(FALSE); nameBox->setFocus(); dirBox->setDuplicatesEnabled(FALSE); nameBox->setInsertionPolicy(TQComboBox::AtTop); dirBox->setInsertionPolicy(TQComboBox::AtTop); const TQString nameWhatsThis = i18n("<qt>Enter the filename you are looking for. <br>" "Alternatives may be separated by a semicolon \";\".<br>" "<br>" "The filename may contain the following special characters:" "<ul>" "<li><b>?</b> matches any single character</li>" "<li><b>*</b> matches zero or more of any characters</li>" "<li><b>[...]</b> matches any of the characters in braces</li>" "</ul>" "<br>" "Example searches:" "<ul>" "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>" "<li><b>go[dt]</b> finds god and got</li>" "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", " "having one character in between</li>" "<li><b>My Document.kwd</b> finds a file of exactly that name</li>" "</ul></qt>"); TQWhatsThis::add(nameBox,nameWhatsThis); TQWhatsThis::add(namedL,nameWhatsThis); const TQString whatsfileindex = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> " "package to speed-up the search; remember to update the index from time to time " "(using <i>updatedb</i>)." "</qt>"); TQWhatsThis::add(useLocateCb,whatsfileindex); // Layout TQGridLayout *grid = new TQGridLayout( pages[0], 3, 2, KDialog::marginHint(), KDialog::spacingHint() ); TQBoxLayout *subgrid = new TQVBoxLayout( -1 , "subgrid" ); grid->addWidget( namedL, 0, 0 ); grid->addMultiCellWidget( nameBox, 0, 0, 1, 2 ); grid->addWidget( lookinL, 1, 0 ); grid->addWidget( dirBox, 1, 1 ); grid->addWidget( browseB, 1, 2); grid->setColStretch(1,1); grid->addMultiCellLayout( subgrid, 2, 2, 1, 2 ); subgrid->addWidget( subdirsCb ); subgrid->addWidget( caseSensCb); subgrid->addWidget( useLocateCb ); subgrid->addStretch(1); // Signals connect( browseB, TQT_SIGNAL(clicked()), this, TQT_SLOT(getDirectory()) ); connect( nameBox, TQT_SIGNAL(activated(int)), this, TQT_SIGNAL(startSearch())); // ************ Page Two pages[1] = new TQWidget( this, "page2" ); findCreated = new TQCheckBox(i18n("Find all files created or &modified:"), pages[1]); bg = new TQButtonGroup(); rb[0] = new TQRadioButton(i18n("&between"), pages[1] ); rb[1] = new TQRadioButton(i18n("&during the previous"), pages[1] ); TQLabel * andL = new TQLabel(i18n("and"), pages[1], "and"); betweenType = new KComboBox(FALSE, pages[1], "comboBetweenType"); betweenType->insertItem(i18n("minute(s)")); betweenType->insertItem(i18n("hour(s)")); betweenType->insertItem(i18n("day(s)")); betweenType->insertItem(i18n("month(s)")); betweenType->insertItem(i18n("year(s)")); betweenType->setCurrentItem(1); TQDate dt = TDEGlobal::locale()->calendar()->addYears(TQDate::currentDate(), -1); fromDate = new KDateCombo(dt, pages[1], "fromDate"); toDate = new KDateCombo(pages[1], "toDate"); timeBox = new TQSpinBox(1, 60, 1, pages[1], "timeBox"); sizeBox =new KComboBox(FALSE, pages[1], "sizeBox"); TQLabel * sizeL =new TQLabel(sizeBox,i18n("File &size is:"), pages[1],"size"); sizeEdit=new TQSpinBox(0, INT_MAX, 1, pages[1], "sizeEdit" ); sizeEdit->setValue(1); sizeUnitBox =new KComboBox(FALSE, pages[1], "sizeUnitBox"); m_usernameBox = new KComboBox( true, pages[1], "m_combo1"); TQLabel *usernameLabel= new TQLabel(m_usernameBox,i18n("Files owned by &user:"******"m_combo2"); TQLabel *groupLabel= new TQLabel(m_groupBox,i18n("Owned by &group:"),pages[1]); sizeBox ->insertItem( i18n("(none)") ); sizeBox ->insertItem( i18n("At Least") ); sizeBox ->insertItem( i18n("At Most") ); sizeBox ->insertItem( i18n("Equal To") ); sizeUnitBox ->insertItem( i18n("Bytes") ); sizeUnitBox ->insertItem( i18n("KB") ); sizeUnitBox ->insertItem( i18n("MB") ); sizeUnitBox ->insertItem( i18n("GB") ); sizeUnitBox ->setCurrentItem(1); int tmp = sizeEdit->fontMetrics().width(" 000000000 "); sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height()); m_usernameBox->setDuplicatesEnabled(FALSE); m_groupBox->setDuplicatesEnabled(FALSE); m_usernameBox->setInsertionPolicy(TQComboBox::AtTop); m_groupBox->setInsertionPolicy(TQComboBox::AtTop); // Setup timeBox->setButtonSymbols(TQSpinBox::PlusMinus); rb[0]->setChecked(true); bg->insert( rb[0] ); bg->insert( rb[1] ); // Layout TQGridLayout *grid1 = new TQGridLayout( pages[1], 5, 6, KDialog::marginHint(), KDialog::spacingHint() ); grid1->addMultiCellWidget(findCreated, 0, 0, 0, 3 ); grid1->addColSpacing(0, KDialog::spacingHint()); grid1->addWidget(rb[0], 1, 1 ); grid1->addWidget(fromDate, 1, 2 ); grid1->addWidget(andL, 1, 3, Qt::AlignHCenter ); grid1->addWidget(toDate, 1, 4 ); grid1->addWidget(rb[1], 2, 1 ); grid1->addMultiCellWidget(timeBox, 2, 2, 2, 3); grid1->addWidget(betweenType, 2, 4 ); grid1->addMultiCellWidget(sizeL,3,3,0,1); grid1->addWidget(sizeBox,3,2); grid1->addWidget(sizeEdit,3,3); grid1->addWidget(sizeUnitBox,3,4); grid1->addMultiCellWidget(usernameLabel,4,4,0,1); grid1->addWidget(m_usernameBox,4,2); grid1->addWidget(groupLabel,4,3); grid1->addWidget(m_groupBox,4,4); for (int c=1; c<=4; c++) grid1->setColStretch(c,1); grid1->setRowStretch(6,1); // Connect connect( findCreated, TQT_SIGNAL(toggled(bool)), TQT_SLOT(fixLayout()) ); connect( bg, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(fixLayout()) ); connect( sizeBox, TQT_SIGNAL(highlighted(int)), this, TQT_SLOT(slotSizeBoxChanged(int))); // ************ Page Three pages[2] = new TQWidget( this, "page3" ); typeBox =new KComboBox(FALSE, pages[2], "typeBox"); typeBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // allow smaller than widest entry TQLabel * typeL =new TQLabel(typeBox, i18n("File &type:"), pages[2], "type"); textEdit=new KLineEdit(pages[2], "textEdit" ); TQLabel * textL =new TQLabel(textEdit, i18n("C&ontaining text:"), pages[2], "text"); connect( textEdit, TQT_SIGNAL(returnPressed(const TQString &)), TQT_SIGNAL( startSearch())); const TQString containingtext = i18n("<qt>If specified, only files that contain this text" " are found. Note that not all file types from the list" " above are supported. Please refer to the documentation" " for a list of supported file types." "</qt>"); TQToolTip::add(textEdit,containingtext); TQWhatsThis::add(textL,containingtext); caseContextCb =new TQCheckBox(i18n("Case s&ensitive"), pages[2]); binaryContextCb =new TQCheckBox(i18n("Include &binary files"), pages[2]); regexpContentCb =new TQCheckBox(i18n("Regular e&xpression"), pages[2]); const TQString binaryTooltip = i18n("<qt>This lets you search in any type of file, " "even those that usually do not contain text (for example " "program files and images).</qt>"); TQToolTip::add(binaryContextCb,binaryTooltip); TQPushButton* editRegExp = 0; if ( !TDETrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() ) { // The editor is available, so lets use it. editRegExp = new TQPushButton(i18n("&Edit..."), pages[2], "editRegExp"); } metainfokeyEdit=new KLineEdit(pages[2], "textEdit" ); metainfoEdit=new KLineEdit(pages[2], "textEdit" ); TQLabel * textMetaInfo = new TQLabel(metainfoEdit, i18n("fo&r:"), pages[2], "text"); TQLabel * textMetaKey = new TQLabel(metainfokeyEdit, i18n("Search &metainfo sections:"), pages[2], "text"); // Setup typeBox->insertItem(i18n("All Files & Folders")); typeBox->insertItem(i18n("Files")); typeBox->insertItem(i18n("Folders")); typeBox->insertItem(i18n("Symbolic Links")); typeBox->insertItem(i18n("Special Files (Sockets, Device Files, ...)")); typeBox->insertItem(i18n("Executable Files")); typeBox->insertItem(i18n("SUID Executable Files")); typeBox->insertItem(i18n("All Images")); typeBox->insertItem(i18n("All Video")); typeBox->insertItem(i18n("All Sounds")); initMimeTypes(); initSpecialMimeTypes(); for ( KMimeType::List::ConstIterator it = m_types.begin(); it != m_types.end(); ++it ) { KMimeType::Ptr typ = *it; typeBox->insertItem(typ->pixmap( TDEIcon::Small ), typ->comment()); } if ( editRegExp ) { // The editor was available, so lets use it. connect( regexpContentCb, TQT_SIGNAL(toggled(bool) ), editRegExp, TQT_SLOT(setEnabled(bool)) ); editRegExp->setEnabled(false); connect( editRegExp, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotEditRegExp() ) ); } else regexpContentCb->hide(); // Layout tmp = sizeEdit->fontMetrics().width(" 00000 "); sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height()); TQGridLayout *grid2 = new TQGridLayout( pages[2], 5, 4, KDialog::marginHint(), KDialog::spacingHint() ); grid2->addWidget( typeL, 0, 0 ); grid2->addWidget( textL, 1, 0 ); grid2->addMultiCellWidget( typeBox, 0, 0, 1, 3 ); grid2->addMultiCellWidget( textEdit, 1, 1, 1, 3 ); grid2->addWidget( regexpContentCb, 2, 2); grid2->addWidget( caseContextCb, 2, 1 ); grid2->addWidget( binaryContextCb, 3, 1); grid2->addWidget( textMetaKey, 4, 0 ); grid2->addWidget( metainfokeyEdit, 4, 1 ); grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter ); grid2->addWidget( metainfoEdit, 4, 3 ); metainfokeyEdit->setText("*"); if ( editRegExp ) { // The editor was available, so lets use it. grid2->addWidget( editRegExp, 2, 3 ); } addTab( pages[0], i18n("Name/&Location") ); addTab( pages[2], i18n("C&ontents") ); addTab( pages[1], i18n("&Properties") ); // Setup const TQString whatsmetainfo = i18n("<qt>Search within files' specific comments/metainfo<br>" "These are some examples:<br>" "<ul>" "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>" "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>" "</ul>" "</qt>"); const TQString whatsmetainfokey = i18n("<qt>If specified, search only in this field<br>" "<ul>" "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>" "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>" "</ul>" "</qt>"); TQWhatsThis::add(textMetaInfo,whatsmetainfo); TQToolTip::add(metainfoEdit,whatsmetainfo); TQWhatsThis::add(textMetaKey,whatsmetainfokey); TQToolTip::add(metainfokeyEdit,whatsmetainfokey); fixLayout(); loadHistory(); }
PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc) : KPageDialog( parent ), m_document( doc ), m_fontPage( 0 ), m_fontModel( 0 ), m_fontInfo( 0 ), m_fontProgressBar( 0 ), m_fontScanStarted( false ) { setFaceType( Tabbed ); setCaption( i18n( "Unknown File" ) ); setButtons( Ok ); // PROPERTIES QFrame *page = new QFrame(); KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) ); item->setIcon( KIcon( "document-properties" ) ); // get document info const Okular::DocumentInfo info = doc->documentInfo(); QFormLayout *layout = new QFormLayout( page ); // mime name based on mimetype id QString mimeName = info.get( Okular::DocumentInfo::MimeType ).section( '/', -1 ).toUpper(); setCaption( i18n( "%1 Properties", mimeName ) ); int valMaxWidth = 100; /* obtains the properties list, conveniently ordered */ QStringList orderedProperties; orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath ) << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize ) << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize ); for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title; ks <= Okular::DocumentInfo::Keywords; ks = Okular::DocumentInfo::Key( ks+1 ) ) { orderedProperties << Okular::DocumentInfo::getKeyString( ks ); } foreach( const QString &ks, info.keys()) { if ( !orderedProperties.contains( ks ) ) { orderedProperties << ks; } } for ( QStringList::Iterator it = orderedProperties.begin(); it != orderedProperties.end(); ++it ) { const QString key = *it; const QString titleString = info.getKeyTitle( key ); const QString valueString = info.get( key ); if ( titleString.isNull() || valueString.isNull() ) continue; // create labels and layout them QWidget *value = NULL; if ( key == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) { /// for mime type fields, show icon as well value = new QWidget( page ); /// place icon left of mime type's name QHBoxLayout *hboxLayout = new QHBoxLayout( value ); hboxLayout->setMargin( 0 ); /// retrieve icon and place it in a QLabel KMimeType::Ptr mimeType = KMimeType::mimeType( valueString ); KSqueezedTextLabel *squeezed; if (!mimeType.isNull()) { /// retrieve icon and place it in a QLabel QLabel *pixmapLabel = new QLabel( value ); hboxLayout->addWidget( pixmapLabel, 0 ); pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), KIconLoader::Small ) ); /// mime type's name and label squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType->comment(), valueString ), value ); } else { /// only mime type name squeezed = new KSqueezedTextLabel( valueString, value ); } squeezed->setTextInteractionFlags( Qt::TextSelectableByMouse ); hboxLayout->addWidget( squeezed, 1 ); } else { /// default for any other document information KSqueezedTextLabel *label = new KSqueezedTextLabel( valueString, page ); label->setTextInteractionFlags( Qt::TextSelectableByMouse ); value = label; } layout->addRow( new QLabel( i18n( "%1:", titleString ) ), value); // refine maximum width of 'value' labels valMaxWidth = qMax( valMaxWidth, fontMetrics().width( valueString ) ); } // FONTS QVBoxLayout *page2Layout = 0; if ( doc->canProvideFontInformation() ) { // create fonts tab and layout it QFrame *page2 = new QFrame(); m_fontPage = addPage(page2, i18n("&Fonts")); m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) ); page2Layout = new QVBoxLayout(page2); page2Layout->setMargin(marginHint()); page2Layout->setSpacing(spacingHint()); // add a tree view QTreeView *view = new QTreeView(page2); view->setContextMenuPolicy(Qt::CustomContextMenu); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showFontsMenu(QPoint))); page2Layout->addWidget(view); view->setRootIsDecorated(false); view->setAlternatingRowColors(true); view->setSortingEnabled( true ); // creating a proxy model so we can sort the data QSortFilterProxyModel *proxymodel = new QSortFilterProxyModel(view); proxymodel->setDynamicSortFilter( true ); proxymodel->setSortCaseSensitivity( Qt::CaseInsensitive ); m_fontModel = new FontsListModel(view); proxymodel->setSourceModel(m_fontModel); view->setModel(proxymodel); view->sortByColumn( 0, Qt::AscendingOrder ); m_fontInfo = new QLabel( this ); page2Layout->addWidget( m_fontInfo ); m_fontInfo->setText( i18n( "Reading font information..." ) ); m_fontInfo->hide(); m_fontProgressBar = new QProgressBar( this ); page2Layout->addWidget( m_fontProgressBar ); m_fontProgressBar->setRange( 0, 100 ); m_fontProgressBar->setValue( 0 ); m_fontProgressBar->hide(); } // current width: left columnt + right column + dialog borders int width = layout->minimumSize().width() + valMaxWidth + 2 * marginHint() + spacingHint() + 30; if ( page2Layout ) width = qMax( width, page2Layout->sizeHint().width() + marginHint() + spacingHint() + 31 ); // stay inside the 2/3 of the screen width QRect screenContainer = KGlobalSettings::desktopGeometry( this ); width = qMin( width, 2*screenContainer.width()/3 ); resize(width, 1); connect( pageWidget(), SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), this, SLOT(pageChanged(KPageWidgetItem*,KPageWidgetItem*)) ); }