Пример #1
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();
}
Пример #2
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();
}
Пример #3
0
QgsBookmarks::QgsBookmarks( QWidget *parent, Qt::WFlags fl )
    : QDialog( parent, fl ),
    mParent( parent )
{
  setupUi( this );
  // user database is created at QGIS startup in QgisApp::createDB
  // we just check whether there is our database [MD]
  QFileInfo myFileInfo;
  myFileInfo.setFile( QgsApplication::qgisSettingsDirPath() );
  if ( !myFileInfo.exists( ) )
  {
    QgsDebugMsg( "The qgis.db does not exist" );
  }

  // Note proper queens english on next line
  initialise();

  //
  // Create the zoomto and delete buttons and add them to the
  // toolbar
  //
  QPushButton * btnDelete = new QPushButton( tr( "&Delete" ) );
  QPushButton * btnZoomTo = new QPushButton( tr( "&Zoom to" ) );
  btnZoomTo->setDefault( true );
  buttonBox->addButton( btnDelete, QDialogButtonBox::ActionRole );
  buttonBox->addButton( btnZoomTo, QDialogButtonBox::ActionRole );
  // connect the slot up to catch when a bookmark is deleted
  connect( btnDelete, SIGNAL( clicked() ), this, SLOT( on_btnDelete_clicked() ) );
  // connect the slot up to catch when a bookmark is zoomed to
  connect( btnZoomTo, SIGNAL( clicked() ), this, SLOT( on_btnZoomTo_clicked() ) );
  // connect the slot up to catch when a new bookmark is added
  connect( mParent, SIGNAL( bookmarkAdded() ), this, SLOT( refreshBookmarks() ) );
}
void QgsBookmarks::on_btnUpdate_clicked()
{
  // get the current item
  QTreeWidgetItem *item = lstBookmarks->currentItem();
  if ( item )
  {
    // make sure the user really wants to update this bookmark
    if ( QMessageBox::Ok == QMessageBox::information( this, tr( "Really Update?" ),
         tr( "Are you sure you want to update the %1 bookmark?" ).arg( item->text( 0 ) ),
         QMessageBox::Ok | QMessageBox::Cancel ) )
    {
      // retrieve the current map extent
      QgsRectangle viewExtent = QgisApp::instance()->mapCanvas()->extent();

      int rc;
      QgsDebugMsg( QString( "Opening user database: %1" ).arg( QgsApplication::qgisUserDbFilePath() ) );
      rc = connectDb();
      if ( SQLITE_OK == rc )
      {
        // prepare the sql statement
        QString sql;
        QTextStream sqlStream( &sql );
        // use '17 g' format; SmartNotation is default
        sqlStream.setRealNumberPrecision( 17 );
        sqlStream << "update tbl_bookmarks set " <<
        "xmin=" << viewExtent.xMinimum() << "," <<
        "ymin=" << viewExtent.yMinimum() << "," <<
        "xmax=" << viewExtent.xMaximum() << "," <<
        "ymax=" << viewExtent.yMaximum() << " " <<
        "where bookmark_id=" << item->text( 3 );
        QgsDebugMsg( QString( "Storing bookmark using: %1" ).arg( sql ) );

        char * errmsg;
        rc = sqlite3_exec( db, sql.toUtf8(), NULL, NULL, &errmsg );
        if ( rc != SQLITE_OK )
        {
          // XXX Provide popup message on failure?
          QMessageBox::warning( this, tr( "Error updating bookmark" ),
                                tr( "Failed to update the %1 bookmark. The database said:\n%2" )
                                .arg( item->text( 0 ) ).arg( errmsg ) );
          sqlite3_free( errmsg );
        }
        // close the database
        sqlite3_close( db );

        refreshBookmarks();

      }
      else
      {
        QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( db ) ) );

        // XXX This will likely never happen since on open, sqlite creates the
        //     database if it does not exist.
        assert( rc == 0 );
      }
    }
  }
}
Пример #5
0
bool Settings::deleteBookmark(const QString &path)
{
    bool success = false;
    for (Bookmark *const bookmark : m_bookmarks)
    {
        if (bookmark->getPath() == path)
        {
            m_bookmarks.removeAll(bookmark);
            delete bookmark;
            refreshBookmarks();
            success = true;
        }
    }
    return success;
}
Пример #6
0
void BookmarkView::onUpdateTimer( wxTimerEvent& /* event */ ) {
    if (!this->IsShown()) {
        return;
    }
    if (doUpdateActive.load()) {
        doUpdateActiveList();
        doUpdateActive.store(false);
    }
    if (doUpdateBookmarks.load()) {

        wxTreeItemId bmSel = refreshBookmarks();
        if (bmSel) {
            m_treeView->SelectItem(bmSel);
        }  
        doUpdateBookmarks.store(false);  
    }
}