QVariant Browser::AbstractCategoryModel::data( const QModelIndex & index, int role) const
{
    if ( !index.isValid() )
        return QVariant();
    const QString name = indexToName( index );
    const int column = index.column();

    if ( role == Qt::DisplayRole ) {
        switch( column ) {
        case 0: return text(name);
        case 1: return i18ncp("@item:intable number of images with a specific tag.","1 image", "%1 images", m_images[name]);
        case 2: return i18ncp("@item:intable number of videos with a specific tag.","1 video", "%1 videos", m_videos[name]);
        }
    }

    else if ( role == Qt::DecorationRole && column == 0) {
        return icon( name );
    }

    else if ( role == Qt::ToolTipRole )
        return text(name);

    else if ( role == ItemNameRole )
        return name;

    else if ( role == ValueRole ) {
        switch ( column ) {
        case 0: return name; // Notice we sort by **None** rather than None, which makes it show up at the top for less than searches.
        case 1: return m_images[name];
        case 2: return m_videos[name];
        }
    }

    return QVariant();
}
void ImageCategoryDrawer::textForTAlbum(TAlbum* talbum, bool recursive, int count, QString* header,
                                        QString* subLine) const
{
    *header = talbum->title();

    if (recursive && talbum->firstChild())
    {
        int n=0;

        for (AlbumIterator it(talbum); it.current(); ++it)
        {
            n++;
        }

        QString firstPart = i18ncp("%2: a tag title; %3: number of subtags",
                                   "%2 including 1 subtag", "%2 including %1 subtags",
                                   n, talbum->tagPath(false));

        *subLine = i18ncp("%2: the previous string (e.g. 'Foo including 7 subtags'); %1: number of items in tag",
                          "%2 - 1 Item", "%2 - %1 Items",
                          count, firstPart);
    }
    else
    {
        *subLine = i18np("%2 - 1 Item", "%2 - %1 Items", count, talbum->tagPath(false));
    }
}
Exemple #3
0
void KfindTabWidget::updateDateLabels(int type, int value)
{
  QString typeKey(type == 0 ? QLatin1Char('i') : type == 1 ? QLatin1Char('h') : type == 2 ? QLatin1Char('d') : type == 3 ? QLatin1Char('m') : QLatin1Char('y'));
  rb[1]->setText(ki18ncp("during the previous minute(s)/hour(s)/...; "
                         "dynamic context 'type': 'i' minutes, 'h' hours, 'd' days, 'm' months, 'y' years",
                         "&during the previous", "&during the previous").subs(value).inContext(QLatin1String("type"), typeKey).toString());
  betweenType->setItemText(0, i18ncp("use date ranges to search files by modified time", "minute", "minutes", value));
  betweenType->setItemText(1, i18ncp("use date ranges to search files by modified time", "hour", "hours", value));
  betweenType->setItemText(2, i18ncp("use date ranges to search files by modified time", "day", "days", value));
  betweenType->setItemText(3, i18ncp("use date ranges to search files by modified time", "month", "months", value));
  betweenType->setItemText(4, i18ncp("use date ranges to search files by modified time", "year", "years", value));
}
Exemple #4
0
QString KSaneOptCombo::getSaneComboString(float fval)
{
    switch (m_optDesc->unit) {
    case SANE_UNIT_NONE:        break;
    case SANE_UNIT_PIXEL:       return i18ncp("Parameter and Unit", "%1 Pixel", "%1 Pixels", fval);
    case SANE_UNIT_BIT:         return i18ncp("Parameter and Unit", "%1 Bit", "%1 Bits", fval);
    case SANE_UNIT_MM:          return i18nc("Parameter and Unit (Millimeter)", "%1 mm", fval);
    case SANE_UNIT_DPI:         return i18nc("Parameter and Unit (Dots Per Inch)", "%1 DPI", fval);
    case SANE_UNIT_PERCENT:     return i18nc("Parameter and Unit (Percentage)", "%1 %", fval);
    case SANE_UNIT_MICROSECOND: return i18nc("Parameter and Unit (Microseconds)", "%1 µs", fval);
    }
    return QString::number(fval, 'F', 4);
}
Exemple #5
0
QString
ConstraintTypes::TagMatch::getName() const
{
    QString v( i18nc( "%1 = empty string or \"not\"; "
                      "%2 = a metadata field, like \"title\" or \"artist name\"; "
                      "%3 = a predicate, can be equals, starts with, ends with or contains; "
                      "%4 = a string to match; "
                      "Example: Match tag: not title contains \"foo\"", "Match tag:%1 %2 %3 %4") );
    v = v.arg( ( m_invert ? i18n(" not") : "" ), m_fieldsModel->pretty_name_of( m_field ), comparisonToString() );
    if ( m_field == "rating" ) {
        double r = m_value.toDouble() / 2.0;
        return v.arg( i18ncp("number of stars in the rating of a track", "%1 star", "%1 stars", r) );
    } else if ( m_field == "length" ) {
        return v.arg( QTime().addMSecs( m_value.toInt() ).toString( "H:mm:ss" ) );
    } else {
        if ( m_fieldsModel->type_of( m_field ) == FieldTypeString ) {
            // put quotes around any strings (eg, track title or artist name) ...
            QString s = QString( i18nc("an arbitrary string surrounded by quotes", "\"%1\"") ).arg( valueToString() );
            return v.arg( s );
        } else {
            // ... but don't quote put quotes around anything else
            return v.arg( valueToString() );
        }
    }
}
void ImageCategoryDrawer::textForPAlbum(PAlbum* album, bool recursive, int count, QString* header, QString* subLine) const
{
    Q_UNUSED(recursive);

    if (!album)
    {
        return;
    }

    QDate date    = album->date();

    KLocale tmpLocale(*KGlobal::locale());

    tmpLocale.setDateFormat("%d"); // day of month with two digits
    QString day   = tmpLocale.formatDate(date);

    tmpLocale.setDateFormat("%b"); // short form of the month
    QString month = tmpLocale.formatDate(date);

    tmpLocale.setDateFormat("%Y"); // long form of the year
    QString year  = tmpLocale.formatDate(date);

    *subLine      = i18ncp("%1: day of month with two digits, %2: short month name, %3: year",
                           "Album Date: %2 %3 %4 - 1 Item", "Album Date: %2 %3 %4 - %1 Items",
                           count, day, month, year);

    if (!album->caption().isEmpty())
    {
        QString caption = album->caption();
        *subLine        += " - " + caption.replace('\n', ' ');
    }

    *header = album->prettyUrl().left(-1);
}
Exemple #7
0
void HistoryPanel::openAll()
{
    QModelIndex index = panelTreeView()->currentIndex();
    if (!index.isValid())
        return;

    QList<KUrl> allChild;

    for (int i = 0; i < index.model()->rowCount(index); i++)
        allChild << qVariantValue<KUrl>(index.child(i, 0).data(Qt::UserRole));

    if (allChild.length() > 8)
    {
        if (!(KMessageBox::warningContinueCancel(this,
                i18ncp("%1=Number of tabs. Value is always >=8",
                       "You are about to open %1 tabs.\nAre you sure?",
                       "You are about to open %1 tabs.\nAre you sure?",
                       allChild.length())) == KMessageBox::Continue)
           )
            return;
    }

    for (int i = 0; i < allChild.length(); i++)
        emit openUrl(allChild.at(i).url(), Rekonq::NewTab);
}
Exemple #8
0
void SelectAuthorsDialog::addAuthor( void )
{
	//check bounds first
	if ( authorsCombo->currentText().length() > int(database->maxAuthorNameLength()) ) {
		KMessageBox::error( this, i18ncp( "@info", "Author name cannot be longer than 1 character.", "Author name cannot be longer than %1 characters." , database->maxAuthorNameLength() ) );
		authorsCombo->lineEdit() ->selectAll();
		return ;
	}

	if ( authorsCombo->lineEdit()->text().isEmpty() )
		return;

	if ( authorsCombo->contains( authorsCombo->currentText() ) )
		authorsCombo->setCurrentItem( authorsCombo->currentText() );

	createNewAuthorIfNecessary();

	int currentItem = authorsCombo->currentIndex();
	Element currentElement = authorList.getElement( currentItem );

	QStandardItem *itemId = new QStandardItem;
	itemId->setData( QVariant(currentElement.id), Qt::EditRole );
	itemId->setEditable( false ); 
	QStandardItem *itemAuthor = new QStandardItem( currentElement.name );
	itemAuthor->setEditable( false );
	QList<QStandardItem*> items;
	items << itemId << itemAuthor;
	authorListModel->appendRow( items );

	authorsCombo->lineEdit()->clear();
}
/** Shows information about a Device in the InfoPane
	@param area the current area the widget's dock is in
	@param d the Device to show information about
*/
void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d)
{
	clear();
	parentWidget()->parentWidget()->setWindowTitle(i18nc("@title:window", "Device Information"));

	int x = 0;
	int y = createHeader(d.name(), cols(area));
	createLabels(i18nc("@label device", "Path:"), d.deviceNode(), cols(area), x, y);

	QString type = QStringLiteral("---");
	QString maxPrimaries = QStringLiteral("---");

	if (d.partitionTable() != NULL)
	{
		type = (d.partitionTable()->isReadOnly())
			? i18nc("@label device", "%1 (read only)", d.partitionTable()->typeName())
			: d.partitionTable()->typeName();
		maxPrimaries = QStringLiteral("%1/%2").arg(d.partitionTable()->numPrimaries()).arg(d.partitionTable()->maxPrimaries());
	}

	createLabels(i18nc("@label device", "Type:"), type, cols(area), x, y);
	createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(d.capacity()), cols(area), x, y);
	createLabels(i18nc("@label device", "Total sectors:"), QLocale().toString(d.totalSectors()), cols(area), x, y);
	createLabels(i18nc("@label device", "Heads:"), QString::number(d.heads()), cols(area), x, y);
	createLabels(i18nc("@label device", "Cylinders:"), QLocale().toString(d.cylinders()), cols(area), x, y);
	createLabels(i18nc("@label device", "Sectors:"), QLocale().toString(d.sectorsPerTrack()), cols(area), x, y);
	createLabels(i18nc("@label device", "Logical sector size:"), Capacity::formatByteSize(d.logicalSectorSize()), cols(area), x, y);
	createLabels(i18nc("@label device", "Physical sector size:"), Capacity::formatByteSize(d.physicalSectorSize()), cols(area), x, y);
	createLabels(i18nc("@label device", "Cylinder size:"), i18ncp("@label", "1 Sector", "%1 Sectors", d.cylinderSize()), cols(area), x, y);
	createLabels(i18nc("@label device", "Primaries/Max:"), maxPrimaries, cols(area), x, y);
}
QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
                                               const QHash<QByteArray, QVariant>& values) const
{
    QString text;
    const QVariant roleValue = values.value(role);

    // Implementation note: In case if more roles require a custom handling
    // use a hash + switch for a linear runtime.

    if (role == "size") {
        if (values.value("isDir").toBool()) {
            // The item represents a directory. Show the number of sub directories
            // instead of the file size of the directory.
            if (!roleValue.isNull()) {
                const int count = roleValue.toInt();
                if (count < 0) {
                    text = i18nc("@item:intable", "Unknown");
                } else {
                    text = i18ncp("@item:intable", "%1 item", "%1 items", count);
                }
            }
        } else {
            const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
            text = KGlobal::locale()->formatByteSize(size);
        }
    } else if (role == "date") {
        const QDateTime dateTime = roleValue.toDateTime();
        text = KGlobal::locale()->formatDateTime(dateTime);
    } else {
        text = KStandardItemListWidgetInformant::roleText(role, values);
    }

    return text;
}
Exemple #11
0
void
decodeSession(const DpySpec &sess, QString &user, QString &loc)
{
    if (sess.flags & isTTY) {
        user =
            i18ncp("user: ...", "%2: TTY login", "%2: %1 TTY logins",
                   sess.count, sess.user);
        loc =
#ifdef HAVE_VTS
            sess.vt ?
                QString("vt%1").arg(sess.vt) :
#endif
                !sess.from.isEmpty() ?
                    sess.from : sess.display;
    } else {
        user =
            sess.session.isEmpty() ?
                i18nc("... session", "Unused") :
                !sess.user.isEmpty() ?
                    i18nc("user: session type", "%1: %2",
                          sess.user, sess.session) :
                    i18nc("... host", "X login on %1", sess.session);
        loc =
#ifdef HAVE_VTS
            sess.vt ?
                QString("%1, vt%2").arg(sess.display).arg(sess.vt) :
#endif
                sess.display;
    }
}
bool GroupIndicatorOverlay::checkIndex(const QModelIndex& index) const
{
    ImageInfo info = ImageModel::retrieveImageInfo(index);
    QRect rect     = static_cast<ImageDelegate*>(delegate())->groupIndicatorRect();

    if (!rect.isNull() && info.hasGroupedImages())
    {
        QString tip = i18ncp("@info:tooltip",
                             "1 grouped item.\n",
                             "%1 grouped items.\n",
                             info.numberOfGroupedImages());

        if (index.data(ImageFilterModel::GroupIsOpenRole).toBool())
        {
            tip += i18n("Group is open.");
        }
        else
        {
            tip += i18n("Group is closed.");
        }

        m_widget->setToolTip(tip);
        
        return true;
    }

    return false;
}
Exemple #13
0
void PresentationAudioPage::updateTracksNumber()
{
    QTime displayTime(0, 0, 0);
    int number = m_SoundFilesListBox->count();

    if ( number > 0 )
    {
        displayTime.addMSecs(1000 * (number - 1));

        for (QMap<QUrl, QTime>::iterator it = d->tracksTime->begin(); it != d->tracksTime->end(); ++it)
        {
            int hours = it.value().hour()   + displayTime.hour();
            int mins  = it.value().minute() + displayTime.minute();
            int secs  = it.value().second() + displayTime.second();

            /* QTime doesn't get a overflow value in input. They need
             * to be cut down to size.
             */

            mins        = mins + (int)(secs / 60);
            secs        = secs % 60;
            hours       = hours + (int)(mins / 60);
            displayTime = QTime(hours, mins, secs);
        }
    }

    m_timeLabel->setText(i18ncp("number of tracks and running time", "1 track [%2]", "%1 tracks [%2]", number, displayTime.toString()));

    m_soundtrackTimeLabel->setText(displayTime.toString());

    d->totalTime = displayTime;

    compareTimes();
}
Exemple #14
0
void TitleWidget::updateFilterWidget()
{
    FilterSettingsList filters = m_settings->currentFilters();
    ColorGroupSettingsList colorGroups = m_settings->currentColorGroups();
    ColorGroupSettingsList disabledColorGroups;
    foreach ( const ColorGroupSettings &colorGroup, colorGroups ) {
        if ( colorGroup.filterOut ) {
            disabledColorGroups << colorGroup;
        }
    }
    if ( filters.isEmpty() && disabledColorGroups.isEmpty() ) {
        m_filterWidget->setOpacity( 0.6 );
        m_filterWidget->setText( i18nc("@info/plain Shown in the applet to indicate that no "
                "filters are currently active", "(No active filter)") );
        // Do not show any text, if no filter is active
        m_filterWidget->nativeWidget()->setToolButtonStyle( Qt::ToolButtonIconOnly );
        m_filterWidget->setIcon( KIcon("view-filter") );
    } else {
        QFontMetrics fm( m_filterWidget->font() );
        QString text;
        m_filterWidget->nativeWidget()->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
        if ( filters.count() == 1 && disabledColorGroups.isEmpty() ) {
            text = fm.elidedText( filters.first().name,
                                  Qt::ElideRight, boundingRect().width() * 0.45 );
            m_filterWidget->setIcon( KIcon("view-filter") );
        } else if ( filters.count() > 1 && disabledColorGroups.isEmpty() ) {
            text = fm.elidedText( i18ncp("@info/plain", "%1 active filter", "%1 active filters",
                                         filters.count()),
                                  Qt::ElideRight, boundingRect().width() * 0.45 );
            m_filterWidget->setIcon( KIcon("object-group") );
        } else if ( filters.isEmpty() && disabledColorGroups.count() >= 1 ) {
            text = fm.elidedText( i18ncp("@info/plain", "%1 disabled color group",
                                         "%1 disabled color groups", disabledColorGroups.count()),
                                  Qt::ElideRight, boundingRect().width() * 0.45 );
            m_filterWidget->setIcon( KIcon("object-group") );
        } else {
            text = fm.elidedText( i18ncp("@info/plain", "%1 active (color) filter",
                                         "%1 active (color) filters",
                                         filters.count() + disabledColorGroups.count()),
                                  Qt::ElideRight, boundingRect().width() * 0.45 );
            m_filterWidget->setIcon( KIcon("view-filter") );
        }

        m_filterWidget->setOpacity( 1 );
        m_filterWidget->setText( text );
    }
}
Exemple #15
0
void Executer::executeFunctionCall(TreeNode* node) {
//	//qDebug() << "called";
	if (node->parent()->token()->type() == Token::Learn) {  // in case we're defining a function
		currentNode = node->parent();
		executeCurrent = true;
		return;
	}

	if (returning) {  // if the function is already executed and returns now
		returnValue = 0;
		returning = false;
		// //qDebug() << "==> functionReturned!";
		return;
	}

	if (!functionTable.contains(node->token()->look())) {
		addError(i18n("An unknown function named '%1' was called", node->token()->look()), *node->token(), 0);
		return;
	}
	
	CalledFunction c;
	c.function      = node;
	c.variableTable = new VariableTable();
	functionStack.push(c);
	// //qDebug() << "==> functionCalled!";
	
	TreeNode* learnNode = functionTable[node->token()->look()];

	// if the parameter numbers are not equal...
	if (node->childCount() != learnNode->child(1)->childCount()) {
		addError(
			i18n("The function '%1' was called with %2, while it should be called with %3",
				node->token()->look(),
				i18ncp("The function '%1' was called with %2, while it should be called with %3", "1 parameter", "%1 parameters", node->childCount()),
				i18ncp("The function '%1' was called with %2, while it should be called with %3", "1 parameter", "%1 parameters", learnNode->child(1)->childCount())
			),
			*node->token(), 0);
		return;
	}
		
	for (uint i = 0; i < node->childCount(); i++) {
		functionStack.top().variableTable->insert(learnNode->child(1)->child(i)->token()->look(), node->child(i)->value());
		// //qDebug() << "inserted variable " << learnNode->child(1)->child(i)->token()->look() << " on function stack";
	}
	newScope = learnNode->child(2);
}
Exemple #16
0
void StatusWidget::updateStatus()
{
    if (m_backend->xapianIndexNeedsUpdate())
        m_backend->updateXapianIndex();

    int upgradeable = m_backend->packageCount(QApt::Package::Upgradeable);
    bool showChanges = m_backend->areChangesMarked();

    QString availableText = i18ncp("@info:status", "1 package available, ", "%1 packages available, ", m_backend->packageCount());
    QString installText = i18nc("@info:status", "%1 installed, ", m_backend->installedCount());
    QString upgradeableText;

    if (upgradeable > 0 && showChanges) {
        upgradeableText = i18nc("@info:status", "%1 upgradeable,", upgradeable);
    } else {
        upgradeableText = i18nc("@info:status", "%1 upgradeable", upgradeable);
        m_countsLabel->setText(availableText % installText % upgradeableText);
    }

    if (showChanges) {
        int toInstallOrUpgrade = m_backend->toInstallCount();
        int toRemove = m_backend->toRemoveCount();

        QString toInstallOrUpgradeText;
        QString toRemoveText;

        if (toInstallOrUpgrade > 0) {
            toInstallOrUpgradeText = i18nc("@info:status Part of the status label", " %1 to install/upgrade", toInstallOrUpgrade);
        }

        if (toRemove > 0 && toInstallOrUpgrade > 0) {
            toRemoveText = i18nc("@info:status Label for the number of packages pending removal when packages are also pending upgrade",
                                 ", %1 to remove", toRemove);
        } else if (toRemove > 0) {
            toRemoveText = i18nc("@info:status Label for the number of packages pending removal when there are only removals",
                                 " %1 to remove", toRemove);
        }

        m_countsLabel->setText(availableText % installText % upgradeableText %
                               toInstallOrUpgradeText % toRemoveText);

        qint64 installSize = m_backend->installSize();
        if (installSize < 0) {
            installSize = -installSize;
            m_downloadLabel->setText(i18nc("@label showing download and install size", "%1 to download, %2 of space to be freed",
                                           KFormat().formatByteSize(m_backend->downloadSize()),
                                           KFormat().formatByteSize(installSize)));
        } else {
            m_downloadLabel->setText(i18nc("@label showing download and install size", "%1 to download, %2 of space to be used",
                                           KFormat().formatByteSize(m_backend->downloadSize()),
                                           KFormat().formatByteSize(installSize)));
        }

        m_downloadLabel->show();
    } else {
        m_downloadLabel->hide();
    }
}
bool ResizeFileSystemJob::run(Report& parent)
{
	Q_ASSERT(partition().fileSystem().firstSector() != -1);
	Q_ASSERT(partition().fileSystem().lastSector() != -1);
	Q_ASSERT(newLength() <= partition().length());

	if (partition().fileSystem().firstSector() == -1 || partition().fileSystem().lastSector() == -1 || newLength() > partition().length())
	{
		kWarning() << "file system first sector: " << partition().fileSystem().firstSector() << ", last sector: " << partition().fileSystem().lastSector() << ", new length: " << newLength() << ", partition length: " << partition().length();
		return false;
	}

	bool rval = false;

	Report* report = jobStarted(parent);

	if (partition().fileSystem().length() == newLength())
	{
		report->line() << i18ncp("@info/plain", "The file system on partition <filename>%2</filename> already has the requested length of 1 sector.", "The file system on partition <filename>%2</filename> already has the requested length of %1 sectors.", newLength(), partition().deviceNode());
		rval = true;
	}
	else
	{
		report->line() << i18nc("@info/plain", "Resizing file system from %1 to %2 sectors.", partition().fileSystem().length(), newLength());

		FileSystem::CommandSupportType support = (newLength() < partition().fileSystem().length()) ? partition().fileSystem().supportShrink() : partition().fileSystem().supportGrow();

		switch(support)
		{
			case FileSystem::cmdSupportBackend:
			{
				Report* childReport = report->newChild();
				childReport->line() << i18nc("@info/plain", "Resizing a %1 file system using internal backend functions.", partition().fileSystem().name());
				rval = resizeFileSystemBackend(*childReport);
				break;
			}

			case FileSystem::cmdSupportFileSystem:
			{
				const qint64 newLengthInByte = Capacity(newLength() * device().logicalSectorSize()).toInt(Capacity::Byte);
				rval = partition().fileSystem().resize(*report, partition().deviceNode(), newLengthInByte);
				break;
			}

			default:
				report->line() << i18nc("@info/plain", "The file system on partition <filename>%1</filename> cannot be resized because there is no support for it.", partition().deviceNode());
				break;
		}

		if (rval)
			partition().fileSystem().setLastSector(partition().fileSystem().firstSector() + newLength() - 1);
	}

	jobFinished(*report, rval);

	return rval;
}
Exemple #18
0
QString KisShortcutConfiguration::buttonsToText(Qt::MouseButtons buttons)
{
    QString text;
    QString sep = i18nc("Separator in the list of mouse buttons for shortcut", " + ");

    int buttonCount = 0;

    if (buttons & Qt::LeftButton) {
        text.append(i18nc("Left Mouse Button", "Left"));
        buttonCount++;
    }

    if (buttons & Qt::RightButton) {
        if (buttonCount++ > 0) {
            text.append(sep);
        }

        text.append(i18nc("Right Mouse Button", "Right"));
    }

    if (buttons & Qt::MidButton) {
        if (buttonCount++ > 0) {
            text.append(sep);
        }

        text.append(i18nc("Middle Mouse Button", "Middle"));
    }

    if (buttons & Qt::XButton1) {
        if (buttonCount++ > 0) {
            text.append(sep);
        }

        text.append(i18nc("Mouse Back Button", "Back"));
    }

    if (buttons & Qt::XButton1) {
        if (buttonCount++ > 0) {
            text.append(sep);
        }

        text.append(i18nc("Mouse Forward Button", "Forward"));
    }

    if (buttonCount == 0) {
        text.append(i18nc("No mouse buttons for shortcut", "None"));
    }
    else {
        text = i18ncp(
            "%1 = List of mouse buttons for shortcut. "
            "Plural form is chosen upon the number of buttons in that list.",
            "%1 Button", "%1 Buttons", text, buttonCount);
    }

    return text;
}
Exemple #19
0
void
PhotosApplet::photoAdded()
{
    setBusy( false );
    setHeaderText( i18ncp( "@title:window Number of photos of artist",
                           "1 Photo: %2",
                           "%1 Photos: %2",
                           m_widget->count(),
                           m_currentArtist ) );
}
Exemple #20
0
 virtual QVariant data( int column, int role ) const
 {
     switch ( role )
     {
         case Qt::ToolTipRole:
             return i18ncp( "%1 is the file name",
                            "%1\n\nOne bookmark", "%1\n\n%2 bookmarks",
                            text( 0 ), childCount() );
     }
     return QTreeWidgetItem::data( column, role );
 }
QString KisShortcutConfiguration::buttonsToText(Qt::MouseButtons buttons)
{
    QString text;

    int buttonCount = 0;

    if (buttons & Qt::LeftButton) {
        text.append(i18nc("Left Mouse Button", "Left"));
        buttonCount++;
    }

    if (buttons & Qt::RightButton) {
        if (buttonCount++ > 0) {
            text.append(" + ");
        }

        text.append(i18nc("Right Mouse Button", "Right"));
    }

    if (buttons & Qt::MidButton) {
        if (buttonCount++ > 0) {
            text.append(" + ");
        }

        text.append(i18nc("Middle Mouse Button", "Middle"));
    }

    if (buttons & Qt::XButton1) {
        if (buttonCount++ > 0) {
            text.append(" + ");
        }

        text.append(i18nc("Mouse Back Button", "Back"));
    }

    if (buttons & Qt::XButton1) {
        if (buttonCount++ > 0) {
            text.append(" + ");
        }

        text.append(i18nc("Mouse Forward Button", "Forward"));
    }

    if (buttonCount == 0) {
        text.append(i18nc("No input", "None"));
    }
    else {
        text.append(' ');
        text.append(i18ncp("Mouse Buttons", "Button", "Buttons", buttonCount));
    }

    return text;
}
void IconSizeGroupBox::showToolTip(QSlider* slider, int value)
{
    const int size = ZoomLevelInfo::iconSizeForZoomLevel(value);
    slider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size));
    if (!slider->isVisible()) {
        return;
    }
    QPoint global = slider->rect().topLeft();
    global.ry() += slider->height() / 2;
    QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
    QApplication::sendEvent(slider, &toolTipEvent);
}
void KFileMetaDataProvider::Private::slotLoadingFinished()
{
#if ! KIO_NO_NEPOMUK
    KFileMetaDataReader *finishedMetaDataReader = qobject_cast<KFileMetaDataReader *>(q->sender());
    // The process that has emitted the finished() signal
    // will get deleted and removed from m_metaDataReaders.
    for (int i = 0; i < m_metaDataReaders.count(); ++i) {
        KFileMetaDataReader *metaDataReader = m_metaDataReaders[i];
        if (metaDataReader == finishedMetaDataReader) {
            m_metaDataReaders.removeAt(i);
            if (metaDataReader != m_latestMetaDataReader) {
                // Ignore data of older processs, as the data got
                // obsolete by m_latestMetaDataReader.
                metaDataReader->deleteLater();
                return;
            }
        }
    }

    m_data = m_latestMetaDataReader->metaData();
    m_latestMetaDataReader->deleteLater();

    if (m_fileItems.count() == 1) {
        // TODO: Handle case if remote URLs are used properly. isDir() does
        // not work, the modification date needs also to be adjusted...
        const KFileItem &item = m_fileItems.first();

        if (item.isDir()) {
            const int count = subDirectoriesCount(item.url().pathOrUrl());
            if (count == -1) {
                m_data.insert(QUrl("kfileitem#size"), QString("Unknown"));
            } else {
                const QString itemCountString = i18ncp("@item:intable", "%1 item", "%1 items", count);
                m_data.insert(QUrl("kfileitem#size"), itemCountString);
            }
        } else {
            m_data.insert(QUrl("kfileitem#size"), KIO::convertSize(item.size()));
        }
        m_data.insert(QUrl("kfileitem#type"), item.mimeComment());
        m_data.insert(QUrl("kfileitem#modified"), _k_fancyFormatDateTime(item.time(KFileItem::ModificationTime)));
        m_data.insert(QUrl("kfileitem#owner"), item.user());
        m_data.insert(QUrl("kfileitem#permissions"), item.permissionsString());
    } else if (m_fileItems.count() > 1) {
        // Calculate the size of all items
        quint64 totalSize = 0;
        foreach (const KFileItem &item, m_fileItems) {
            if (!item.isDir() && !item.isLink()) {
                totalSize += item.size();
            }
        }
        m_data.insert(QUrl("kfileitem#totalSize"), KIO::convertSize(totalSize));
    }
void
UpcomingEventsWidget::setDate( const KDateTime &date )
{
    QLabel *dateLabel = static_cast<QLabel*>( m_date->widget() );
    dateLabel->setText( KGlobal::locale()->formatDateTime( date, KLocale::FancyLongDate ) );
    KDateTime currentDT = KDateTime::currentLocalDateTime();
    if( currentDT.compare(date) == KDateTime::Before )
    {
        int daysTo = currentDT.daysTo( date );
        dateLabel->setToolTip( i18ncp( "@info:tooltip Number of days till an event",
                                       "Tomorrow", "In <strong>%1</strong> days", daysTo ) );
    }
}
Exemple #25
0
void DietWizardDialog::changeMealNumber( int mn )
{
	mealNumberLabel->setText( i18n( "- %1 -" , mn ) );
	if ( mn > mealNumber ) {

		while ( mealNumber != mn ) {
			mealNumber++;
			newTab( i18ncp( "@title:tab" , "Meal 1" , "Meal %1" , mealNumber ) );
		}
	}
	else if ( mn < mealNumber ) {

		while ( mealNumber != mn ) {
			mealNumber--;
			delete mealTabs->widget( mealTabs->count() - 1 );
		}
	}
}
void InformationPanelContent::showItems(const KFileItemList& items)
{
    m_pendingPreview = false;

    KIconLoader iconLoader;
    QPixmap icon = iconLoader.loadIcon("dialog-information",
                                       KIconLoader::NoGroup,
                                       KIconLoader::SizeEnormous);
    m_preview->setPixmap(icon);
    setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count()));

    if (m_metaDataWidget) {
        m_metaDataWidget->setItems(items);
    }

    m_phononWidget->hide();

    m_item = KFileItem();
}
/** Returns the name of a given Unit.
	@param u the Unit to find the name for
	@return the name
*/
QString Capacity::unitName(Unit u, qint64 val)
{
	static QString unitNames[] =
	{
		i18ncp("@info/plain unit", "Byte", "Bytes", val),
		i18nc("@info/plain unit", "KiB"),
		i18nc("@info/plain unit", "MiB"),
		i18nc("@info/plain unit", "GiB"),
		i18nc("@info/plain unit", "TiB"),
		i18nc("@info/plain unit", "PiB"),
		i18nc("@info/plain unit", "EiB"),
		i18nc("@info/plain unit", "ZiB"),
		i18nc("@info/plain unit", "YiB")
	};

	if (static_cast<quint32>(u) >= sizeof(unitNames) / sizeof(unitNames[0]))
		return i18nc("@info/plain unit", "(unknown unit)");

	return unitNames[u];
}
Exemple #28
0
void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bkGoup)
{
    QList<KUrl> urlList = bkGoup.groupUrlList();

    if (urlList.length() > 8)
    {
        if (KMessageBox::warningContinueCancel(
                    rApp->rekonqWindow(),
                    i18ncp("%1=Number of tabs. Value is always >=8",
                           "You are about to open %1 tabs.\nAre you sure?",
                           "You are about to open %1 tabs.\nAre you sure?", urlList.length()))
                != KMessageBox::Continue
           )
            return;
    }

    Q_FOREACH(const KUrl & url, urlList)
    {
        emit openUrl(url, Rekonq::NewFocusedTab);
    }
KSGKipiImageCollectionSelector::KSGKipiImageCollectionSelector(KIPI::Interface *interface, QWidget *parent)
    : KIPI::ImageCollectionSelector(parent),
      mInterface(interface),
      mListWidget(new QListWidget)
{
    Q_FOREACH (const auto &collection, interface->allAlbums()) {
        QListWidgetItem *item = new QListWidgetItem(mListWidget);
        QString name = collection.name();
        int imageCount = collection.images().size();
        QString title = i18ncp("%1 is collection name, %2 is image count in collection",
                               "%1 (%2 image)", "%1 (%2 images)", name, imageCount);
        item->setText(title);
        item->setData(Qt::UserRole, name);
    }
    connect(mListWidget, &QListWidget::currentRowChanged, this, &KIPI::ImageCollectionSelector::selectionChanged);

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(mListWidget);
    layout->setMargin(0);
}
Exemple #30
0
KIOWIDGETS_EXPORT QString KIO::pasteActionText(const QMimeData *mimeData, bool *enable, const KFileItem &destItem)
{
    bool canPasteData = false;
    QList<QUrl> urls;

    // mimeData can be 0 according to https://bugs.kde.org/show_bug.cgi?id=335053
    if (mimeData) {
        canPasteData = KIO::canPasteMimeData(mimeData);
        urls = KUrlMimeData::urlsFromMimeData(mimeData);
    } else {
        qCWarning(KIO_WIDGETS) << "QApplication::clipboard()->mimeData() is 0!";
    }

    QString text;
    if (!urls.isEmpty() || canPasteData) {
        // disable the paste action if no writing is supported
        if (!destItem.isNull()) {
            if (destItem.url().isEmpty()) {
                *enable = false;
            } else {
                *enable = KFileItemListProperties(KFileItemList() << destItem).supportsWriting();
            }
        } else {
            *enable = false;
        }

        if (urls.count() == 1 && urls.first().isLocalFile()) {
            const bool isDir = QFileInfo(urls.first().toLocalFile()).isDir();
            text = isDir ? i18nc("@action:inmenu", "Paste One Folder") :
                           i18nc("@action:inmenu", "Paste One File");
        } else if (!urls.isEmpty()) {
            text = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
        } else {
            text = i18nc("@action:inmenu", "Paste Clipboard Contents...");
        }
    } else {
        *enable = false;
        text = i18nc("@action:inmenu", "Paste");
    }
    return text;
}