Exemplo n.º 1
0
void MainWindow::mkconnections()
{
    connect(bar,SIGNAL(closeClicked()),SLOT(close()));
    connect(bar,SIGNAL(maximizeClicked(bool)),SLOT(showWind(bool)));
    connect(bar,SIGNAL(hideClicked()),SLOT(showMinimized()));
    connect(playlists,SIGNAL(songAdded(QString,QString)),&library,SLOT(addSongInPlaylist(QString,QString)));
    connect(bar,SIGNAL(addFilePressed()),SLOT(addFiles()));
    connect(bar,SIGNAL(addFolderPressed()),SLOT(addFolder()));
    connect(&player,SIGNAL(inPlaylist(bool)),SLOT(changePlayerConnections(bool)));
    connect(&library,SIGNAL(newSong(Song)),table,SLOT(addSongInList(Song)));
    connect(&player,SIGNAL(positionChanged(qint64)),bar,SIGNAL(seekChanged(qint64)));
    connect(&player,SIGNAL(currentSongChanged(Song)),bar,SIGNAL(songChanged(Song)));
    connect(bar,SIGNAL(playClicked()),&player,SLOT(playpause()));
    connect(addFile,SIGNAL(triggered()),SLOT(addFiles()));
    connect(actionAddFolder,SIGNAL(triggered()),SLOT(addFolder()));
    connect(actionOuvrir,SIGNAL(triggered()),SLOT(openFile()));
    connect(bar,SIGNAL(volumeChanged(int)),&player,SLOT(setVolume(int)));
    connect(bar,SIGNAL(positionChanged(int)),&player,SLOT(setPosition(int)));
    connect(bar,SIGNAL(seekBarPressed()),&player,SLOT(pause()));
    connect(bar,SIGNAL(seekBarReleased()),&player,SLOT(play()));
    connect(&player,SIGNAL(playbackStateChanged(bool)),bar,SLOT(changeButton(bool)));
    connect(tree,SIGNAL(albumChosen(QString,QString)),table,SLOT(showSongsFrom(QString,QString)));
    connect(tree,SIGNAL(artistChosen(QString)),table,SLOT(showSongsBy(QString)));
    connect(&library,SIGNAL(libraryChanged(Library*)),tree,SLOT(updateTree(Library*)));
    connect(table,SIGNAL(newPlaylist(Song)),this,SLOT(mkPlaylist(Song)));
    connect(playlists,SIGNAL(playlistChosen(QString)),table,SLOT(showSongsIn(QString)));
    connect(table,SIGNAL(deleteSong(Song,bool)),&library,SLOT(deleteSong(Song,bool)));
    connect(bar,SIGNAL(newQuery(QString,int)),table,SLOT(setQuery(QString,int)));
    connect(bar,SIGNAL(newPlaybackMode(QMediaPlaylist::PlaybackMode)),&player,SLOT(setPlayBackMode(QMediaPlaylist::PlaybackMode)));
    connect(table,SIGNAL(songChosen(int)),&player,SLOT(play(int)));
    connect(table,SIGNAL(newSongList(SongList)),&player,SLOT(update(SongList)));
    connect(&player,SIGNAL(inPlaylist(bool)),bar,SLOT(enableNavigation(bool)));
    connect(bar,SIGNAL(miniLecteur()),&mLecteur,SLOT(show()));
    connect(bar,SIGNAL(miniLecteur()),SLOT(hide()));
    connect(&mLecteur,SIGNAL(windowedMode()),SLOT(show()));
    connect(&mLecteur,SIGNAL(positionChanged(int)),bar,SIGNAL(positionChanged(int)));
    connect(&mLecteur,SIGNAL(seekBarPressed()),bar,SIGNAL(seekBarPressed()));
    connect(&mLecteur,SIGNAL(seekBarReleased()),bar,SIGNAL(seekBarReleased()));
    connect(&mLecteur,SIGNAL(positionChanged(int)),bar,SIGNAL(positionChanged(int)));
    connect(&mLecteur,SIGNAL(playClicked()),bar,SIGNAL(playClicked()));
    connect(&mLecteur,SIGNAL(nextClicked()),bar,SIGNAL(nextClicked()));
    connect(&mLecteur,SIGNAL(previousClicked()),bar,SIGNAL(previousClicked()));
    connect(&mLecteur,SIGNAL(volumeChanged(int)),bar,SIGNAL(volumeChanged(int)));
    connect(&player,SIGNAL(currentSongChanged(Song)),&mLecteur,SLOT(setNewSong(Song)));
    connect(&player,SIGNAL(positionChanged(qint64)),&mLecteur,SLOT(setPosition(qint64)));
    connect(&player,SIGNAL(playbackStateChanged(bool)),&mLecteur,SLOT(changeButton(bool)));
    connect(&player,SIGNAL(indexChanged(int,int)),table,SLOT(setIconTo(int,int)));
    connect(table,SIGNAL(addFileTriggered()),SLOT(addFiles()));
    connect(table,SIGNAL(addFolderTriggered()),SLOT(addFolder()));

}
Exemplo n.º 2
0
void SearchListView::onCustomContextMenu(const QPoint &pos)
{
    QModelIndex index = ui->bookmarks->indexAt(pos);
    TreeItem *item = model()->getItem(index);
    if (index.isValid())
    {
        QAction *action = NULL;

        switch(item->getType())
        {
        case ModelUtil::Folder:
            {
                // Context menu for folders
                QMenu *contextMenu = new QMenu(this);

                contextMenu->addAction(ui->actionAddBookmark);
                contextMenu->addAction(ui->actionRemoveBookmark);
                contextMenu->addSeparator();
                contextMenu->addAction(ui->actionAddFolder);
                contextMenu->addAction(ui->actionRemoveFolder);

                action = contextMenu->exec(ui->bookmarks->mapToGlobal(pos));

                break;
            }
        case ModelUtil::Link:
            {
                // Context menu for links
                QMenu *contextMenu = new QMenu(this);
                contextMenu->addAction(ui->actionAddBookmark);
                contextMenu->addAction(ui->actionRemoveBookmark);
                action = contextMenu->exec(ui->bookmarks->mapToGlobal(pos));

                // New bookmark will be created in same folder!
                index = index.parent();

                break;
            }
        default:
            break;
        }

        if(action == ui->actionAddBookmark)
        {
            emit addBookmark(index);
        }
        else if(action == ui->actionRemoveBookmark)
        {
            emit removeBookmark(index);
        }
        else if(action == ui->actionAddFolder)
        {
            emit addFolder(index);
        }
        else if(action == ui->actionRemoveFolder)
        {
            emit removeFolder(index);
        }
    }
}
Exemplo n.º 3
0
QMenu* VlcWidget::GenerateMenuForOpenAction ()
{
    QMenu *result = new QMenu;

    connect (result->addAction (tr ("Open file")),
             SIGNAL (triggered ()),
             this,
             SLOT (addFiles ()));

    connect (result->addAction (tr ("Open folder")),
             SIGNAL (triggered ()),
             this,
             SLOT (addFolder ()));

    connect (result->addAction (tr ("Open URL")),
             SIGNAL (triggered ()),
             this,
             SLOT (addUrl ()));

    connect (result->addAction (tr ("Open DVD")),
             SIGNAL (triggered ()),
             this,
             SLOT (addDVD ()));

    connect (result->addAction (tr ("Open Simple DVD")),
             SIGNAL (triggered ()),
             this,
             SLOT (addSimpleDVD ()));

    return result;
}
Exemplo n.º 4
0
LanguageManager::LanguageManager() : m_invariant(OS_NEW LanguageCulture()),
    m_root(OS_NEW LanguageFolder())
{
    addFolder(m_root);

    m_dumpKey = false;
}
Exemplo n.º 5
0
void addtoPlaylist(struct filelist *dir_list[],
		struct playlist *play_list[],
		int explorer_item,
		char current_dir[],
		int *max_playlist_item)
/*! \brief Adds selected file of folder to playlist
 *
 * \param dir_list current directory structure
 * \param play_list current playlist structure
 * \param explorer_item selected item in explorer window
 * \param current_dir current directory :)
 * \param max_playlist_item the last playlist item
 */

{
	if (dir_list[explorer_item]->f_type == 'm') {
		(*max_playlist_item)++;
		addFile(play_list,dir_list,current_dir,*max_playlist_item,explorer_item);
	}
		
	if (dir_list[explorer_item]->f_type == 'd') {
		char tmp[MAX_FILE_NAME];
		strcpy(tmp,current_dir);
		strcat(tmp,dir_list[explorer_item]->f_name);
		strcat(tmp,"/");
		addFolder(tmp, play_list, max_playlist_item);
	}
}
Exemplo n.º 6
0
//Add folder to playlist
void addFolder(char dir[], 
		struct playlist *play_list[], 
		int *max_item)
/*! \brief Adds all files in folder and subfolders to playlist recurcevely
 *
 * \param dir path to the directory to add
 * \param play_list array of pointers to playlist items
 * \param max_item the number of the last playlist item
 */
{
	int num, i;
	struct filelist *list[MAX_LIST];
	num = listDir(dir, list);
	for (i=0; i<=num; i++) {
		if ( list[i]->f_type == 'm' ) {
			if ((*max_item)<MAX_LIST-1) 
				(*max_item)++;
			else
				break;
			addFile(play_list, list, dir,*max_item,i);
		}

		if ( list[i]->f_type == 'd' ) {
			char tmp[MAX_FILE_NAME];
			strcpy(tmp,dir);
			strcat(tmp,list[i]->f_name);
			strcat(tmp,"/");
			addFolder(tmp, play_list, max_item);
		}
	}
}
Exemplo n.º 7
0
void EditorObject::loadFromSettings()
{
  QSettings& settings = EditorModule::application->getLayoutSettings();
  int count = 1;
  for(int i = 0; i < count; ++i)
  {
    count = settings.beginReadArray(fullName);
    if(i >= count)
    {
      settings.endArray();
      break;
    }
    settings.setArrayIndex(i);
    QString filePath = settings.value("filePath").toString();
    if(filePath.isEmpty())
    {
      QString name = settings.value("name").toString();
      settings.endArray();
      ((EditorObject*)addFolder(name))->loadFromSettings();
    }
    else
    {
      QString subFileRegExpPattern = settings.value("subFileRegExpPattern").toString();
      settings.endArray();
      ((EditorObject*)addEditor(filePath, subFileRegExpPattern, false))->loadFromSettings();
    }
  }
}
Exemplo n.º 8
0
void KNCollectionView::addFolder(KNFolder *f)
{
    KNCollectionViewItem *it;

    if(!f->parent())
    {
        // root folder
        it = new KNCollectionViewItem(this, KFolderTreeItem::Local);
    }
    else
    {
        // make sure the parent folder has already been added
        if(!f->parent()->listItem())
            addFolder(static_cast<KNFolder *>(f->parent()));
        // handle special folders
        KFolderTreeItem::Type type = KFolderTreeItem::Other;
        switch(f->id())
        {
            case 1:
                type = KFolderTreeItem::Drafts;
                break;
            case 2:
                type = KFolderTreeItem::Outbox;
                break;
            case 3:
                type = KFolderTreeItem::SentMail;
                break;
        }
        it = new KNCollectionViewItem(f->parent()->listItem(), KFolderTreeItem::Local, type);
    }
    f->setListItem(it);
    updateFolder(f);
}
Exemplo n.º 9
0
QStandardItem * NotesItemView::addFolder(const QString &id, const QString &title, const QString &parentID)
{
    QStandardItem *parentItem;
    if(parentID.isEmpty()) {
        parentItem = m_itemModel->invisibleRootItem();
    } else {
        parentItem = find(parentID);
    }
    return addFolder(id,title,parentItem);
}
Exemplo n.º 10
0
void ProjectPanel::recursiveAddFilesFrom(const TCHAR *folderPath, HTREEITEM hTreeItem)
{
    bool isRecursive = true;
    bool isInHiddenDir = false;
    generic_string dirFilter(folderPath);
    if (folderPath[lstrlen(folderPath)-1] != '\\')
        dirFilter += TEXT("\\");

    dirFilter += TEXT("*.*");
    WIN32_FIND_DATA foundData;
    std::vector<generic_string> files;

    HANDLE hFile = ::FindFirstFile(dirFilter.c_str(), &foundData);

    do {
        if (hFile == INVALID_HANDLE_VALUE)
            break;

        if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            if (!isInHiddenDir && (foundData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
            {
                // do nothing
            }
            else if (isRecursive)
            {
                if ((lstrcmp(foundData.cFileName, TEXT("."))) && (lstrcmp(foundData.cFileName, TEXT(".."))))
                {
                    generic_string pathDir(folderPath);
                    if (folderPath[lstrlen(folderPath)-1] != '\\')
                        pathDir += TEXT("\\");
                    pathDir += foundData.cFileName;
                    pathDir += TEXT("\\");
                    HTREEITEM addedItem = addFolder(hTreeItem, foundData.cFileName);
                    recursiveAddFilesFrom(pathDir.c_str(), addedItem);
                }
            }
        }
        else
        {
            files.push_back(foundData.cFileName);
        }
    } while (::FindNextFile(hFile, &foundData));

    for (size_t i = 0, len = files.size() ; i < len ; ++i)
    {
        generic_string pathFile(folderPath);
        if (folderPath[lstrlen(folderPath)-1] != '\\')
            pathFile += TEXT("\\");
        pathFile += files[i];
        _treeView.addItem(files[i].c_str(), hTreeItem, INDEX_LEAF, pathFile.c_str());
    }

    ::FindClose(hFile);
}
Exemplo n.º 11
0
void KNCollectionView::addPendingFolders()
{
    QValueList<KNFolder *> folders = knGlobals.folderManager()->folders();
    for(QValueList<KNFolder *>::Iterator it = folders.begin(); it != folders.end(); ++it)
        if(!(*it)->listItem())
            addFolder((*it));
    // now open the folders if they were open in the last session
    for(QValueList<KNFolder *>::Iterator it = folders.begin(); it != folders.end(); ++it)
        if((*it)->listItem())
            (*it)->listItem()->setOpen((*it)->wasOpen());
}
Exemplo n.º 12
0
bool RegularBackup::Compare() {
    FileTree ft_bkp = GetFileTree();

    while(b->c.IsNextBackupDirectory()) {
        addFolder(b->c.GetNextBackupDirectory(), true, false);
    }

    ft_bkp.compare(&ft);
    ft_bkp.printChanges(&ft);
    return true;
}
Exemplo n.º 13
0
void BookmarksSideBar::changeFolderParent(const QString &name, bool isSubfolder)
{
    if (isSubfolder) { // folder moved to _bookmarksToolbar as a subfolder
        removeFolder(name);
    }
    else {
        addFolder(name);
        QVector<Bookmark> bookmarksList = m_bookmarksModel->folderBookmarks(name);
        foreach (const Bookmark &b, bookmarksList) {
            addBookmark(b);
        }
    }
Exemplo n.º 14
0
QT_BEGIN_NAMESPACE

BookmarkDialog::BookmarkDialog(BookmarkModel *sourceModel, const QString &title,
        const QString &url, QWidget *parent)
    : QDialog(parent)
    , m_url(url)
    , m_title(title)
    , bookmarkModel(sourceModel)
{
    TRACE_OBJ
    ui.setupUi(this);

    ui.bookmarkEdit->setText(m_title);
    ui.newFolderButton->setVisible(false);
    ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);

    connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(accepted()));
    connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(rejected()));
    connect(ui.newFolderButton, SIGNAL(clicked()), this, SLOT(addFolder()));
    connect(ui.toolButton, SIGNAL(clicked()), this, SLOT(toolButtonClicked()));
    connect(ui.bookmarkEdit, SIGNAL(textChanged(QString)), this,
        SLOT(textChanged(QString)));

    bookmarkProxyModel = new BookmarkFilterModel(this);
    bookmarkProxyModel->setSourceModel(bookmarkModel);
    ui.bookmarkFolders->setModel(bookmarkProxyModel);
    connect(ui.bookmarkFolders, SIGNAL(currentIndexChanged(int)), this,
        SLOT(currentIndexChanged(int)));

    bookmarkTreeModel = new BookmarkTreeModel(this);
    bookmarkTreeModel->setSourceModel(bookmarkModel);
    ui.treeView->setModel(bookmarkTreeModel);

    ui.treeView->expandAll();
    ui.treeView->setVisible(false);
    ui.treeView->installEventFilter(this);
    ui.treeView->viewport()->installEventFilter(this);
    ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(ui.treeView, SIGNAL(customContextMenuRequested(QPoint)), this,
        SLOT(customContextMenuRequested(QPoint)));
    connect(ui.treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,
        QModelIndex)), this, SLOT(currentIndexChanged(QModelIndex)));

    ui.bookmarkFolders->setCurrentIndex(0);
    ui.treeView->setCurrentIndex(ui.treeView->indexAt(QPoint(2, 2)));

    const HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
    if (helpEngine.usesAppFont())
        setFont(helpEngine.appFont());
}
Exemplo n.º 15
0
CommandListTree::CommandListTree(QWidget* parent)
	: QTreeWidget(parent)
{
	setObjectName("SolidLineFrame");
	setAlternatingRowColors(true);
	setDragEnabled(true);
	setDragDropMode(QAbstractItemView::DragOnly);
	setColumnCount(1);
	header()->close();

	QIcon menuFolderIcon(":Resources/browser_project_close.png");
	menuFolderIcon.addFile(":Resources/browser_project_open.png", QSize(), QIcon::Normal, QIcon::On);
	invisibleRootItem()->setIcon(0, menuFolderIcon);

	QTreeWidgetItem *menuCommandFolder = new QTreeWidgetItem(this); 
	menuCommandFolder->setFlags( Qt::ItemIsEnabled );
	menuCommandFolder->setText(0, ShortcutTree::tr("Menu Commands"));
	menuCommandFolder->setExpanded(true);
	menuCommandFolder->setIcon(0,invisibleRootItem()->icon(0));

	addFolder(ShortcutTree::tr("File"), MenuFileCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("Edit"), MenuEditCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("Scan & Cleanup"), MenuScanCleanupCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("Level"), MenuLevelCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("Xsheet"), MenuXsheetCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("Cells"), MenuCellsCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("View"), MenuViewCommandType, menuCommandFolder);
	addFolder(ShortcutTree::tr("Windows"), MenuWindowsCommandType, menuCommandFolder);

	addFolder(ShortcutTree::tr("Tools"), ToolCommandType);

	MenuBarSeparatorItem* sep = new MenuBarSeparatorItem(0);
	sep->setToolTip(0, QObject::tr("[Drag&Drop] to copy separator to menu bar"));
	addTopLevelItem(sep);

}
Exemplo n.º 16
0
void NotesItemView::create(const QString &id, QStandardItem *parentItem)
{
    //DEBUG_FUNC_NAME
    foreach(const QString & i, m_idC) {
        if(id == "-1") {
            parentItem = m_itemModel->invisibleRootItem();
        }
        if((id == "-1" && m_notes->getRef(i, "parent").isEmpty()) || m_notes->getRef(i, "parent") == id) {
            if(m_notes->getType(i) == "text") {
                QStandardItem *noteItem = addNote(i, m_notes->getTitle(i), parentItem);
                create(i, noteItem);
            } else if(m_notes->getType(i) == "folder") {
                QStandardItem *folderItem = addFolder(i, m_notes->getTitle(i), parentItem);
                create(i, folderItem);
            }
        }

    }
}
Exemplo n.º 17
0
void BookmarksManager::createContextMenu(const QPoint &pos)
{
    QMenu menu;
    QAction* actNewTab = menu.addAction(QIcon::fromTheme("tab-new", QIcon(":/icons/menu/tab-new.png")), tr("Open in new tab"));
    QAction* actNewWindow = menu.addAction(QIcon::fromTheme("window-new"), tr("Open in new window"));
    QAction* actNewPrivateWindow = menu.addAction(QIcon(":icons/locationbar/privatebrowsing.png"), tr("Open in new private window"));

    menu.addSeparator();
    menu.addAction(tr("New Bookmark"), this, SLOT(addBookmark()));
    menu.addAction(tr("New Folder"), this, SLOT(addFolder()));
    menu.addAction(tr("New Separator"), this, SLOT(addSeparator()));
    menu.addSeparator();
    QAction* actDelete = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));

    connect(actNewTab, SIGNAL(triggered()), this, SLOT(openBookmarkInNewTab()));
    connect(actNewWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewWindow()));
    connect(actNewPrivateWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewPrivateWindow()));
    connect(actDelete, SIGNAL(triggered()), this, SLOT(deleteBookmarks()));

    bool canBeDeleted = false;
    QList<BookmarkItem*> items = ui->tree->selectedBookmarks();

    foreach (BookmarkItem* item, items) {
        if (m_bookmarks->canBeModified(item)) {
            canBeDeleted = true;
            break;
        }
    }

    if (!canBeDeleted) {
        actDelete->setDisabled(true);
    }

    if (!m_selectedBookmark || !m_selectedBookmark->isUrl()) {
        actNewTab->setDisabled(true);
        actNewWindow->setDisabled(true);
        actNewPrivateWindow->setDisabled(true);
    }

    menu.exec(pos);
}
Exemplo n.º 18
0
SharedFoldersWidget::SharedFoldersWidget(QWidget *parent)
	:QWidget(parent)
	,client(nullptr)
	,api(nullptr)
{
	setupUi(this);

	foldersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);

	QTimer *updateTimer = new QTimer(this);
	updateTimer->setInterval(2000);
	updateTimer->start();

	connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTick()));

	connect(addButton, SIGNAL(clicked()), this, SLOT(addFolder()));
	connect(removeButton, SIGNAL(clicked()), this, SLOT(removeFolder()));
	connect(infoButton, SIGNAL(clicked()), this, SLOT(folderInfo()));

	connect(foldersTable, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(itemDoubleClicked(QTableWidgetItem*)));
}
Exemplo n.º 19
0
void widget::setExistingDirectory()

{  //选择一个文件夹;

    QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly;

//    if (!native->isChecked())
//        options |= QFileDialog::DontUseNativeDialog;

    QString initialName=QDir::homePath();
    QString directory = QFileDialog::getExistingDirectory(this,
                                tr("QFileDialog::getExistingDirectory()"),
                                initialName,
                                options);

    if (!directory.isEmpty()){
        addFolder(directory);
    }

        //directoryLabel->setText(directory);
}
Exemplo n.º 20
0
BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent)
    : QWidget(parent)
    , m_isRefreshing(false)
    , ui(new Ui::BookmarksSideBar)
    , p_QupZilla(mainClass)
    , m_bookmarksModel(mApp->bookmarksModel())
{
    ui->setupUi(this);
    ui->bookmarksTree->setViewType(BookmarksTree::SideBarView);

    ui->bookmarksTree->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->bookmarksTree->setDragDropReceiver(true, m_bookmarksModel);
    ui->bookmarksTree->setMimeType(QLatin1String("application/qupzilla.treewidgetitem.bookmarks"));

    ui->expandAll->setIcon(QIcon::fromTheme("view-sort-ascending", QIcon(":/icons/faenza/expand.png")));
    ui->collapseAll->setIcon(QIcon::fromTheme("view-sort-descending", QIcon(":/icons/faenza/collapse.png")));

    ui->bookmarksTree->setDefaultItemShowMode(TreeWidget::ItemsExpanded);
    connect(ui->bookmarksTree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
    connect(ui->bookmarksTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
    connect(ui->bookmarksTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
    connect(ui->bookmarksTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
    connect(ui->search, SIGNAL(textChanged(QString)), ui->bookmarksTree, SLOT(filterString(QString)));
    connect(ui->collapseAll, SIGNAL(clicked()), ui->bookmarksTree, SLOT(collapseAll()));
    connect(ui->expandAll, SIGNAL(clicked()), ui->bookmarksTree, SLOT(expandAll()));

    connect(m_bookmarksModel, SIGNAL(bookmarkAdded(BookmarksModel::Bookmark)), this, SLOT(addBookmark(BookmarksModel::Bookmark)));
    connect(m_bookmarksModel, SIGNAL(bookmarkDeleted(BookmarksModel::Bookmark)), this, SLOT(removeBookmark(BookmarksModel::Bookmark)));
    connect(m_bookmarksModel, SIGNAL(bookmarkEdited(BookmarksModel::Bookmark,BookmarksModel::Bookmark)),
            this, SLOT(bookmarkEdited(BookmarksModel::Bookmark,BookmarksModel::Bookmark)));
    connect(m_bookmarksModel, SIGNAL(folderAdded(QString)), this, SLOT(addFolder(QString)));
    connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(removeFolder(QString)));
    connect(m_bookmarksModel, SIGNAL(folderRenamed(QString,QString)), this, SLOT(renameFolder(QString,QString)));
    connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString,bool)), this, SLOT(changeFolderParent(QString,bool)));
    connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString,QByteArray,int,QUrl,QString,QString)),
            this, SLOT(changeBookmarkParent(QString,QByteArray,int,QUrl,QString,QString)));

    QTimer::singleShot(0, this, SLOT(refreshTable()));
}
Exemplo n.º 21
0
void CWizFolderView::initFolders()
{
    CWizCategoryViewAllFoldersItem* pAllFoldersItem = new CWizCategoryViewAllFoldersItem(m_app, tr("Note Folders"), m_dbMgr.db().kbGUID());
    addTopLevelItem(pAllFoldersItem);

    CWizStdStringArray arrayAllLocation;
    m_dbMgr.db().GetAllLocations(arrayAllLocation);

    initFolders(pAllFoldersItem, "", arrayAllLocation);

    if (arrayAllLocation.empty()) {
        const QString strNotes("/My Notes/");
        m_dbMgr.db().AddExtraFolder(strNotes);
        m_dbMgr.db().SetObjectVersion("folder", 0);
        arrayAllLocation.push_back(strNotes);
    }

    //init extra folders
    CWizStdStringArray arrayExtLocation;
    m_dbMgr.db().GetExtraFolder(arrayExtLocation);

    CWizStdStringArray::const_iterator it;
    for (it = arrayExtLocation.begin(); it != arrayExtLocation.end(); it++) {
        QString strLocation = *it;

        if (strLocation.isEmpty())
            continue;

        if (m_dbMgr.db().IsInDeletedItems(strLocation))
            continue;

        addFolder(strLocation, true);
    }

    pAllFoldersItem->setExpanded(true);
    pAllFoldersItem->sortChildren(0, Qt::AscendingOrder);
}
Exemplo n.º 22
0
void QtSE::fsProjectTreeContextMenu( QPoint point )
{
	activeProjectItem = (CProjectTreeItem*)fsProjectTree->itemAt( point );

	if( activeProjectItem )
	{
		QMenu *menu = new QMenu();
		menu->setAttribute( Qt::WA_DeleteOnClose , true );

		switch( activeProjectItem->getPartType() )
		{
			case CProjectTreeItem::dir:
			{
				//activeFilePath.clear();
				//activeProjectItem->getRelativePath( activeFilePath );
				//activeFilePath.prepend( projectPath.getPath( true ) );

				menu->addAction( "Add Folder" , this , SLOT(addFolder()) );
				menu->addSeparator();
				menu->addAction( "Add Stage" , this , SLOT(addStage()) );
				menu->addAction( "Add Framebuffer" , this , SLOT(addFramebuffer()) );
				menu->addAction( "Add Shader" , this , SLOT(addShader()) );
				menu->addAction( "Add Model" , this , SLOT(addModel()) );
				menu->addAction( "Add Texture" , this , SLOT(addTexture()) );
				menu->addSeparator();
				menu->addAction( "Delete Folder" , this , SLOT(deleteItem()) );
				break;
			}
			default:
				delete menu;
				return;
		}

		menu->popup( QCursor::pos() , NULL );
	}
}
Exemplo n.º 23
0
MailClient::MailClient()
{
    QIcon folderIcon(style()->standardPixmap(QStyle::SP_DirClosedIcon));
    QIcon trashIcon(style()->standardPixmap(QStyle::SP_FileIcon));

    QStringList folderLabels;
    folderLabels << tr("Folders");

    foldersTreeWidget = new QTreeWidget;
    foldersTreeWidget->setHeaderLabels(folderLabels);
    addFolder(folderIcon, tr("Inbox"));
    addFolder(folderIcon, tr("Outbox"));
    addFolder(folderIcon, tr("Sent"));
    addFolder(trashIcon, tr("Trash"));

    QStringList messageLabels;
    messageLabels << tr("Subject") << tr("Sender") << tr("Date");

    messagesTreeWidget = new QTreeWidget;
    messagesTreeWidget->setHeaderLabels(messageLabels);
    addMessage(tr("Happy New Year!"),
               tr("Grace K. <*****@*****.**>"),
               tr("2006-12-31"));
    addMessage(tr("Radically new concept!"),
               tr("Grace K. <*****@*****.**>"),
               tr("2006-12-22"));
    addMessage(tr("Accounts"),
               tr("*****@*****.**"),
               tr("2006-12-31"));
    addMessage(tr("Expenses"),
               tr("Joe Bloggs <*****@*****.**>"),
               tr("2006-12-25"));
    addMessage(tr("Re: Expenses"),
               tr("Andy <*****@*****.**>"),
               tr("2007-01-02"));
    addMessage(tr("Re: Accounts"),
               tr("Joe Bloggs <*****@*****.**>"),
               tr("2007-01-03"));
    addMessage(tr("Re: Accounts"),
               tr("Andy <*****@*****.**>"),
               tr("2007-01-03"));
    messagesTreeWidget->resizeColumnToContents(0);
    messagesTreeWidget->resizeColumnToContents(1);

    textEdit = new QTextEdit;
    textEdit->setReadOnly(true);
    textEdit->setHtml("<table bolder=0>"
                      "<tr><td align=right><b>Subject:</b>"
                      "<td><p>Happy New Year!"
                      "<tr><td align=right><b>Date:</b>"
                      "<td><p>Sun, 31 Dec 2006"
                      "<tr><td align=right><b>From:</b>"
                      "<td><p>Grace K. &lt;[email protected]&gt;"
                      "<tr><td align=right><b>To:</b>"
                      "<td>[email protected]"
                      "</table>"
                      "<br>I want to seize this occasion to thank "
                      "everybody for the year that has gone, and want "
                      "to wish you the best for next year. It has been "
                      "a pleasure to work with you all on the Hawk "
                      "project, and I'm sure we'll get concrete "
                      "results shortly."
                      "<br><br>Happy New Year!"
                      "<br>--Grace");

    menuBar()->addMenu(tr("&File"));
    menuBar()->addMenu(tr("&Edit"));
    menuBar()->addMenu(tr("&View"));
    menuBar()->addMenu(tr("F&older"));
    menuBar()->addMenu(tr("&Message"));
    menuBar()->addMenu(tr("&Settings"));
    menuBar()->addMenu(tr("&Help"));
    statusBar()->showMessage(tr("No new messages on server"));

    rightSplitter = new QSplitter(Qt::Vertical);
    rightSplitter->addWidget(messagesTreeWidget);
    rightSplitter->addWidget(textEdit);
    rightSplitter->setStretchFactor(1, 1);

    mainSplitter = new QSplitter(Qt::Horizontal);
    mainSplitter->addWidget(foldersTreeWidget);
    mainSplitter->addWidget(rightSplitter);
    mainSplitter->setStretchFactor(1, 1);
    setCentralWidget(mainSplitter);

    setWindowTitle(tr("Mail Client"));
    readSettings();
}
Exemplo n.º 24
0
void ProjectPanel::popupMenuCmd(int cmdID)
{
    // get selected item handle
    HTREEITEM hTreeItem = _treeView.getSelection();
    if (!hTreeItem)
        return;

    switch (cmdID)
    {
    //
    // Toolbar menu buttons
    //
    case IDB_PROJECT_BTN:
    {
        POINT p = getMenuDisplayPoint(0);
        TrackPopupMenu(_hWorkSpaceMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL);
    }
    break;

    case IDB_EDIT_BTN:
    {
        POINT p = getMenuDisplayPoint(1);
        HMENU hMenu = NULL;
        NodeType nodeType = getNodeType(hTreeItem);
        if (nodeType == nodeType_project)
            hMenu = _hProjectMenu;
        else if (nodeType == nodeType_folder)
            hMenu = _hFolderMenu;
        else if (nodeType == nodeType_file)
            hMenu = _hFileMenu;
        if (hMenu)
            TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL);
    }
    break;

    //
    // Toolbar menu commands
    //
    case IDM_PROJECT_NEWPROJECT :
    {
        HTREEITEM root = _treeView.getRoot();

        NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
        generic_string newProjectLabel = pNativeSpeaker->getAttrNameStr(PM_NEWPROJECTNAME, "ProjectManager", "NewProjectName");
        HTREEITEM addedItem = _treeView.addItem(newProjectLabel.c_str(),  root, INDEX_PROJECT);
        setWorkSpaceDirty(true);
        _treeView.expand(hTreeItem);
        TreeView_EditLabel(_treeView.getHSelf(), addedItem);
    }
    break;

    case IDM_PROJECT_NEWWS :
    {
        if (_isDirty)
        {
            int res = ::MessageBox(_hSelf, TEXT("The current workspace was modified. Do you want to save the current project?"), TEXT("New Workspace"), MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL);
            if (res == IDYES)
            {
                if (!saveWorkSpace())
                    return;
            }
            else if (res == IDNO)
            {
                // Don't save so do nothing here
            }
            else if (res == IDCANCEL)
            {
                // User cancels action "New Workspace" so we interrupt here
                return;
            }
        }
        _treeView.removeAllItems();
        newWorkSpace();
    }
    break;

    case IDM_PROJECT_RENAME :
        TreeView_EditLabel(_treeView.getHSelf(), hTreeItem);
        break;

    case IDM_PROJECT_NEWFOLDER :
    {
        NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
        generic_string newFolderLabel = pNativeSpeaker->getAttrNameStr(PM_NEWFOLDERNAME, "ProjectManager", "NewFolderName");
        addFolder(hTreeItem, newFolderLabel.c_str());
        setWorkSpaceDirty(true);
    }
    break;

    case IDM_PROJECT_MOVEDOWN :
    {
        if (_treeView.moveDown(hTreeItem))
            setWorkSpaceDirty(true);
    }
    break;

    case IDM_PROJECT_MOVEUP :
    {
        if (_treeView.moveUp(hTreeItem))
            setWorkSpaceDirty(true);
    }
    break;

    case IDM_PROJECT_ADDFILES :
    {
        addFiles(hTreeItem);
        if (getNodeType(hTreeItem) == nodeType_folder)
            _treeView.setItemImage(hTreeItem, INDEX_OPEN_NODE, INDEX_OPEN_NODE);
    }
    break;

    case IDM_PROJECT_ADDFILESRECUSIVELY :
    {
        addFilesFromDirectory(hTreeItem);
        if (getNodeType(hTreeItem) == nodeType_folder)
            _treeView.setItemImage(hTreeItem, INDEX_OPEN_NODE, INDEX_OPEN_NODE);
    }
    break;

    case IDM_PROJECT_OPENWS:
    {
        if (_isDirty)
        {
            int res = ::MessageBox(_hSelf, TEXT("The current workspace was modified. Do you want to save the current project?"), TEXT("Open Workspace"), MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL);
            if (res == IDYES)
            {
                if (!saveWorkSpace())
                    return;
            }
            else if (res == IDNO)
            {
                // Don't save so do nothing here
            }
            else if (res == IDCANCEL)
            {
                // User cancels action "New Workspace" so we interrupt here
                return;
            }
        }

        FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL));
        fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
        if (TCHAR *fn = fDlg.doOpenSingleFileDlg())
        {
            if (!openWorkSpace(fn))
            {
                ::MessageBox(_hSelf, TEXT("The workspace could not be opened.\rIt seems the file to open is not a valid project file."), TEXT("Open Workspace"), MB_OK);
                return;
            }
        }
    }
    break;

    case IDM_PROJECT_RELOADWS:
    {
        if (_isDirty)
        {
            int res = ::MessageBox(_hSelf, TEXT("The current workspace was modified. Reloading will discard all modifications.\rDo you want to continue?"), TEXT("Reload Workspace"), MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL);
            if (res == IDYES)
            {
                // Do nothing
            }
            else if (res == IDNO)
            {
                return;
            }
        }

        if (::PathFileExists(_workSpaceFilePath.c_str()))
        {
            openWorkSpace(_workSpaceFilePath.c_str());
        }
        else
        {
            ::MessageBox(_hSelf, TEXT("Cannot find the file to reload."), TEXT("Reload Workspace"), MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
        }
    }
    break;

    case IDM_PROJECT_SAVEWS:
        saveWorkSpace();
        break;

    case IDM_PROJECT_SAVEACOPYASWS:
    case IDM_PROJECT_SAVEASWS:
    {
        saveWorkSpaceAs(cmdID == IDM_PROJECT_SAVEACOPYASWS);
    }
    break;

    case IDM_PROJECT_DELETEFOLDER :
    {
        HTREEITEM parent = _treeView.getParent(hTreeItem);

        if (_treeView.getChildFrom(hTreeItem) != NULL)
        {
            TCHAR str2display[MAX_PATH] = TEXT("All the sub-items will be removed.\rAre you sure you want to remove this folder from the project?");
            if (::MessageBox(_hSelf, str2display, TEXT("Remove folder from project"), MB_YESNO) == IDYES)
            {
                _treeView.removeItem(hTreeItem);
                setWorkSpaceDirty(true);
            }
        }
        else
        {
            _treeView.removeItem(hTreeItem);
            setWorkSpaceDirty(true);
        }
        if (getNodeType(parent) == nodeType_folder)
            _treeView.setItemImage(parent, INDEX_CLOSED_NODE, INDEX_CLOSED_NODE);
    }
    break;

    case IDM_PROJECT_DELETEFILE :
    {
        HTREEITEM parent = _treeView.getParent(hTreeItem);

        TCHAR str2display[MAX_PATH] = TEXT("Are you sure you want to remove this file from the project?");
        if (::MessageBox(_hSelf, str2display, TEXT("Remove file from project"), MB_YESNO) == IDYES)
        {
            _treeView.removeItem(hTreeItem);
            setWorkSpaceDirty(true);
            if (getNodeType(parent) == nodeType_folder)
                _treeView.setItemImage(parent, INDEX_CLOSED_NODE, INDEX_CLOSED_NODE);
        }
    }
    break;

    case IDM_PROJECT_MODIFYFILEPATH :
    {
        FileRelocalizerDlg fileRelocalizerDlg;
        fileRelocalizerDlg.init(_hInst, _hParent);

        TCHAR textBuffer[MAX_PATH];
        TVITEM tvItem;
        tvItem.hItem = hTreeItem;
        tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
        tvItem.pszText = textBuffer;
        tvItem.cchTextMax = MAX_PATH;

        SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
        if (!tvItem.lParam)
            return;
        generic_string * fn = (generic_string *)tvItem.lParam;

        if (fileRelocalizerDlg.doDialog(fn->c_str()) == 0)
        {
            generic_string newValue = fileRelocalizerDlg.getFullFilePath();
            if (*fn == newValue)
                return;

            *fn = newValue;
            TCHAR *strValueLabel = ::PathFindFileName(fn->c_str());
            lstrcpy(textBuffer, strValueLabel);
            int iImage = ::PathFileExists(fn->c_str())?INDEX_LEAF:INDEX_LEAF_INVALID;
            tvItem.iImage = tvItem.iSelectedImage = iImage;
            SendMessage(_treeView.getHSelf(), TVM_SETITEM, 0,(LPARAM)&tvItem);
            setWorkSpaceDirty(true);
        }
    }
    break;
    }
}
Exemplo n.º 25
0
BookmarksContentsWidget::BookmarksContentsWidget(Window *window) : ContentsWidget(window),
	m_model(new QStandardItemModel(this)),
	m_isLoading(true),
	m_ui(new Ui::BookmarksContentsWidget)
{
	m_ui->setupUi(this);

	QMenu *addMenu = new QMenu(m_ui->addButton);
	addMenu->addAction(Utils::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder()));
	addMenu->addAction(tr("Add Bookmark"), this, SLOT(addBookmark()));
	addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator()));

	m_ui->addButton->setMenu(addMenu);

	QTimer::singleShot(100, this, SLOT(populateBookmarks()));

	connect(m_ui->propertiesButton, SIGNAL(clicked()), this, SLOT(bookmarkProperties()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeBookmark()));
	connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addBookmark()));
}
Exemplo n.º 26
0
ProjectsView::ProjectsView( QObject* parent, QWidget* parentWidget ) : View( parent ),
    m_folderUpdateCounter( 0 ),
    m_updateCounter( 0 ),
    m_sessionExpired( false )
{
    m_systemAdmin = dataManager->currentUserAccess() == AdminAccess;

    QAction* action;

    action = new QAction( IconLoader::icon( "file-reload" ), tr( "&Update Projects" ), this );
    action->setShortcut( QKeySequence::Refresh );
    connect( action, SIGNAL( triggered() ), this, SLOT( updateProjects() ), Qt::QueuedConnection );
    setAction( "updateProjects", action );

    action = new QAction( IconLoader::icon( "edit-access" ), tr( "&Manage Permissions..." ), this );
    action->setIconText( tr( "Permissions" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( managePermissions() ), Qt::QueuedConnection );
    setAction( "managePermissions", action );

    if ( m_systemAdmin ) {
        action = new QAction( IconLoader::icon( "project-new" ), tr( "Add &Project..." ), this );
        connect( action, SIGNAL( triggered() ), this, SLOT( addProject() ), Qt::QueuedConnection );
        setAction( "addProject", action );
    }

    action = new QAction( IconLoader::icon( "folder-new" ), tr( "Add &Folder..." ), this );
    action->setShortcut( QKeySequence::New );
    connect( action, SIGNAL( triggered() ), this, SLOT( addFolder() ), Qt::QueuedConnection );
    setAction( "addFolder", action );

    action = new QAction( IconLoader::icon( "edit-rename" ), tr( "&Rename Folder..." ), this );
    action->setIconText( tr( "Rename" ) );
    action->setShortcut( tr( "F2" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( editRename() ), Qt::QueuedConnection );
    setAction( "editRename", action );

    action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Delete Folder" ), this );
    action->setIconText( tr( "Delete" ) );
    action->setShortcut( QKeySequence::Delete );
    connect( action, SIGNAL( triggered() ), this, SLOT( editDelete() ), Qt::QueuedConnection );
    setAction( "editDelete", action );

    action = new QAction( IconLoader::icon( "folder-move" ), tr( "&Move Folder..." ), this );
    action->setIconText( tr( "Move" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( moveFolder() ), Qt::QueuedConnection );
    setAction( "moveFolder", action );

    action = new QAction( IconLoader::icon( "project" ), tr( "&Open Project" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openProject() ), Qt::QueuedConnection );
    setAction( "openProject", action );

    action = new QAction( IconLoader::icon( "folder-open" ), tr( "&Open Folder" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openFolder() ), Qt::QueuedConnection );
    setAction( "openFolder", action );

    action = new QAction( IconLoader::icon( "folder-open" ), tr( "&Open List" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openGlobalList() ), Qt::QueuedConnection );
    setAction( "openGlobalList", action );

    action = new QAction( IconLoader::icon( "configure-alerts" ), tr( "&Manage Alerts..." ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( manageAlerts() ), Qt::QueuedConnection );
    setAction( "manageAlerts", action );

    setTitle( "sectionAdd", tr( "Add" ) );
    setTitle( "sectionProjects", tr( "Projects" ) );

    setDefaultMenuAction( "menuProject", "openProject" );
    setDefaultMenuAction( "menuProjectAdmin", "openProject" );
    setDefaultMenuAction( "menuFolder", "openFolder" );
    setDefaultMenuAction( "menuGlobalList", "openGlobalList" );

    loadXmlUiFile( ":/resources/projectsview.xml" );

    m_list = new QTreeView( parentWidget );

    TreeViewHelper helper( m_list );
    helper.initializeView( TreeViewHelper::TreeStyle );

    connect( m_list, SIGNAL( customContextMenuRequested( const QPoint& ) ),
        this, SLOT( contextMenu( const QPoint& ) ) );
    connect( m_list, SIGNAL( doubleClicked( const QModelIndex& ) ),
        this, SLOT( doubleClicked( const QModelIndex& ) ) );

    setMainWidget( m_list );
}
Exemplo n.º 27
0
Config::Config() : _d( new Impl )
{
  _d->extensions << ".smk";
  addFolder( vfs::Directory() );
  addFolder( vfs::Path( ":/smk/" ) );
}
Exemplo n.º 28
0
NotesContentsWidget::NotesContentsWidget(Window *window) : ContentsWidget(window),
	m_ui(new Ui::NotesContentsWidget)
{
	m_ui->setupUi(this);

	QMenu *addMenu(new QMenu(m_ui->addButton));
	addMenu->addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder()));
	addMenu->addAction(tr("Add Note"), this, SLOT(addNote()));
	addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator()));

	m_ui->addButton->setMenu(addMenu);
	m_ui->notesViewWidget->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->notesViewWidget->setModel(NotesManager::getModel());
	m_ui->notesViewWidget->setExpanded(NotesManager::getModel()->getRootItem()->index(), true);
	m_ui->notesViewWidget->setFilterRoles(QSet<int>({BookmarksModel::UrlRole, BookmarksModel::TitleRole, BookmarksModel::DescriptionRole, BookmarksModel::KeywordRole}));
	m_ui->notesViewWidget->viewport()->installEventFilter(this);
	m_ui->notesViewWidget->viewport()->setMouseTracking(true);
	m_ui->filterLineEdit->installEventFilter(this);
	m_ui->textEdit->setPlaceholderText(tr("Add note…"));

	if (!window)
	{
		m_ui->actionsWidget->hide();
	}

	connect(NotesManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeNote()));
	connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addNote()));
	connect(m_ui->textEdit, SIGNAL(textChanged()), this, SLOT(updateText()));
	connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->notesViewWidget, SLOT(setFilterString(QString)));
	connect(m_ui->notesViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openUrl(QModelIndex)));
	connect(m_ui->notesViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
	connect(m_ui->notesViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));
}
Exemplo n.º 29
0
void NotesContentsWidget::showContextMenu(const QPoint &point)
{
	const QModelIndex index(m_ui->notesViewWidget->indexAt(point));
	const BookmarksModel::BookmarkType type(static_cast<BookmarksModel::BookmarkType>(index.data(BookmarksModel::TypeRole).toInt()));
	QMenu menu(this);

	if (type != BookmarksModel::UrlBookmark && type != BookmarksModel::TrashBookmark)
	{
		menu.addAction(getAction(ActionsManager::PasteAction));
		menu.addSeparator();
	}

	if (type == BookmarksModel::TrashBookmark)
	{
		menu.addAction(ThemesManager::getIcon(QLatin1String("trash-empty")), tr("Empty Trash"), NotesManager::getModel(), SLOT(emptyTrash()))->setEnabled(NotesManager::getModel()->getTrashItem()->rowCount() > 0);
	}
	else if (type == BookmarksModel::UnknownBookmark)
	{
		menu.addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder()));
		menu.addAction(tr("Add Bookmark"), this, SLOT(addNote()));
		menu.addAction(tr("Add Separator"), this, SLOT(addSeparator()));
	}
	else
	{
		const bool isInTrash(index.data(BookmarksModel::IsTrashedRole).toBool());

		if (type == BookmarksModel::UrlBookmark)
		{
			menu.addAction(getAction(ActionsManager::CutAction));
			menu.addAction(getAction(ActionsManager::CopyAction));
			menu.addAction(getAction(ActionsManager::PasteAction));
			menu.addSeparator();
		}

		menu.addAction(ThemesManager::getIcon(QLatin1String("document-open")), tr("Open source page"), this, SLOT(openUrl()))->setEnabled(type == BookmarksModel::UrlBookmark && index.data(BookmarksModel::UrlRole).toUrl().isValid());

		if (type != BookmarksModel::RootBookmark)
		{
			Action *copyLinkAction(getAction(ActionsManager::CopyLinkToClipboardAction));
			copyLinkAction->setEnabled(type == BookmarksModel::UrlBookmark && index.data(BookmarksModel::UrlRole).toUrl().isValid());

			menu.addAction(copyLinkAction);
		}

		if (!isInTrash)
		{
			menu.addSeparator();

			QMenu *addMenu(menu.addMenu(tr("Add Note")));
			addMenu->addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder()));
			addMenu->addAction(tr("Add Note"), this, SLOT(addNote()));
			addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator()));
		}

		if (type != BookmarksModel::RootBookmark)
		{
			menu.addSeparator();

			if (isInTrash)
			{
				menu.addAction(tr("Restore Note"), this, SLOT(restoreNote()));
			}
			else
			{
				menu.addAction(getAction(ActionsManager::DeleteAction));
			}
		}
	}

	menu.exec(m_ui->notesViewWidget->mapToGlobal(point));
}
Exemplo n.º 30
0
ShortcutTree::ShortcutTree(QWidget *parent)
	: QTreeWidget(parent)
{

	setObjectName("ShortcutTree");
	setIndentation(14);
	setAlternatingRowColors(true);

	setColumnCount(1);
	header()->close();
	//setStyleSheet("border-bottom:1px solid rgb(120,120,120); border-left:1px solid rgb(120,120,120); border-top:1px solid rgb(120,120,120)");

	QTreeWidgetItem *menuCommandFolder = new QTreeWidgetItem(this);
	menuCommandFolder->setText(0, tr("Menu Commands"));
	addFolder(tr("Fill"), FillCommandType);
	addFolder(tr("File"), MenuFileCommandType, menuCommandFolder);
	addFolder(tr("Edit"), MenuEditCommandType, menuCommandFolder);
	addFolder(tr("Scan & Cleanup"), MenuScanCleanupCommandType, menuCommandFolder);
	addFolder(tr("Level"), MenuLevelCommandType, menuCommandFolder);
	addFolder(tr("Xsheet"), MenuXsheetCommandType, menuCommandFolder);
	addFolder(tr("Cells"), MenuCellsCommandType, menuCommandFolder);
	addFolder(tr("View"), MenuViewCommandType, menuCommandFolder);
	addFolder(tr("Windows"), MenuWindowsCommandType, menuCommandFolder);

	addFolder(tr("Right-click Menu Commands"), RightClickMenuCommandType);

	addFolder(tr("Tools"), ToolCommandType);
	addFolder(tr("Tool Modifiers"), ToolModifierCommandType);
	addFolder(tr("Visualization"), ZoomCommandType);
	addFolder(tr("Misc"), MiscCommandType);
	addFolder(tr("Playback Controls"), PlaybackCommandType);
	addFolder(tr("RGBA Channels"), RGBACommandType);

	sortItems(0, Qt::AscendingOrder);

	connect(
		this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
		this, SLOT(onCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
}