Beispiel #1
0
TransfersView::TransfersView(QWidget * parent)
    : QTreeView(parent)
{
//     setItemsExpandable(false);
    setRootIsDecorated(false);
    setAnimated(true);
    setAllColumnsShowFocus(true);
    header()->setDefaultAlignment(Qt::AlignCenter);
    header()->setMinimumSectionSize(80);    
    header()->setContextMenuPolicy(Qt::CustomContextMenu);
    header()->setClickable(true);
    m_headerMenu = new KMenu(header());

    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setDragEnabled(true);
    setAcceptDrops(true);
    setDropIndicatorShown(true);
    setEditTriggers(QAbstractItemView::NoEditTriggers);
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);

    connect(header(), SIGNAL(customContextMenuRequested(QPoint)),
                      SLOT(slotShowHeaderMenu(QPoint)));
    connect(header(), SIGNAL(sectionCountChanged(int,int)), this, SLOT(populateHeaderActions()));
    connect(header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(slotSectionMoved(int,int,int)));
    connect(header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(slotSaveHeader()));
    connect(this,     SIGNAL(doubleClicked(QModelIndex)),
            this,     SLOT(slotItemActivated(QModelIndex)));
    connect(this,     SIGNAL(collapsed(QModelIndex)),
            this,     SLOT(slotItemCollapsed(QModelIndex)));
    connect(KGet::model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), 
            this,          SLOT(closeExpandableDetails(QModelIndex,int,int)));
}
Beispiel #2
0
void ScanGallery::slotSelectImage(const KUrl &url)
{
    FileTreeViewItem *found = findItemByUrl(url);
    if (found==NULL) found = m_defaultBranch->root();

    scrollToItem(found);
    setCurrentItem(found);
    slotItemActivated(found);
}
Beispiel #3
0
void ScanGallery::slotActivateItem(const KUrl &url)
{
    kDebug() << url;

    FileTreeViewItem *found = findItemByUrl(url);
    if (found==NULL) return;

    slotItemActivated(found);
}
Beispiel #4
0
void ScanGallery::slotUpdatedItem(const KUrl &url)
{
    FileTreeViewItem *found = findItemByUrl(url);
    if (found==NULL) return;

    if (found->isSelected())				// only if still selected
    {
        slotUnloadItem(found);				// ensure unloaded for updating
        slotItemActivated(found);			// load the new image
    }
}
Beispiel #5
0
void ScanGallery::slotSelectDirectory(const QString &branchName, const QString &relPath)
{
    kDebug() << "branch" << branchName << "path" << relPath;

    FileTreeViewItem *item;
    if (!branchName.isEmpty()) item = findItemInBranch(branchName, relPath);
    else item = findItemInBranch(branches().at(0), relPath);
							// assume the 1st/only branch
    if (item==NULL) return;

    scrollToItem(item);
    setCurrentItem(item);
    slotItemActivated(item);				// load thumbnails, etc.
}
Beispiel #6
0
void ScanGallery::slotDecorate(FileTreeViewItem *item)
{
    if (item==NULL) return;

    if (!item->isDir())					// dir is done in another slot
    {
        ImageFormat format = getImgFormat(item);	// this is safe for any file
        item->setText(2,(" "+format.name()+" "));

        const KookaImage *img = imageForItem(item);
        if (img!=NULL)					// image appears to be loaded
        {						// set image depth pixmap
            if (img->depth()==1) item->setIcon(0, mPixBw);
            else
            {
                if (img->isGrayscale()) item->setIcon(0, mPixGray);
                else item->setIcon(0, mPixColor);
            }
							// set image size column
            QString t = i18n(" %1 x %2", img->width(), img->height());
            item->setText(1,t);
        }
        else						// not yet loaded, show file info
        {
            if (format.isValid())			// if a valid image file
            {
                item->setIcon(0, mPixFloppy);
                const KFileItem *kfi = item->fileItem();
                if (!kfi->isNull()) item->setText(1, (" "+KIO::convertSize(kfi->size())));
            }
            else
            {
                item->setIcon(0, KIO::pixmapForUrl(item->url(), 0, KIconLoader::Small));
            }
        }
    }

    // This code is quite similar to m_nextUrlToSelect in FileTreeView::slotNewTreeViewItems
    // When scanning a new image, we wait for the KDirLister to notice the new file,
    // and then we have the FileTreeViewItem that we need to display the image.
    if (!m_nextUrlToShow.isEmpty())
    {
        if (m_nextUrlToShow.equals(item->url(), KUrl::CompareWithoutTrailingSlash))
        {
            m_nextUrlToShow = KUrl();			// do this first to prevent recursion
            slotItemActivated(item);
            setCurrentItem(item);			// neccessary in case of new file from D&D
        }
    }
}
Beispiel #7
0
const KookaImage *ScanGallery::getCurrImage(bool loadOnDemand)
{
    FileTreeViewItem *curr = highlightedFileTreeViewItem();
    if (curr==NULL) return (NULL);			// no current item
    if (curr->isDir()) return (NULL);			// is a directory

    KookaImage *img = imageForItem(curr);		// see if already loaded
    if (img==NULL)					// no, try to do that
    {
        if (!loadOnDemand) return (NULL);		// not loaded, and don't want to
        slotItemActivated(curr);			// select/load this image
        img = imageForItem(curr);			// and get image for it
    }

    return (img);
}
Beispiel #8
0
MetaListViewPart::MetaListViewPart(QObject *parent)
    : KParts::Part(parent), m_proxyModel(NULL), m_defaultRow(-1)
{
    m_widget = new MetaListViewWidget;
    setWidget(m_widget);

    connect(m_widget, SIGNAL(itemActivated(QModelIndex)),
            SLOT(slotItemActivated(QModelIndex)) );
    connect(m_widget, SIGNAL(selectionChanged(QItemSelection)),
            SLOT(slotSelectionChanged(QItemSelection)) );
    connect(m_widget, SIGNAL(contextMenuRequested(QModelIndex)),
            SLOT(slotContextMenuRequested(QModelIndex)) );

    // Show initial information on the metaBar
    slotSelectionChanged(QItemSelection());

    //populate the listView (later, in order to respect the size of the listView)
    QMetaObject::invokeMethod(this, "loadModel", Qt::QueuedConnection);

    /* ACTIONS */
    KSelectAction *view_mode = new KSelectAction(i18n("View mode"), this);
    connect(view_mode, SIGNAL(triggered(int)), SLOT(changeViewMode(int)) );
    actionCollection()->addAction("view_mode", view_mode);
    actionCollection()->addAction("view_mode_list",
                view_mode->addAction(KIcon("view-list-details"), i18n("List")) );
    actionCollection()->addAction("view_mode_icons",
                view_mode->addAction(KIcon("view-list-icons"), i18n("Icons")) );

    KSelectAction *metabar_position = new KSelectAction(i18n("Metabar position"), this);
    connect(metabar_position, SIGNAL(triggered(int)), SLOT(changeMetaBarPosition(int)) );
    actionCollection()->addAction("metabar_position", metabar_position);

    QString str_left = i18nc("Opposite of right", "Left");
    QString str_right = i18nc("Opposite of left", "Right");
    if ( QApplication::isLeftToRight() ) {
        actionCollection()->addAction("metabar_position_left", metabar_position->addAction(str_left));
        actionCollection()->addAction("metabar_position_right", metabar_position->addAction(str_right));
    } else {
        actionCollection()->addAction("metabar_position_right", metabar_position->addAction(str_right));
        actionCollection()->addAction("metabar_position_left", metabar_position->addAction(str_left));
    }
    actionCollection()->addAction("metabar_position_hidden", metabar_position->addAction(i18n("Hidden")) );
}
Beispiel #9
0
int VCCueList::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = VCWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: slotFunctionRemoved((*reinterpret_cast< quint32(*)>(_a[1]))); break;
        case 1: slotFunctionChanged((*reinterpret_cast< quint32(*)>(_a[1]))); break;
        case 2: slotNextCue(); break;
        case 3: slotPreviousCue(); break;
        case 4: slotCurrentStepChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 5: slotItemActivated((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break;
        case 6: slotKeyPressed((*reinterpret_cast< const QKeySequence(*)>(_a[1]))); break;
        case 7: slotNextInputValueChanged((*reinterpret_cast< quint32(*)>(_a[1])),(*reinterpret_cast< quint32(*)>(_a[2])),(*reinterpret_cast< uchar(*)>(_a[3]))); break;
        case 8: slotPreviousInputValueChanged((*reinterpret_cast< quint32(*)>(_a[1])),(*reinterpret_cast< quint32(*)>(_a[2])),(*reinterpret_cast< uchar(*)>(_a[3]))); break;
        default: ;
        }
        _id -= 9;
    }
    return _id;
}
Beispiel #10
0
K3b::DataViewImpl::DataViewImpl( View* view, DataDoc* doc, KActionCollection* actionCollection )
:
    QObject( view ),
    m_view( view ),
    m_doc( doc ),
    m_model( new DataProjectModel( doc, view ) ),
    m_sortModel( new DataProjectSortProxyModel( this ) ),
    m_fileView( new QTreeView( view ) )
{
    connect( m_doc, SIGNAL(importedSessionChanged(int)), this, SLOT(slotImportedSessionChanged(int)) );
    connect( m_model, SIGNAL(addUrlsRequested(QList<QUrl>,K3b::DirItem*)), SLOT(slotAddUrlsRequested(QList<QUrl>,K3b::DirItem*)) );
    connect( m_model, SIGNAL(moveItemsRequested(QList<K3b::DataItem*>,K3b::DirItem*)), SLOT(slotMoveItemsRequested(QList<K3b::DataItem*>,K3b::DirItem*)) );

    m_sortModel->setSourceModel( m_model );

    m_fileView->setItemDelegate( new DataProjectDelegate( this ) );
    m_fileView->setModel( m_sortModel );
    m_fileView->setAcceptDrops( true );
    m_fileView->setDragEnabled( true );
    m_fileView->setDragDropMode( QTreeView::DragDrop );
    m_fileView->setItemsExpandable( false );
    m_fileView->setRootIsDecorated( false );
    m_fileView->setSelectionMode( QTreeView::ExtendedSelection );
    m_fileView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    m_fileView->setContextMenuPolicy( Qt::ActionsContextMenu );
    m_fileView->setSortingEnabled( true );
    m_fileView->sortByColumn( DataProjectModel::FilenameColumn, Qt::AscendingOrder );
    m_fileView->setMouseTracking( true );
    m_fileView->setAllColumnsShowFocus( true );
    connect( m_fileView, SIGNAL(doubleClicked(QModelIndex)),
             this, SLOT(slotItemActivated(QModelIndex)) );
    connect( m_fileView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             this, SLOT(slotSelectionChanged()) );

    m_columnAdjuster = new ViewColumnAdjuster( this );
    m_columnAdjuster->setView( m_fileView );
    m_columnAdjuster->addFixedColumn( DataProjectModel::TypeColumn );
    m_columnAdjuster->setColumnMargin( DataProjectModel::TypeColumn, 10 );
    m_columnAdjuster->addFixedColumn( DataProjectModel::SizeColumn );
    m_columnAdjuster->setColumnMargin( DataProjectModel::SizeColumn, 10 );

    m_actionNewDir = new QAction( QIcon::fromTheme( "folder-new" ), i18n("New Folder..."), m_fileView );
    m_actionNewDir->setShortcut( Qt::CTRL + Qt::Key_N );
    m_actionNewDir->setShortcutContext( Qt::WidgetShortcut );
    actionCollection->addAction( "new_dir", m_actionNewDir );
    connect( m_actionNewDir, SIGNAL(triggered(bool)), this, SLOT(slotNewDir()) );

    m_actionRemove = new QAction( QIcon::fromTheme( "edit-delete" ), i18n("Remove"), m_fileView );
    m_actionRemove->setShortcut( Qt::Key_Delete );
    m_actionRemove->setShortcutContext( Qt::WidgetShortcut );
    actionCollection->addAction( "remove", m_actionRemove );
    connect( m_actionRemove, SIGNAL(triggered(bool)), this, SLOT(slotRemove()) );

    m_actionRename = new QAction( QIcon::fromTheme( "edit-rename" ), i18n("Rename"), m_fileView );
    m_actionRename->setShortcut( Qt::Key_F2 );
    m_actionRename->setShortcutContext( Qt::WidgetShortcut );
    actionCollection->addAction( "rename", m_actionRename );
    connect( m_actionRename, SIGNAL(triggered(bool)), this, SLOT(slotRename()) );

    m_actionParentDir = new QAction( QIcon::fromTheme( "go-up" ), i18n("Parent Folder"), m_fileView );
    m_actionParentDir->setShortcut( Qt::Key_Backspace );
    m_actionParentDir->setShortcutContext( Qt::WidgetShortcut );
    actionCollection->addAction( "parent_dir", m_actionParentDir );

    m_actionProperties = new QAction( QIcon::fromTheme( "document-properties" ), i18n("Properties"), m_fileView );
    m_actionProperties->setShortcut( Qt::ALT + Qt::Key_Return );
    m_actionProperties->setShortcutContext( Qt::WidgetShortcut );
    actionCollection->addAction( "properties", m_actionProperties );
    connect( m_actionProperties, SIGNAL(triggered(bool)), this, SLOT(slotProperties()) );

    m_actionOpen = new QAction( QIcon::fromTheme( "document-open" ), i18n("Open"), m_view );
    actionCollection->addAction( "open", m_actionOpen );
    connect( m_actionOpen, SIGNAL(triggered(bool)), this, SLOT(slotOpen()) );

    m_actionImportSession = new QAction( QIcon::fromTheme( "document-import" ), i18n("&Import Session..."), m_view );
    m_actionImportSession->setToolTip( i18n("Import a previously burned session into the current project") );
    actionCollection->addAction( "project_data_import_session", m_actionImportSession );
    connect( m_actionImportSession, SIGNAL(triggered(bool)), this, SLOT(slotImportSession()) );

    m_actionClearSession = new QAction( QIcon::fromTheme( "edit-clear" ), i18n("&Clear Imported Session"), m_view );
    m_actionClearSession->setToolTip( i18n("Remove the imported items from a previous session") );
    m_actionClearSession->setEnabled( m_doc->importedSession() > -1 );
    actionCollection->addAction( "project_data_clear_imported_session", m_actionClearSession );
    connect( m_actionClearSession, SIGNAL(triggered(bool)), this, SLOT(slotClearImportedSession()) );

    m_actionEditBootImages = new QAction( QIcon::fromTheme( "document-properties" ), i18n("&Edit Boot Images..."), m_view );
    m_actionEditBootImages->setToolTip( i18n("Modify the bootable settings of the current project") );
    actionCollection->addAction( "project_data_edit_boot_images", m_actionEditBootImages );
    connect( m_actionEditBootImages, SIGNAL(triggered(bool)), this, SLOT(slotEditBootImages()) );

    QWidgetAction* volumeNameWidgetAction = new VolumeNameWidgetAction( m_doc, this );
    actionCollection->addAction( "project_volume_name", volumeNameWidgetAction );

    QShortcut* enterShortcut = new QShortcut( QKeySequence( Qt::Key_Return ), m_fileView );
    enterShortcut->setContext( Qt::WidgetShortcut );
    connect( enterShortcut, SIGNAL(activated()), this, SLOT(slotEnterPressed()) );

    // Create data context menu
    QAction* separator = new QAction( this );
    separator->setSeparator( true );
    m_fileView->addAction( m_actionParentDir );
    m_fileView->addAction( separator );
    m_fileView->addAction( m_actionRename );
    m_fileView->addAction( m_actionRemove );
    m_fileView->addAction( m_actionNewDir );
    m_fileView->addAction( separator );
    m_fileView->addAction( m_actionOpen );
    m_fileView->addAction( separator );
    m_fileView->addAction( m_actionProperties );
    m_fileView->addAction( separator );
    m_fileView->addAction( actionCollection->action("project_burn") );
}