void EditColorMap::setCombos (Palette palette) { comboBoxType->setCurrentIndex (palette.m_type); comboBoxPalette->clear (); if (palette.m_type == PaletteType::SEQUENTIAL) fillCombo (palette.m_sequential); else fillCombo (palette.m_diverging); }
void HistoryConfig::realRename() { QString newName = cmbStyle->lineEdit()->text(); cmbStyle->lineEdit()->removeEventFilter(this); cmbStyle->setEditable(false); if (newName != m_styles[m_edit].name){ int n = 0; vector<StyleDef>::iterator it; for (it = m_styles.begin(); it != m_styles.end(); ++it, n++){ if ((*it).name == newName){ if (n < m_edit) m_edit--; m_styles.erase(it); break; } } string nn; nn = STYLES; nn += QFile::encodeName(m_styles[m_edit].name); nn += EXT; nn = user_file(nn.c_str()); if (m_styles[m_edit].text.isEmpty()){ QFile f(QFile::decodeName(nn.c_str())); if (f.open(IO_ReadOnly)){ string s; s.append(f.size(), '\x00'); f.readBlock((char*)(s.c_str()), f.size()); m_styles[m_edit].text = QString::fromUtf8(s.c_str()); } } QFile::remove(QFile::decodeName(nn.c_str())); m_styles[m_edit].name = newName; } fillCombo(newName); }
HistoryConfig::HistoryConfig(QWidget *parent) : HistoryConfigBase(parent) { chkOwn->setChecked(CorePlugin::m_plugin->getOwnColors()); chkSmile->setChecked(CorePlugin::m_plugin->getUseSmiles()); cmbPage->setEditable(true); cmbPage->insertItem("100"); cmbPage->insertItem("50"); cmbPage->insertItem("25"); m_cur = -1; QLineEdit *edit = cmbPage->lineEdit(); edit->setValidator(new QIntValidator(1, 500, edit)); edit->setText(QString::number(CorePlugin::m_plugin->getHistoryPage())); QString str1 = i18n("Show %1 messages per page"); QString str2; int n = str1.find("%1"); if (n >= 0){ str2 = str1.mid(n + 2); str1 = str1.left(n); } lblPage1->setText(str1); lblPage2->setText(str2); edtStyle->setWordWrap(QTextEdit::NoWrap); edtStyle->setTextFormat(QTextEdit::RichText); #if (QT_VERSION < 0x300) || ((QT_VERSION >= 0x300) && defined(HAVE_QSYNTAXHIGHLIGHTER_H)) new XmlHighlighter(edtStyle); #endif QStringList styles; addStyles(user_file(STYLES).c_str(), true); #ifdef USE_KDE QStringList lst = KGlobal::dirs()->findDirs("data", "sim"); for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it){ QFile fi(*it + STYLES); if (!fi.exists()) continue; addStyles(QFile::encodeName(fi.name()), false); } #else addStyles(app_file(STYLES).c_str(), false); #endif fillCombo(CorePlugin::m_plugin->getHistoryStyle()); connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(styleSelected(int))); connect(btnCopy, SIGNAL(clicked()), this, SLOT(copy())); connect(btnRename, SIGNAL(clicked()), this, SLOT(rename())); connect(btnDelete, SIGNAL(clicked()), this, SLOT(del())); connect(tabStyle, SIGNAL(currentChanged(QWidget*)), this, SLOT(viewChanged(QWidget*))); connect(edtStyle, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(chkOwn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkSmile, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkDays, SIGNAL(toggled(bool)), this, SLOT(toggledDays(bool))); connect(chkSize, SIGNAL(toggled(bool)), this, SLOT(toggledSize(bool))); HistoryUserData *data = (HistoryUserData*)(getContacts()->getUserData(CorePlugin::m_plugin->history_data_id)); chkDays->setChecked(data->CutDays.bValue); chkSize->setChecked(data->CutSize.bValue); edtDays->setValue(data->Days.value); edtSize->setValue(data->MaxSize.value); toggledDays(chkDays->isChecked()); toggledSize(chkSize->isChecked()); }
HistoryConfig::HistoryConfig(QWidget *parent) : HistoryConfigBase(parent) { chkOwn->setChecked(CorePlugin::m_plugin->getOwnColors()); chkSmile->setChecked(CorePlugin::m_plugin->getUseSmiles()); cmbPage->setEditable(true); cmbPage->insertItem("100"); cmbPage->insertItem("50"); cmbPage->insertItem("25"); m_cur = -1; QLineEdit *edit = cmbPage->lineEdit(); edit->setValidator(new QIntValidator(1, 500, edit)); edit->setText(QString::number(CorePlugin::m_plugin->getHistoryPage())); QString str1 = i18n("Show %1 messages per page"); QString str2; int n = str1.find("%1"); if (n >= 0){ str2 = str1.mid(n + 2); str1 = str1.left(n); } lblPage1->setText(str1); lblPage2->setText(str2); edtStyle->setWordWrap(QTextEdit::NoWrap); edtStyle->setTextFormat(QTextEdit::RichText); new XmlHighlighter(edtStyle); QStringList styles; addStyles(user_file(STYLES).c_str(), true); addStyles(app_file(STYLES).c_str(), false); fillCombo(CorePlugin::m_plugin->getHistoryStyle()); connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(styleSelected(int))); connect(btnCopy, SIGNAL(clicked()), this, SLOT(copy())); connect(btnRename, SIGNAL(clicked()), this, SLOT(rename())); connect(btnDelete, SIGNAL(clicked()), this, SLOT(del())); connect(tabStyle, SIGNAL(currentChanged(QWidget*)), this, SLOT(viewChanged(QWidget*))); connect(edtStyle, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(chkOwn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkSmile, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); connect(chkDays, SIGNAL(toggled(bool)), this, SLOT(toggledDays(bool))); connect(chkSize, SIGNAL(toggled(bool)), this, SLOT(toggledSize(bool))); HistoryUserData *data = (HistoryUserData*)(getContacts()->getUserData(CorePlugin::m_plugin->history_data_id)); chkDays->setChecked(data->CutDays != 0); chkSize->setChecked(data->CutSize != 0); edtDays->setValue(data->Days); edtSize->setValue(data->MaxSize); toggledDays(chkDays->isChecked()); toggledSize(chkSize->isChecked()); }
void HistoryConfig::realDelete() { int cur = cmbStyle->currentItem(); if (cur < 0) return; if (!m_styles[cur].bCustom) return; QString name = m_styles[cur].name; for (vector<StyleDef>::iterator it = m_styles.begin(); it != m_styles.end(); ++it) if (cur-- == 0) break; m_styles.erase(it); string n; n = STYLES; n += QFile::encodeName(name); n += EXT; n = user_file(n.c_str()); QFile::remove(QFile::decodeName(n.c_str())); fillCombo(CorePlugin::m_plugin->getHistoryStyle()); }
void HistoryConfig::copy() { int cur = cmbStyle->currentItem(); if (cur < 0) return; QString name = m_styles[cur].name; QString newName; QRegExp re("\\.[0-9]+$"); unsigned next = 0; for (vector<StyleDef>::iterator it = m_styles.begin(); it != m_styles.end(); ++it){ QString nn = (*it).name; int n = nn.find(re); if (n < 0) continue; nn = nn.mid(n + 1); next = QMAX(next, nn.toUInt()); } int nn = name.find(re); if (nn >= 0){ newName = name.left(nn); }else{ newName = name; } newName += "."; newName += QString::number(next + 1); string n; n = STYLES; n += QFile::encodeName(name); n += EXT; if (m_styles[cur].bCustom){ n = user_file(n.c_str()); }else{ n = app_file(n.c_str()); } QFile from(QFile::decodeName(n.c_str())); if (!from.open(IO_ReadOnly)){ log(L_WARN, "Can't open %s", n.c_str()); return; } n = STYLES; n += QFile::encodeName(newName); n += EXT; n = user_file(n.c_str()); QFile to(QFile::decodeName((n + BACKUP_SUFFIX).c_str())); if (!to.open(IO_WriteOnly | IO_Truncate)){ log(L_WARN, "Cam't create %s", n.c_str()); return; } string s; s.append(from.size(), '\x00'); from.readBlock((char*)(s.c_str()), from.size()); to.writeBlock(s.c_str(), s.length()); from.close(); const int status = to.status(); #if QT_VERSION >= 0x030200 const QString errorMessage = to.errorString(); #else const QString errorMessage = "write file fail"; #endif to.close(); if (status != IO_Ok) { log(L_ERROR, "IO error during writting to file %s : %s", (const char*)to.name().local8Bit(), (const char*)errorMessage.local8Bit()); return; } // rename to normal file QFileInfo fileInfo(to.name()); QString desiredFileName = QFile::decodeName(n.c_str()); if (!fileInfo.dir().rename(fileInfo.fileName(), desiredFileName)) { log(L_ERROR, "Can't rename file %s to %s", (const char*)fileInfo.fileName().local8Bit(), (const char*)desiredFileName.local8Bit()); return; } s = ""; StyleDef d; d.name = newName; d.bCustom = true; m_styles.push_back(d); fillCombo(QFile::encodeName(newName)); }
void HistoryConfig::copy() { int cur = cmbStyle->currentItem(); if (cur < 0) return; QString name = m_styles[cur].name; QString newName; QRegExp re("\\.[0-9]+$"); unsigned next = 0; for (vector<StyleDef>::iterator it = m_styles.begin(); it != m_styles.end(); ++it){ QString nn = (*it).name; int n = nn.find(re); if (n < 0) continue; nn = nn.mid(n + 1); next = QMAX(next, nn.toUInt()); } int nn = name.find(re); if (nn >= 0){ newName = name.left(nn); }else{ newName = name; } newName += "."; newName += QString::number(next + 1); string n; n = STYLES; n += QFile::encodeName(name); n += EXT; if (m_styles[cur].bCustom){ n = user_file(n.c_str()); }else{ n = app_file(n.c_str()); } QFile from(QFile::decodeName(n.c_str())); if (!from.open(IO_ReadOnly)){ log(L_WARN, "Can't open %s", n.c_str()); return; } n = STYLES; n += QFile::encodeName(newName); n += EXT; n = user_file(n.c_str()); QFile to(QFile::decodeName(n.c_str())); if (!to.open(IO_WriteOnly | IO_Truncate)){ log(L_WARN, "Cam't create %s", n.c_str()); return; } string s; s.append(from.size(), '\x00'); from.readBlock((char*)(s.c_str()), from.size()); to.writeBlock(s.c_str(), s.length()); from.close(); to.close(); s = ""; StyleDef d; d.name = newName; d.bCustom = true; m_styles.push_back(d); fillCombo(QFile::encodeName(newName)); }
DcmtkServerDialog::DcmtkServerDialog() { setWindowTitle("Dicom Downloader"); listWidget_ = new DcmtkSeriesListWidget(); configDialog_ = new DcmtkServerConfigDialog(); serverCombo_ = new QComboBox(); serverCombo_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); newServerButton_ = new QPushButton("New"); newServerButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); deleteServerButton_ = new QPushButton("Delete"); deleteServerButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); editServerButton_ = new QPushButton("Edit"); editServerButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); updateListButton_ = new QPushButton("Update"); updateListButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); openButton_ = new QPushButton("Open"); openButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); openButton_->setDisabled(true); outputDirectory_ = new QLineEdit(""); outputDirectory_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); changeDirectoryButton_ = new QPushButton("..."); changeDirectoryButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); loadServers(); connect(newServerButton_, SIGNAL(clicked()), this, SLOT(addServer())); connect(deleteServerButton_, SIGNAL(clicked()), this, SLOT(deleteServer())); connect(serverCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(displayConfig(int))); connect(editServerButton_, SIGNAL(clicked()), this, SLOT(editConfig())); connect(updateListButton_, SIGNAL(clicked()), this, SLOT(updateList())); connect(openButton_, SIGNAL(clicked()), this, SLOT(open())); connect(listWidget_, SIGNAL(seriesSelected()), this, SLOT(enableOpenButton())); #ifdef VRN_DICOMLOADER connect(changeDirectoryButton_, SIGNAL(clicked()), this, SLOT(selectOutputDir())); #endif QGridLayout *layout = new QGridLayout; layout->addWidget(new QLabel("Server:"),0,0,(Qt::Alignment)0); layout->addWidget(serverCombo_,0,1,(Qt::Alignment)0); fillCombo(); layout->addWidget(editServerButton_,0,2,(Qt::Alignment)0); layout->addWidget(newServerButton_,0,3,(Qt::Alignment)0); layout->addWidget(deleteServerButton_,0,4,(Qt::Alignment)0); layout->addWidget(listWidget_,1,0,1,5,(Qt::Alignment)0); layout->addWidget(updateListButton_,2,3,1,1,(Qt::Alignment)0); layout->addWidget(openButton_,2,4,1,1,(Qt::Alignment)0); #ifdef VRN_DICOMLOADER layout->addWidget(new QLabel("Output Directory:"),4,0,(Qt::Alignment)0); layout->addWidget(outputDirectory_,4,1,1,3,(Qt::Alignment)0); layout->addWidget(changeDirectoryButton_,4,4,1,1,(Qt::Alignment)0); #endif listWidget_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setLayout(layout); // if (servers_.size() > 0) // displayConfig(servers_[0]); dt_ = 0; }