当前位置: 首页>>代码示例>>C++>>正文


C++ QListWidgetItem类代码示例

本文整理汇总了C++中QListWidgetItem的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem类的具体用法?C++ QListWidgetItem怎么用?C++ QListWidgetItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QListWidgetItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QDialog

ImportMegaLinksDialog::ImportMegaLinksDialog(MegaApi *megaApi, Preferences *preferences, LinkProcessor *processor, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ImportMegaLinksDialog)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_QuitOnClose, false);

    const int SLOT_HEIGHT = 35;
    this->megaApi = megaApi;
    this->linkProcessor = processor;

    for (int i = 0; i < linkProcessor->size(); i++)
    {
        ImportListWidgetItem *customItem = new ImportListWidgetItem(linkProcessor->getLink(i), i, ui->linkList);
        connect(customItem, SIGNAL(stateChanged(int,int)), this, SLOT(onLinkStateChanged(int, int)));
        QListWidgetItem *item = new QListWidgetItem(ui->linkList);
        ui->linkList->addItem(item);
        item->setSizeHint(customItem->size());
        ui->linkList->setItemWidget(item, customItem);
    }

    int extraSlots = linkProcessor->size() - 1;
    if (extraSlots > 7)
    {
        extraSlots = 7;
    }
    ui->linkList->setMinimumHeight(ui->linkList->minimumHeight() + SLOT_HEIGHT * extraSlots);
    this->setMinimumHeight(this->minimumHeight() + SLOT_HEIGHT * extraSlots);

    ui->linkList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setMaximumHeight(this->minimumHeight());

    QString defaultFolderPath;
    QString downloadFolder = QDir::toNativeSeparators(preferences->downloadFolder());
    QFileInfo test(downloadFolder);
    if (!test.isDir())
    {
#ifdef WIN32
    #if QT_VERSION < 0x050000
        QDir defaultFolder(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + QString::fromUtf8("/MEGAsync Downloads"));
    #else
        QDir defaultFolder(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0] + QString::fromUtf8("/MEGAsync Downloads"));
    #endif
#else
    #if QT_VERSION < 0x050000
        QDir defaultFolder(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + QString::fromUtf8("/MEGAsync Downloads"));
    #else
        QDir defaultFolder(QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0] + QString::fromUtf8("/MEGAsync Downloads"));
    #endif
#endif

        defaultFolder.mkpath(QString::fromAscii("."));
        defaultFolderPath = defaultFolder.absolutePath();
        defaultFolderPath = QDir::toNativeSeparators(defaultFolderPath);
    }
    else
    {
        defaultFolderPath = downloadFolder;
    }

    ui->eLocalFolder->setText(defaultFolderPath);

    if (preferences->logged())
    {
        MegaNode *testNode = megaApi->getNodeByHandle(preferences->importFolder());
        if (testNode)
        {
            const char *tPath = megaApi->getNodePath(testNode);
            if (tPath)
            {
                ui->eMegaFolder->setText(QString::fromUtf8(tPath));
                delete [] tPath;
            }
            else
            {
                delete testNode;
                ui->eMegaFolder->setText(tr("/MEGAsync Imports"));
                testNode = megaApi->getNodeByPath(tr("/MEGAsync Imports").toUtf8().constData());
            }
        }
        else
        {
            ui->eMegaFolder->setText(tr("/MEGAsync Imports"));
            testNode = megaApi->getNodeByPath(tr("/MEGAsync Imports").toUtf8().constData());
        }

        if (!testNode)
        {
            testNode = megaApi->getRootNode();
        }

        MegaNode *p = testNode;
        while (p)
        {
            if (megaApi->isSynced(p))
            {
                ui->cDownload->setChecked(false);
                this->on_cDownload_clicked();
                delete p;
                break;
//.........这里部分代码省略.........
开发者ID:Avin15,项目名称:MEGAsync,代码行数:101,代码来源:ImportMegaLinksDialog.cpp

示例2: end

void KIconCanvas::KIconCanvasPrivate::_k_slotLoadFiles()
{
    q->setResizeMode(QListWidget::Fixed);
    QApplication::setOverrideCursor(Qt::WaitCursor);

    // disable updates to not trigger paint events when adding child items
    q->setUpdatesEnabled(false);

    m_bLoading = true;
    int i;
    QStringList::ConstIterator it;
    uint emitProgress = 10; // so we will emit it once in the beginning
    QStringList::ConstIterator end(mFiles.end());
    for (it=mFiles.begin(), i=0; it!=end; ++it, i++)
    {
	if ( emitProgress >= 10 ) {
            emit q->progress(i);
            emitProgress = 0;
        }

        emitProgress++;

        if (!m_bLoading) { // user clicked on a button that will load another set of icons
            break;
        }
	QImage img;

	// Use the extension as the format. Works for XPM and PNG, but not for SVG
	QString path= *it;
	QString ext = path.right(3).toUpper();

	if (ext != "SVG" && ext != "VGZ")
	    img.load(*it);
	else {
            // Special stuff for SVG icons
            img = QImage(60, 60, QImage::Format_ARGB32_Premultiplied);
            img.fill(0);
            KSvgRenderer renderer(*it);
            if (renderer.isValid()) {
                QPainter p(&img);
                renderer.render(&p);
            }
        }

	if (img.isNull())
	    continue;
	if (img.width() > 60 || img.height() > 60)
	{
	    if (img.width() > img.height())
	    {
		int height = (int) ((60.0 / img.width()) * img.height());
		img = img.scaled(60, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
	    } else
	    {
		int width = (int) ((60.0 / img.height()) * img.width());
		img = img.scaled(width, 60, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
	    }
	}
	QPixmap pm = QPixmap::fromImage(img);
	QFileInfo fi(*it);
        QListWidgetItem *item = new QListWidgetItem(pm, fi.completeBaseName(), q);
	item->setData(Qt::UserRole, *it);
        item->setToolTip(fi.completeBaseName());
    }

    // enable updates since we have to draw the whole view now
    q->setUpdatesEnabled(true);

    QApplication::restoreOverrideCursor();
    m_bLoading = false;
    emit q->finished();
    q->setResizeMode(QListWidget::Adjust);
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:73,代码来源:kleo_kicondialog.cpp

示例3: QObject


//.........这里部分代码省略.........
    m_appearanceUi.activeIconIndication->addItem(i18n("Zoom"), QVariant(ZoomIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Glow"), QVariant(GlowIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Fade"), QVariant(FadeIndication));
    m_appearanceUi.activeIconIndication->setCurrentIndex(m_appearanceUi.activeIconIndication->findData(QVariant(configuration.readEntry("activeIconIndication", static_cast<int>(FadeIndication)))));

    m_appearanceUi.useThumbnails->setChecked(configuration.readEntry("useThumbnails", false));
    m_appearanceUi.customBackgroundImage->setUrl(KUrl(configuration.readEntry("customBackgroundImage", QString())));
    m_appearanceUi.customBackgroundImage->setFilter("image/svg+xml image/svg+xml-compressed");
    m_appearanceUi.moveAnimation->setCurrentIndex(moveAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("moveAnimation", static_cast<int>(ZoomAnimation)))));
    m_appearanceUi.parabolicMoveAnimation->setChecked(configuration.readEntry("parabolicMoveAnimation", true));
    m_appearanceUi.demandsAttentionAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("demandsAttentionAnimation", static_cast<int>(BlinkAnimation)))));
    m_appearanceUi.startupAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("startupAnimation", static_cast<int>(BounceAnimation)))));

    m_arrangementUi.removeButton->setIcon(KIcon("go-previous"));
    m_arrangementUi.addButton->setIcon(KIcon("go-next"));
    m_arrangementUi.moveUpButton->setIcon(KIcon("go-up"));
    m_arrangementUi.moveDownButton->setIcon(KIcon("go-down"));
    m_arrangementUi.availableActionsListWidget->addItem(i18n("--- separator ---"));

    QStringList arrangement = configuration.readEntry("arrangement", QStringList("tasks"));

    if (!arrangement.contains("tasks"))
    {
        m_arrangementUi.availableActionsListWidget->addItem(i18n("--- tasks area ---"));
    }

    if (!arrangement.contains("jobs"))
    {
        m_arrangementUi.availableActionsListWidget->addItem(i18n("--- jobs area ---"));
    }

    for (int i = 0; i < arrangement.count(); ++i)
    {
        QListWidgetItem *item;

        if (arrangement.at(i) == "tasks")
        {
            item = new QListWidgetItem(i18n("--- tasks area ---"), m_arrangementUi.currentActionsListWidget);
        }
        else if (arrangement.at(i) == "jobs")
        {
            item = new QListWidgetItem(i18n("--- jobs area ---"), m_arrangementUi.currentActionsListWidget);
        }
        else if (arrangement.at(i) == "separator")
        {
            item = new QListWidgetItem(i18n("--- separator ---"), m_arrangementUi.currentActionsListWidget);
        }
        else
        {
            Launcher *launcher = m_applet->launcherForUrl(KUrl(arrangement.at(i)));

            if (!launcher)
            {
                continue;
            }

            item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.currentActionsListWidget);
            item->setToolTip(launcher->launcherUrl().pathOrUrl());
        }

        m_arrangementUi.currentActionsListWidget->addItem(item);
    }

    QStringList actionNames;
    actionNames << i18n("Activate Item") << i18n("Activate Task") << i18n("Activate Launcher") << i18n("Show Item Menu") << i18n("Show Item Children List") << i18n("Show Item Windows") << i18n("Close Task");
开发者ID:amithash,项目名称:fancytasks,代码行数:66,代码来源:FancyTasksConfiguration.cpp

示例4: QObject


//.........这里部分代码省略.........
    m_appearanceUi.activeIconIndication->addItem(i18n("None"), QVariant(NoIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Zoom"), QVariant(ZoomIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Glow"), QVariant(GlowIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Fade"), QVariant(FadeIndication));
    m_appearanceUi.activeIconIndication->setCurrentIndex(m_appearanceUi.activeIconIndication->findData(QVariant(configuration.readEntry("activeIconIndication", static_cast<int>(FadeIndication)))));

    m_appearanceUi.customBackgroundImage->setUrl(KUrl(configuration.readEntry("customBackgroundImage", QString())));
    m_appearanceUi.customBackgroundImage->setFilter("image/svg+xml image/svg+xml-compressed");

    if (m_applet->location() != Plasma::Floating && (!m_applet->containment() || m_applet->containment()->objectName() != "FancyPanel")) {
        m_appearanceUi.customBackgroundImageLabel->hide();
        m_appearanceUi.customBackgroundImage->hide();
    }

    m_appearanceUi.moveAnimation->setCurrentIndex(moveAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("moveAnimation", static_cast<int>(GlowAnimation)))));
    m_appearanceUi.parabolicMoveAnimation->setChecked(configuration.readEntry("parabolicMoveAnimation", false));
    m_appearanceUi.demandsAttentionAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("demandsAttentionAnimation", static_cast<int>(BlinkAnimation)))));
    m_appearanceUi.startupAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("startupAnimation", static_cast<int>(BounceAnimation)))));

    m_arrangementUi.removeButton->setIcon(KIcon("go-previous"));
    m_arrangementUi.addButton->setIcon(KIcon("go-next"));
    m_arrangementUi.moveUpButton->setIcon(KIcon("go-up"));
    m_arrangementUi.moveDownButton->setIcon(KIcon("go-down"));

    KConfig kickoffConfiguration("kickoffrc", KConfig::NoGlobals);
    KConfigGroup favoritesGroup(&kickoffConfiguration, "Favorites");
    const QStringList currentEntries = configuration.readEntry("arrangement", QStringList("tasks"));
    QStringList availableEntries;
    availableEntries << i18n("--- separator ---") << i18n("--- tasks area ---") << i18n("--- jobs area ---") << "menu:/";
    availableEntries.append(favoritesGroup.readEntry("FavoriteURLs", QStringList()));

    for (int i = 0; i < currentEntries.count(); ++i)
    {
        QListWidgetItem *item = NULL;

        if (currentEntries.at(i) == "tasks")
        {
            item = new QListWidgetItem(i18n("--- tasks area ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else if (currentEntries.at(i) == "jobs")
        {
            item = new QListWidgetItem(i18n("--- jobs area ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else if (currentEntries.at(i) == "separator")
        {
            item = new QListWidgetItem(i18n("--- separator ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else
        {
            if (hasEntry(currentEntries.at(i), false))
            {
                continue;
            }

            Launcher *launcher = m_applet->launcherForUrl(KUrl(currentEntries.at(i)));

            if (!launcher)
            {
                continue;
            }

            item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.currentEntriesListWidget);
            item->setToolTip(launcher->launcherUrl().pathOrUrl());

            m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded());
        }
开发者ID:B-Rich,项目名称:plasmoid-fancy-tasks,代码行数:67,代码来源:Configuration.cpp

示例5: QListWidgetItem

//------------------------------------------------------------------------------
// Name: on_btnAdd_clicked()
// Desc:
//------------------------------------------------------------------------------
void DialogArguments::on_btnAdd_clicked() {
    QListWidgetItem *p = new QListWidgetItem(tr("New Argument"), ui->listWidget);
    p->setFlags(p->flags() | Qt::ItemIsEditable);
}
开发者ID:avplayer,项目名称:avdbg,代码行数:8,代码来源:DialogArguments.cpp

示例6: GetString

wxString wxListBox::GetString(unsigned int n) const
{    
    QListWidgetItem* item = m_qtListWidget->item(n);
    wxCHECK_MSG(item != NULL, wxString(), wxT("wrong listbox index") );
    return wxQtConvertString( item->text() );
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:6,代码来源:listbox.cpp

示例7:

void *wxListBox::DoGetItemClientData(unsigned int n) const
{
    QListWidgetItem* item = m_qtListWidget->item(n);
    QVariant variant = item->data(Qt::UserRole);
    return variant.value<void *>();
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:6,代码来源:listbox.cpp

示例8: setWindowTitle

//
// user_edit_dialog
//
user_edit_dialog::user_edit_dialog(int role_oid)
{
  m_role_oid = role_oid;
  setWindowTitle(role_oid==0?tr("Add a database user"):tr("Edit a database user"));
  m_mode = (role_oid==0)?new_user:existing_user;

  user u;
  if (m_mode == existing_user)
    u.fetch_by_oid(role_oid);

  QVBoxLayout* top_layout = new QVBoxLayout;

  db_cnx db;
  QString dbname=QString(tr("Current database: <b>%1</b>")).arg(db.dbname().toHtmlEscaped());
  QLabel* ldb = new QLabel(dbname);
  ldb->setTextFormat(Qt::RichText);
  top_layout->addWidget(ldb, 0, Qt::AlignHCenter);

  QFormLayout* layout = new QFormLayout;
  m_fullname = new QLineEdit;
#ifdef PERM_LOGIN
  m_perm_login = new QCheckBox;
#endif
  m_perm_connect = new QCheckBox;
  m_registered = new QCheckBox;

  m_email = new QLineEdit;

  /* m_login, m_password and m_password2 should keep the same width
     even though m_password is part of a QHBoxLayout and the others
     are not (as they're tied to the outer QFormLayout). This is why
     they're implemented as instance of the "field_follow_size" class */

  m_login = new field_follow_size; //QLineEdit;
  m_login->setMaxLength(name_maxlength);
  m_password = new field_follow_size;
  m_password2 = new field_follow_size;
  connect(m_password, SIGNAL(resized(const QSize)),
	  m_password2, SLOT(follow_resize(const QSize)));
  connect(m_password, SIGNAL(resized(const QSize)),
	  m_login, SLOT(follow_resize(const QSize)));
  m_change_password_btn = new QCheckBox(tr("Change"));
  m_password->setEchoMode(QLineEdit::Password);
  m_password2->setEchoMode(QLineEdit::Password);
  m_password->setMaxLength(name_maxlength);
  m_password2->setMaxLength(name_maxlength);

  QHBoxLayout* vlpassw = new QHBoxLayout;
  vlpassw->addWidget(m_password);
  vlpassw->addWidget(m_change_password_btn);
  if (m_mode==existing_user) {
    m_password->setEnabled(false);
    m_password2->setEnabled(false);
    m_change_password_btn->setEnabled(true);
    connect(m_change_password_btn, SIGNAL(clicked()),
	    this, SLOT(enable_alter_user()));
  }
  else {
    m_change_password_btn->setEnabled(false);
  }

  m_qlist_roles = new QListWidget;

  QList<user> roles_list = users_repository::get_list();

  QList<QString> assigned_roles = user::granted_roles(m_role_oid);

  for (int ri=0; ri<roles_list.size(); ri++) {
    const user& u = roles_list.at(ri);
    if (!u.m_can_login && u.m_role_oid>0) {
      // keep only entries from pg_roles without the LOGIN privilege
      // they're supposed to be roles to assign rather than users
      QListWidgetItem* item = new QListWidgetItem(u.m_db_login, m_qlist_roles);
      item->setFlags(Qt::ItemIsUserCheckable|/*Qt::ItemIsSelectable|*/Qt::ItemIsEnabled);
      item->setCheckState(assigned_roles.indexOf(u.m_db_login) >= 0 ?
			  Qt::Checked : Qt::Unchecked);
    }
  }
  //  m_case_sensitive = new QCheckBox;
  m_custom1 = new custom_user_field;
  m_custom2 = new custom_user_field;
  m_custom3 = new custom_user_field;

  if (u.m_is_superuser) {
    QLabel* label = new QLabel(tr("<b>Superuser account: unrestricted permissions.</b>"));
    layout->addRow(QString(), label);
  }

  layout->addRow(tr("Login <sup>(*)</sup>:"), m_login);

  layout->addRow(tr("Password <sup>(*)</sup>:"), /*m_password*/ vlpassw);
  layout->addRow(tr("Retype password <sup>(*)</sup>:"), m_password2);
  /*
  m_password2->resize(QSize(m_password->width(), m_password2->height()));
  m_password2->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
  */
#ifdef PERM_LOGIN
//.........这里部分代码省略.........
开发者ID:manitou-mail,项目名称:manitou-mail-ui,代码行数:101,代码来源:users_dialog.cpp

示例9: text

void SvgCanvas::actionExport_to_callback()
{
	QDialog dialog;
	ExportToDialog export_to_dialog;
	export_to_dialog.setupUi(&dialog);
	QListWidget *list = export_to_dialog.formats_listWidget;
	QListWidgetItem *item;
	//Pixmaps formats
	QList<QByteArray> formats=QImageWriter::supportedImageFormats();
	for(int i=0;i<formats.size();i++)
	{
		QString text(formats[i]);
		item=new QListWidgetItem(text,list);
		item->setData(1,QVariant(PIXMAP));
	}
	//Vector formats
	formats= QPicture::outputFormats();
	for(int i=0;i<formats.size();i++)
	{
		QString text(formats[i]);
		item=new QListWidgetItem(text,list);
		item->setData(1,QVariant(PICTURE));
	}
	
	item=new QListWidgetItem("ps",list);
	item->setData(1,QVariant(PRINTER));
	
	item=new QListWidgetItem("pdf",list);
	item->setData(1,QVariant(PDF));
	
	item=new QListWidgetItem("svg",list);
	item->setData(1,QVariant(SVG));
	
	int ok=dialog.exec();
	if(ok==QDialog::Rejected) return;
	
	item =list->currentItem();
	int format=item->data(1).toInt();
	
	QPainter plot;
	switch(format)
	{
		case PIXMAP:
		{
			bool ok;
			int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok);
			if(!ok) return;
			h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok);
			if(!ok) return;
			QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save");
			if(s.isEmpty()) return;
			QImage image(w,h,QImage::Format_RGB32);
			plot.begin(&image);
			svg_plot->renderer()->render(&plot);
			plot.end();
			image.save(s,item->data(0).toString().toLocal8Bit().data());
		}
		break;
		case PICTURE:
		{
			bool ok;
			int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok);
			if(!ok) return;
			h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok);
			if(!ok) return;
			QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save");
			if(s.isEmpty()) return;
			QPicture image;
			const QRect r(0,0,w,h);
			image.setBoundingRect(r);
			plot.begin(&image);
			svg_plot->renderer()->render(&plot);
			plot.end();
			image.save(s,item->data(0).toString().toLocal8Bit().data());
		}
		break;
		case PRINTER:
		{
			QPrinter p;
			QPrintDialog printDialog(&p, this);
			if (printDialog.exec() != QDialog::Accepted) return;
			plot.begin(&p);
			svg_plot->renderer()->render(&plot);
			plot.end();
		}
		break;
		case PDF:
		{
			QPrinter p;
			QPrintDialog printDialog(&p, this);
			p.setOutputFormat(QPrinter::PdfFormat);
			if (printDialog.exec() != QDialog::Accepted) return;
			
			plot.begin(&p);
			svg_plot->renderer()->render(&plot);
			plot.end();
		}
		break;
		case SVG:
		{
//.........这里部分代码省略.........
开发者ID:OpticaMonografia,项目名称:QtOctave,代码行数:101,代码来源:svgcanvas.cpp

示例10: dbc

void
role_perms_edit_dialog::set_grants()
{
  db_ctxt dbc(true);
  struct { QCheckBox* checkbox; const char* ability; }
  mail_perms[] = {
    {m_perm_read, "read"},
    {m_perm_update, "update"},
    {m_perm_trash, "trash"},
    {m_perm_delete, "delete"},
    {m_perm_compose, "compose"},
    {m_perm_basic_management, "admin-level1"},
  };

  QString rolname = m_role_name->text().trimmed();

  try {
    dbc.m_db->begin_transaction();
    if (!m_role_oid) {
      // Create the new role
      user::create_db_user(rolname, QString(), false, &dbc);
      m_role_oid = user::oid_db_role(rolname, true);
      if (!m_role_oid) {
	QMessageBox::critical(this, tr("Error"), tr("The role could not be created."));
	return;
      }
    }

    db_role role(m_role_oid);
    role.fetch_properties(&dbc);

    if (rolname != role.name()) {
      // Rename it in the db
      role.rename(rolname, &dbc);
    }

    for (uint iperm=0; iperm<sizeof(mail_perms)/sizeof(mail_perms[0]); iperm++) {
      // Set or unset permissions to exercise ability on messages
      DBG_PRINTF(5, "processing permissions for ability: %s", mail_perms[iperm].ability);
      QList<db_obj_privilege> privs = db_obj_privilege::ability_privileges(mail_perms[iperm].ability, &dbc);
      for (int pi=0; pi < privs.size(); pi++) {
	if (mail_perms[iperm].checkbox->isChecked())
	  role.grant(privs.at(pi), &dbc);
	else
	  role.revoke(privs.at(pi), &dbc);
      }
    }

    if (dbc.m_db->datab()->has_row_level_security()) {
      QList<int> list_ids;  // list of checked private identities
      bool ids_changed = false;	// did any checkbox switch state?
      for (int row=0; row < m_list_idents->count(); row++) {
	QListWidgetItem* item = m_list_idents->item(row);
	int iid = item->data(Qt::UserRole).toInt(); // identity_id
	if ((item->checkState() == Qt::Checked) != m_a_ids.contains(iid)) // compare 2 states
	  ids_changed = true;
	if (item->checkState() == Qt::Checked)
	  list_ids.append(iid);
      }
      if (ids_changed) {
	// call set_identity_permissions(in_oid, in_identities int[], in_perms char[] = ['A']);
	sql_stream s("select set_identity_permissions(:o, :t, null)", *dbc.m_db);
	s << m_role_oid << list_ids;
      }
    }
    dbc.m_db->commit_transaction();
  }
  catch(db_excpt& p) {
    dbc.m_db->rollback_transaction();
    DBEXCPT (p);
  }
}
开发者ID:manitou-mail,项目名称:manitou-mail-ui,代码行数:72,代码来源:users_dialog.cpp

示例11: assert


//.........这里部分代码省略.........
            button = new QPushButton( qfu( p_widget->psz_text ), this );
            clickMapper->setMapping( button, new WidgetMapper( p_widget ) );
            CONNECT( button, clicked(), clickMapper, map() );
            p_widget->p_sys_intf = button;
            return button;

        case EXTENSION_WIDGET_IMAGE:
            label = new QLabel( this );
            label->setPixmap( QPixmap( qfu( p_widget->psz_text ) ) );
            if( p_widget->i_width > 0 )
                label->setMaximumWidth( p_widget->i_width );
            if( p_widget->i_height > 0 )
                label->setMaximumHeight( p_widget->i_height );
            label->setScaledContents( true );
            p_widget->p_sys_intf = label;
            return label;

        case EXTENSION_WIDGET_HTML:
            textArea = new QTextBrowser( this );
            textArea->setOpenExternalLinks( true );
            textArea->setHtml( qfu( p_widget->psz_text ) );
            p_widget->p_sys_intf = textArea;
            return textArea;

        case EXTENSION_WIDGET_TEXT_FIELD:
            textInput = new QLineEdit( this );
            textInput->setText( qfu( p_widget->psz_text ) );
            textInput->setReadOnly( false );
            textInput->setEchoMode( QLineEdit::Normal );
            inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) );
            /// @note: maybe it would be wiser to use textEdited here?
            CONNECT( textInput, textChanged(const QString &),
                     inputMapper, map() );
            p_widget->p_sys_intf = textInput;
            return textInput;

        case EXTENSION_WIDGET_PASSWORD:
            textInput = new QLineEdit( this );
            textInput->setText( qfu( p_widget->psz_text ) );
            textInput->setReadOnly( false );
            textInput->setEchoMode( QLineEdit::Password );
            inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) );
            /// @note: maybe it would be wiser to use textEdited here?
            CONNECT( textInput, textChanged(const QString &),
                     inputMapper, map() );
            p_widget->p_sys_intf = textInput;
            return textInput;

        case EXTENSION_WIDGET_CHECK_BOX:
            checkBox = new QCheckBox( this );
            checkBox->setText( qfu( p_widget->psz_text ) );
            checkBox->setChecked( p_widget->b_checked );
            clickMapper->setMapping( checkBox, new WidgetMapper( p_widget ) );
            CONNECT( checkBox, stateChanged( int ), clickMapper, map() );
            p_widget->p_sys_intf = checkBox;
            return checkBox;

        case EXTENSION_WIDGET_DROPDOWN:
            comboBox = new QComboBox( this );
            comboBox->setEditable( false );
            for( p_value = p_widget->p_values;
                 p_value != NULL;
                 p_value = p_value->p_next )
            {
                comboBox->addItem( qfu( p_value->psz_text ), p_value->i_id );
            }
            /* Set current item */
            if( p_widget->psz_text )
            {
                int idx = comboBox->findText( qfu( p_widget->psz_text ) );
                if( idx >= 0 )
                    comboBox->setCurrentIndex( idx );
            }
            selectMapper->setMapping( comboBox, new WidgetMapper( p_widget ) );
            CONNECT( comboBox, currentIndexChanged( const QString& ),
                     selectMapper, map() );
            return comboBox;

        case EXTENSION_WIDGET_LIST:
            list = new QListWidget( this );
            list->setSelectionMode( QAbstractItemView::ExtendedSelection );
            for( p_value = p_widget->p_values;
                 p_value != NULL;
                 p_value = p_value->p_next )
            {
                QListWidgetItem *item =
                    new QListWidgetItem( qfu( p_value->psz_text ) );
                item->setData( Qt::UserRole, p_value->i_id );
                list->addItem( item );
            }
            selectMapper->setMapping( list, new WidgetMapper( p_widget ) );
            CONNECT( list, itemSelectionChanged(),
                     selectMapper, map() );
            return list;

        default:
            msg_Err( p_intf, "Widget type %d unknown", p_widget->type );
            return NULL;
    }
}
开发者ID:cobr123,项目名称:qtVlc,代码行数:101,代码来源:extensions.cpp

示例12: QDialog

QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl )
    : QDialog( parent, fl )
    , mMapCanvas( mapCanvas )
{
  setupUi( this );
  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
  connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
  connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
  connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
  connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) );

  ///////////////////////////////////////////////////////////
  // Properties stored in map canvas's QgsMapRenderer
  // these ones are propagated to QgsProject by a signal

  QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
  QGis::UnitType myUnit = myRenderer->mapUnits();
  setMapUnits( myUnit );

  // we need to initialize it, since the on_cbxProjectionEnabled_stateChanged()
  // callback triggered by setChecked() might use it.
  mProjectSrsId = myRenderer->destinationCrs().srsid();

  //see if the user wants on the fly projection enabled
  bool myProjectionEnabled = myRenderer->hasCrsTransformEnabled();
  cbxProjectionEnabled->setChecked( myProjectionEnabled );

  QgsDebugMsg( "Read project CRSID: " + QString::number( mProjectSrsId ) );
  projectionSelector->setSelectedCrsId( mProjectSrsId );
  projectionSelector->setEnabled( myProjectionEnabled );

  ///////////////////////////////////////////////////////////
  // Properties stored in QgsProject

  title( QgsProject::instance()->title() );

  // get the manner in which the number of decimal places in the mouse
  // position display is set (manual or automatic)
  bool automaticPrecision = QgsProject::instance()->readBoolEntry( "PositionPrecision", "/Automatic" );
  if ( automaticPrecision )
  {
    radAutomatic->setChecked( true );
    spinBoxDP->setDisabled( true );
    labelDP->setDisabled( true );
  }
  else
  {
    radManual->setChecked( true );
  }

  cbxAbsolutePath->setCurrentIndex( QgsProject::instance()->readBoolEntry( "Paths", "/Absolute", true ) ? 0 : 1 );

  int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
  spinBoxDP->setValue( dp );

  QString format = QgsProject::instance()->readEntry( "PositionPrecision", "/DegreeFormat", "D" );
  if ( format == "DM" )
    radDM->setChecked( true );
  else if ( format == "DMS" )
    radDMS->setChecked( true );
  else
    radD->setChecked( true );

  //get the color selections and set the button color accordingly
  int myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
  int myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );
  int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 );
  int myAlphaInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", 255 );
  QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt, myAlphaInt );
  pbnSelectionColor->setColor( myColor );

  //get the color for map canvas background and set button color accordingly (default white)
  myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorRedPart", 255 );
  myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorGreenPart", 255 );
  myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 );
  myColor = QColor( myRedInt, myGreenInt, myBlueInt );
  pbnCanvasColor->setColor( myColor );

  //get project scales
  QStringList myScales = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
  if ( !myScales.isEmpty() )
  {
    QStringList::const_iterator scaleIt = myScales.constBegin();
    for ( ; scaleIt != myScales.constEnd(); ++scaleIt )
    {
      QListWidgetItem* newItem = new QListWidgetItem( lstScales );
      newItem->setText( *scaleIt );
      newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
      lstScales->addItem( newItem );
    }
  }

  grpProjectScales->setChecked( QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" ) );

  QgsMapLayer* currentLayer = 0;

  QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" );

  const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();

//.........这里部分代码省略.........
开发者ID:endmax,项目名称:Quantum-GIS,代码行数:101,代码来源:qgsprojectproperties.cpp

示例13: describePlanet

void Details :: describePlanet()
 {
  fileIndex = qBound(0, fileIndex, filesCount() - 1);

  bool exists = planet != A::Planet_None;
  positionLabel -> setVisible(exists);
  aspectsList   -> setVisible(exists);
  powerLabel    -> setVisible(exists);
  if (!exists) return;

  const A::Planet& p = file(fileIndex)->horoscope().planets[planet];


  QString powerText = A::describePowerInHtml(p, file(fileIndex)->horoscope());
  if (!powerText.isEmpty())
    powerText = "<p align='center'><b><i>" +
                QString("<font color='#71aeec' size='+2'>+%1</font> | "
                        "<font color='#dfb096' size='+2'>%2</font>")
                         .arg(p.power.dignity)
                         .arg(p.power.deficient) +
                "</i></b></p>" + powerText;

  positionLabel -> setText(A::describePlanetCoordInHtml(p));
  powerLabel    -> setText(powerText);


  aspectsList->clear();
  A::AspectList list;
  QString tag1, tag2;

  if (filesCount() == 1)
   {
    list = file()->horoscope().aspects;
    aspects->setTitle(tr("Aspects"));
   }
  else
   {
    list = calculateSynastryAspects();
    aspects->setTitle(tr("Synastry aspects"));
    tag1 = "#1";
    tag2 = "#2";
   }

  foreach (const A::Aspect& asp, list)
   {
    if (*asp.planet1 != p && *asp.planet2 != p) continue;

    QListWidgetItem* item = new QListWidgetItem;
    item->setIcon(QIcon(asp.d->userData["icon"].toString()));
    item->setText(A::describeAspect(asp));
    item->setToolTip(A::describeAspectFull(asp, tag1, tag2));
    item->setStatusTip(QString("%1+%2+%3").arg(asp.d->name)
                                          .arg(asp.planet1->name)
                                          .arg(asp.planet2->name));
    aspectsList->addItem(item);
   }

  QListWidgetItem* item = new QListWidgetItem("...");
  item->setToolTip(tr("more"));
  item->setWhatsThis("more");
  item->setTextAlignment(Qt::AlignCenter);
  aspectsList->addItem(item);

  if (expandedAspects)
    expandAspects();
  else
    updateListHeight(aspectsList);
 }
开发者ID:ChezRD,项目名称:zodiac,代码行数:68,代码来源:details.cpp

示例14: message

void cutDialog::edit_current_row()
{

    QItemSelectionModel *selectionModel = listWidget->selectionModel();
    QModelIndexList selected = selectionModel->selectedIndexes();
    int row = listWidget ->currentRow();
    QListWidgetItem * item = listWidget ->item(row);

    if(selected.length() != 1)
    {
        QMessageBox message(QMessageBox::Critical, "编辑错误        ",
                            "<p>请选择单条文本内容进行编辑 !</font></strong></p>"
                            ,QMessageBox::Ok ,this,Qt::Tool);
        this ->activateWindow();
        message.exec();
        return;
    }

    if(row >= 0 && item ->isSelected())
    {
        editDialog = new QDialog(this);
        cutEdit = new QTextEdit(editDialog);
        QPushButton *okButton = new QPushButton("确定",editDialog);
        connect(okButton,SIGNAL(clicked()),this,SLOT(ok_edit_button()));
        QPushButton *cancelButton = new QPushButton("取消",editDialog);
        connect(cancelButton,SIGNAL(clicked()),this,SLOT(cancel_edit_button()));

        QListWidgetItem * item = listWidget ->item(row);
        int key = item->data(Qt::UserRole).toInt();
        QString sqlStr = "select * from info where id = " + QString::number(key);
        QSqlQuery query;
        query.exec(sqlStr);
        while(query.next())
        {
            if(query.value(2).toString() == "文本")
            {
                   cutEdit ->setPlainText(query.value(3).toString());
             }
             else
             {
                   QMessageBox message(QMessageBox::Warning, "编辑提示        ",
                                       "文件不能编辑 !"
                                       ,QMessageBox::Ok ,this,Qt::Tool);
                   this ->activateWindow();
                   message.exec();
                   return;
             }
        }

        QHBoxLayout *hboxLayout = new QHBoxLayout;
        hboxLayout ->addWidget(okButton);
        hboxLayout ->addStretch();
        hboxLayout ->addWidget(cancelButton);

        QVBoxLayout *vboxLayout = new QVBoxLayout;
        vboxLayout ->addWidget(cutEdit);
        vboxLayout ->addLayout(hboxLayout);
        editDialog ->setLayout(vboxLayout);
        editDialog ->setWindowTitle("编辑");
        //editDialog ->resize(400,500);
        editDialog ->setFixedSize(400,500);
        editDialog ->exec();

    }
    else
    {
        QMessageBox message(QMessageBox::Critical, "编辑错误        ",
                            "<p>请选择编辑的内容 !</font></strong></p>"
                            ,QMessageBox::Ok ,this,Qt::Tool);
        this ->activateWindow();
        message.exec();
    }
}
开发者ID:alex159s,项目名称:fangdeQC,代码行数:73,代码来源:cutDialog.cpp

示例15: QIcon

/** Creates intems into \a listWidget. */
void OptionsDialog::insertItems(QListWidget *listWidget) {
    QString imagesDirPath = QCoreApplication::applicationDirPath() +
                            "/../share/sir/images/";

    // General
    QIcon icon = QIcon::fromTheme("preferences-system",
                                  QIcon(imagesDirPath + "options_general.png"));
    QListWidgetItem *listWidgetItem = new QListWidgetItem(listWidget);
    listWidgetItem->setIcon(icon);
    listWidgetItem->setText(tr("General"));
    // File list
    icon = QIcon::fromTheme("preferences-desktop",
                            QIcon(imagesDirPath + "options_list.png"));
    listWidgetItem = new QListWidgetItem(listWidget);
    listWidgetItem->setIcon(icon);
    listWidgetItem->setText(tr("File list"));
#ifdef SIR_METADATA_SUPPORT
    // Metadata
    icon = QIcon::fromTheme("document-properties",
                            QIcon(imagesDirPath + "options_metadata.png"));
    listWidgetItem = new QListWidgetItem(listWidget);
    listWidgetItem->setIcon(icon);
    listWidgetItem->setText(tr("Metadata"));
    // File details
    icon = QIcon::fromTheme("x-office-document",
                            QIcon(imagesDirPath + "options_details.png"));
    listWidgetItem = new QListWidgetItem(listWidget);
    listWidgetItem->setIcon(icon);
    listWidgetItem->setText(tr("File details"));
#endif // SIR_METADATA_SUPPORT
    // Selection
    icon = QIcon::fromTheme("edit-find",
                            QIcon(imagesDirPath + "options_selection.png"));
    listWidgetItem = new QListWidgetItem(listWidget);
    listWidgetItem->setIcon(icon);
    listWidgetItem->setText(tr("Selection"));
    // Raw
    icon = QIcon::fromTheme("emblem-photos",
                            QIcon(imagesDirPath + "options_raw.png"));
    listWidgetItem = new QListWidgetItem(listWidget);
    listWidgetItem->setIcon(icon);
    listWidgetItem->setText(tr("Raw"));
}
开发者ID:marek629,项目名称:SIR,代码行数:44,代码来源:OptionsDialog.cpp


注:本文中的QListWidgetItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。