void ctkCmdLineModuleExplorerShowXmlAction::run()
{
  QDialog* dialog = new QDialog();
  try
  {
    dialog->setWindowTitle(this->ModuleRef.description().title());
  }
  catch (const ctkCmdLineModuleXmlException&)
  {
    dialog->setWindowTitle(this->ModuleRef.location().toString());
  }

  dialog->setLayout(new QVBoxLayout());

  QHBoxLayout* buttonLayout = new QHBoxLayout();
  buttonLayout->addStretch(1);
  QPushButton* closeButton = new QPushButton(tr("Close"), dialog);
  buttonLayout->addWidget(closeButton);

  QTextEdit* textEdit = new QTextEdit(dialog);
  textEdit->setPlainText(this->ModuleRef.rawXmlDescription().data());

  QLabel* statusLabel = new QLabel(dialog);
  statusLabel->setWordWrap(true);
  if (this->ModuleRef.xmlValidationErrorString().isEmpty())
  {
    statusLabel->setText(tr("No validation errors."));
  }
  else
  {
    statusLabel->setText(this->ModuleRef.xmlValidationErrorString());
  }
  dialog->layout()->addWidget(statusLabel);
  dialog->layout()->addWidget(textEdit);
  dialog->layout()->addItem(buttonLayout);

  connect(closeButton, SIGNAL(clicked()), dialog, SLOT(close()));

  dialog->resize(800, 600);
  dialog->show();
}
void UpgradeMessage::createPage034 ()
{
  QWidget *w = new QWidget(this);
  
  QVBoxLayout *vbox = new QVBoxLayout(w);
  vbox->setMargin(5);
  vbox->setSpacing(5);

  QString s = tr("Your workspace will be converted into the ~/.qtstalker/data1/ directory.");
  s.append(tr(" It could take a long time if there are many data items."));
  s.append(tr(" When satisfied, the old workspace can be manually removed from ~/.qtstalker/data0/\n"));
  s.append(tr("\n"));
  s.append(tr(" If you choose Cancel, then Quit immediately and see the cleanup notes in docs/install.html"));
  QTextEdit *message = new QTextEdit(w);
  message->setReadOnly(TRUE);
  message->setText(s);
  vbox->addWidget(message);

  QHBoxLayout *hbox = new QHBoxLayout(vbox);
  hbox->setSpacing(2);

  QLabel *label = new QLabel(tr("Progress"), w);
  hbox->addWidget(label);

  progBar = new QProgressBar(w);
  hbox->addWidget(progBar);

  addTab(w, tr("Chart Conversion"));

  QPushButton *button = new QPushButton(tr("Perform Conversion"), w);
  QObject::connect(button, SIGNAL(clicked()), this, SLOT(convert034()));
  vbox->addWidget(button);

  vbox->addStretch(1);
  
  setOkButton(QString::null);  

  setCancelButton(tr("&Cancel"));

  resize(500, 300);
}
Example #3
0
void
QUimTextUtil::QTextEditPositionForward( int *cursor_para, int *cursor_index )
{
    QTextEdit *edit = (QTextEdit *)mWidget;
    int n_para = edit->paragraphs();
    int preedit_len, preedit_cursor_pos;
    int current_para_len;
    int para, index;
    int current_para, current_index;

    current_para = *cursor_para;
    current_index = *cursor_index;

    current_para_len = edit->paragraphLength( current_para );
    if ( ! mPreeditSaved ) {
        preedit_len = mIc->getPreeditString().length();
        preedit_cursor_pos = mIc->getPreeditCursorPosition();
    } else {
        preedit_len = 0;
        preedit_cursor_pos = 0;
    }
    edit->getCursorPosition( &para, &index );

    if ( current_para == para && current_index >= ( index - preedit_cursor_pos ) && current_index < ( index - preedit_cursor_pos + preedit_len ) )
        current_index = index - preedit_cursor_pos + preedit_len;

    if ( current_para == n_para - 1 ) {
        if ( current_index < current_para_len )
            current_index++;
    } else {
        if ( current_index < current_para_len )
            current_index++;
        else {
            current_para++;
            current_index = 0;
        }
    }

    *cursor_para = current_para;
    *cursor_index = current_index;
}
void
CSAVE_WORKSHEET::
updateMasterPm( QTabWidget * tabWidget)
{
    QTextEdit * textEdit = new QTextEdit();
    textEdit->clear();
    textEdit->hide();
    tabWidget->hide();

    // reset tab3 row count
    tabWidget->setCurrentIndex(3);
    QTableWidget * table3 = dynamic_cast<QTableWidget *>(tabWidget->currentWidget());
    table3->setRowCount(0);

    for ( int i = 0; i < tabWidget->count()-1; i++ )
    {
        tabWidget->setCurrentIndex(i);
        QTableWidget *table = dynamic_cast<QTableWidget *>(tabWidget->currentWidget()); // get control
        for ( int j = 0; j < table->rowCount(); j++ )
        {
            QString itemData;
            for ( int k = 0; k < 12; k++ )
                 itemData.append(table->item(j,k)->text().trimmed().toLatin1()+" | ");

            table3->insertRow(table3->rowCount());
            for ( int col = 0; col < 12; col++ )
            {
                QTableWidgetItem * item = new QTableWidgetItem(itemData.split("|").at(col).trimmed());

                if ( col == 0 )
                    item->setTextAlignment(Qt::AlignVCenter | Qt::AlignLeft);
                else
                    item->setTextAlignment(Qt::AlignCenter);

                item->setFlags(item->flags() & ~Qt::ItemIsEditable);
                table3->setItem(table3->rowCount()-1,col,item);
            }
        }
    }
    tabWidget->show();
}
Example #5
0
bool GCF::Components::AboutBox::eventFilter(QObject* obj, QEvent* event)
{
    if(!obj->isWidgetType())
        return false;

    if(event->type() != QEvent::MouseButtonPress)
        return false;

    QWidget* wid = (QWidget*)obj;
    QTextEdit* te = qobject_cast<QTextEdit*>(wid->parentWidget());
    if(!te)
        return false;

    QMouseEvent* me = (QMouseEvent*)event;
    QString anchor = te->anchorAt(me->pos());
    if(anchor.isEmpty())
        return false;

    QDesktopServices::openUrl( QUrl(anchor) );
    return false;
}
void SourceViewer::onSelectionChanged()
{
	if(workingHighlightText_)
		return;

	if(gGlobalEvent.isMousePressed() == true)
		return;

	QTextEdit *logTextEdit = getCurrentSourceEdit();
	if(logTextEdit != NULL)
	{
		QString s = logTextEdit->textCursor().selectedText();

		if(s.isEmpty() == false && s.length() < 50)
		{
			qDebug() << "onLogSelectionChanged : " << gGlobalEvent.isMousePressed() << s;

			ui.searchText->setText(s);
		}
	}
}
Example #7
0
void DelegateDoubleItem::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
    QTextEdit *textEdit = static_cast<QTextEdit*>(editor);

    QString data = textEdit->toPlainText();

    data.replace( "m","e-3" );
    data.replace( "u", "e-6" );
    data.replace("n","e-9");
    data.replace("p","e-12");
    data.replace("f","e-15");
    data.replace("K","e3");
    data.replace("M","e6");
    data.replace("G","e9");
    data.replace("T","e12");

    double prevData = model->data(index,Qt::EditRole).toDouble();
    bool ok;
    double value = data.toDouble(&ok);
    if(!ok) value = prevData;
    model->setData(index,value,Qt::EditRole);
}
Example #8
0
void PsiTipLabel::initUi()
{
	margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
	setFrameStyle(QFrame::NoFrame);

	// doc = new QTextDocument(this);
	// QTextDocumentLayout is private in Qt4
	// and it's impossible to set wrapping mode directly.
	// So we create this QTextEdit instance and use its QTextDocument,
	// just because QTextEdit can set the wrapping mode.
	// Yes, this is crazy...
	QTextEdit *edit = new QTextEdit(this);
	edit->hide();
	edit->setWordWrapMode(QTextOption::WordWrap);
	doc = edit->document();
	doc->setUndoRedoEnabled(false);
	doc->setDefaultFont(font());

	ensurePolished();
	setText(theText_);
}
void MainWindow::hamza(){
    int hamza[9][9] = {
      { 0, 0, 0, 7, 0, 0, 8, 0, 0 },
      { 0, 0, 0, 0, 4, 0, 0, 3, 0 },
      { 0, 0, 0, 0, 0, 9, 0, 0, 1 },
      { 6, 0, 0, 5, 0, 0, 0, 0, 0 },
      { 0, 1, 0, 0, 3, 0, 0, 4, 0 },
      { 0, 0, 5, 0, 0, 1, 0, 0, 7 },
      { 5, 0, 0, 2, 0, 0, 6, 0, 0 },
      { 0, 3, 0, 0, 8, 0, 0, 9, 0 },
      { 0, 0, 7, 0, 0, 0, 0, 0, 2 }
    };
    QList<QTextEdit*> textEdits = centralWidget->findChildren<QTextEdit *>();
    for(int i = 0; i < textEdits.count(); i++) {
        int y = (int(floor(i / 3)) % 3) + (3 * floor(i / 27));
        int x = (i % 3) + (3 * floor(i / 9)) - (9 * floor(i / 27));
        QTextEdit * tile = textEdits.at(i);
        QString s = QString::number(hamza[y][x]);
        tile->setText(s);
    }
}
Example #10
0
void EditProfileDialog::showEnvironmentEditor()
{
    const Profile::Ptr info = lookupProfile();

    KDialog* dialog = new KDialog(this);
    QTextEdit* edit = new QTextEdit(dialog);

    QStringList currentEnvironment = info->property<QStringList>(Profile::Environment);

    edit->setPlainText( currentEnvironment.join("\n") );
    dialog->setPlainCaption(i18n("Edit Environment"));
    dialog->setMainWidget(edit);

    if ( dialog->exec() == QDialog::Accepted )
    {
        QStringList newEnvironment = edit->toPlainText().split('\n');
        _tempProfile->setProperty(Profile::Environment,newEnvironment);
    }

    dialog->deleteLater();
}
Example #11
0
void PeersDialog::checkChat()
{
	/* if <return> at the end of the text -> we can send it! */
        QTextEdit *chatWidget = ui.lineEdit;
        std::string txt = chatWidget->toPlainText().toStdString();
	if ('\n' == txt[txt.length()-1])
	{
		//std::cerr << "Found <return> found at end of :" << txt << ": should send!";
		//std::cerr << std::endl;
		if (txt.length()-1 == txt.find('\n')) /* only if on first line! */
		{
			/* should remove last char ... */
			sendMsg();
		}
	}
	else
	{
		//std::cerr << "No <return> found in :" << txt << ":";
		//std::cerr << std::endl;
	}
}
Example #12
0
/**
 * Constructor.
 *
 * @param message The error message to be displayed
 * @param data The line of CSV data which triggered the error
 * @param parent The parent widget, if any
 */
CSVErrorDialog::CSVErrorDialog(const QString &message, const QString &data, QWidget *parent)
  : PBDialog("", parent)
{
    vbox->addWidget(new QLabel(message, this));
    vbox->addWidget(new QLabel(tr("Problematic row") + ":", this));

    QTextEdit *dataBox = new QTextEdit(parent);
    dataBox->setReadOnly(true);
#if defined(Q_WS_MAEMO_5)
    QVariant ksProp = dataBox->property("kineticScroller");
    QAbstractKineticScroller *ks = ksProp.value<QAbstractKineticScroller *>();
    if (ks) {
        ks->setEnabled(true);
    }
#endif
    dataBox->setLineWrapMode(QTextEdit::NoWrap);
    dataBox->setPlainText(data);
    vbox->addWidget(dataBox);

    finishLayout(true, false);
}
Example #13
0
void EulaWidget::setupUi()
{
   QVBoxLayout * vb = new QVBoxLayout;
   setLayout(vb);
   
   QTextEdit * plain = new QTextEdit(this);
   plain->setReadOnly(true);
   
   QFile file(":/text/license.txt");
   file.open(QIODevice::ReadOnly | QIODevice::Text);
   if (file.isOpen())
   {
      QByteArray ba = file.readAll();
      file.close();
      QString str = QString::fromUtf8(ba.data());

      plain->setText(str);
   }

   vb->addWidget(plain);
}
Example #14
0
void ClipboardDialog::on_listWidgetFormats_currentItemChanged(
        QListWidgetItem *current, QListWidgetItem *)
{
    ui->actionRemove_Format->setEnabled(current != NULL);

    QTextEdit *edit = ui->textEditContent;
    QString mime = current ? current->text() : QString();

    edit->clear();
    const QByteArray bytes = m_data.value(mime).toByteArray();
    if ( mime.startsWith(QString("image")) ) {
        edit->document()->addResource( QTextDocument::ImageResource,
                                       QUrl("data://1"), bytes );
        edit->setHtml( QString("<img src=\"data://1\" />") );
    } else {
        edit->setPlainText( dataToText(bytes, mime) );
    }

    ui->labelProperties->setText(
                tr("<strong>Size:</strong> %1 bytes", "Size of data in bytes").arg(bytes.size()) );
}
Example #15
0
void FindDialog::find(bool backwards)
{
	QString text = m_find_string->text();
	if (text.isEmpty()) {
		return;
	}

	QTextDocument::FindFlags flags;
	if (!m_ignore_case->isChecked()) {
		flags |= QTextDocument::FindCaseSensitively;
	}
	if (m_whole_words->isChecked()) {
		flags |= QTextDocument::FindWholeWords;
	}
	if (backwards) {
		flags |= QTextDocument::FindBackward;
	}

	QTextEdit* document = m_documents->currentDocument()->text();
	QTextCursor cursor = document->document()->find(text, document->textCursor(), flags);
	if (cursor.isNull()) {
		cursor = document->textCursor();
		cursor.movePosition(!backwards ? QTextCursor::Start : QTextCursor::End);
		cursor = document->document()->find(text, cursor, flags);
	}

	if (!cursor.isNull()) {
		document->setTextCursor(cursor);
	} else {
		QMessageBox::information(this, tr("Sorry"), tr("Phrase not found."));
	}
}
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QFont font("ZYSong18030",12);
    a.setFont(font);
    //主分割窗口
    QSplitter *splitterMain =new QSplitter(Qt::Horizontal,0);
    QTextEdit *textLeft =new QTextEdit(QObject::tr("Left Widget"),splitterMain);
    textLeft->setAlignment(Qt::AlignCenter);
    //右部分割窗口
    QSplitter *splitterRight =new QSplitter(Qt::Vertical,splitterMain);
    splitterRight->setOpaqueResize(false);
    QTextEdit *textUp =new QTextEdit(QObject::tr("Top Widget"),splitterRight);
    textUp->setAlignment(Qt::AlignCenter);
    QTextEdit *textBottom =new QTextEdit(QObject::tr("Bottom Widget"),splitterRight);
    textBottom->setAlignment(Qt::AlignCenter);
    splitterMain->setStretchFactor(1,1);
    splitterMain->setWindowTitle(QObject::tr("Splitter"));
    splitterMain->show();

    //MainWindow w;
    //w.show();
    
    return a.exec();
}
Example #17
0
bool
ResizableMessageBox::event(QEvent *e)
{
    bool result = QMessageBox::event(e);

    //QMessageBox::event in this case will call setFixedSize on the dialog frame, making it not resizable by the user
    if ( (e->type() == QEvent::LayoutRequest) || (e->type() == QEvent::Resize) ) {
        setMinimumHeight(0);
        setMaximumHeight(QWIDGETSIZE_MAX);
        setMinimumWidth(0);
        setMaximumWidth(QWIDGETSIZE_MAX);
        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

        // make the detailed text expanding
        QTextEdit *textEdit = findChild<QTextEdit *>();

        if (textEdit) {
            textEdit->setMinimumHeight(0);
            textEdit->setMaximumHeight(QWIDGETSIZE_MAX);
            textEdit->setMinimumWidth(0);
            textEdit->setMaximumWidth(QWIDGETSIZE_MAX);
            textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        }
    }

    return result;
}
Example #18
0
void MainWindow::on_insertImage_clicked()
{
    //get select image
    QString fn = QFileDialog::getOpenFileName(this, tr("插入图像"),
                                              QString(),
                                              tr("Joint Photographic Experts Group (*.jpg *.jpeg);;") +
                                              "Portable Network Graphics (*.png);;" +
                                              "Windows Bitmap (*.bmp);;" +
                                              "GIF (*.gif);;" +
                                              "Portable Bitmap (*.pbm);;" +
                                              "Portable Graymap (*.pgm);;" +
                                              "Portable Pixmap (*.ppm);;" +
                                              "X11 Bitmap (*.xbm);;" +
                                              "X11 Pixmap (*.xpm);;" +
                                              "Scalable Vector Graphics (*.svg);;" +
                                              "All Files (*)");

    if (fn.isEmpty())
        return;
    if (!(fn.endsWith(".jpg", Qt::CaseInsensitive)
          || fn.endsWith(".jpeg", Qt::CaseInsensitive)
          || fn.endsWith(".png", Qt::CaseInsensitive)
          || fn.endsWith(".gif", Qt::CaseInsensitive)
          || fn.endsWith(".pbm", Qt::CaseInsensitive)
          || fn.endsWith(".pgm", Qt::CaseInsensitive)
          || fn.endsWith(".ppm", Qt::CaseInsensitive)
          || fn.endsWith(".xbm", Qt::CaseInsensitive)
          || fn.endsWith(".xpm", Qt::CaseInsensitive)
          || fn.endsWith(".svg", Qt::CaseInsensitive))) {
        QMessageBox::warning(this, tr("自动出卷系统"), tr("不支持的文件格式。"));
        return;
    }

    QTextEdit *pEdit = textEditor.editor;
    QTextCursor cursor = pEdit->textCursor();
    QTextImageFormat imageFormat;
    imageFormat.setName(fn);
    //pEdit->setText();
    cursor.insertImage(imageFormat);
}
AboutDialog::AboutDialog(QWidget *parent)
	: QDialog(parent)
{
	QLabel *pixmapLabel = new QLabel;
	pixmapLabel->setPixmap(QPixmap(":/icons/qtikz-128.png"));
	QLabel *label = new QLabel(QString("<h1>%1 %2</h1><p>%3</p><p>%4</p>")
	                           .arg(KtikzApplication::applicationName())
	                           .arg(QCoreApplication::applicationVersion())
	                           .arg(tr("Copyright 2007-2011 Florian Hackenberger and Glad Deschrijver"))
	                           .arg(tr("This is a program for creating TikZ (from the LaTeX pgf package) diagrams.")));
	label->setWordWrap(true);

	QWidget *topWidget = new QWidget;
	QHBoxLayout *topLayout = new QHBoxLayout;
	topLayout->addWidget(pixmapLabel);
	topLayout->addWidget(label);
	topWidget->setLayout(topLayout);

	QTextEdit *textEdit = new QTextEdit(tr("<p>This program is free "
	                                       "software; you can redistribute it and/or modify it under the "
	                                       "terms of the GNU General Public License as published by the "
	                                       "Free Software Foundation; either version 2 of the License, "
	                                       "or (at your option) any later version.</p>"
	                                       "<p>This program is distributed in the hope that it will "
	                                       "be useful, but WITHOUT ANY WARRANTY; without even the implied "
	                                       "warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  "
	                                       "See the GNU General Public License for more details.</p>"));
	textEdit->setReadOnly(true);
	QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));

	QVBoxLayout *mainLayout = new QVBoxLayout(this);
	mainLayout->addWidget(topWidget);
	mainLayout->addWidget(textEdit);
	mainLayout->addWidget(buttonBox);
	mainLayout->setSpacing(10);
	buttonBox->setFocus();

	setWindowTitle(tr("About %1").arg(KtikzApplication::applicationName()));
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //ui->setupUi(this);
    //ustvarim Widget
    centralWidget = new QWidget(this);
    this->setCentralWidget( centralWidget );
    centralWidget->setWindowTitle("DLX");
    centralWidget->setMaximumSize(1000, 1000);
    centralWidget->setMinimumSize(10, 10);
    centralWidget->resize(400,400);
    mainLayout = new QGridLayout( centralWidget );
    mainLayout->setSpacing(0);
    for(int mr = 0; mr < 3; mr++)//ustvarim 3 vrstice
    {
        for(int mc = 0; mc < 3; mc++)//ustvarim 3 stolpce
        {
            //veliki robovi
            QFrame * widget = new QFrame;
            widget->setFrameStyle(QFrame::Plain);
            widget->setFrameShape(QFrame::Box);

            //znotraj velikih robov se en grid
            QGridLayout * gridLayout = new QGridLayout(widget);
            gridLayout->setSpacing(0);
            gridLayout->setMargin(0);

            for(int r = 0; r < 3; r++)//3 vrstice
            {
                for(int c = 0; c < 3; c++)//3 stolpci
                {
                    //ustvarim skatlo s textom
                    QTextEdit * tile = new QTextEdit("");
                    tile->setFrameStyle(QFrame::Plain);
                    tile->setFrameShape(QFrame::Box);
                    tile->setAlignment(Qt::AlignCenter);
                    tile->setTabChangesFocus(true);
                    tile->setStyleSheet("font: 24pt ;");

                    gridLayout->addWidget(tile, r, c, 1, 1, Qt::AlignCenter);
                }
            }
           mainLayout->addWidget(widget, mr, mc, 1, 1, Qt::AlignCenter);
        }
    }
    //ustvarim menu z eventom
    QMenuBar* menuBar = new QMenuBar();
    QMenu *fileMenu = new QMenu("Algoritem");
    menuBar->addMenu(fileMenu);
    QAction *helpAction = fileMenu->addAction("Find solution");
    connect(helpAction, SIGNAL(triggered()), this, SLOT(algoritem()));
    centralWidget->layout()->setMenuBar(menuBar);
    QMenu *fileMenu1 = new QMenu("Input");
    menuBar->addMenu(fileMenu1);
    QAction *Action = fileMenu1->addAction("Reset");
    connect(Action, SIGNAL(triggered()), this, SLOT(reset()));
    QAction *Action2 = fileMenu1->addAction("Qassim Hamza");
    connect(Action2, SIGNAL(triggered()), this, SLOT(hamza()));
}
Example #21
0
// LicensePage
LicensePage::LicensePage(QWidget * parent)
: QWizardPage(parent)
{
   isAgreed_ = false;
   setTitle(tr("License Agreement"));
   
   QVBoxLayout * vl = new QVBoxLayout;
   QTextEdit * plain = new QTextEdit(this);
   plain->setReadOnly(true);
   
   QString suffix;
   suffix = QLocale::system().name();
   suffix.truncate(2);
   QString licFile = QString(":/text/license_%1.txt").arg(suffix);
   if (!QFile::exists(licFile))
   {
      licFile = ":/text/license_en.txt";
   }
   QFile file(licFile);
   file.open(QIODevice::ReadOnly | QIODevice::Text);
   if (file.isOpen())
   {
      QByteArray ba = file.readAll();
      file.close();
      QString str = QString::fromUtf8(ba.data());

      plain->setText(str);
   }
   radYes_ = new QRadioButton(tr("I &accept the agreement"), this);
   radNo_ = new QRadioButton(tr("I &don't accept the agreenemt"), this);
   connect(radYes_, SIGNAL(toggled(bool)), this, SLOT(agreed(bool)));

   QLabel * lbl = new QLabel(tr("Please read the following License Agreement. You must accept the terms of this agreement before continuing with the installation."), this);
   lbl->setWordWrap(true);
   vl->addWidget(lbl);
   vl->addWidget(plain);
   vl->addWidget(radYes_);
   vl->addWidget(radNo_);
   setLayout(vl);
}
Example #22
0
    void highlightMatches(const QString &pattern)
    {
        QTextEdit *ed = qobject_cast<QTextEdit *>(m_widget);
        if (!ed)
            return;

        QTextCursor cur = ed->textCursor();

        QTextEdit::ExtraSelection selection;
        selection.format.setBackground(Qt::yellow);
        selection.format.setForeground(Qt::black);

        // Highlight matches.
        QTextDocument *doc = ed->document();
        QRegExp re(pattern);
        cur = doc->find(re);

        m_searchSelection.clear();

        int a = cur.position();
        while ( !cur.isNull() ) {
            if ( cur.hasSelection() ) {
                selection.cursor = cur;
                m_searchSelection.append(selection);
            } else {
                cur.movePosition(QTextCursor::NextCharacter);
            }
            cur = doc->find(re, cur);
            int b = cur.position();
            if (a == b) {
                cur.movePosition(QTextCursor::NextCharacter);
                cur = doc->find(re, cur);
                b = cur.position();
                if (a == b) break;
            }
            a = b;
        }

        updateExtraSelections();
    }
Example #23
0
/**
 * Creates a new tab, and initializes a new conversation with given ip and name.
 * @brief MainWindow::createTab
 * @param cid Conversation id.
 * @param ip IPv4 address
 * @param name Nickname
 */
void MainWindow::createTab(QString cid, QString ip, QString name)
{
    // Inflate tablelayout from file
        QFormBuilder builder;
        QFile file(FORM_TAB);
        file.open(QFile::ReadOnly);
        QWidget *tabLayout = builder.load(&file, this);
        file.close();

    // Add layout to a new tab
        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(tabLayout);
        QWidget *newTab = new QWidget(ui->tabgrpConversations);
        newTab->setLayout(layout);
        ui->tabgrpConversations->addTab(newTab, name + "/" + ip);

    //Add eventlisteners to new tab button, message text-box and smiley-list.
    QPushButton* btnSend = tabLayout->findChild<QPushButton*>("btnTabSend");
    connect(btnSend, SIGNAL(clicked()), this, SLOT(sendConvoMessage()));

    QTextEdit* txtMsg = tabLayout->findChild<QTextEdit*>(CONVO_TAB_MSG_ID);
    txtMsg->installEventFilter(this);

    QListWidget* lstSmil = tabLayout->findChild<QListWidget*>("lstTabSmileys");
    connect(lstSmil, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_lstSmileys_doubleClicked(QModelIndex)));
    for (int i = 0; i < smileys->count(); i++)
    {
        QListWidgetItem* qlwi = new QListWidgetItem(QIcon(RES_SMILEYS + QString::number(i) + ".png"), "");
        lstSmil->addItem(qlwi);
    }

    Conversation* c = new Conversation(cid);
    if(controller->isExternal(ip)) //External ip
    {
        c->add(ip, name, true);
    }
    else c->add(ip, name);

    convos->append(c);
}
Example #24
0
AboutDialog::AboutDialog(QWidget *p, AboutDialogOptions options) : QDialog(p) {
	setWindowTitle(tr("About Murmur"));
	setMinimumSize(QSize(400, 300));

	QTabWidget *qtwTab = new QTabWidget(this);
	QVBoxLayout *vblMain = new QVBoxLayout(this);

	QTextEdit *qteLicense = new QTextEdit(qtwTab);
	qteLicense->setReadOnly(true);
	qteLicense->setPlainText(License::license());

	QTextEdit *qteAuthors = new QTextEdit(qtwTab);
	qteAuthors->setReadOnly(true);
	qteAuthors->setPlainText(License::authors());

	QTextBrowser *qtb3rdPartyLicense = new QTextBrowser(qtwTab);
	qtb3rdPartyLicense->setReadOnly(true);
	qtb3rdPartyLicense->setOpenExternalLinks(true);

	QList<LicenseInfo> thirdPartyLicenses = License::thirdPartyLicenses();
	foreach(LicenseInfo li, thirdPartyLicenses) {
		qtb3rdPartyLicense->append(QString::fromLatin1("<h3>%1 (<a href=\"%2\">%2</a>)</h3><pre>%3</pre>")
				.arg(Qt::escape(li.name))
				.arg(Qt::escape(li.url))
				.arg(Qt::escape(li.license)));
	}
Example #25
0
  /*!
     * \class TextCursorInsertLink
   * \author Anders Fernström
   * \date 2005-12-05
     *
     * \brief Command for inserting an link
     */
  void TextCursorInsertLink::execute()

  {

//    QTextCursor cursor( document()->getCursor()->currentCell()->textCursor() );
    if( !cursor.isNull() )
    {
      if( cursor.hasSelection() )
      {
        QDir dir;
        QString currentfilepath = document()->getFilename();
        if( !currentfilepath.isEmpty() && !currentfilepath.isNull() )
          dir.setPath( QFileInfo(currentfilepath).absolutePath() );

        // check if dir exist
        if( !dir.exists() )
          return;
        // get the relative link path
        QString relativepath = dir.relativeFilePath( filepath_ );

        // create html code for the link and insert it to the document'
        QString text = cursor.selection().toHtml();
        int fragmentStart = text.indexOf( "<!--StartFragment-->",
          0, Qt::CaseInsensitive ) + 20;
        int fragmentEnd = text.indexOf( "<!--EndFragment-->",
          fragmentStart, Qt::CaseInsensitive );

        QString html = text.mid( fragmentStart, fragmentEnd - fragmentStart );
        QString htmlcode = "<a href=\"" + relativepath + "\">" +
          html + "</a>";
        cursor.insertFragment( QTextDocumentFragment::fromHtml( htmlcode ));

        // set the cursor, so there is no selection
                QTextEdit *editor = document()->getCursor()->currentCell()->textEdit();
        if( editor )
          editor->setTextCursor( cursor );
      }
    }
  }
Example #26
0
void Gui::privateMessage(const QString &receiver, const QString &message)
{
#ifdef DEBUG
	qDebug() << "You got the private message";
#endif
	QTextEdit* outputArea = NULL;
	bool isNeededTab = false;
	for (int i = 0; i < _tabs->count(); ++i)
		if (_tabs->tabText(i) == receiver) 
		{
			_outputAreas.at(i)->append(receiver + ": " + message);
			isNeededTab = true;
			break;
		}
	if (isNeededTab) return;
	outputArea = new QTextEdit;
	outputArea->setReadOnly(true);
	_tabs->addTab(outputArea, receiver);
	_outputAreas.append(outputArea);
	outputArea->setGeometry(0,0,395,230);
	outputArea->append(receiver + ": " + message);
}
Example #27
0
  virtual int setup() {
    QTextEdit *qw;
    uint32_t flags;
    GWEN_WIDGET *wParent;
    QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
    QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
    const char *s;
    QString text;
    QT4_GuiDialog *qtDialog;

    flags=GWEN_Widget_GetFlags(_widget);
    wParent=GWEN_Widget_Tree_GetParent(_widget);
    s=GWEN_Widget_GetText(_widget, 0);
    if (s)
      text=QString::fromUtf8(s);

    qw=new QTextEdit(text);

    /* handle flags */
    if (flags & GWEN_WIDGET_FLAGS_FILLX)
      hpolicy=QSizePolicy::Expanding;
    if (flags & GWEN_WIDGET_FLAGS_FILLY)
      vpolicy=QSizePolicy::Expanding;
    qw->setSizePolicy(hpolicy, vpolicy);

    GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);

    qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
    assert(qtDialog);

    qw->connect(qw, SIGNAL(returnPressed()),
                qtDialog->getMainWindow(),
                SLOT(slotActivated()));


    if (wParent)
      GWEN_Widget_AddChildGuiWidget(wParent, _widget);
    return 0;
  }
// -------------------------------------------------------------------------------------------------
void AboutDialog::setupLicenseTab()
{
    QVBox* licenseTab = new QVBox(this);
    
    QTextEdit* textEdit = new QTextEdit(licenseTab);
    textEdit->setReadOnly(true);
    textEdit->setWordWrap(QTextEdit::FixedColumnWidth);
    textEdit->setWrapColumnOrWidth(100);
    
    QString fileName = qApp->applicationDirPath() + "/../share/tfla-01/COPYING";
    if (QFile::exists(fileName))
    {
        QFile file(fileName);
        if (file.open( IO_ReadOnly )) 
        {
            QTextStream stream(&file);
            textEdit->setText("<pre>" + stream.read() + "</pre>");
        }
    }
    
    m_tabWidget->addTab(licenseTab, tr("&License"));
}
Example #29
0
InfoPanel::InfoPanel(QWidget *parent) :QWidget(parent)
{
    #ifdef K_DEBUG
           TINIT;
    #endif

    QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);

    QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);
    QLabel *label = new QLabel(tr("Tips"));
    label->setAlignment(Qt::AlignHCenter); 
    layout->addWidget(label);

    mainLayout->addLayout(layout);

    QTextEdit *textArea = new QTextEdit; 
    textArea->setFixedHeight(250);
    textArea->setHtml("<p><b>" + tr("Close line") + ":</b> " + tr("X key or Right mouse button") + "</p>"); 
    mainLayout->addWidget(textArea);
   
    mainLayout->addStretch(2);
}
/*!

*/
void
DebugMessageWindow::findString( const QString & expr )
{
    // case insentive && no whole word
    QTextDocument::FindFlags flags( M_find_forward_rb->isChecked()
                                    ? 0
                                    : QTextDocument::FindBackward );
    QTextEdit * edit = M_message[ M_tab_widget->currentIndex() ];
    if ( ! edit->find( expr, flags ) )
    {
        if ( M_find_forward_rb->isChecked() )
        {
            edit->moveCursor( QTextCursor::Start );
        }
        else
        {
            edit->moveCursor( QTextCursor::End );
        }

        edit->find( expr, flags );
    }
}