Пример #1
0
/// Deserializes the given application state
/// @param app a reference to the application
/// @param map the map with serialized data
void WorkspaceSerializer::deserializeWorkspace(Workspace* workspace, const QVariantMap& map)
{
    WindowManager* winManager = edbeeApp()->windowManager();
    QVariantList windows = map.value("windows").toList();
    foreach( QVariant winVar, windows ) {
        QVariantMap winMap = winVar.toMap();
        MainWindow* win = winManager->createWindow( workspace );
        deserializeMainWindow( win, winMap );
        win->show();
    }
Пример #2
0
/// Serializes the application
/// @paramapp the application to serialize
QVariantMap WorkspaceSerializer::serializeWorkspace(Workspace* workspace)
{
    QVariantMap result;

    // 'remember' all open files per window
    QVariantList windowList;
    WindowManager* wm = edbeeApp()->windowManager();
    for( int i=0,cnt=wm->size(); i<cnt; ++i ) {
        MainWindow* window = wm->window(i);
        if( window->workspace() == workspace ) {
            windowList.append( serializeMainWindow( window ));
        }
    }
    result.insert("windows",windowList);
    return result;
}
Пример #3
0
/// Loads the project
/// @param fileName the filename to load the project
/// @return the project object or 0 on error. The error-message can be recieved by caller errorMessage()
Workspace* WorkspaceSerializer::loadWorkspace( const QString& fileName )
{
    errorMessage_.clear();

    // serialize the data (into a json document)
    edbee::JsonParser parser;
    if( !parser.parse(fileName) ) {
        errorMessage_ = parser.errorMessage();
        return 0;
    }
    QVariantMap map = parser.result().toMap();


    // change the application workspace
    Workspace* result = edbeeApp()->workspaceManager()->createWorkspace();
    result->setFilename( fileName );            // this need to be set before giving it to the workspace

    // load the data into the workspace
    // Unfortunately the current implementation depends on the window being available.
    // so the deserialization needs to take place after giving it to the application
    deserializeWorkspace( result, map );
    return result;
}
Пример #4
0
void FindWidget::constructUI()
{

    QHBoxLayout* layout = new QHBoxLayout();// QBoxLayout::LeftToRight );
    layout->setMargin(7);
     setLayout( layout );



    QToolButton* toggleButton = new QToolButton(this);
    toggleButton->setFont( edbeeApp()->iconFont() );
    toggleButton->setText( QChar(icon_repeat) );
    toggleButton->setToolTip(tr("Wrap Around"));
    toggleButton->setCheckable(true);
    layout->addWidget( toggleButton, 0 );

    toggleButton = new QToolButton(this);
    toggleButton->setFont( edbeeApp()->iconFont() );
    toggleButton->setText( QChar(icon_asterisk) );
    toggleButton->setToolTip(tr("Regular Expressions"));
    toggleButton->setCheckable(true);
    layout->addWidget( toggleButton, 0 );

    toggleButton = new QToolButton(this);
    toggleButton->setFont( edbeeApp()->iconFont() );
    toggleButton->setText( QChar(icon_font) );
    toggleButton->setToolTip(tr("Case Sensitive"));
    toggleButton->setCheckable(true);
    layout->addWidget( toggleButton, 0 );




    QLabel* label = new QLabel( tr("Find") );
    layout->addWidget( label, 0, Qt::AlignLeft );


    lineEditRef_ = new QLineEdit(this);
//    lineEditRef_->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred);
//    lineEditRef_->setSizePolicy( QSizePolicy::M);
//    lineEditRef_->setMaximumWidth( 10000 );
    layout->addWidget( lineEditRef_, 1);//, Qt::AlignLeft);
//    layout->insertStretch(1);

    // add the action

    QToolButton* but = new QToolButton( this );
    but->setFont( edbeeApp()->iconFont() );
    but->setText( QChar(icon_caret_left) ); //<
    but->setShortcut( editorRef_->controller()->keyMap()->getSequence("find_prev_match") );
    but->setToolTip( QString(tr("Find Previous (%1)")).arg(but->shortcut().toString()) );
    connect( but, SIGNAL(clicked()), SLOT(findPrevWord()) );
    layout->addWidget( but, 0  );

    but = new QToolButton( this );
    but->setFont( edbeeApp()->iconFont() );
    but->setText( QChar(icon_caret_right) ); // >
    but->setShortcut( editorRef_->controller()->keyMap()->getSequence("find_next_match") );
    but->setToolTip( QString(tr("Find Next (%1)")).arg(but->shortcut().toString()) );
    connect( but, SIGNAL(clicked()), SLOT(findNextWord()) );
    layout->addWidget( but, 0 );


    but = new QToolButton( this );
    but->setFont( edbeeApp()->iconFont() );
    but->setText( QChar(icon_th) ); // >
    but->setShortcut( editorRef_->controller()->keyMap()->getSequence("sel_all_matches") );
    but->setToolTip( QString(tr("Select All (%1)")).arg(but->shortcut().toString()) );
    connect( but, SIGNAL(clicked()), SLOT(selectAllWords()) );
    layout->addWidget( but, 0 );


//    setWindowFlags( Qt::Popup );
}