本文整理汇总了C++中KFileItem::url方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileItem::url方法的具体用法?C++ KFileItem::url怎么用?C++ KFileItem::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileItem
的用法示例。
在下文中一共展示了KFileItem::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TQListViewItem
KfFileLVI::KfFileLVI(KfindWindow* lv, const KFileItem &item, const TQString& matchingLine)
: TQListViewItem(lv),
fileitem(item)
{
fileInfo = new TQFileInfo(item.url().path());
TQString size = TDEGlobal::locale()->formatNumber(item.size(), 0);
TQDateTime dt;
dt.setTime_t(item.time(TDEIO::UDS_MODIFICATION_TIME));
TQString date = TDEGlobal::locale()->formatDateTime(dt);
int perm_index;
if(fileInfo->isReadable())
perm_index = fileInfo->isWritable() ? RW : RO;
else
perm_index = fileInfo->isWritable() ? WO : NA;
// Fill the item with data
setText(0, item.url().fileName(false));
setText(1, lv->reducedDir(item.url().directory(false)));
setText(2, size);
setText(3, date);
setText(4, i18n(perm[perm_index]));
setText(5, matchingLine);
// put the icon into the leftmost column
setPixmap(0, item.pixmap(16));
}
示例2: requestDelayedItemInfo
void InformationPanel::requestDelayedItemInfo(const KFileItem& item)
{
if (!isVisible() || (item.isNull() && m_fileItem.isNull())) {
return;
}
if (QApplication::mouseButtons() & Qt::LeftButton) {
// Ignore the request of an item information when a rubberband
// selection is ongoing.
return;
}
cancelRequest();
if (item.isNull()) {
// The cursor is above the viewport. If files are selected,
// show information regarding the selection.
if (m_selection.size() > 0) {
m_fileItem = KFileItem();
m_infoTimer->start();
}
} else if (item.url().isValid() && !isEqualToShownUrl(item.url())) {
// The cursor is above an item that is not shown currently
m_urlCandidate = item.url();
m_fileItem = item;
m_infoTimer->start();
}
}
示例3: data
QVariant DirModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return QVariant();
}
switch (role) {
case UrlRole: {
KFileItem item = itemForIndex(index);
return item.url().toString();
}
case MimeTypeRole: {
KFileItem item = itemForIndex(index);
return item.mimetype();
}
case Thumbnail: {
KFileItem item = itemForIndex(index);
QImage preview = QImage(m_screenshotSize, QImage::Format_ARGB32_Premultiplied);
if (m_imageCache->findImage(item.url().toString(), &preview)) {
return preview;
}
m_previewTimer->start(100);
const_cast<DirModel *>(this)->m_filesToPreview[item.url()] = QPersistentModelIndex(index);
}
default:
return KDirModel::data(index, role);
}
}
示例4: saveResults
void KFindTreeView::saveResults()
{
KFileDialog *dlg = new KFileDialog(QUrl(), QString(), this);
dlg->setOperationMode (KFileDialog::Saving);
dlg->setWindowTitle( i18nc("@title:window", "Save Results As") );
dlg->setFilter( QString::fromLatin1("*.html|%1\n*.txt|%2").arg( i18n("HTML page"), i18n("Text file") ) );
dlg->setConfirmOverwrite(true);
dlg->exec();
QUrl u = dlg->selectedUrl();
QString filter = dlg->currentFilter();
delete dlg;
if (!u.isValid() || !u.isLocalFile())
return;
QString filename = u.toLocalFile();
QFile file(filename);
if ( !file.open(QIODevice::WriteOnly) )
{
KMessageBox::error(parentWidget(),
i18n("Unable to save results."));
}
else
{
QTextStream stream( &file );
stream.setCodec( QTextCodec::codecForLocale() );
QList<KFindItem> itemList = m_model->getItemList();
if ( filter == QLatin1String("*.html") )
{
stream << QString::fromLatin1("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
"<head>\n"
"<title>%2</title></head>\n"
"<meta charset=\"%1\">\n"
"<body>\n<h1>%2</h1>\n"
"<dl>\n")
.arg(QString::fromLatin1(QTextCodec::codecForLocale()->name()))
.arg(i18n("KFind Results File"));
Q_FOREACH( const KFindItem & item, itemList )
{
const KFileItem fileItem = item.getFileItem();
stream << QString::fromLatin1("<dt><a href=\"%1\">%2</a></dt>\n").arg(
fileItem.url().url(), fileItem.url().toDisplayString() );
}
stream << QString::fromLatin1("</dl>\n</body>\n</html>\n");
}
else
{
示例5: showPreview
void DirModel::showPreview(const KFileItem &item, const QPixmap &preview)
{
QPersistentModelIndex index = m_previewJobs.value(item.url());
m_previewJobs.remove(item.url());
if (!index.isValid()) {
return;
}
m_imageCache->insertImage(item.url().toString(), preview.toImage());
//qDebug() << "preview size:" << preview.size();
emit dataChanged(index, index);
}
示例6: verifyDirectory
void VersionControlObserver::verifyDirectory()
{
if (!m_model) {
return;
}
const KFileItem rootItem = m_model->rootItem();
if (rootItem.isNull() || !rootItem.url().isLocalFile()) {
return;
}
if (m_plugin) {
m_plugin->disconnect(this);
}
m_plugin = searchPlugin(rootItem.url());
if (m_plugin) {
KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
if (pluginV2) {
connect(pluginV2, SIGNAL(itemVersionsChanged()),
this, SLOT(silentDirectoryVerification()));
} else {
connect(m_plugin, SIGNAL(versionStatesChanged()),
this, SLOT(silentDirectoryVerification()));
}
connect(m_plugin, SIGNAL(infoMessage(QString)),
this, SIGNAL(infoMessage(QString)));
connect(m_plugin, SIGNAL(errorMessage(QString)),
this, SIGNAL(errorMessage(QString)));
connect(m_plugin, SIGNAL(operationCompletedMessage(QString)),
this, SIGNAL(operationCompletedMessage(QString)));
if (!m_versionedDirectory) {
m_versionedDirectory = true;
// The directory is versioned. Assume that the user will further browse through
// versioned directories and decrease the verification timer.
m_dirVerificationTimer->setInterval(100);
}
updateItemStates();
} else if (m_versionedDirectory) {
m_versionedDirectory = false;
// The directory is not versioned. Reset the verification timer to a higher
// value, so that browsing through non-versioned directories is not slown down
// by an immediate verification.
m_dirVerificationTimer->setInterval(500);
}
}
示例7: updateURL
void DolphinView::updateURL()
{
KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
static_cast<KFileView*>(m_detailsView);
KFileItem* fileItem = fileView->currentFileItem();
if (fileItem == 0) {
return;
}
if (fileItem->isDir()) {
// Prefer the local path over the URL. This assures that the
// volume space information is correct. Assuming that the URL is media:/sda1,
// and the local path is /windows/C: For the URL the space info is related
// to the root partition (and hence wrong) and for the local path the space
// info is related to the windows partition (-> correct).
const QString localPath(fileItem->localPath());
if (localPath.isEmpty()) {
setURL(fileItem->url());
}
else {
setURL(KURL(localPath));
}
}
else if (fileItem->isFile()) {
// allow to browse through ZIP and tar files
KMimeType::Ptr mime = fileItem->mimeTypePtr();
if (mime->is("application/x-zip")) {
KURL url = fileItem->url();
url.setProtocol("zip");
setURL(url);
}
else if (mime->is("application/x-tar") ||
mime->is("application/x-tarz") ||
mime->is("application/x-tbz") ||
mime->is("application/x-tgz") ||
mime->is("application/x-tzo")) {
KURL url = fileItem->url();
url.setProtocol("tar");
setURL(url);
}
else {
fileItem->run();
}
}
else {
fileItem->run();
}
}
示例8: cachedMetaInfo
static KFileMetaInfo cachedMetaInfo(const KFileItem& file)
{
QString dbName="metainfocache";
if (!QSqlDatabase::contains(dbName))
{
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE",dbName);
db.setDatabaseName(KStandardDirs::locateLocal("appdata", dbName+".sqlite"));
if (KDE_ISUNLIKELY( !db.open() ))
return KFileMetaInfo(file.url());
initDataBase(db);
}
QSqlDatabase db=QSqlDatabase::database(dbName);
if (!db.isOpen())
return KFileMetaInfo(file.url());
static const QString fields[]={
"translation.translated",
"translation.untranslated",
"translation.fuzzy",
"translation.last_translator",
"translation.source_date",
"translation.translation_date",
"translation.translated_reviewer",
"translation.translated_approver",
"translation.fuzzy_reviewer",
"translation.fuzzy_approver"
};
static const int nFields = sizeof(fields) / sizeof(fields[0]);
QByteArray result;
QSqlQuery queryCache(db);
queryCache.prepare("SELECT * from metainfo where filepath=?");
queryCache.bindValue(0, qHash(file.localPath()));
queryCache.exec();
if (queryCache.next() && file.time(KFileItem::ModificationTime).dateTime()==queryCache.value(2).toDateTime())
{
result=queryCache.value(1).toByteArray();
QDataStream stream(&result,QIODevice::ReadOnly);
//unfortunately direct KFileMetaInfo << operator doesn't work
KFileMetaInfo info;
QVector<QVariant> keys;
stream>>keys;
for(int i=0;i<keys.count();i++)
info.item(fields[i]).setValue(keys.at(i));
return info;
}
示例9: slotItemMiddleClicked
void FoldersPanel::slotItemMiddleClicked(int index)
{
const KFileItem item = m_model->fileItem(index);
if (!item.isNull()) {
emit folderMiddleClicked(item.url());
}
}
示例10: selectionChanged
void KoRecentDocumentsPane::selectionChanged(const QModelIndex& index)
{
if (index.isValid()) {
KoFileListItem* item = static_cast<KoFileListItem*>(model()->itemFromIndex(index));
m_openButton->setEnabled(true);
m_titleLabel->setText(item->data(Qt::DisplayRole).toString());
m_previewLabel->setPixmap(item->data(Qt::UserRole).value<QPixmap>());
KFileItem fileItem = item->fileItem();
if (!fileItem.isNull()) {
QString details = QString("<center>%1<br>").arg(fileItem.url().path());
details += "<table border=\"0\">";
details += i18nc("File modification date and time. %1 is date time",
"<tr><td><b>Modified:</b></td><td>%1</td></tr>",
QString(fileItem.timeString(KFileItem::ModificationTime)));
details += i18nc("File access date and time. %1 is date time",
"<tr><td><b>Accessed:</b></td><td>%1</td></tr>",
QString(fileItem.timeString(KFileItem::AccessTime)));
details += "</table></center>";
m_detailsLabel->setHtml(details);
} else {
m_detailsLabel->clear();
}
} else {
m_openButton->setEnabled(false);
m_titleLabel->clear();
m_previewLabel->setPixmap(QPixmap());
m_detailsLabel->clear();
}
}
示例11: updatePreview
void KoRecentDocumentsPane::updatePreview(const KFileItem& fileItem, const QPixmap& preview)
{
if (preview.isNull()) {
return;
}
QStandardItem* rootItem = model()->invisibleRootItem();
for (int i = 0; i < rootItem->rowCount(); ++i) {
KoFileListItem* item = static_cast<KoFileListItem*>(rootItem->child(i));
if (item->fileItem().url() == fileItem.url()) {
item->setData(preview, Qt::UserRole);
QImage icon = preview.toImage();
icon = icon.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
icon = icon.convertToFormat(QImage::Format_ARGB32);
icon = icon.copy((icon.width() - 64) / 2, (icon.height() - 64) / 2, 64, 64);
item->setData(QPixmap::fromImage(icon), Qt::DecorationRole);
if (m_documentList->selectionModel()->currentIndex() == item->index()) {
m_previewLabel->setPixmap(preview);
}
break;
}
}
}
示例12: contentsDropEvent
void KFileDetailView::contentsDropEvent( TQDropEvent *e )
{
d->dropItem = 0;
d->autoOpenTimer.stop();
if ( ! acceptDrag( e ) ) { // can we decode this ?
e->ignore(); // No
return;
}
e->acceptAction(); // Yes
KFileListViewItem *item = dynamic_cast<KFileListViewItem*>(itemAt( contentsToViewport( e->pos() ) ));
KFileItem * fileItem = 0;
if (item)
fileItem = item->fileInfo();
emit dropped(e, fileItem);
KURL::List urls;
if (KURLDrag::decode( e, urls ) && !urls.isEmpty())
{
emit dropped(e, urls, fileItem ? fileItem->url() : KURL());
sig->dropURLs(fileItem, e, urls);
}
}
示例13: beginEditing
KUrl ProjectModel::beginEditing(const QModelIndex& index)
{
Q_ASSERT(index.isValid());
QModelIndex poIndex = poIndexForOuter(index);
QModelIndex potIndex = potIndexForOuter(index);
if (poIndex.isValid())
{
KFileItem item = m_poModel.itemForIndex(poIndex);
return item.url();
}
else if (potIndex.isValid())
{
//copy over the file
KUrl potFile = m_potModel.itemForIndex(potIndex).url();
KUrl poFile = potToPo(potFile);
//EditorTab::fileOpen takes care of this
//be careful, copy only if file does not exist already.
// if (!KIO::NetAccess::exists(poFile, KIO::NetAccess::DestinationSide, NULL))
// KIO::NetAccess::file_copy(potFile, poFile);
return poFile;
}
else
{
Q_ASSERT(false);
return KUrl();
}
}
示例14: KPropertiesDialogPlugin
LicensePropsPlugin::LicensePropsPlugin(KPropertiesDialog *_props, const QStringList &) : KPropertiesDialogPlugin(_props)
{
m_vBox = new KVBox();
m_widget = new QWidget( m_vBox );
QVBoxLayout * vbox = new QVBoxLayout( m_widget );
QWidget *main = new QWidget(m_widget);
vbox->addWidget( main );
licenseChooser = new LicenseChooser(main);
connect( licenseChooser, SIGNAL(licenseChanged()), this, SLOT(setDirty()) );
m_widget->show(); // In case the dialog was shown already.
if ( properties->items().count() == 1 ) {
KFileItem *item = properties->item();
if (item->url().isLocalFile()) {
_props->addPage( m_vBox, i18n("&License") );
QByteArray ba = item->localPath().toUtf8();
char *license = ll_read(ba.data());
if (license) {
licenseChooser->setLicenseURI(QString::fromUtf8(license));
} else {
ll_uri_t uri = ll_get_default();
licenseChooser->setLicenseURI(QString::fromUtf8(uri),false);
free(uri);
}
}
}
}
示例15: KDialog
HgRenameDialog::HgRenameDialog(const KFileItem &source, QWidget *parent):
KDialog(parent, Qt::Dialog),
m_source(source.name()),
m_source_dir(source.url().directory())
{
this->setCaption(i18nc("@title:window",
"<application>Hg</application> Rename"));
this->setButtons(KDialog::Ok | KDialog::Cancel);
this->setDefaultButton(KDialog::Ok);
this->setButtonText(KDialog::Ok, i18nc("@action:button", "Rename"));
QFrame *frame = new QFrame(this);
QGridLayout *mainLayout = new QGridLayout(frame);
QLabel *sourceLabel = new QLabel(i18nc("@label:label to source file",
"Source "), frame);
QLabel *sourceFileLabel = new QLabel("<b>" + m_source + "</b>");
mainLayout->addWidget(sourceLabel, 0, 0);
mainLayout->addWidget(sourceFileLabel, 0, 1);
QLabel *destinationLabel
= new QLabel(i18nc("@label:rename", "Rename to "), frame);
m_destinationFile = new KLineEdit(m_source, frame);
mainLayout->addWidget(destinationLabel, 1, 0);
mainLayout->addWidget(m_destinationFile, 1, 1);
frame->setLayout(mainLayout);
setMainWidget(frame);
m_destinationFile->setFocus();
m_destinationFile->selectAll();
connect(m_destinationFile, SIGNAL(textChanged(const QString &)),
this, SLOT(slotTextChanged(const QString &)));
}