Пример #1
0
void HierarchyItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
    QColorGroup g( cg );
    g.setColor( QColorGroup::Base, backgroundColor() );
    g.setColor( QColorGroup::Foreground, Qt::black );
    g.setColor( QColorGroup::Text, Qt::black );
    QString txt = text( 0 );
    if ( rtti() == Slot &&
   ( txt == "init()" || txt == "destroy()" ) ) {
  listView()->setUpdatesEnabled( false );
  if ( txt == "init()" )
      setText( 0, txt + " " + i18n( "(Constructor)" ) );
  else
      setText( 0, txt + " " + i18n( "(Destructor)" ) );
  QListViewItem::paintCell( p, g, column, width, align );
  setText( 0, txt );
  listView()->setUpdatesEnabled( true );
    } else {
  QListViewItem::paintCell( p, g, column, width, align );
    }
    p->save();
    p->setPen( QPen( cg.dark(), 1 ) );
    if ( column == 0 )
  p->drawLine( 0, 0, 0, height() - 1 );
    if ( listView()->firstChild() != this ) {
  if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) {
      int d = depth() - itemBelow()->depth();
      p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 );
  }
    }
    p->drawLine( 0, height() - 1, width, height() - 1 );
    p->drawLine( width - 1, 0, width - 1, height() );
    p->restore();
}
Пример #2
0
void PlaylistItem::setup()
{
    KListViewItem::setup();

    if( this == listView()->currentTrack() )
        setHeight( listView()->fontMetrics().height() * 2 );
}
Пример #3
0
/** Replaces the ImagesList::slotAddImages method, so that
  * MyImageListViewItems can be added instead of ImagesListViewItems
  */
void MyImageList::slotAddImages(const KUrl::List& list)
{
    // Figure out which of the supplied URL's should actually be added and which
    // of them already exist.
    bool found = false;

    for (KUrl::List::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
    {
        KUrl imageUrl = *it;
        found         = false;

        for (int i = 0; i < listView()->topLevelItemCount(); ++i)
        {
            MyImageListViewItem* const currItem = dynamic_cast<MyImageListViewItem*>(listView()->topLevelItem(i));

            if (currItem && currItem->url() == imageUrl)
            {
                found = true;
                break;
            }
        }

        if (!found && KPMetadata::isRawFile(imageUrl))
        {
            new MyImageListViewItem(listView(), imageUrl);
        }
    }

    // Duplicate the signalImageListChanged of the ImageWindow, to enable the
    // upload button again.
    emit signalImageListChanged();
}
Пример #4
0
void Directory::setOpen( bool o )
{
  if ( o )
    setPixmap( 0, QPixmap( folder_open_xpm ) );
  else
    setPixmap( 0, QPixmap( folder_closed_xpm ) );

  if ( o && !childCount() ){
    QString s( fullName() );
    QDir thisDir( s );
    if ( !thisDir.isReadable() ) {
    readable = false;
    setExpandable( false );
    return;
  }

  listView()->setUpdatesEnabled( false );
  const QFileInfoList * files = thisDir.entryInfoList();
  if ( files ){
    QFileInfoListIterator it( *files );
    QFileInfo * f;
    while( (f=it.current()) != 0 ){
      ++it;
      if ( f->fileName() != "." && f->fileName() != ".." && f->isDir() )
        (void)new Directory( this, f->fileName() );
      }
    }
    listView()->setUpdatesEnabled( true );
  }
  QListViewItem::setOpen( o );
}
Пример #5
0
KMMimePartTreeItem::KMMimePartTreeItem( KMMimePartTreeItem * parent,
                                        partNode* node,
                                        const QString & description,
                                        const QString & mimetype,
                                        const QString & encoding,
                                        KIO::filesize_t size,
                                        bool revertOrder )
  : QListViewItem( parent, description,
		   QString::null, // set by setIconAndTextForType()
		   encoding,
		   KIO::convertSize( size ) ),
    mPartNode( node ), mOrigSize(size)
{
  if( revertOrder && nextSibling() ){
    QListViewItem* sib = nextSibling();
    while( sib->nextSibling() )
      sib = sib->nextSibling();
    moveItem( sib );
  }
  if( node )
    node->setMimePartTreeItem( this );
  setIconAndTextForType( mimetype );
  if ( listView() )
    static_cast<KMMimePartTree*>(listView())->correctSize(this);
}
Пример #6
0
void
Item::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align )
{
    bool dirty = false;
    QStringList &cs_m_dirs = CollectionSetup::instance()->m_dirs;

    // Figure out if a child folder is activated
    for ( QStringList::const_iterator iter = cs_m_dirs.begin(); iter != cs_m_dirs.end();
            ++iter )
        if ( ( *iter ).startsWith( m_url.path(1) ) )
            if ( *iter != "/" ) // "/" should not match as a child of "/"
                dirty = true;

    // Use a different color if this folder has an activated child folder
    const QFont f = p->font();
    QColorGroup _cg = cg;
    if ( dirty )
    {
        _cg.setColor( QColorGroup::Text, listView()->colorGroup().link() );
        QFont font = p->font();
        font.setBold( !font.bold() );
        p->setFont( font );
    }

    QCheckListItem::paintCell( p, isDisabled() ? listView()->palette().disabled() : _cg, column, width, align );
    p->setFont( f );
}
Пример #7
0
/*! \reimp */
QRect QAccessibleListView::itemRect(int child) const
{
    Q3ListViewItem *item = findLVItem(listView(), child);
    if (!item)
        return QRect();
    return listView()->itemRect(item);
}
Пример #8
0
void PlaylistItem::incrementTotals()
{
    if( Amarok::entireAlbums() && m_album )
    {
        const uint prevCount = m_album->tracks.count();
        // Multiple tracks with same track number are possible; 
        // e.g. with "various_artist" albums or albums with multiple disks.
        // We are trying to keep m_album->tracks sorted first by discNumber() and then by track().
        // It seems that the following assumption is made for the following: 
        // ``Either all the tracks in an album have their track()'s set (to nonzero) or none of them have.''
        if( !track() || !m_album->tracks.count() ||
	    ( m_album->tracks.getLast()->track() &&
	      ( ( m_album->tracks.getLast()->discNumber() < discNumber() ) || 
		( m_album->tracks.getLast()->discNumber() == discNumber() && m_album->tracks.getLast()->track() < track() ) ) ) )
            m_album->tracks.append( this );
        else
            for( int i = 0, n = m_album->tracks.count(); i < n; ++i )
                if(!m_album->tracks.at(i)->track() || m_album->tracks.at(i)->discNumber() > discNumber() ||
		   ( m_album->tracks.at(i)->discNumber() == discNumber() && m_album->tracks.at(i)->track() > track() ) )
                {
                    m_album->tracks.insert( i, this );
                    break;
                }
        const Q_INT64 prevTotal = m_album->total;
        Q_INT64 total = m_album->total * prevCount;
        total += totalIncrementAmount();
        m_album->total = Q_INT64( double( total + 0.5 ) / m_album->tracks.count() );
        if( listView()->m_prevAlbums.findRef( m_album ) == -1 )
            listView()->m_total = listView()->m_total - prevTotal + m_album->total;
    }
    else if( listView()->m_prevTracks.findRef( this ) == -1 )
        listView()->m_total += totalIncrementAmount();
}
Пример #9
0
RawCameraDlg::RawCameraDlg(QWidget* const parent)
    : InfoDlg(parent),
      d(new Private)
{
    setWindowTitle(i18n("List of supported RAW cameras"));

    QStringList list = RawEngine::DRawDecoder::supportedCamera();

    // --------------------------------------------------------

    d->header    = new QLabel(this);
    d->searchBar = new SearchTextBar(this, QLatin1String("RawCameraDlgSearchBar"));
    updateHeader();

    listView()->setColumnCount(1);
    listView()->setHeaderLabels(QStringList() << QLatin1String("Camera Model")); // Header is hidden. No i18n here.
    listView()->header()->hide();

    for (QStringList::const_iterator it = list.constBegin() ; it != list.constEnd() ; ++it)
    {
        new QTreeWidgetItem(listView(), QStringList() << *it);
    }

    // --------------------------------------------------------

    QGridLayout* const  grid = dynamic_cast<QGridLayout*>(mainWidget()->layout());
    grid->addWidget(d->header,    1, 0, 1, -1);
    grid->addWidget(d->searchBar, 3, 0, 1, -1);

    // --------------------------------------------------------

    connect(d->searchBar, SIGNAL(signalSearchTextSettings(SearchTextSettings)),
            this, SLOT(slotSearchTextChanged(SearchTextSettings)));
}
Пример #10
0
/**
 * @brief Overwritten drop handler
 *
 * @param evt the event
 */
void TreeEntry::dropped(QDropEvent *evt)
{
    if (evt->provides("application/x-qpamat")) {
        evt->accept();
        QString xml = QString::fromUtf8(evt->encodedData("application/x-qpamat"));
        QDomDocument doc;
        doc.setContent(xml);
        QDomElement elem = doc.documentElement();

        Q3ListViewItem* src = reinterpret_cast<TreeEntry*>(elem.attribute("memoryAddress").toLong());

        QpamatWindow *win = Qpamat::instance()->getWindow();
        if (src == this) {
            win->message(tr("Cannot dray to itself."));
            return;
        }

        TreeEntry* item = m_isCategory ? this : dynamic_cast<TreeEntry*>(parent());
        TreeEntry* appended = 0;
        if (item)
            appended = appendFromXML(item, elem);
        else
            appended = appendFromXML(listView(), elem);

        if (!isOpen())
            setOpen(true);

        listView()->setSelected(appended, true);
        dynamic_cast<Tree*>(listView())->updatePasswordStrengthView();
        delete src;
    }
}
Пример #11
0
void QRListViewItem::paintCell( QPainter *p, const QColorGroup &cg,
                                int column, int width, int alignment)

{
    p->save();
    QColorGroup cgn(cg);

    if (isWritable(column)) {
        cgn.setColor(QColorGroup::Base, QColor(231,255,216));
    }

    if (((QRTreeBox *) listView()->parent())->isHighlight()) {
        if (column == 0 && m_node && ((QRTreeBox *) listView()->parent())->isNodeInCache(m_node)) {
            //cgn.setColor(QColorGroup::Base, QColor(231,255,216));
            cgn.setColor(QColorGroup::Base, QColor(216,239,202));
        }
    }

    Q3ListViewItem::paintCell(p,cgn,column,width,alignment);

    // Draw a box around the Cell
    int nheight = height() - 1;
    int nwidth = width - 1;
    p->setPen(cg.color(QColorGroup::Background));
    p->drawLine(0,nheight,nwidth,nheight);

    //p->lineTo(nwidth, 0);
    QPainterPath path;
    path.lineTo(nwidth, 0);
    p->drawPath(path);

    p->restore();

}
Пример #12
0
void MsgViewItem::SetEventLine()
{
  QString s = EventDescription(msg);
  QString text;

  switch(msg->SubCommand())
  {
    case ICQ_CMDxSUB_MSG:
      text = m_codec->toUnicode(msg->Text());
      break;

    case ICQ_CMDxSUB_URL:
      text = m_codec->toUnicode(((CEventUrl *)msg)->Url());
      break;

    case ICQ_CMDxSUB_CHAT:
      text = m_codec->toUnicode(((CEventChat *)msg)->Reason());
      break;

    case ICQ_CMDxSUB_FILE:
      text = m_codec->toUnicode(((CEventFile *)msg)->Filename());
      break;

    case ICQ_CMDxSUB_EMAILxALERT:
      text = m_codec->toUnicode(((CEventEmailAlert *)msg)->From());
      break;

    default:
      break;
  }

  if (!text.isNull())
  {
    int width = listView()->columnWidth(1);
    QFont f = listView()->font();
    if (m_nEventId != -1) f.setBold(true);
    QFontMetrics fm(f);
    width -= fm.width(s) + fm.width(" [...]") + listView()->itemMargin() * 2;

    s += " [";
    
    // We're going to take the event's message and display as much of it
    // as fits in the widget. If not everything fits, we'll append "..."
    uint length = text.length();
    const QChar *c = text.unicode();
    while (length--) {
      if (*c == '\n') break; // we only print the first line
      width -= fm.width(*c);
      if (width <= 0) {
         s += "...";
         break;
      }
      s += *c;
      c++;
    }
    s += "]";
  }

  setText(1, s);
}
Пример #13
0
void PlaylistItem::setup()
{
    KListViewItem::setup();

    // We make the current track item a bit taller than ordinary items
    if( this == listView()->currentTrack() )
        setHeight( int( float( listView()->fontMetrics().height() ) * 1.53 ) );
}
Пример #14
0
void EvaListViewItem::setText(const TQString &text)
{
    if(!listView()) return;
    if(m_richText) delete m_richText;
    TQListViewItem::setText(0, text);
    m_richText = new TQSimpleRichText( "<qt><nobr>" + text + "</nobr></qt>",
                                listView()->viewport()->font(), TQString::null, 0/*, mimeFactory_*/ );
}
Пример #15
0
void ImgurImagesList::slotAddImages(const QList<QUrl>& list)
{
    /* Replaces the KPImagesList::slotAddImages method, so that
     * ImgurImageListViewItems can be added instead of ImagesListViewItems */

    // Figure out which of the supplied URL's should actually be added and which
    // of them already exist.
    bool found;

    for (QList<QUrl>::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
    {
        QUrl imageUrl = *it;
        found         = false;

        if (iface())
        {
            QPointer<MetadataProcessor> meta = iface()->createMetadataProcessor();

            if (meta && meta->load(imageUrl))
            {
                const QString sUrl       = meta->getXmpTagString(QLatin1String("Xmp.kipi.Imgur.Hash"));
                const QString sDeleteUrl = meta->getXmpTagString(QLatin1String("Xmp.kipi.Imgur.Delete"));

                for (int i = 0; i < listView()->topLevelItemCount(); ++i)
                {
                    ImgurImageListViewItem* const currItem = dynamic_cast<ImgurImageListViewItem*>(listView()->topLevelItem(i));

                    if (currItem && currItem->url() == imageUrl)
                    {
                        found = true;

                        if (!sUrl.isEmpty())
                        {
                            currItem->setUrl(sUrl);
                        }

                        if (!sDeleteUrl.isEmpty())
                        {
                            currItem->setDeleteUrl(sDeleteUrl);
                        }

                        break;
                    }
                }

                if (!found)
                {
                    new ImgurImageListViewItem(listView(), imageUrl);
                }
            }
        }
    }

    // Duplicate the signalImageListChanged of the ImageWindow, to enable the
    // upload button again.
    emit signalImageListChanged();
    emit signalAddItems(list);
}
Пример #16
0
MyImageList::MyImageList(QWidget* const parent)
    : KPImagesList(parent)
{
    setControlButtonsPlacement(KPImagesList::ControlButtonsBelow);
    listView()->setColumnLabel(KPImagesListView::Filename, i18n("Raw File"));
    listView()->setColumn(static_cast<KPImagesListView::ColumnType>(MyImageList::TARGETFILENAME), i18n("Target File"), true);
    listView()->setColumn(static_cast<KPImagesListView::ColumnType>(MyImageList::IDENTIFICATION), i18n("Camera"),      true);
    listView()->setColumn(static_cast<KPImagesListView::ColumnType>(MyImageList::STATUS),         i18n("Status"),      true);
}
Пример #17
0
/**
 * @brief Sets the text of the entry.
 *
 * Sets the name internally.
 *
 * @param column the column
 * @param text the new text
 */
void TreeEntry::setText(int column, const QString& text)
{
    UNUSED(column);
    Q_ASSERT(column == 0);

    m_name = text;
    listView()->sort();
    listView()->triggerUpdate();
}
Пример #18
0
void PlaylistItem::refAlbum()
{
    if( Amarok::entireAlbums() )
    {
        if( listView()->m_albums[artist_album()].find( album() ) == listView()->m_albums[artist_album()].end() )
            listView()->m_albums[artist_album()][album()] = new PlaylistAlbum;
        m_album = listView()->m_albums[artist_album()][album()];
        m_album->refcount++;
    }
}
Пример #19
0
void HostListItem::updateColumn( int column ) const
{
  const QRect r = listView()->itemRect( this );
  if( !r.isValid() )
    return;

  listView()->viewport()->update( listView()->header()->sectionPos( column ) - listView()->contentsX() + 1,
      r.y() + 1,
      listView()->header()->sectionSize( column ) - 2, height() - 2 );
}
Пример #20
0
void PlaylistItem::setVisible( bool visible )
{
    if( isEmpty() )
        return;

    if( !visible && isSelected() )
    {
        listView()->m_selCount--;
        listView()->m_selLength -= length();
        KListViewItem::setSelected( false );
        listView()->countChanged();
    }

    const bool prevVisible = isVisible();
    KListViewItem::setVisible( visible );
    if( prevVisible && !isVisible() )
    {
        listView()->m_visCount--;
        listView()->m_visLength -= length();
        listView()->countChanged();
        decrementTotals();
    }
    else if( !prevVisible && isVisible() )
    {
        listView()->m_visCount++;
        listView()->m_visLength += length();
        listView()->countChanged();
        incrementTotals();
    }
}
Пример #21
0
void PlaylistItem::setVisible( bool visible )
{
    const int length = seconds().toInt();
    if( !visible && isSelected() )
    {
        listView()->m_selCount--;
        listView()->m_selLength -= length;
        KListViewItem::setSelected( false );
        listView()->countChanged();
    }

    const bool prevVisible = isVisible();
    KListViewItem::setVisible( visible );
    if( prevVisible && !isVisible() )
    {
        listView()->m_visCount--;
        listView()->m_visLength -= length;
        listView()->countChanged();
    }
    else if( !prevVisible && isVisible() )
    {
        listView()->m_visCount++;
        listView()->m_visLength += length;
        listView()->countChanged();
    }
}
Пример #22
0
PlaylistItem::PlaylistItem( const MetaBundle &bundle, QListViewItem *lvi )
        : KListViewItem( lvi->listView(), lvi->itemAbove(), filename( bundle.url() ) )
        , m_url( bundle.url() )
        , m_missing( false )
        , m_enabled( true )
{
    setDragEnabled( true );

    setText( bundle );

    const int length = seconds().toInt();
    listView()->m_totalCount++;
    listView()->m_totalLength += length;
    if( isSelected() )
    {
        listView()->m_selCount++;
        listView()->m_selLength += length;
    }
    if( isVisible() )
    {
        listView()->m_visCount++;
        listView()->m_visLength += length;
    }

    listView()->setFilterForItem( listView()->m_filter, this );

    listView()->countChanged();
}
Пример #23
0
void UserViewItemBase::drawSeparator(QPainter *p, int x, int width, const QColorGroup &cg)
{
    if (x < width - 6){
#if QT_VERSION > 300
        QRect rcSep(x, height()/2, width - 6 - x, 1);
        listView()->style().drawPrimitive(QStyle::PE_Separator, p, rcSep, cg);
#else
        listView()->style().drawSeparator(p, x, height() / 2, width - 6, height() / 2, cg);
#endif
    }
}
Пример #24
0
 FreeBusyItem( Attendee *attendee, KDGanttView *parent ) :
   KDGanttViewTaskItem( parent, parent->lastItem() ), mAttendee( attendee ), mTimerID( 0 ),
   mIsDownloading( false )
 {
   Q_ASSERT( attendee );
   updateItem();
   setFreeBusyPeriods( 0 );
   setDisplaySubitemsAsGroup( true );
   if ( listView () )
       listView ()->setRootIsDecorated( false );
 }
void toResultViewCheck::setText(int col, const QString &txt)
{
    if (txt != text(col))
    {
        if (col >= ColumnCount || !ColumnData)
        {
            int ns = (col + ALLOC_SIZE) / ALLOC_SIZE * ALLOC_SIZE;
            keyData *nd = new keyData[ns];
            int i;
            for (i = 0; i < ColumnCount; i++)
                nd[i] = ColumnData[i];
            while (i < ns)
            {
                nd[i].Width = 0;
                nd[i].Type = keyData::String;
                i++;
            }
            delete[] ColumnData;
            ColumnData = nd;
            ColumnCount = ns;
        }

        static QRegExp number(QString::fromLatin1("^\\d*\\.?\\d+E?-?\\d*.?.?$"));

        ColumnData[col].Data = txt;

        if (txt == "N/A")
        {
            ColumnData[col].Type = keyData::String;
            ColumnData[col].KeyAsc = "\xff";
            ColumnData[col].KeyDesc = "\x00";
        }
// qt4        else if (number.match(txt) >= 0)
        else if (number.indexIn(txt) >= 0)
        {
            ColumnData[col].Type = keyData::Number;

            static char buf[100];
            double val = txt.toFloat();
            if (val < 0)
                sprintf(buf, "\x01%015.5f", val);
            else
                sprintf(buf, "%015.5f", val);
            ColumnData[col].KeyAsc = ColumnData[col].KeyDesc = QString::fromLatin1(buf);
        }
        else
        {
            ColumnData[col].Type = keyData::String;
            ColumnData[col].KeyAsc = ColumnData[col].KeyDesc = ColumnData[col].Data;
        }
        ColumnData[col].Width = realWidth(listView()->fontMetrics(), listView(), col, txt);
    }
    toTreeWidgetCheck::setText(col, firstText(col));
}
Пример #26
0
void PlaylistItem::decrementLengths()
{
    listView()->m_totalLength -= length();
    if( isSelected() )
    {
        listView()->m_selLength -= length();
    }
    if( isVisible() )
    {
        listView()->m_visLength -= length();
    }
}
Пример #27
0
PlaylistItem::PlaylistItem( QDomNode node, QListViewItem *item )
        : KListViewItem( item->listView(), item->itemAbove() )
        , m_url( node.toElement().attribute( "url" ) )
        , m_missing( false )
        , m_enabled( true )
{
    setDragEnabled( true );
    KListViewItem::setText( Filename, filename( m_url ) );

    //NOTE we use base versions to speed this up (this function is called 100s of times during startup)
    for( uint x = 1, n = listView()->columns(); x < n; ++x ) {
        const QString text = node.namedItem( columnName( x ) ).toElement().text();

        switch( x ) {
        case Artist:
        case Album:
        case Genre:
        case Year:
        case Directory:
            KListViewItem::setText( x, attemptStore( text ) );
            continue;
        case Score:
            KListViewItem::setText( x,
                    QString::number( CollectionDB::instance()->getSongPercentage( m_url.path() ) ) );
            continue;
        case Playcount:
            KListViewItem::setText( x,
                    QString::number( CollectionDB::instance()->getPlayCount( m_url.path() ) ) );
            continue;
        case Type:
        default:
            KListViewItem::setText( x, text );
        }
    }

    const int length = seconds().toInt();
    listView()->m_totalCount++;
    listView()->m_totalLength += length;
    if( isSelected() )
    {
        listView()->m_selCount++;
        listView()->m_selLength += length;
    }
    if( isVisible() )
    {
        listView()->m_visCount++;
        listView()->m_visLength += length;
    }

    listView()->setFilterForItem( listView()->m_filter, this );

    listView()->countChanged();
}
Пример #28
0
void SkinListItem::setup()
{
    widthChanged();

    item_text->setDefaultFont(listView()->font());
    item_text->setWidth(listView()->columnWidth(0));
    int text_height = item_text->height()+(MARGIN*2);

    if (text_height < 32)
        setHeight(32+(MARGIN*2));
    else
        setHeight(text_height);
}
Пример #29
0
void PlaylistItem::decrementCounts()
{
    listView()->m_totalCount--;
    if( isSelected() )
    {
        listView()->m_selCount--;
    }
    if( isVisible() )
    {
        listView()->m_visCount--;
        decrementTotals();
    }
}
Пример #30
0
void VocabTreeItem::setOn( bool isOn ) {
    // We clear the selection in order to effectively reset it after
    // changing the state of the item.  This is needed because the
    // item is updated when a selection event occurs.
    bool isUpdateHackEnabled = listView()->isUpdatesEnabled();
    if( isUpdateHackEnabled )
        listView()->clearSelection();
    QCheckListItem::setOn( isOn );
    vocab->setMarkedForStudy( isOn );
    // Force updating the event.
    if( isUpdateHackEnabled )
        listView()->setSelected( this, true );
}