Ejemplo n.º 1
0
bool Prefs::updateBookmark(const QString &url, const QString &alias)
{
    bool hasTransaction = db.transaction();
    bool success = removeBookmark(url);

    if (success)
    {
        QSqlQuery query(db);
        query.prepare("INSERT INTO bookmarks(url, alias)VALUES(:url, :alias);");
        query.bindValue(":url", url);
        query.bindValue(":alias", alias);

        success = query.exec();
    }

    if (hasTransaction)
    {
        if (success)
            db.commit();
        else
            db.rollback();
    }

    return success;
}
Ejemplo n.º 2
0
bool BookmarksModel::removeFolder(const QString &name)
{
    if (name == _bookmarksMenu || name == _bookmarksToolbar) {
        return false;
    }

    QSqlQuery query;
    query.prepare("SELECT id FROM bookmarks WHERE folder = ? ");
    query.bindValue(0, name);
    if (!query.exec()) {
        return false;
    }
    while (query.next()) {
        removeBookmark(query.value(0).toInt());
    }

    query.prepare("DELETE FROM folders WHERE name=?");
    query.bindValue(0, name);
    if (!query.exec()) {
        return false;
    }

    query.prepare("DELETE FROM bookmarks WHERE folder=?");
    query.bindValue(0, name);
    if (!query.exec()) {
        return false;
    }

    emit folderDeleted(name);
    mApp->sendMessages(Qz::AM_BookmarksChanged, true);
    return true;
}
bool HelpDialogBase::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: languageChange(); break;
    case 1: init(); break;
    case 2: destroy(); break;
    case 3: addBookmark(); break;
    case 4: currentBookmarkChanged((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 5: currentIndexChanged((QListBoxItem*)static_QUType_ptr.get(_o+1)); break;
    case 6: currentTabChanged((const QString&)static_QUType_QString.get(_o+1)); break;
    case 7: loadIndexFile(); break;
    case 8: currentContentsChanged((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 9: removeBookmark(); break;
    case 10: searchInIndex((const QString&)static_QUType_QString.get(_o+1)); break;
    case 11: showTopic(); break;
    case 12: showTopic((int)static_QUType_int.get(_o+1),(QListBoxItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 13: showSearchHelp(); break;
    case 14: startSearch(); break;
    case 15: showResultPage((QListBoxItem*)static_QUType_ptr.get(_o+1)); break;
    case 16: showResultPage((int)static_QUType_int.get(_o+1),(QListBoxItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 17: showResultPage((int)static_QUType_int.get(_o+1),(QListViewItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 4
0
void BookmarksToolBar::contextMenuRequested(const QPoint &position)
{
    QAction *action = actionAt(position);
    QMenu menu;

    if (action) {
        QVariant variant = action->data();
        Q_ASSERT(variant.canConvert<QModelIndex>());

        QAction *menuAction = 0;

        if (!action->menu()) {
            menuAction = menu.addAction(tr("Open"), this, SLOT(openBookmarkInCurrentTab()));
            menuAction->setData(variant);

            menuAction = menu.addAction(tr("Open in New &Tab"), this, SLOT(openBookmarkInNewTab()));
            menuAction->setData(variant);

            menu.addSeparator();
        }

        menuAction = menu.addAction(tr("Remove"), this, SLOT(removeBookmark()));
        menuAction->setData(variant);

        menu.addSeparator();
    }

    menu.addAction(tr("Add Bookmark..."), this, SLOT(newBookmark()));
    menu.addAction(tr("Add Folder..."), this, SLOT(newFolder()));

    menu.exec(QCursor::pos());
}
Ejemplo n.º 5
0
void BookmarksModel::removeBookmark(int id)
{
    QList<int> list;
    list.append(id);

    return removeBookmark(list);
}
Ejemplo n.º 6
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);
        }
    }
}
Ejemplo n.º 7
0
BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent)
        : QMenu(parent)
        , m_bookmark(new KBookmark(bookmark))
{
    setAttribute(Qt::WA_DeleteOnClose);
    setFixedWidth(350);

    QFormLayout *layout = new QFormLayout(this);

    // Bookmark icon
    QHBoxLayout *hLayout = new QHBoxLayout(this);
    QLabel *bookmarkIcon = new QLabel(this);
    bookmarkIcon->setPixmap(KIcon("bookmarks").pixmap(32, 32));
    hLayout->setSpacing(10);
    hLayout->addWidget(bookmarkIcon);

    // Title
    QVBoxLayout *vLayout = new QVBoxLayout(this);
    QLabel *bookmarkInfo = new QLabel(this);
    bookmarkInfo->setText(i18n("<h4>Edit this Bookmark</h4>"));
    bookmarkInfo->setAlignment(Qt::AlignCenter);
    vLayout->addWidget(bookmarkInfo);

    // Remove button
    QPushButton *removeButton = new QPushButton(this);
    removeButton->setText(i18n("Remove this Bookmark"));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeBookmark()));
    vLayout->addWidget(removeButton);

    hLayout->addLayout(vLayout);
    layout->addItem(hLayout);

    // Bookmark name
    QLabel *nameLabel = new QLabel(this);
    nameLabel->setText(i18n("Name:"));
    m_name = new KLineEdit(this);
    if (m_bookmark->isNull())
    {
        m_name->setEnabled(false);
    }
    else
    {
        m_name->setText(m_bookmark->text());
        m_name->setFocus();
    }
    layout->addRow(nameLabel, m_name);

    // Ok & Cancel buttons
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
    layout->addWidget(buttonBox);

    setLayout(layout);
}
Ejemplo n.º 8
0
/// Adds or removes a bookmark from a given address
/// @param hwnd HWND of the emu window
/// @param address Address of the bookmark
int toggleBookmark(HWND hwnd, uint32 address)
{
	int val = findBookmark(address);
	
	// If there's no bookmark at the given address add one.
	if (val == -1)
	{
		return addBookmark(hwnd, address);
	}
	else // else remove the bookmark
	{
		removeBookmark(val);
		return 0;
	}
}
Ejemplo n.º 9
0
void BookmarksToolBar::contextMenuRequested(const QPoint &position)
{
    QToolButton *button = qobject_cast<QToolButton *>(childAt(position));

    QMenu menu;
    QAction *action;

    if (button) {
        QModelIndex index;
        QVariant variant;

        BookmarkToolButton *bookmarkButton = qobject_cast<BookmarkToolButton *>(button);
        ModelMenu *modelMenu = qobject_cast<ModelMenu *>(button->menu());
        if (modelMenu) {
            index = modelMenu->rootIndex();
            variant.setValue(index);
        } else if (bookmarkButton) {
            index = bookmarkButton->index();
            variant.setValue(index);

            action = menu.addAction(tr("Open"), this, SLOT(openBookmark()));
            action->setData(variant);

            action = menu.addAction(tr("Open in New &Tab"), this, SLOT(openBookmarkInNewTab()));
            action->setData(variant);

            menu.addSeparator();
        }

        if (variant.isValid()) {
            action = menu.addAction(tr("Remove"), this, SLOT(removeBookmark()));
            action->setData(variant);
        }

        menu.addSeparator();
    }

    action = menu.addAction(tr("Add Bookmark..."), this, SLOT(newBookmark()));

    action = menu.addAction(tr("Add Folder..."), this, SLOT(newFolder()));

    menu.exec(QCursor::pos());
}
BookmarksContentsWidget::BookmarksContentsWidget(Window *window) : ContentsWidget(window),
	m_ui(new Ui::BookmarksContentsWidget)
{
	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 Bookmark"), this, SLOT(addBookmark()));
	addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator()));

	QSet<int> filterRoles;
	filterRoles << BookmarksModel::UrlRole << BookmarksModel::TitleRole << BookmarksModel::DescriptionRole << BookmarksModel::KeywordRole;

	QList<QPair<QString, int> > rolesMapping;
	rolesMapping << qMakePair(tr("Title"), BookmarksModel::TitleRole) << qMakePair(tr("Address"), BookmarksModel::UrlRole) << qMakePair(tr("Description"), BookmarksModel::DescriptionRole) << qMakePair(tr("Keyword"), BookmarksModel::KeywordRole) << qMakePair(tr("Added"), BookmarksModel::TimeAddedRole) << qMakePair(tr("Modified"), BookmarksModel::TimeModifiedRole) << qMakePair(tr("Visited"), BookmarksModel::TimeVisitedRole) << qMakePair(tr("Visits"), BookmarksModel::VisitsRole);

	ProxyModel *model(new ProxyModel(BookmarksManager::getModel(), rolesMapping, this));

	m_ui->addButton->setMenu(addMenu);
	m_ui->bookmarksViewWidget->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->bookmarksViewWidget->setModel(model);
	m_ui->bookmarksViewWidget->setExpanded(m_ui->bookmarksViewWidget->model()->index(0, 0), true);
	m_ui->bookmarksViewWidget->setFilterRoles(filterRoles);
	m_ui->bookmarksViewWidget->installEventFilter(this);
	m_ui->bookmarksViewWidget->viewport()->installEventFilter(this);
	m_ui->bookmarksViewWidget->viewport()->setMouseTracking(true);
	m_ui->filterLineEdit->installEventFilter(this);

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

	connect(BookmarksManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions()));
	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()));
	connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->bookmarksViewWidget, SLOT(setFilterString(QString)));
	connect(m_ui->bookmarksViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openBookmark(QModelIndex)));
	connect(m_ui->bookmarksViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
	connect(m_ui->bookmarksViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));
}
Ejemplo n.º 11
0
void ResourcesBrowser::showBookmarksPopupMenu( const QPoint& pos )
{
   QListWidgetItem* clickedItem = m_bookmarks->itemAt( pos );
   if ( !clickedItem )
   {
      // no item was clicked - ignore
      return;
   }

   // create the menu
   QMenu* popupMenu = new QMenu( this );
   {
      QAction* removeBookmarkAction = new RemoveBookmarkAction( QIcon( m_iconsDir + "removeBookmark.png" ), "Remove", this, m_bookmarks, clickedItem );
      connect( removeBookmarkAction, SIGNAL( triggered() ), this, SLOT( removeBookmark() ) );
      popupMenu->addAction( removeBookmarkAction );
   }

   // display the menu
   popupMenu->popup( mapToGlobal( pos ) );
}
Ejemplo n.º 12
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()));
}
Ejemplo n.º 13
0
void BookmarksToolbar::bookmarkEdited(const BookmarksModel::Bookmark &before, const BookmarksModel::Bookmark &after)
{
    if (before.folder == QLatin1String("bookmarksToolbar") && after.folder != QLatin1String("bookmarksToolbar")) {
        // Editing from toolbar folder to other folder -> Remove bookmark
        removeBookmark(before);
    }
    else if (before.folder != QLatin1String("bookmarksToolbar") && after.folder == QLatin1String("bookmarksToolbar")) {
        // Editing from other folder to toolbar folder -> Add bookmark
        addBookmark(after);
    }
    else {
        // Editing bookmark already in toolbar
        for (int i = 0; i < m_layout->count(); i++) {
            ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget());
            if (!button) {
                continue;
            }

            Bookmark book = button->data().value<Bookmark>();

            if (book == before) {
                QString title = after.title;
                if (title.length() > 15) {
                    title.truncate(13);
                    title += "..";
                }

                QVariant v;
                v.setValue<Bookmark>(after);

                button->setText(title);
                button->setData(v);
                button->setIcon(qIconProvider->iconFromImage(after.image));
                button->setToolTip(after.url.toEncoded());
                return;
            }
        }
    }
}
BookmarksContentsWidget::BookmarksContentsWidget(Window *window) : ContentsWidget(window),
	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()));

	QSet<int> filterRoles;
	filterRoles << BookmarksModel::UrlRole << BookmarksModel::TitleRole << BookmarksModel::DescriptionRole << BookmarksModel::KeywordRole;

	m_ui->addButton->setMenu(addMenu);
	m_ui->bookmarksViewWidget->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->bookmarksViewWidget->setModel(BookmarksManager::getModel());
	m_ui->bookmarksViewWidget->setItemDelegate(new ItemDelegate(this));
	m_ui->bookmarksViewWidget->setExpanded(BookmarksManager::getModel()->getRootItem()->index(), true);
	m_ui->bookmarksViewWidget->setFilterRoles(filterRoles);
	m_ui->bookmarksViewWidget->installEventFilter(this);
	m_ui->bookmarksViewWidget->viewport()->installEventFilter(this);
	m_ui->bookmarksViewWidget->viewport()->setMouseTracking(true);
	m_ui->filterLineEdit->installEventFilter(this);

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

	connect(BookmarksManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions()));
	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()));
	connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->bookmarksViewWidget, SLOT(setFilterString(QString)));
	connect(m_ui->bookmarksViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openBookmark(QModelIndex)));
	connect(m_ui->bookmarksViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
	connect(m_ui->bookmarksViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));
}
Ejemplo n.º 15
0
bool HelpDialog::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: showTopic((int)static_QUType_int.get(_o+1),(QListBoxItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 1: showTopic((int)static_QUType_int.get(_o+1),(QListViewItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 2: showTopic((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 3: loadIndexFile(); break;
    case 4: insertContents(); break;
    case 5: setupFullTextIndex(); break;
    case 6: currentTabChanged((const QString&)static_QUType_QString.get(_o+1)); break;
    case 7: currentIndexChanged((QListBoxItem*)static_QUType_ptr.get(_o+1)); break;
    case 8: showTopic(); break;
    case 9: searchInIndex((const QString&)static_QUType_QString.get(_o+1)); break;
    case 10: addBookmark(); break;
    case 11: removeBookmark(); break;
    case 12: currentBookmarkChanged((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 13: currentContentsChanged((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 14: startSearch(); break;
    case 15: showSearchHelp(); break;
    case 16: initialize(); break;
    case 17: toggleContents(); break;
    case 18: toggleIndex(); break;
    case 19: toggleBookmarks(); break;
    case 20: toggleSearch(); break;
    case 21: lastWinClosed(); break;
    case 22: showResultPage((int)static_QUType_int.get(_o+1),(QListBoxItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 23: showResultPage((QListBoxItem*)static_QUType_ptr.get(_o+1)); break;
    case 24: setIndexingProgress((int)static_QUType_int.get(_o+1)); break;
    case 25: showItemMenu((QListBoxItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 26: showItemMenu((QListViewItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 27: insertBookmarks(); break;
    case 28: processEvents(); break;
    default:
	return HelpDialogBase::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 16
0
void BookmarksToolbar::changeBookmarkParent(const QString &name, const QByteArray &imageData, int id,
        const QUrl &url, const QString &oldParent, const QString &newParent)
{
    if (oldParent != _bookmarksToolbar && newParent != _bookmarksToolbar) {
        return;
    }

    bool itemIsAboutToRemove = (newParent != _bookmarksToolbar);

    Bookmark bookmark;
    bookmark.id =  id;
    bookmark.url = url;
    bookmark.title = name;
    bookmark.folder = QLatin1String("bookmarksToolbar");
    bookmark.image = QImage::fromData(imageData);
    bookmark.inSubfolder = false;

    if (itemIsAboutToRemove) {
        removeBookmark(bookmark);
    }
    else {
        addBookmark(bookmark);
    }
}
Ejemplo n.º 17
0
void BookmarksContentsWidget::showContextMenu(const QPoint &point)
{
	BookmarkInformation *bookmark = static_cast<BookmarkInformation*>(m_ui->bookmarksView->indexAt(point).data(Qt::UserRole).value<void*>());
	QMenu menu(this);

	if (bookmark)
	{
		menu.addAction(Utils::getIcon(QLatin1String("document-open")), tr("Open"), this, SLOT(openBookmark()));
		menu.addAction(tr("Open in New Tab"), this, SLOT(openBookmark()))->setObjectName(QLatin1String("new-tab"));
		menu.addAction(tr("Open in New Background Tab"), this, SLOT(openBookmark()))->setObjectName(QLatin1String("new-background-tab"));
		menu.addSeparator();
		menu.addAction(tr("Open in New Window"), this, SLOT(openBookmark()))->setObjectName(QLatin1String("new-window"));
		menu.addAction(tr("Open in New Background Window"), this, SLOT(openBookmark()))->setObjectName(QLatin1String("new-background-window"));

		if (bookmark->type == SeparatorBookmark || (bookmark->type == FolderBookmark && bookmark->children.isEmpty()))
		{
			for (int i = 0; i < menu.actions().count(); ++i)
			{
				menu.actions().at(i)->setEnabled(false);
			}
		}

		menu.addSeparator();
		menu.addAction(tr("Copy Link to Clipboard"), this, SLOT(copyBookmarkLink()))->setEnabled(bookmark->type == UrlBookmark);
		menu.addSeparator();
		menu.addAction(tr("Remove Bookmark"), this, SLOT(removeBookmark()));
		menu.addSeparator();
		menu.addAction(tr("Properties..."), this, SLOT(bookmarkProperties()));
	}
	else
	{
		menu.addAction(tr("Add Bookmark..."), this, SLOT(addBookmark()));
	}

	menu.exec(m_ui->bookmarksView->mapToGlobal(point));
}
Ejemplo n.º 18
0
bool BookmarksModel::removeBookmark(const QUrl &url)
{
    return removeBookmark(bookmarkId(url));
}
Ejemplo n.º 19
0
bool BookmarksModel::removeBookmark(WebView* view)
{
    return removeBookmark(bookmarkId(view->url()));
}
Ejemplo n.º 20
0
BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
    : QWidget(parent)
    , p_QupZilla(mainClass)
    , m_bookmarksModel(mApp->bookmarksModel())
    , m_historyModel(mApp->history())
{
    setObjectName("bookmarksbar");
    m_layout = new QHBoxLayout();
    m_layout->setContentsMargins(9, 3, 9, 3);
    m_layout->setSpacing(0);
    setLayout(m_layout);

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));

    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(subfolderAdded(QString)), this, SLOT(subfolderAdded(QString)));
    connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(folderDeleted(QString)));
    connect(m_bookmarksModel, SIGNAL(folderRenamed(QString, QString)), this, SLOT(folderRenamed(QString, QString)));

//    QTimer::singleShot(0, this, SLOT(refreshBookmarks()));
    refreshBookmarks();
}
Ejemplo n.º 21
0
QxFileBrowser::QxFileBrowser(QWidget* parent)
	: QWidget(parent),
	  gotoMenu_(0),
	  recentMenu_(0),
	  showHidden_(false),
	  showDetails_(true),
	  createFileDialog_(0),
	  createDirDialog_(0),
	  renameDialog_(0)
{
	//--------------------------------------------------------------------------
	// setup primary model and view
	
	cwdModel_ = new QFileSystemModel(this);
	cwdModel_->setReadOnly(false);
	QModelIndex root = cwdModel_->setRootPath(QDir::currentPath());
	connect( cwdModel_, SIGNAL(fileRenamed(const QString&, const QString&, const QString&)),
	         this, SLOT(fileRenamed(const QString&, const QString&, const QString&)) );
	
	dirView_ = new QxFileSystemView(this);
	dirView_->setModel(cwdModel_);
	dirView_->header()->hide();
	dirView_->setRootIndex(root);
	dirView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	dirView_->setDragDropMode(QAbstractItemView::DragOnly);
	connect(dirView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(cwdSet(const QModelIndex&)));
	connect(dirView_, SIGNAL(escape()), this, SIGNAL(escape()));
	connect(dirView_, SIGNAL(cdUp()), this, SLOT(cdUp()));
	connect(cwdModel_, SIGNAL(layoutChanged()), dirView_, SLOT(resizeColumnsToContents()));
	
	setFocusProxy(dirView_);
	
	// dirView_->setTextElideMode(Qt::ElideMiddle);
	dirView_->setFrameStyle(QFrame::NoFrame);
	// dirView_->setIndentation(18); // together with a branch pixmap could improve branch alignment
	dirView_->setLineWidth(0);
	dirView_->setMidLineWidth(0);
	#ifdef Q_WS_MAC
	dirView_->setStyleSheet(
		"QTreeView {"
		"  font-size: 12px;"
		"}"
		"QTreeView::item {"
		"  padding-top: 1px;"
		"}"
	);
	#endif
	{
		QPalette pal = dirView_->palette();
		pal.setColor(QPalette::Base, styleManager()->color("fileBrowserDirViewBgColor"));
		dirView_->setPalette(pal);
	}
	
	//--------------------------------------------------------------------------
	// setup navigation bar / panel head
	
	gotoButton_ = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserGotoButton")));
	gotoButton_->setMode(QxControl::MenuMode);
	gotoButton_->visual()->setText(QDir::current().dirName());
	gotoButton_->setMinimumWidth(10); // design HACK
	gotoButton_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
	{
		QPixmap folderIcon = QFileIconProvider().icon(QFileInfo(QDir::currentPath())).pixmap(QSize(16, 16));
		gotoButton_->visual()->setLeadingIcon(folderIcon);
	}
	#ifdef Q_WS_MAC
	#ifdef QT_MAC_USE_COCOA
	connect(gotoButton_, SIGNAL(toggled(bool)), this, SLOT(blockFloating(bool)));
	#endif // QT_MAC_USE_COCOA
	#endif // Q_WS_MAC
	
	updateGotoMenu();
	
	class QxCdUpButton: public QxControl {
	public:
		QxCdUpButton(QWidget* parent)
			: QxControl(parent, new QxVisual(styleManager()->style("fileBrowserCdUpButton")))
		{}
	private:
		// workaround HACK, prevent undocking, map double click event to single click
		virtual void mouseDoubleClickEvent(QMouseEvent* event) { press(); event->accept(); }
	};
	QxControl* cdUpButton = new QxCdUpButton(this);
	cdUpButton->setMode(QxControl::TouchMode);
	connect(cdUpButton, SIGNAL(pressed()), this, SLOT(cdUp()));
	
	//--------------------------------------------------------------------------
	// define context actions
	
	contextMenu_ = new QMenu(this);
	
	// QxDesignHack::beautify(contextMenu_);
	openDefaultAction_ = new QAction(tr("Open in Default App."), this);
	openDefaultAction_->setShortcut(tr("Ctrl+D"));
	openDefaultAction_->setShortcutContext(Qt::WidgetShortcut);
	openFileAction_ = new QAction(tr("Open in %1").arg(qApp->applicationName()), this);
	
	createFileAction_ = contextMenu_->addAction(tr("New File"));
	createDirAction_ = contextMenu_->addAction(tr("New Folder"));
	contextMenu_->addSeparator();
	contextMenu_->addAction(openFileAction_);
	contextMenu_->addAction(openDefaultAction_);
	contextMenu_->addSeparator();
	renameAction_ = contextMenu_->addAction(tr("Rename"));
	deleteAction_ = contextMenu_->addAction(tr("Move To Trash"));
	contextMenu_->addSeparator();
	bookmarkAction_ = contextMenu_->addAction(tr("Bookmark"));
	contextMenu_->addSeparator();
	showHiddenAction_ = contextMenu_->addAction(tr("Show Hidden"));
	showDetailsAction_ = contextMenu_->addAction(tr("Show Details"));
	
	connect(createFileAction_, SIGNAL(triggered()), this, SLOT(createFile()));
	connect(createDirAction_, SIGNAL(triggered()), this, SLOT(createDir()));
	connect(openDefaultAction_, SIGNAL(triggered()), this, SLOT(openDefault()));
	connect(openFileAction_, SIGNAL(triggered()), this, SLOT(openFile()));
	connect(renameAction_, SIGNAL(triggered()), this, SLOT(rename()));
	connect(deleteAction_, SIGNAL(triggered()), this, SLOT(delete_()));
	connect(dirView_, SIGNAL(delKeyPressed()), this, SLOT(delete_()));
	connect(showHiddenAction_, SIGNAL(toggled(bool)), this, SLOT(showHidden(bool)));
	connect(showDetailsAction_, SIGNAL(toggled(bool)), this, SLOT(showDetails(bool)));
	connect(bookmarkAction_, SIGNAL(triggered()), this, SLOT(bookmark()));
	
	showHiddenAction_->setCheckable(true);
	showDetailsAction_->setCheckable(true);
	showHiddenAction_->setChecked(false);
	showDetailsAction_->setChecked(false);
	
	//--------------------------------------------------------------------------
	// setup toolbar
	
	QxControl* plusButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserPlusButton")));
	plusButton->setMode(QxControl::TouchMode);
	connect(plusButton, SIGNAL(pressed()), this, SLOT(createFile()));
	
	QxControl* wheelButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserWheelButton")));
	wheelButton->setMenu(contextMenu_);
	wheelButton->setMenuPopupMode(QxControl::DownsideMenuPopup|QxControl::UpsideMenuPopup|QxControl::PreferUpsideMenuPopup);
	
	QxControl* recentButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserRecentButton")));
	recentButton->setMode(QxControl::TouchMode);
	connect(recentButton, SIGNAL(pressed()), this, SLOT(recentShowOrHide()));
	
	QxControl* bookmarksButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserBookmarksButton")));
	bookmarksButton->setMode(QxControl::TouchMode);
	connect(bookmarksButton, SIGNAL(pressed()), this, SLOT(bookmarksShowOrHide()));
	
	statusBar_ = new QxStatusBar(this);
	
	showHidden(false);
	showDetails(false);
	
	//--------------------------------------------------------------------------
	// setup bottom views
	
	recentModel_ = new QxUrlListModel(this);
	
	recentView_ = new QxUrlListView(this);
	// recentView_->header()->hide();
	// recentView_->setViewMode(QListView::IconMode);
	// recentView_->setIconSize(QSize(16, 16));
	recentView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	recentView_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	recentView_->setTextElideMode(Qt::ElideLeft);
	recentView_->setFrameStyle(QFrame::NoFrame);
	recentView_->setLineWidth(0);
	recentView_->setMidLineWidth(0);
	recentView_->setStyleSheet(
		"QListView::item {"
		"  padding-top: 1px;"
		"}"
	);
	// recentView_->setAlternatingRowColors(true);
	recentView_->setModel(recentModel_);
	connect(recentView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(gotoRecent(const QModelIndex&)));
	
	recentContextMenu_ = new QMenu(this);
	recentContextMenu_->addAction(tr("Goto"), this, SLOT(gotoRecent()));
	recentContextMenu_->addAction(tr("Add To Bookmarks"), this, SLOT(recentAddToBookmarks()));
	
	bookmarksModel_ = new QxUrlListModel(this);
	bookmarksModel_->setPathReduction(1);
	
	bookmarksView_ = new QxUrlListView(this);
	bookmarksView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	bookmarksView_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	bookmarksView_->setTextElideMode(Qt::ElideLeft);
	bookmarksView_->setFrameStyle(QFrame::NoFrame);
	bookmarksView_->setLineWidth(0);
	bookmarksView_->setMidLineWidth(0);
	bookmarksView_->setStyleSheet(
		"QListView::item {"
		"  padding-top: 1px;"
		"}"
	);
	bookmarksView_->setModel(bookmarksModel_);
	bookmarksView_->setDragDropMode(QAbstractItemView::InternalMove);
	bookmarksView_->setDragEnabled(true);
	bookmarksView_->setAcceptDrops(true);
	bookmarksView_->setDropIndicatorShown(true);
	connect(bookmarksView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(gotoBookmark(const QModelIndex&)));
	
	bookmarksContextMenu_ = new QMenu(this);
	bookmarksContextMenu_->addAction(tr("Add Current Directory"), this, SLOT(cwdAddToBookmark()));
	bookmarksContextMenu_->addAction(tr("Add Other Directory"), this, SLOT(addDirBookmark()));
	bookmarksContextMenu_->addSeparator();
	bookmarksContextMenu_->addAction(tr("Goto Here"), this, SLOT(gotoBookmark()));
	bookmarksContextMenu_->addAction(tr("Remove From List"), this, SLOT(removeBookmark()));
	bookmarksContextMenu_->addSeparator();
	bookmarksShowFullPathAction_ = bookmarksContextMenu_->addAction(tr("Show Full Path"));
	bookmarksShowFullPathAction_->setCheckable(true);
	bookmarksShowFullPathAction_->setChecked(bookmarksModel_->pathReduction() == -1);
	connect(bookmarksShowFullPathAction_, SIGNAL(toggled(bool)), this, SLOT(bookmarksShowFullPath(bool)));
	
	#ifdef Q_WS_MAC
	{
		QProxyStyle* proxyStyle = qobject_cast<QProxyStyle*>(style());
		QMacStyle* macStyle = qobject_cast<QMacStyle*>((proxyStyle) ? proxyStyle->baseStyle() : style());
		if (macStyle) {
			macStyle->setFocusRectPolicy(dirView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(recentView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(dirView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(bookmarksView_, QMacStyle::FocusDisabled);
		}
	}
	#endif
	
	//--------------------------------------------------------------------------
	// layout widgets
	
	handle_ = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserSplitter")));
	handle_->visual()->setText("");
	handleTextRecent_ = tr("Recent Places");
	handleTextBookmarks_ = tr("Bookmarks");
	
	bottomStack_ = new QxControl(this);
	bottomStackLayout_ = new QStackedLayout;
	bottomStackLayout_->addWidget(recentView_);
	bottomStackLayout_->addWidget(bookmarksView_);
	bottomStack_->setLayout(bottomStackLayout_);
	bottomStack_->setVisible(false);
	
	splitter_ = new QxSplitter(this);
	splitter_->setOrientation(Qt::Vertical);
	splitter_->setHandle(1, handle_);
	splitter_->setHandleWidth(styleManager()->constant("fileBrowserSplitterWidth"));
	splitter_->addWidget(dirView_);
	/*{
		QxControl* carrier = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserDirView")));
		QGridLayout* layout = new QGridLayout;
		layout->setSpacing(0);
		layout->setMargin(0);
		layout->addWidget(dirView_);
		carrier->setLayout(layout);
		splitter_->addWidget(carrier);
	}*/
	splitter_->addWidget(bottomStack_);
	
	// make dirView_ grow/shrink dynamically, while bottomStack_ keeps user-defined size
	splitter_->setStretchFactor(0, 1);
	splitter_->setStretchFactor(1, 0);
	
	QDockWidget* dock = qobject_cast<QDockWidget*>(parent);
	if (dock) {
		dock->setWidget(this);
		// connect(dock, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(adaptToDockLocation(Qt::DockWidgetArea)));
	}
	
	QVBoxLayout* col = new QVBoxLayout;
	col->setSpacing(0);
	col->setMargin(0);
	{
		QxControl* carrier = new QxControl(parent, new QxVisual(styleManager()->style("fileBrowserNavCarrier")));
		QHBoxLayout* row = new QHBoxLayout;
		row->setSpacing(0);
		row->setMargin(0);
		row->addWidget(gotoButton_);
		row->addStretch();
		row->addWidget(cdUpButton);
		carrier->setLayout(row);
		
		if (dock)
			dock->setTitleBarWidget(carrier);
		else
			col->addWidget(carrier);
	}
	col->addWidget(splitter_);
	col->addWidget(styleManager()->hl(this));
	{
		QBoxLayout* row = new QBoxLayout(QBoxLayout::LeftToRight);
		row->setSpacing(0);
		row->setMargin(0);
		row->addWidget(plusButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(wheelButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(recentButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(bookmarksButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(statusBar_);
		col->addLayout(row);
		
		bottomToolLayout_ = row;
	}
	setLayout(col);
}
//never used
const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
{
	if (parent)
	{
		parent->hide();
	}

	frameBuffer = CFrameBuffer::getInstance();
	visible = false;
	selected = 0;
	// Max
	width = 90;
	footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+8; //initial height value for buttonbar
	theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	x=getScreenStartX( width );
	y=getScreenStartY( height + info_height );
	listmaxshow = (height-theight-0)/(fheight*2);
	liststart = 0;

	height = (g_settings.screen_EndY-g_settings.screen_StartY)-(info_height+50);
	listmaxshow = (height-theight-0)/(fheight*2);
	height = theight+0+listmaxshow*fheight*2;	// recalc height
	if (bookmarks.size() < listmaxshow)
	{
		listmaxshow=bookmarks.size();
		height = theight+0+listmaxshow*fheight*2;	// recalc height
	}
	if ((!bookmarks.empty() && selected==bookmarks.size()))
	{
		selected=bookmarks.size()-1;
		liststart = (selected/listmaxshow)*listmaxshow;
	}


	int res = -1;

	uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
	uint32_t msg;
	uint32_t data;

	bool loop=true;
	bool update=true;
	while (loop)
	{
		if (update)
		{
			hide();
			update=false;
			paint();
		}
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if ( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);

		if ( ( msg == CRCInput::RC_timeout ) ||
				( msg == CRCInput::RC_home) )
		{ //Exit after timeout or cancel key
			res = -1;
			loop=false;
		}
		else if ((msg == CRCInput::RC_up) && !(bookmarks.empty()))
		{
			int prevselected=selected;
			if (selected==0)
			{
				selected = bookmarks.size()-1;
			}
			else
				selected--;
			paintItem(prevselected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}
		}
		else if ((msg == CRCInput::RC_down) && !(bookmarks.empty()))
		{
			int prevselected=selected;
			selected = (selected+1)%bookmarks.size();
			paintItem(prevselected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}
		}
		else if ((msg == CRCInput::RC_ok) && !(bookmarks.empty()))
		{
			res = selected;
			loop=false;
		}
		else if ((msg == CRCInput::RC_red) && !(bookmarks.empty()))
		{
			removeBookmark(selected);
			update=true;
		}
		else if ((msg==CRCInput::RC_yellow) && !(bookmarks.empty()))
		{
			renameBookmark(selected);
			update=true;
		}
		else if ((msg==CRCInput::RC_blue)||(msg==CRCInput::RC_green)||
				(CRCInput::isNumeric(msg)) )
		{
			//Ignore
		}
		else if (msg==CRCInput::RC_setup)
		{
			res=-1;
			loop=false;
		}
		else if ( msg == CRCInput::RC_help )
		{
			// TODO Add Help
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
				res = menu_return::RETURN_EXIT_ALL;
			}
		}
	}
	hide();

	if ((res >=0) && (((unsigned int)res) < bookmarks.size()))
		return &bookmarks[res];
	else
		return NULL;
}
Ejemplo n.º 23
0
void BookmarksSideBar::bookmarkEdited(const BookmarksModel::Bookmark &before, const BookmarksModel::Bookmark &after)
{
    removeBookmark(before);
    addBookmark(after);
}
Ejemplo n.º 24
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()));
}
Ejemplo n.º 25
0
const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
{
	if(parent)
	{
		parent->hide();
	}
	
	frameBuffer = CFrameBuffer::getInstance();
	visible = false;
	selected = 0;

	width = w_max (720, 30);

	int iconw = 0, iconh = 0;
	frameBuffer->getIconSize(NEUTRINO_ICON_BOOKMARKMANAGER, &ticonwidth, &ticonheight);
	theight = std::max(ticonheight, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight());
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_OKAY, &iconw, &iconh);
	footHeight = std::max(iconh, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight());
	liststart = 0;
	
	height = h_max(576, 50);
	listmaxshow = (height-theight-footHeight-0)/(fheight*2);
	height = theight+footHeight+0+listmaxshow*fheight*2;	// recalc height
	if(bookmarks.size() < listmaxshow)
	{
		listmaxshow=bookmarks.size();
		height = theight+footHeight+0+listmaxshow*fheight*2;	// recalc height
	}
	if (!bookmarks.empty() && selected==bookmarks.size())
	{
		selected=bookmarks.size()-1;
		liststart = (selected/listmaxshow)*listmaxshow;
	}
	x = getScreenStartX (width);
	y = getScreenStartY (height);


	int res = -1;

	unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
	neutrino_msg_t msg;
	neutrino_msg_data_t data;

	bool loop=true;
	bool update=true;
	while(loop)
	{
		if(update)
		{
			hide();
			update=false;
			paint();
		}
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);

		if( ( msg == CRCInput::RC_timeout ) ||
			 ( msg == CRCInput::RC_home) )
		{ //Exit after timeout or cancel key
			res = -1;
			loop=false;
		}
		else if ((msg_repeatok == CRCInput::RC_up || msg_repeatok == g_settings.key_channelList_pageup) && !(bookmarks.empty()))
		{
			int step = (msg_repeatok == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			int new_selected = selected - step;
			if (new_selected < 0)
				new_selected = bookmarks.size() - 1;
			updateSelection(new_selected);
		}
		else if ((msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown) && !(bookmarks.empty()))
		{
			unsigned int step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			unsigned int new_selected = selected + step;
			unsigned int b_size = bookmarks.size();
			if (new_selected >= b_size)
			{
				if ((b_size / listmaxshow + 1) * listmaxshow == b_size + listmaxshow) // last page has full entries
					new_selected = 0;
				else
					new_selected = ((step == listmaxshow) && (new_selected < ((b_size / listmaxshow + 1) * listmaxshow))) ? (b_size - 1) : 0;
			}
			updateSelection(new_selected);
		}
		else if ((msg == CRCInput::RC_ok) && !(bookmarks.empty()))
		{
    		res = selected;
    		loop=false;
		}
		else if((msg == CRCInput::RC_red) && !(bookmarks.empty()))
		{
			removeBookmark(selected);
			update=true;
		}
		else if((msg==CRCInput::RC_yellow) && !(bookmarks.empty()))
		{
			renameBookmark(selected);
			update=true;
		}
		else if((msg==CRCInput::RC_blue)||(msg==CRCInput::RC_green)||
				  (CRCInput::isNumeric(msg)) )
		{
			//Ignore
		}
		else if(msg==CRCInput::RC_setup)
		{
			res=-1;
			loop=false;
		}
		else if( msg == CRCInput::RC_help )
		{
			// TODO Add Help
		}
		else
		{
			if( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
				res = -1;
			}
		}
	}
	hide();

	if ((res >=0) && (((unsigned int)res) < bookmarks.size()))
		return &bookmarks[res];
	else
		return NULL;
}
Ejemplo n.º 26
0
BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
    : QWidget(parent)
    , p_QupZilla(mainClass)
    , m_bookmarksModel(mApp->bookmarksModel())
    , m_historyModel(mApp->history())
    , m_toolButtonStyle(Qt::ToolButtonTextBesideIcon)
{
    setObjectName("bookmarksbar");
    m_layout = new QHBoxLayout();
    m_layout->setMargin(3);
    m_layout->setSpacing(0);
    setLayout(m_layout);

    setAcceptDrops(true);

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));

    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(subfolderAdded(QString)), this, SLOT(subfolderAdded(QString)));
    connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(folderDeleted(QString)));
    connect(m_bookmarksModel, SIGNAL(folderRenamed(QString,QString)), this, SLOT(folderRenamed(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)));

    setMaximumWidth(p_QupZilla->width());

    refreshBookmarks();
    showOnlyIconsChanged();
}
Ejemplo n.º 27
0
WidgetArea::WidgetArea(QWidget *parent) :
    QFrame(parent), m_menu(new QMenu(this)), m_undoStack(this)
{
    m_widgetIdCounter = 0;
    m_skipNextMove = false;
    m_prev = NULL;
    m_show_grid = sConfig.get(CFG_BOOL_ANALYZER_SHOW_GRID);
    m_grid = sConfig.get(CFG_BOOL_ANALYZER_ENABLE_GRID) ? sConfig.get(CFG_QUINT32_ANALYZER_GRID_SIZE) : 1;
    m_enablePlacementLines = sConfig.get(CFG_BOOL_ANALYZER_PLACEMENT_LINES);
    m_active_bookmk = NULL;
    m_bookmk_ids = 0;
    m_show_bookmk = sConfig.get(CFG_BOOL_ANALYZER_SHOW_BOOKMARKS);
    m_draggin = false;

    setCursor(Qt::OpenHandCursor);

    QAction *addPoint = m_menu->addAction(tr("Add bookmark..."));
    m_actShowBookmk = m_menu->addAction(tr("Show bookmarks"));
    m_actShowBookmk->setCheckable(true);
    m_actShowBookmk->setChecked(m_show_bookmk);

    m_menu->addSeparator();

    QMenu *gridMenu = m_menu->addMenu(tr("Grid"));

    m_actEnableGrid = gridMenu->addAction(tr("Enable grid"));
    m_actShowGrid = gridMenu->addAction(tr("Show grid"));
    QAction *gridSize = gridMenu->addAction(tr("Set grid size..."));
    QAction *align = gridMenu->addAction(tr("Align widgets to the grid"));
    m_actEnableGrid->setCheckable(true);
    m_actEnableGrid->setChecked(m_grid != 1);
    m_actShowGrid->setCheckable(true);
    m_actShowGrid->setChecked(m_show_grid);

    QAction *linesAct = m_menu->addAction(tr("Enable placement lines"));
    linesAct->setCheckable(true);
    linesAct->setChecked(m_enablePlacementLines);

    m_menu->addSeparator();

    m_actTitleVisibility = m_menu->addAction(tr("Show widget's title bar"));
    QAction *lockAll = m_menu->addAction(tr("Lock all widgets"));
    QAction *unlockAll = m_menu->addAction(tr("Unlock all widgets"));

    m_actShowPreview = m_menu->addAction(tr("Show preview while moving the area"));
    m_actEnableSearch = m_menu->addAction(tr("Enable quick search (spacebar)"));

    m_actTitleVisibility->setCheckable(true);
    m_actTitleVisibility->setChecked(true);
    m_actShowPreview->setCheckable(true);
    m_actShowPreview->setChecked(sConfig.get(CFG_BOOL_ANALYZER_SHOW_PREVIEW));
    m_actEnableSearch->setCheckable(true);
    m_actEnableSearch->setChecked(sConfig.get(CFG_BOOL_ANALYZER_SEARCH_WIDGET));

    m_menu->addSeparator();

    QAction *undo = m_menu->addAction(tr("Undo"), &m_undoStack, SLOT(undo()), QKeySequence("Ctrl+Z"));
    QAction *redo = m_menu->addAction(tr("Redo"), &m_undoStack, SLOT(redo()), QKeySequence("Shift+Ctrl+Z"));
    undo->setEnabled(false);
    redo->setEnabled(false);
    addAction(undo);
    addAction(redo);

    m_bookmk_menu = new QMenu(this);
    QAction *keyseqAct = m_bookmk_menu->addAction(tr("Change shortcut"));
    QAction *rmPntAct = m_bookmk_menu->addAction(tr("Remove"));

    connect(m_actEnableGrid,      SIGNAL(toggled(bool)),                SLOT(enableGrid(bool)));
    connect(m_actEnableGrid,      SIGNAL(toggled(bool)), m_actShowGrid, SLOT(setEnabled(bool)));
    connect(m_actEnableGrid,      SIGNAL(toggled(bool)), gridSize,      SLOT(setEnabled(bool)));
    connect(m_actShowGrid,        SIGNAL(toggled(bool)),                SLOT(showGrid(bool)));
    connect(m_actEnableSearch,    SIGNAL(triggered(bool)),              SLOT(enableSearchClicked(bool)));
    connect(m_actEnableSearch,    SIGNAL(toggled(bool)),                SLOT(enableSearchToggled(bool)));
    connect(gridSize,             SIGNAL(triggered()),                  SLOT(setGridSize()));
    connect(align,                SIGNAL(triggered()),                  SLOT(alignWidgets()));
    connect(linesAct,             SIGNAL(toggled(bool)),                SLOT(enableLines(bool)));
    connect(m_actTitleVisibility, SIGNAL(triggered(bool)),              SLOT(titleVisibilityAct(bool)));
    connect(m_actShowPreview,     SIGNAL(toggled(bool)),                SLOT(setShowPreview(bool)));
    connect(lockAll,              SIGNAL(triggered()),                  SLOT(lockAll()));
    connect(unlockAll,            SIGNAL(triggered()),                  SLOT(unlockAll()));
    connect(&m_undoStack,         SIGNAL(undoAvailable(bool)),    undo, SLOT(setEnabled(bool)));
    connect(&m_undoStack,         SIGNAL(redoAvailable(bool)),    redo, SLOT(setEnabled(bool)));
    connect(&m_bookmk_mapper,     SIGNAL(mapped(int)),                  SLOT(jumpToBookmark(int)));
    connect(keyseqAct,            SIGNAL(triggered()),                  SLOT(changeBookmarkSeq()));
    connect(rmPntAct,             SIGNAL(triggered()),                  SLOT(removeBookmark()));
    connect(addPoint,             SIGNAL(triggered()),                  SLOT(addBookmark()));
    connect(m_actShowBookmk,      SIGNAL(toggled(bool)),                SLOT(setShowBookmarks(bool)));
}