コード例 #1
0
ファイル: advancedrenameinput.cpp プロジェクト: KDE/digikam
void AdvancedRenameLineEdit::setupConnections()
{
    connect(d->parseTimer, SIGNAL(timeout()),
            this, SLOT(slotParseTimer()));

    connect(this, SIGNAL(textChanged()),
            this, SLOT(slotTextChanged()));

    connect(this, SIGNAL(cursorPositionChanged()),
            this, SLOT(slotCursorPositionChanged()));
}
コード例 #2
0
ファイル: leftsidebarwidgets.cpp プロジェクト: UIKit0/digikam
void TimelineSideBarWidget::slotInit()
{
    // Date Maps are loaded from AlbumManager to TimeLineWidget after than GUI is initialized.
    // AlbumManager query Date KIO slave to stats items from database and it can take a while.
    // We waiting than TimeLineWidget is ready before to set last config from users.

    loadState();

    disconnect(d->timeLineWidget, SIGNAL(signalDateMapChanged()),
               this, SLOT(slotInit()));

    connect(d->timeLineWidget, SIGNAL(signalDateMapChanged()),
            this, SLOT(slotCursorPositionChanged()));
}
コード例 #3
0
ファイル: editor.cpp プロジェクト: vdg1/cs8-components
Editor::Editor ( QWidget * parent, cs8LoggerWidget *mainimpl, QString name )
//    : QWidget ( parent ), m_parent ( parent ), m_mainimpl ( cs8LoggerWidget )
{
  m_filename =  name;
  
  int vposLayout = 0;
  m_textEdit = new TextEdit ( this, mainimpl );
  m_backward = false;
  m_activeEditor = false;
  //
  QGridLayout *gridLayout = new QGridLayout ( this );
  gridLayout->setSpacing ( 0 );
  gridLayout->setMargin ( 0 );
  gridLayout->setObjectName ( QString::fromUtf8 ( "gridLayout" ) );
  //
  //
  //
  //
  connect ( m_textEdit, SIGNAL ( editorModified ( bool ) ), this, SLOT ( slotModifiedEditor ( bool ) ) );
  connect ( m_textEdit, SIGNAL ( cursorPositionChanged() ), this, SLOT ( slotCursorPositionChanged() ) );
  //
  m_findWidget = new QWidget;
  uiFind.setupUi ( m_findWidget );
  connect ( uiFind.toolClose, SIGNAL ( clicked() ), m_findWidget, SLOT ( hide() ) );
  connect ( uiFind.editFind, SIGNAL ( textChanged ( QString ) ), this, SLOT ( slotFindWidget_textChanged ( QString ) ) );
  connect ( uiFind.editFind, SIGNAL ( returnPressed() ), this, SLOT ( slotFindNext() ) );
  connect ( uiFind.toolPrevious, SIGNAL ( clicked() ), this, SLOT ( slotFindPrevious() ) );
  connect ( uiFind.toolNext, SIGNAL ( clicked() ), this, SLOT ( slotFindNext() ) );
  //
  autoHideTimer = new QTimer ( this );
  autoHideTimer->setInterval ( 5000 );
  autoHideTimer->setSingleShot ( true );
  connect ( autoHideTimer, SIGNAL ( timeout() ), m_findWidget, SLOT ( hide() ) );
  //
  gridLayout->addWidget ( m_textEdit, vposLayout++, 0, 1, 1 );
  gridLayout->addWidget ( m_findWidget, vposLayout++, 0, 1, 1 );
  uiFind.labelWrapped->setVisible ( false );
  m_findWidget->hide();
  //
  connect ( &m_timerCheckLastModified, SIGNAL ( timeout() ), this, SLOT ( slotTimerCheckIfModifiedOutside() ) );
  
  setLineNumbers ( true );
  setSyntaxHighlight ( true );
  setHighlightCurrentLine ( true );
}
コード例 #4
0
AdvancedRenameLineEdit::AdvancedRenameLineEdit(QWidget* parent)
    : QTextEdit(parent), d(new AdvancedRenameLineEditPriv)
{
    setLineWrapMode(QTextEdit::NoWrap);
    setWordWrapMode(QTextOption::NoWrap);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFrameStyle(QFrame::NoFrame);
    setPalette(kapp->palette());
    setFocusPolicy(Qt::StrongFocus);

    viewport()->setAutoFillBackground(false);
    setAutoFillBackground(false);

    QFontMetrics fm = fontMetrics();
    setFixedHeight(fm.height());

    // --------------------------------------------------------

    d->parseTimer = new QTimer(this);
    d->parseTimer->setInterval(500);
    d->parseTimer->setSingleShot(true);

    // --------------------------------------------------------

    // layout widget correctly by setting a dummy text and calling ensureCursorVisible().
    // Save the scrollbar position now, to avoid scrolling of the text when selecting with the mouse
    setPlainText("DUMMY TEXT");
    ensureCursorVisible();
    d->verticalSliderPosition = verticalScrollBar()->value();
    clear();

    // --------------------------------------------------------

    connect(d->parseTimer, SIGNAL(timeout()),
            this, SLOT(slotParseTimer()));

    connect(this, SIGNAL(textChanged()),
            this, SLOT(slotTextChanged()));

    connect(this, SIGNAL(cursorPositionChanged()),
            this, SLOT(slotCursorPositionChanged()));
}
コード例 #5
0
KNoteEdit::KNoteEdit( KActionCollection *actions, QWidget *parent )
  : KTextEdit( parent ), m_note( 0 )
{
  setAcceptDrops( true );
  setWordWrapMode( QTextOption::WordWrap );
  setLineWrapMode( WidgetWidth );
  if ( acceptRichText() ) {
    setAutoFormatting( AutoAll );
  } else {
    setAutoFormatting( AutoNone );
  }
  setCheckSpellingEnabled( true );

  // create the actions modifying the text format
  m_textBold  = new KToggleAction( KIcon( "format-text-bold" ), i18n( "Bold" ),
                                   this );
  actions->addAction( "format_bold", m_textBold );
  m_textBold->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_B ) );
  m_textItalic  = new KToggleAction( KIcon( "format-text-italic" ),
                                    i18n( "Italic" ), this );
  actions->addAction( "format_italic", m_textItalic );
  m_textItalic->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_I ) );
  m_textUnderline  = new KToggleAction( KIcon( "format-text-underline" ),
                                        i18n( "Underline" ), this );
  actions->addAction( "format_underline", m_textUnderline );
  m_textUnderline->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_U ) );
  m_textStrikeOut  = new KToggleAction( KIcon( "format-text-strikethrough" ),
                                        i18n( "Strike Out" ), this );
  actions->addAction( "format_strikeout", m_textStrikeOut );
  m_textStrikeOut->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_S ) );

  connect( m_textBold, SIGNAL(toggled(bool)), SLOT(textBold(bool)) );
  connect( m_textItalic, SIGNAL(toggled(bool)),
           SLOT(setFontItalic(bool)) );
  connect( m_textUnderline, SIGNAL(toggled(bool)),
           SLOT(setFontUnderline(bool)) );
  connect( m_textStrikeOut, SIGNAL(toggled(bool)),
           SLOT(textStrikeOut(bool)) );

  m_textAlignLeft = new KToggleAction( KIcon( "format-justify-left" ),
                                       i18n( "Align Left" ), this );
  actions->addAction( "format_alignleft", m_textAlignLeft );
  connect( m_textAlignLeft, SIGNAL(triggered(bool)),
           SLOT(textAlignLeft()) );
  m_textAlignLeft->setShortcut( QKeySequence( Qt::ALT + Qt::Key_L ) );
  m_textAlignLeft->setChecked( true ); // just a dummy, will be updated later
  m_textAlignCenter  = new KToggleAction( KIcon( "format-justify-center" ),
                                          i18n( "Align Center" ), this );
  actions->addAction( "format_aligncenter", m_textAlignCenter );
  connect( m_textAlignCenter, SIGNAL(triggered(bool)),
          SLOT(textAlignCenter()) );
  m_textAlignCenter->setShortcut( QKeySequence( Qt::ALT + Qt::Key_C ) );
  m_textAlignRight = new KToggleAction( KIcon( "format-justify-right" ),
                                        i18n( "Align Right" ), this );
  actions->addAction( "format_alignright", m_textAlignRight );
  connect( m_textAlignRight, SIGNAL(triggered(bool)),
           SLOT(textAlignRight()) );
  m_textAlignRight->setShortcut( QKeySequence( Qt::ALT + Qt::Key_R ) );
  m_textAlignBlock = new KToggleAction( KIcon( "format-justify-fill" ),
                                        i18n( "Align Block" ), this );
  actions->addAction( "format_alignblock", m_textAlignBlock );
  connect( m_textAlignBlock, SIGNAL(triggered(bool)),
           SLOT(textAlignBlock()) );
  m_textAlignBlock->setShortcut( QKeySequence( Qt::ALT + Qt::Key_B ) );

  QActionGroup *group = new QActionGroup( this );
  group->addAction( m_textAlignLeft );
  group->addAction( m_textAlignCenter );
  group->addAction( m_textAlignRight );
  group->addAction( m_textAlignBlock );

  m_textList  = new KToggleAction( KIcon( "format-list-ordered" ), i18n( "List" ), this );
  actions->addAction( "format_list", m_textList );
  connect( m_textList, SIGNAL(triggered(bool)), SLOT(textList()) );

  m_textSuper  = new KToggleAction( KIcon( "format-text-superscript" ),
                                    i18n( "Superscript" ), this );
  actions->addAction( "format_super", m_textSuper );
  connect( m_textSuper, SIGNAL(triggered(bool)),
           SLOT(textSuperScript()) );
  m_textSub  = new KToggleAction( KIcon( "format-text-subscript" ), i18n( "Subscript" ),
                                  this );
  actions->addAction( "format_sub", m_textSub );
  connect( m_textSub, SIGNAL(triggered(bool)), SLOT(textSubScript()) );


  m_textIncreaseIndent = new KAction( KIcon( "format-indent-more" ),
                                      i18n( "Increase Indent" ), this );
  actions->addAction( "format_increaseindent", m_textIncreaseIndent );
  m_textIncreaseIndent->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT +
                                                   Qt::Key_I ) );
  connect( m_textIncreaseIndent, SIGNAL(triggered(bool)),
           SLOT(textIncreaseIndent()) );

  m_textDecreaseIndent = new KAction(  KIcon( "format-indent-less" ),
                                       i18n( "Decrease Indent" ), this );
  actions->addAction( "format_decreaseindent", m_textDecreaseIndent );
  m_textDecreaseIndent->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT +
                                                   Qt::Key_D ) );
  connect( m_textDecreaseIndent, SIGNAL(triggered(bool)), SLOT(
           textDecreaseIndent() ) );

  group = new QActionGroup( this );
  group->addAction( m_textIncreaseIndent );
  group->addAction( m_textDecreaseIndent );

  QPixmap pix( ICON_SIZE, ICON_SIZE );
  pix.fill( Qt::black ); // just a dummy, gets updated before widget is shown
  m_textColor  = new KAction( i18n( "Text Color..." ), this );
  actions->addAction( "format_color", m_textColor );
  m_textColor->setIcon( pix );
  connect( m_textColor, SIGNAL(triggered(bool)), SLOT(slotTextColor()) );

  KAction *act = new KAction(KIcon( "format-fill-color" ), i18n( "Text Background Color..." ), this );
  actions->addAction( "text_background_color", act );
  connect( act, SIGNAL(triggered(bool)), SLOT(slotTextBackgroundColor()) );

  m_textFont  = new KFontAction( i18n( "Text Font" ), this );
  actions->addAction( "format_font", m_textFont );
  connect( m_textFont, SIGNAL(triggered(QString)),
           this, SLOT(setFontFamily(QString)) );

  m_textSize  = new KFontSizeAction( i18n( "Text Size" ), this );
  actions->addAction( "format_size", m_textSize );
  connect( m_textSize, SIGNAL(fontSizeChanged(int)),
           this, SLOT(setTextFontSize(int)) );

  // QTextEdit connections
  connect( this, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
           SLOT(slotCurrentCharFormatChanged(QTextCharFormat)) );
  connect( this, SIGNAL(cursorPositionChanged()),
           SLOT(slotCursorPositionChanged()) );
  slotCurrentCharFormatChanged( currentCharFormat() );
  slotCursorPositionChanged();
}
コード例 #6
0
ファイル: CDiaryEdit.cpp プロジェクト: Nikoli/qlandkartegt
CDiaryEdit::CDiaryEdit(CDiary& diary, QWidget * parent)
: QWidget(parent)
, isInternalEdit(0)
, diary(diary)
{
    setAttribute(Qt::WA_DeleteOnClose, true);
    setupUi(this);

    connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(slotCurrentCharFormatChanged(const QTextCharFormat &)));
    connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(slotCursorPositionChanged()));

    toolSave->setIcon(QIcon(":/icons/save.png"));
    connect(toolSave, SIGNAL(clicked(bool)), this, SLOT(slotSave()));

    toolReload->setIcon(QIcon(":/icons/refresh.png"));
    connect(toolReload, SIGNAL(clicked(bool)), this, SLOT(slotReload()));

    toolPrint->setIcon(QIcon(":/icons/iconPrint22x22.png"));
    connect(toolPrint, SIGNAL(clicked(bool)), this, SLOT(slotPrintPreview()));

    connect(textEdit, SIGNAL(textChanged()), this, SLOT(setWindowModified()));
    connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));

    toolExit->setIcon(QIcon(":/icons/iconExit16x16.png"));
    connect(toolExit, SIGNAL(clicked(bool)), this, SLOT(close()));

    actionTextBold = new QAction(QIcon(":/icons/textbold.png"), tr("&Bold"), this);
    actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
    QFont bold;
    bold.setBold(true);
    actionTextBold->setFont(bold);
    connect(actionTextBold, SIGNAL(triggered()), this, SLOT(slotTextBold()));
    actionTextBold->setCheckable(true);
    toolBold->setDefaultAction(actionTextBold);

    actionTextItalic = new QAction(QIcon(":/icons/textitalic.png"), tr("&Italic"), this);
    actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
    QFont italic;
    italic.setItalic(true);
    actionTextItalic->setFont(italic);
    connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(slotTextItalic()));
    actionTextItalic->setCheckable(true);
    toolItalic->setDefaultAction(actionTextItalic);

    actionTextUnderline = new QAction(QIcon(":/icons/textunder.png"), tr("&Underline"), this);
    actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
    QFont underline;
    underline.setUnderline(true);
    actionTextUnderline->setFont(underline);
    connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(slotTextUnderline()));
    actionTextUnderline->setCheckable(true);
    toolUnder->setDefaultAction(actionTextUnderline);

    QPixmap pix(24, 24);
    pix.fill(Qt::black);
    actionTextColor = new QAction(pix, tr("&Color..."), this);
    connect(actionTextColor, SIGNAL(triggered()), this, SLOT(slotTextColor()));
    toolColor->setDefaultAction(actionTextColor);

    comboStyle->addItem("standard");
    comboStyle->addItem("Bullet List (Disc)");
    comboStyle->addItem("Bullet List (Circle)");
    comboStyle->addItem("Bullet List (Square)");
    comboStyle->addItem("Ordered List (Decimal)");
    comboStyle->addItem("Ordered List (Alpha lower)");
    comboStyle->addItem("Ordered List (Alpha upper)");
    connect(comboStyle, SIGNAL(activated(int)), this, SLOT(slotTextStyle(int)));

    QAction *a;
    a = actionUndo = new QAction(QIcon(":/icons/editundo.png"), tr("&Undo"), this);
    a->setShortcut(QKeySequence::Undo);
    toolUndo->setDefaultAction(a);

    a = actionRedo = new QAction(QIcon(":/icons/editredo.png"), tr("&Redo"), this);
    a->setShortcut(QKeySequence::Redo);
    toolRedo->setDefaultAction(a);

    a = actionCut = new QAction(QIcon(":/icons/editcut.png"), tr("Cu&t"), this);
    a->setShortcut(QKeySequence::Cut);
    toolCut->setDefaultAction(a);

    a = actionCopy = new QAction(QIcon(":/icons/editcopy.png"), tr("&Copy"), this);
    a->setShortcut(QKeySequence::Copy);
    toolCopy->setDefaultAction(a);

    a = actionPaste = new QAction(QIcon(":/icons/editpaste.png"), tr("&Paste"), this);
    a->setShortcut(QKeySequence::Paste);
    toolPaste->setDefaultAction(a);

    actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty());
    actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
    actionRedo->setEnabled(textEdit->document()->isRedoAvailable());

    connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool)));

    connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));

    actionCut->setEnabled(false);
    actionCopy->setEnabled(false);

    connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));

    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged()));

    textEdit->setFocus();
    colorChanged(textEdit->textColor());

    SETTINGS;
    checkGeoCache->setChecked(cfg.value("diary/showGeoCaches", false).toBool());
    connect(checkGeoCache, SIGNAL(clicked()), this, SLOT(slotIntReload()));

    checkProfile->setChecked(cfg.value("diary/showProfiles", true).toBool());
    connect(checkProfile, SIGNAL(clicked()), this, SLOT(slotIntReload()));

    checkAddMap->setChecked(cfg.value("diary/addMapView", true).toBool());

}
コード例 #7
0
ファイル: mrichtextedit.cpp プロジェクト: Iownnoname/qt
MRichTextEdit::MRichTextEdit(QWidget *parent)
    : QWidget(parent)
{
    setupUi(this);
    m_lastBlockList = 0;
    f_textedit->setTabStopWidth(40);

    connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this,     SLOT(slotCurrentCharFormatChanged(QTextCharFormat)));
    connect(f_textedit, SIGNAL(cursorPositionChanged()),
            this,     SLOT(slotCursorPositionChanged()));

    m_fontsize_h1 = 18;
    m_fontsize_h2 = 16;
    m_fontsize_h3 = 14;
    m_fontsize_h4 = 12;

    fontChanged(f_textedit->font());
    bgColorChanged(f_textedit->textColor());

    // paragraph formatting

    m_paragraphItems    << tr("Standard")
                        << tr("Heading 1")
                        << tr("Heading 2")
                        << tr("Heading 3")
                        << tr("Heading 4")
                        << tr("Monospace");
    f_paragraph->addItems(m_paragraphItems);

    connect(f_paragraph, SIGNAL(activated(int)),
            this, SLOT(textStyle(int)));

    // undo & redo

    f_undo->setShortcut(QKeySequence::Undo);
    f_redo->setShortcut(QKeySequence::Redo);

    connect(f_textedit->document(), SIGNAL(undoAvailable(bool)),
            f_undo, SLOT(setEnabled(bool)));
    connect(f_textedit->document(), SIGNAL(redoAvailable(bool)),
            f_redo, SLOT(setEnabled(bool)));

    f_undo->setEnabled(f_textedit->document()->isUndoAvailable());
    f_redo->setEnabled(f_textedit->document()->isRedoAvailable());

    connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo()));
    connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo()));

    // cut, copy & paste
    f_cut->setShortcut(QKeySequence::Cut);
    f_copy->setShortcut(QKeySequence::Copy);
    f_paste->setShortcut(QKeySequence::Paste);

    f_cut->setEnabled(false);
    f_copy->setEnabled(false);

    connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut()));
    connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy()));
    connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste()));

    connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool)));
    connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool)));

#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged()));
#endif

    // link
    f_link->setShortcut(Qt::CTRL + Qt::Key_L);

    connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool)));

    // bold, italic & underline
    f_bold->setShortcut(Qt::CTRL + Qt::Key_B);
    f_italic->setShortcut(Qt::CTRL + Qt::Key_I);
    f_underline->setShortcut(Qt::CTRL + Qt::Key_U);

    connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold()));
    connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic()));
    connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline()));
    connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout()));

    // lists
    f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus);
    f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal);

    connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool)));
    connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool)));

    // indentation
    f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma);
    f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period);

    connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation()));
    connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation()));

    // font size
    QFontDatabase db;
    foreach(int size, db.standardSizes())
    {
        f_fontsize->addItem(QString::number(size));
    }

    connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString)));
    f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font().pointSize())));


    // text background color
    QPixmap pix(16, 16);
    pix.fill(QApplication::palette().background().color());
    f_bgcolor->setIcon(pix);

    connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor()));

    // images
    connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage()));
}
コード例 #8
0
ファイル: leftsidebarwidgets.cpp プロジェクト: UIKit0/digikam
TimelineSideBarWidget::TimelineSideBarWidget(QWidget* parent, SearchModel* searchModel,
        SearchModificationHelper* searchModificationHelper)
    : SidebarWidget(parent), d(new TimelineSideBarWidgetPriv)
{
    setObjectName("TimeLine Sidebar");

    d->searchModificationHelper = searchModificationHelper;
    d->timer                    = new QTimer(this);
    setAttribute(Qt::WA_DeleteOnClose);

    QVBoxLayout* vlay = new QVBoxLayout(this);
    QFrame* panel     = new QFrame(this);
    panel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
    panel->setLineWidth(1);

    QGridLayout* grid = new QGridLayout(panel);

    // ---------------------------------------------------------------

    QWidget* hbox1    = new QWidget(panel);
    QHBoxLayout* hlay = new QHBoxLayout(hbox1);

    QLabel* label1 = new QLabel(i18n("Time Unit:"), hbox1);
    d->timeUnitCB  = new KComboBox(hbox1);
    d->timeUnitCB->addItem(i18n("Day"),   TimeLineWidget::Day);
    d->timeUnitCB->addItem(i18n("Week"),  TimeLineWidget::Week);
    d->timeUnitCB->addItem(i18n("Month"), TimeLineWidget::Month);
    d->timeUnitCB->addItem(i18n("Year"),  TimeLineWidget::Year);
    d->timeUnitCB->setCurrentIndex((int)TimeLineWidget::Month);
    d->timeUnitCB->setFocusPolicy(Qt::NoFocus);
    d->timeUnitCB->setWhatsThis(i18n("<p>Select the histogram time unit.</p>"
                                     "<p>You can change the graph decade to zoom in or zoom out over time.</p>"));

    QWidget* scaleBox  = new QWidget(hbox1);
    QHBoxLayout* hlay2 = new QHBoxLayout(scaleBox);
    d->scaleBG         = new QButtonGroup(scaleBox);
    d->scaleBG->setExclusive(true);
    scaleBox->setWhatsThis( i18n("<p>Select the histogram scale.</p>"
                                 "<p>If the date's maximal counts are small, you can use the linear scale.</p>"
                                 "<p>Logarithmic scale can be used when the maximal counts are big; "
                                 "if it is used, all values (small and large) will be visible on the "
                                 "graph.</p>"));

    QToolButton* linHistoButton = new QToolButton(scaleBox);
    linHistoButton->setToolTip( i18n( "Linear" ) );
    linHistoButton->setIcon(KIcon("view-object-histogram-linear"));
    linHistoButton->setCheckable(true);
    d->scaleBG->addButton(linHistoButton, TimeLineWidget::LinScale);

    QToolButton* logHistoButton = new QToolButton(scaleBox);
    logHistoButton->setToolTip( i18n( "Logarithmic" ) );
    logHistoButton->setIcon(KIcon("view-object-histogram-logarithmic"));
    logHistoButton->setCheckable(true);
    d->scaleBG->addButton(logHistoButton, TimeLineWidget::LogScale);

    hlay2->setMargin(0);
    hlay2->setSpacing(0);
    hlay2->addWidget(linHistoButton);
    hlay2->addWidget(logHistoButton);

    hlay->setMargin(0);
    hlay->setSpacing(KDialog::spacingHint());
    hlay->addWidget(label1);
    hlay->addWidget(d->timeUnitCB);
    hlay->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum));
    hlay->addWidget(scaleBox);

    // ---------------------------------------------------------------

    d->timeLineWidget = new TimeLineWidget(panel);
    d->scrollBar      = new QScrollBar(panel);
    d->scrollBar->setOrientation(Qt::Horizontal);
    d->scrollBar->setMinimum(0);
    d->scrollBar->setSingleStep(1);

    d->cursorDateLabel  = new KSqueezedTextLabel(0, panel);
    d->cursorCountLabel = new QLabel(panel);
    d->cursorCountLabel->setAlignment(Qt::AlignRight);

    // ---------------------------------------------------------------

    KHBox* hbox2 = new KHBox(panel);
    hbox2->setMargin(0);
    hbox2->setSpacing(KDialog::spacingHint());

    d->resetButton = new QToolButton(hbox2);
    d->resetButton->setIcon(SmallIcon("document-revert"));
    d->resetButton->setToolTip(i18n("Clear current selection"));
    d->resetButton->setWhatsThis(i18n("If you press this button, the current date selection on the time-line will be cleared."));
    d->nameEdit    = new KLineEdit(hbox2);
    d->nameEdit->setClearButtonShown(true);
    d->nameEdit->setWhatsThis(i18n("Enter the name of the current dates search to save in the "
                                   "\"My Date Searches\" view"));

    d->saveButton  = new QToolButton(hbox2);
    d->saveButton->setIcon(SmallIcon("document-save"));
    d->saveButton->setEnabled(false);
    d->saveButton->setToolTip(i18n("Save current selection to a new virtual Album"));
    d->saveButton->setWhatsThis(i18n("If you press this button, the dates selected on the time-line will be "
                                     "saved to a new search virtual Album using the name set on the left."));

    // ---------------------------------------------------------------

    grid->addWidget(hbox1,               0, 0, 1, 4);
    grid->addWidget(d->cursorDateLabel,  1, 0, 1, 3);
    grid->addWidget(d->cursorCountLabel, 1, 3, 1, 1);
    grid->addWidget(d->timeLineWidget,   2, 0, 1, 4);
    grid->addWidget(d->scrollBar,        3, 0, 1, 4);
    grid->addWidget(hbox2,               4, 0, 1, 4);
    grid->setColumnStretch(2, 10);
    grid->setMargin(KDialog::spacingHint());
    grid->setSpacing(KDialog::spacingHint());

    // ---------------------------------------------------------------

    d->timeLineFolderView = new EditableSearchTreeView(this, searchModel, searchModificationHelper);
    d->timeLineFolderView->setConfigGroup(getConfigGroup());
    d->timeLineFolderView->filteredModel()->listTimelineSearches();
    d->timeLineFolderView->filteredModel()->setListTemporarySearches(false);
    d->timeLineFolderView->setAlbumManagerCurrentAlbum(true);
    d->searchDateBar      = new SearchTextBar(this, "TimeLineViewSearchDateBar");
    d->searchDateBar->setModel(d->timeLineFolderView->filteredModel(),
                               AbstractAlbumModel::AlbumIdRole,
                               AbstractAlbumModel::AlbumTitleRole);
    d->searchDateBar->setFilterModel(d->timeLineFolderView->albumFilterModel());

    vlay->addWidget(panel);
    vlay->addWidget(d->timeLineFolderView);
    vlay->addItem(new QSpacerItem(KDialog::spacingHint(), KDialog::spacingHint(),
                                  QSizePolicy::Minimum, QSizePolicy::Minimum));
    vlay->addWidget(d->searchDateBar);
    vlay->setMargin(0);
    vlay->setSpacing(0);

    // ---------------------------------------------------------------

    connect(AlbumManager::instance(), SIGNAL(signalDatesMapDirty(const QMap<QDateTime, int>&)),
            d->timeLineWidget, SLOT(slotDatesMap(const QMap<QDateTime, int>&)));

    connect(d->timeLineFolderView, SIGNAL(currentAlbumChanged(Album*)),
            this, SLOT(slotAlbumSelected(Album*)));

    connect(d->timeUnitCB, SIGNAL(activated(int)),
            this, SLOT(slotTimeUnitChanged(int)));

    connect(d->scaleBG, SIGNAL(buttonReleased(int)),
            this, SLOT(slotScaleChanged(int)));

    connect(d->timeLineWidget, SIGNAL(signalDateMapChanged()),
            this, SLOT(slotInit()));

    connect(d->timeLineWidget, SIGNAL(signalCursorPositionChanged()),
            this, SLOT(slotCursorPositionChanged()));

    connect(d->timeLineWidget, SIGNAL(signalSelectionChanged()),
            this, SLOT(slotSelectionChanged()));

    connect(d->timeLineWidget, SIGNAL(signalRefDateTimeChanged()),
            this, SLOT(slotRefDateTimeChanged()));

    connect(d->timer, SIGNAL(timeout()),
            this, SLOT(slotUpdateCurrentDateSearchAlbum()));

    connect(d->resetButton, SIGNAL(clicked()),
            this, SLOT(slotResetSelection()));

    connect(d->saveButton, SIGNAL(clicked()),
            this, SLOT(slotSaveSelection()));

    connect(d->scrollBar, SIGNAL(valueChanged(int)),
            this, SLOT(slotScrollBarValueChanged(int)));

    connect(d->nameEdit, SIGNAL(textChanged(const QString&)),
            this, SLOT(slotCheckAboutSelection()));

    connect(d->nameEdit, SIGNAL(returnPressed(const QString&)),
            d->saveButton, SLOT(animateClick()));
}
コード例 #9
0
TextEdit::TextEdit(QWidget *parent): QTextEdit(parent)
{

    this->setFont(QFont("Monaco", 10));
    this->setTabStopWidth(fontMetrics().width("\t")/2);
    connect(this,SIGNAL(cursorPositionChanged()),this,SLOT(slotCursorPositionChanged()));

    QFile file("/tmp/a.m");
    file.open(QIODevice::ReadOnly|QIODevice::Text);
    QByteArray data = file.readAll();
    QTextStream in(&data);
    QString decodedStr = in.readAll();
    setPlainText(decodedStr);
    file.close();
    cx_index = clang_createIndex(0,0);
    struct CXUnsavedFile unsaved_file;
    unsaved_file.Filename = "/tmp/a.m";
    unsaved_file.Contents = (char*)calloc(sizeof(char), 4096);
    unsaved_file.Length = this->toPlainText().length();
    char **cmd_args =  (char**)calloc(sizeof(char*), 6);
    int i = 0;
    for(i ; i <6; i++) {
    cmd_args[i] = (char*)calloc(sizeof(char), 1000 + 1);
    strcpy(cmd_args[i], "-cc1");
    strcpy(cmd_args[i], "-fsyntax-only");
    strcpy(cmd_args[i], "-code-completion-macros");
    strcpy(cmd_args[i], "-code-completion-patterns");
    strcpy(cmd_args[i], "-x objective-c");
    strcpy(cmd_args[i], "-I/usr/share/iPhoneOS5.0.sdk/usr/include");
    }

    cx_tu = clang_parseTranslationUnit(cx_index, "/tmp/a.m" , cmd_args, 6, &unsaved_file, 1, CXTranslationUnit_PrecompiledPreamble|CXTranslationUnit_Incomplete);
    if(!cx_tu)
        qDebug()<<"cx_tu";

    //connect(this,SIGNAL(textChanged()), this,SLOT(slotReparse()));



    completionList = new QListWidget(this);
    completionList->setSelectionMode( QAbstractItemView::SingleSelection );
    completionList->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
    completionList->hide();
    completionList->setSortingEnabled( true );
    completionList->setSelectionMode( QAbstractItemView::SingleSelection );
    QPalette palette;
    palette.setBrush(QPalette::Active, QPalette::Base, Qt::white);
    completionList->setPalette(palette);

    m_formatFunction.setForeground(Qt::black);
    m_formatSingleLineComment.setForeground(Qt::red);
    m_formatKeyword.setForeground(Qt::blue);
    m_formatUserKeyword.setForeground(Qt::darkBlue);
    m_formatOperator.setForeground(Qt::black);
    m_formatNumber.setForeground(Qt::darkMagenta);
    m_formatEscapeChar.setForeground(Qt::darkBlue);
    m_formatMacro.setForeground(Qt::darkGreen);
    m_formatMultiLineComment.setForeground(Qt::red);
    m_formatString.setForeground(Qt::darkCyan);

    //connect(m_completionList, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(slotWordCompletion(QListWidgetItem *)) );
}