ClipboardBrowser::ClipboardBrowser(QWidget *parent, const ClipboardBrowserSharedPtr &sharedData) : QListView(parent) , m_itemLoader() , m_tabName() , m_lastFiltered(-1) , m(this) , d(this) , m_invalidateCache(false) , m_expireAfterEditing(false) , m_editor(NULL) , m_sharedData(sharedData ? sharedData : ClipboardBrowserSharedPtr(new ClipboardBrowserShared)) , m_loadButton(NULL) , m_searchProgress(NULL) , m_dragTargetRow(-1) , m_dragStartPosition() , m_spinLock(0) , m_scrollSaver() { setLayoutMode(QListView::Batched); setBatchSize(1); setFrameShape(QFrame::NoFrame); setTabKeyNavigation(false); setSelectionMode(QAbstractItemView::ExtendedSelection); setWrapping(false); setLayoutMode(QListView::SinglePass); setEditTriggers(QAbstractItemView::NoEditTriggers); setAlternatingRowColors(true); initSingleShotTimer( &m_timerSave, 30000, this, SLOT(saveItems()) ); initSingleShotTimer( &m_timerScroll, 50 ); initSingleShotTimer( &m_timerUpdate, 10, this, SLOT(doUpdateCurrentPage()) ); initSingleShotTimer( &m_timerFilter, 10, this, SLOT(filterItems()) ); initSingleShotTimer( &m_timerExpire, 0, this, SLOT(expire()) ); // ScrollPerItem doesn't work well with hidden items setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(updateCurrentPage()) ); setAttribute(Qt::WA_MacShowFocusRect, 0); setAcceptDrops(true); connectModelAndDelegate(); }
// Note: the QDesktopViewWidget Class will become it's own widget // so others can easly create there own desktopsor file managers with // only a few lines of code QDesktopViewWidget::QDesktopViewWidget(QWidget *parent) : QListWidget(parent) { // This sets the QDesktopViewWidget(QListWidget) to transparent so that the // desktop wallpaper below it can be seen. Note: the color: white propertiy // needs to be moved to the desktop config file setStyleSheet("QListView {background-color: transparent; color: white;}"); // Note: Need to check if config files exist, if it doesnt we need to // create it. // In the future the below QDesktopViewWidget settings will be wrapped // in this block of code so every aspect of how the desktop looks and feels // can be configured. // Note: Needs to be moved to a class function of it's own //desktopSettings = new QSettings("chipara", "desktop"); //desktopSettings->beginGroup("desktop"); //desktopSettings->endGroup(); // Variouse settings for the QDesktopViewWidget(QListWidget) class setSelectionMode(QAbstractItemView::ExtendedSelection); setViewMode(QListView::IconMode); setSpacing(20); setFlow(QListView::TopToBottom); setMovement(QListView::Snap); setLayoutMode(QListView::Batched); setBatchSize(100); setMovement(QListView::Snap); setIconSize(QSize(48, 48)); setUniformItemSizes(true); setWrapping(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setSortingEnabled(true); setLayoutDirection(Qt::LeftToRight); setSelectionRectVisible(true); setTextElideMode(Qt::ElideMiddle); setDragEnabled(true); setFrameStyle(0); setFrameShape(QFrame::NoFrame); setAutoScroll(true); setResizeMode(QListView::Adjust); // Right Click Desktop Menu menu = new QMenu(this); // Create submenu for Create Document QMenu *viewMenu = menu->addMenu(tr("&View")); QActionGroup *viewGroup = new QActionGroup(this); // Large Icons extraLargeIcons = new QAction(QIcon::fromTheme("folder"), "X-Large Icons", this); extraLargeIcons->setCheckable(true); viewGroup->addAction(extraLargeIcons); viewMenu->addAction(extraLargeIcons); connect(extraLargeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Large Icons largeIcons = new QAction(QIcon::fromTheme("folder"), "Large Icons", this); largeIcons->setCheckable(true); viewGroup->addAction(largeIcons); viewMenu->addAction(largeIcons); connect(largeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Medium Icons mediumIcons = new QAction(QIcon::fromTheme("folder"), "Medium Icons", this); mediumIcons->setCheckable(true); mediumIcons->setChecked(true); viewGroup->addAction(mediumIcons); viewMenu->addAction(mediumIcons); connect(mediumIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Medium Icons smallIcons = new QAction(QIcon::fromTheme("folder"), "Small Icons", this); smallIcons->setCheckable(true); viewGroup->addAction(smallIcons); viewMenu->addAction(smallIcons); connect(smallIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Add a separator to the menu viewMenu->addSeparator(); QActionGroup *layoutGroup = new QActionGroup(this); // Medium Icons leftToRight = new QAction(QIcon::fromTheme("folder"), "Left To Right", this); leftToRight->setCheckable(true); layoutGroup->addAction(leftToRight); viewMenu->addAction(leftToRight); connect(leftToRight, SIGNAL(triggered()), this, SLOT(layoutDirection())); // Medium Icons rightToLeft = new QAction(QIcon::fromTheme("folder"), "Right To Left", this); rightToLeft->setCheckable(true); layoutGroup->addAction(rightToLeft); viewMenu->addAction(rightToLeft); connect(rightToLeft, SIGNAL(triggered()), this, SLOT(layoutDirection())); // Add a separator to the menu viewMenu->addSeparator(); // Sort By Size showIcons = new QAction(QIcon::fromTheme("folder"), "Show Desktop Icons", this); showIcons->setCheckable(true); showIcons->setChecked(true); viewMenu->addAction(showIcons); connect(showIcons, SIGNAL(triggered()), this, SLOT(showDesktopIcons())); // Create submenu for Create Document QMenu *sortMenu = menu->addMenu(tr("&Sort By")); QActionGroup *sortGroup = new QActionGroup(this); // Sort By Name QAction *nameSort = new QAction(QIcon::fromTheme("folder"), "Name", this); nameSort->setCheckable(true); nameSort->setChecked(true); sortGroup->addAction(nameSort); sortMenu->addAction(nameSort); // Sort By Size QAction *sizeSort = new QAction(QIcon::fromTheme("folder"), "Size", this); sizeSort->setCheckable(true); sizeSort->setDisabled(true); sortGroup->addAction(sizeSort); sortMenu->addAction(sizeSort); // Sort By Size QAction *typeSort = new QAction(QIcon::fromTheme("folder"), "Item Type", this); typeSort->setCheckable(true); typeSort->setDisabled(true); sortGroup->addAction(typeSort); sortMenu->addAction(typeSort); // Sort By Size QAction *dateSort = new QAction(QIcon::fromTheme("folder"), "Date Modified", this); dateSort->setCheckable(true); dateSort->setDisabled(true); sortGroup->addAction(dateSort); sortMenu->addAction(dateSort); // Refresh QAction *refresh = new QAction(QIcon::fromTheme("folder"), "Refresh", this); menu->addAction(refresh); // Add a separator to the menu menu->addSeparator(); // Paste QAction *paste = new QAction(QIcon::fromTheme("folder"), "Paste", this); paste->setEnabled(false); menu->addAction(paste); // Paste Shortcut QAction *pasteShortCut = new QAction(QIcon::fromTheme("folder"), "Paste Shortcut", this); pasteShortCut->setEnabled(false); menu->addAction(pasteShortCut); // Add a separator to the menu menu->addSeparator(); // New Menu QMenu *create = menu->addMenu(tr("&New")); // Create Folder QAction *createFolder = new QAction(QIcon::fromTheme("folder"), tr("&Folder"), this); create->addAction(createFolder); createFolder->setIconVisibleInMenu(true); connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder())); // Create Launcher QAction *createLauncher = new QAction(QIcon::fromTheme("application-x-desktop"), tr("&Launcher"), this); create->addAction(createLauncher); createLauncher->setIconVisibleInMenu(true); connect(createLauncher, SIGNAL(triggered()), this, SLOT(createLauncher())); // Create Empty File QAction *createEmptyFile = new QAction(QIcon::fromTheme("text-plain"), tr("&Empty File"), this); create->addAction(createEmptyFile); createEmptyFile->setIconVisibleInMenu(true); connect(createEmptyFile, SIGNAL(triggered()), this, SLOT(createEmptyFile())); // Add a separator to the menu menu->addSeparator(); // Paste QAction *desktopSettings = new QAction(QIcon::fromTheme("preferences-desktop"), "Desktop Settings", this); desktopSettings->setIconVisibleInMenu(true); menu->addAction(desktopSettings); connect(desktopSettings, SIGNAL(triggered()), this, SLOT(execDesktopSettings())); // Right Click Desktop Icon Menu iconMenu = new QIconMenu(this); // desktopDir = new QFileSystemWatcher; desktopDir->addPath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); // dSettings = new QSettings("chipara", "desktop"); dSettings->beginGroup("window"); if (dSettings->value("showIcons") == 1) { showIcons->setChecked(true); } else { showIcons->setChecked(false); } // if (dSettings->value("layoutDirection") == 1) { setLayoutDirection(Qt::LeftToRight); leftToRight->setChecked(true); } else { setLayoutDirection(Qt::RightToLeft); rightToLeft->setChecked(true); } // if (dSettings->value("iconSize") == 1) { this->setIconSize(QSize(128, 128)); extraLargeIcons->setChecked(true); } else if (dSettings->value("iconSize") == 2) { this->setIconSize(QSize(64, 64)); largeIcons->setChecked(true); } else if (dSettings->value("iconSize") == 3) { this->setIconSize(QSize(48, 48)); mediumIcons->setChecked(true); } else if (dSettings->value("iconSize") == 4) { this->setIconSize(QSize(36, 36)); smallIcons->setChecked(true); } populatedDesktop(); dSettings->endGroup(); // Desktop Icon Double Click EventexecDesktopSettings connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(iconClicked(QListWidgetItem*))); connect(desktopDir, SIGNAL(directoryChanged(QString)), this, SLOT(populatedDesktop())); }
ClipboardBrowser::ClipboardBrowser(QWidget *parent, const ClipboardBrowserSharedPtr &sharedData) : QListView(parent) , m_loaded(false) , m_id() , m_lastFilter() , m_update(false) , m( new ClipboardModel(this) ) , d( new ItemDelegate(viewport()) ) , m_timerSave( new QTimer(this) ) , m_timerScroll( new QTimer(this) ) , m_menu( new QMenu(this) ) , m_sharedData(sharedData ? sharedData : ClipboardBrowserSharedPtr(new ClipboardBrowserShared)) { setLayoutMode(QListView::Batched); setBatchSize(1); setFrameShadow(QFrame::Sunken); setTabKeyNavigation(false); setAlternatingRowColors(true); setSelectionMode(QAbstractItemView::ExtendedSelection); setWrapping(false); setLayoutMode(QListView::SinglePass); setEditTriggers(QAbstractItemView::EditKeyPressed); setSpacing(5); m_timerSave->setSingleShot(true); connect( m_timerSave, SIGNAL(timeout()), this, SLOT(saveItems()) ); m_timerScroll->setSingleShot(true); m_timerScroll->setInterval(50); // delegate for rendering and editing items setItemDelegate(d); // set new model QItemSelectionModel *old_model = selectionModel(); setModel(m); delete old_model; connect( d, SIGNAL(editingActive(bool)), SIGNAL(editingActive(bool)) ); connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(rowsRemoved(QModelIndex,int,int)) ); connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)), d, SLOT(rowsInserted(QModelIndex, int, int)) ); connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), d, SLOT(rowsMoved(QModelIndex, int, int, QModelIndex, int)) ); // save if data in model changed connect( m, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(onDataChanged(QModelIndex,QModelIndex)) ); connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(delayedSaveItems()) ); connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(delayedSaveItems()) ); connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), SLOT(delayedSaveItems()) ); // update on change connect( d, SIGNAL(rowSizeChanged(int)), SLOT(onRowSizeChanged(int)) ); connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(updateCurrentPage()) ); connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(updateCurrentPage()) ); connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), SLOT(updateCurrentPage()) ); connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(updateCurrentPage()) ); connect( verticalScrollBar(), SIGNAL(rangeChanged(int,int)), SLOT(updateCurrentPage()), Qt::QueuedConnection ); // ScrollPerItem doesn't work well with hidden items setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setAttribute(Qt::WA_MacShowFocusRect, 0); }
int QListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractItemView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< Movement*>(_v) = movement(); break; case 1: *reinterpret_cast< Flow*>(_v) = flow(); break; case 2: *reinterpret_cast< bool*>(_v) = isWrapping(); break; case 3: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break; case 4: *reinterpret_cast< LayoutMode*>(_v) = layoutMode(); break; case 5: *reinterpret_cast< int*>(_v) = spacing(); break; case 6: *reinterpret_cast< QSize*>(_v) = gridSize(); break; case 7: *reinterpret_cast< ViewMode*>(_v) = viewMode(); break; case 8: *reinterpret_cast< int*>(_v) = modelColumn(); break; case 9: *reinterpret_cast< bool*>(_v) = uniformItemSizes(); break; case 10: *reinterpret_cast< int*>(_v) = batchSize(); break; case 11: *reinterpret_cast< bool*>(_v) = wordWrap(); break; case 12: *reinterpret_cast< bool*>(_v) = isSelectionRectVisible(); break; } _id -= 13; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setMovement(*reinterpret_cast< Movement*>(_v)); break; case 1: setFlow(*reinterpret_cast< Flow*>(_v)); break; case 2: setWrapping(*reinterpret_cast< bool*>(_v)); break; case 3: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break; case 4: setLayoutMode(*reinterpret_cast< LayoutMode*>(_v)); break; case 5: setSpacing(*reinterpret_cast< int*>(_v)); break; case 6: setGridSize(*reinterpret_cast< QSize*>(_v)); break; case 7: setViewMode(*reinterpret_cast< ViewMode*>(_v)); break; case 8: setModelColumn(*reinterpret_cast< int*>(_v)); break; case 9: setUniformItemSizes(*reinterpret_cast< bool*>(_v)); break; case 10: setBatchSize(*reinterpret_cast< int*>(_v)); break; case 11: setWordWrap(*reinterpret_cast< bool*>(_v)); break; case 12: setSelectionRectVisible(*reinterpret_cast< bool*>(_v)); break; } _id -= 13; } else if (_c == QMetaObject::ResetProperty) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 13; } #endif // QT_NO_PROPERTIES return _id; }