#include <QSettings>
#include <QKeyEvent>
#include "extrapushbutton.h"
-#include "separatorline.h"
#include <cmath>
#include <QLayoutItem>
#include <QSslCertificate>
#include <QSslConfiguration>
#include <QtAlgorithms>
#include <qjson-qjson/src/parser.h>
-#include <qjson-qjson/src/serializer.h>
+#include <QDateTime>
+#include <QShortcut>
/*
publidc functions
*/
ui->setupUi(this);
QString oauthIniName = qApp->applicationDirPath()
- + QDir::separator()
- + "QtTC.ini";
+ + "/verification.ini";
_oauthSettings = new QSettings(oauthIniName, QSettings::IniFormat);
_oauthSettings->setIniCodec("utf-8");
//-------------------------
_oauthManager->setNetworkManager(new QNetworkAccessManager);
+ connect(_oauthManager, SIGNAL(authorizedRequestDone()),
+ this, SLOT(onAuthorizedRequestDone()));
+
_oauthRequest->setEnableDebugOutput(true); // デバッグ出力ON
// _oauthRequest->setEnableDebugOutput(false); // デバッグ出力OFF
//-------------------------
- if (_oauthSettings->childKeys().size() == 2) {
+ if (_oauthSettings->childKeys().size() == 3) {
// 既に認証キー取得済みならボタン2を有効にする
ui->pushButton_2->setEnabled(true);
+
+ ui->lineEdit->setText(_oauthSettings->value("number").toString());
}
QString shortCutKeysIniName = qApp->applicationDirPath()
- + QDir::separator()
- + "key.txt";
+ + "/key.txt";
_shortCutKeysSettings = new QSettings(shortCutKeysIniName, QSettings::IniFormat);
_shortCutKeysSettings->setIniCodec("utf-8");
QStringList keyKeys = _shortCutKeysSettings->childKeys();
ui->buttonsGridLayout->addWidget(p,0,i);
// Succession of slots can not go well.
connect(p, SIGNAL(clicked()), p, SLOT(click()));
- //connect(p, SIGNAL(clicked(QString)), this, SLOT(sendTweet(QString)));
+ connect(p, SIGNAL(clicked(QString)), this, SLOT(sendTweet(QString)));
+ connect(p, SIGNAL(showingToolTip(QString)), ui->plainTextEdit, SLOT(setPlainText(QString)));
}
- separatorLine *sl = new separatorLine(this);
- ui->timeLienVerticalLayout->addWidget(sl);
-
QString sizeIniName = qApp->applicationDirPath()
- + QDir::separator()
- + "size.ini";
+ + "/size.ini";
_sizeSettings = new QSettings(sizeIniName, QSettings::IniFormat);
if(_sizeSettings->allKeys().count()==2)
{
resize(200,200);
}
- QList<QSslCertificate> cList;
+ // Short Cut Key for Post.
+ QShortcut *post1 = new QShortcut(ui->lineEdit_2);
+ QShortcut *post2 = new QShortcut(ui->lineEdit_3);
+ QShortcut *post3 = new QShortcut(ui->lineEdit_4);
+ QShortcut *post4 = new QShortcut(ui->lineEdit_5);
+ QShortcut *post5 = new QShortcut(ui->lineEdit_6);
+ QList<QShortcut*> postShortCutList;
+ postShortCutList << post1 << post2 << post3 << post4 << post5;
+ for(int i=0;i<postShortCutList.size();++i)
+ {
+ this->setShortCutKeyAndContext(postShortCutList.at(i), QKeyStandard(Qt::CTRL + Qt::Key_Return), Qt::WidgetShortcut);
+ }
+
+ connect(post1, SIGNAL(activated()), ui->pushButton_4, SLOT(click()));
+ connect(post2, SIGNAL(activated()), ui->pushButton_4, SLOT(click()));
+ connect(post3, SIGNAL(activated()), ui->pushButton_4, SLOT(click()));
+ connect(post4, SIGNAL(activated()), ui->pushButton_4, SLOT(click()));
+ connect(post5, SIGNAL(activated()), ui->pushButton_4, SLOT(click()));
+
+ //initializeOwnPostsWidgets();
+ /* QList<QSslCertificate> cList;
QFile f1(qApp->applicationDirPath() + "\\" + "v.cer");
f1.open(QIODevice::ReadOnly);
sock->setCaCertificates(cList);
qDebug() << "[CLIENT]: Attempting Connection...";
//sock->connectToHostEncrypted("userstream.twitter.com/2/user.json", 443);
- //sock->connectToHostEncrypted("userstream.twitter.com", 443);
- sock->connectToHostEncrypted("api.twitter.com", 443);
+ sock->connectToHostEncrypted("userstream.twitter.com", 443);
+ //sock->connectToHostEncrypted("api.twitter.com", 443);
if(sock->waitForConnected())
{
}
qDebug("Writing");
- if(true)
+ if(false)
{
- QUrl url("https://api.twitter.com/1/statuses/home_timeline.json");
+ //QUrl url("https://api.twitter.com/1/statuses/home_timeline.json");
//QUrl url("https://userstream.twitter.com/2/user.json");
+ QUrl url("http://stream.twitter.com/1/filter.json");
_oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, url);
_oauthRequest->setHttpMethod(KQOAuthRequest::GET); // GET指定
_oauthRequest->setConsumerKey("nXrjGagSLIQxCC4AmJ1J3g");
this, SLOT(onAuthorizedRequestDone()));
// _oauthManager->executeRequest(_oauthRequest);
}
- else
+ else if(false)
{
QUrl url("https://api.twitter.com/1/statuses/update.xml");
_oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest,url);
_oauthRequest->setAdditionalParameters(params);
// _oauthManager->executeRequest(_oauthRequest);
}
+ else if(false)
+ {
+ QUrl url("http://stream.twitter.com/1/statuses/filter.json");
+ _oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest,url);
+ _oauthRequest->setHttpMethod(KQOAuthRequest::POST); // POST指定
+ _oauthRequest->setConsumerKey("nXrjGagSLIQxCC4AmJ1J3g");
+ _oauthRequest->setConsumerSecretKey("QkTRr36zT6wAMERWqKUefyshxXIeaGzPKxB5pwMN0tg");
+ _oauthRequest->setToken(_oauthSettings->value("oauth_token").toString());
+ _oauthRequest->setTokenSecret(_oauthSettings->value("oauth_token_secret").toString());
+ KQOAuthParameters params;
+ params.insert("follow", "2062439");
+ _oauthRequest->setAdditionalParameters(params);
+
+ connect(sock, SIGNAL(readyRead()), this, SLOT(readyRead()));
+ disconnect(_oauthManager, SIGNAL(requestReady(QByteArray)));
+ connect(_oauthManager, SIGNAL(requestReady(QByteArray)),
+ this, SLOT(onRequestReadyTimeline(QByteArray)));
+ connect(_oauthManager, SIGNAL(authorizedRequestDone()),
+ this, SLOT(onAuthorizedRequestDone()));
+ // _oauthManager->executeRequest(_oauthRequest);
+ }
+ else
+ {
+ QUrl url("http://stream.twitter.com/1/sample.json");
+ _oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, url);
+ _oauthRequest->setHttpMethod(KQOAuthRequest::GET); // GET指定
+ _oauthRequest->setConsumerKey("nXrjGagSLIQxCC4AmJ1J3g");
+ _oauthRequest->setConsumerSecretKey("QkTRr36zT6wAMERWqKUefyshxXIeaGzPKxB5pwMN0tg");
+ _oauthRequest->setToken(_oauthSettings->value("oauth_token").toString());
+ _oauthRequest->setTokenSecret(
+ _oauthSettings->value("oauth_token_secret").toString());
+
+ connect(sock, SIGNAL(readyRead()), this, SLOT(readyRead()));
+ disconnect(_oauthManager, SIGNAL(requestReady(QByteArray)));
+ connect(_oauthManager, SIGNAL(requestReady(QByteArray)),
+ this, SLOT(onRequestReadyTimeline(QByteArray)));
+ connect(_oauthManager, SIGNAL(authorizedRequestDone()),
+ this, SLOT(onAuthorizedRequestDone()));
+ // _oauthManager->executeRequest(_oauthRequest);
+ }
QNetworkRequest networkRequest;
networkRequest.setUrl( _oauthRequest->requestEndpoint() );
// Submit the request including the params.
//QNetworkReply *reply = d->networkManager->get(networkRequest);
- QNetworkReply *reply = _oauthManager->networkManager()->get(networkRequest);
+ //QNetworkReply *reply = _oauthManager->networkManager()->get(networkRequest);
//qDebug() << reply->readAll();
//QByteArray array("GET /1/statuses/home_timeline.json");
- QByteArray array("GET /2/user.json");
+ //QByteArray array("GET /2/user.json");
+ QByteArray array("GET /1/statuses/sample.json");
array.append("\r\nAuthorization: " + authHeader);
- // array.append("HTTP/1.1\r\n");
- // .append("Accept: */* \r\n")
- // .append("Accept-Language: ja\r\n")
- // .append("If-Modified-Since: Mon,04 Dec 2000 00:11:45 GMT; length=35\r\n")
- // .append("User-Agent: Mozilla/4.0(compatible; MSIE 5.5; Windows NT 5.0)\r\n")
- //array.append("Host: ").append("api.twitter.com").append("\r\n");
- // array.append("Host: ").append("userstream.twitter.com").append("\r\n");
- // .append("Connection: Keep-Alive")
- //qDebug() << array;
- //sock->write(array);
-
- connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(slotError(QNetworkReply::NetworkError)));
+ // array.append("HTTP/1.1\r\n");
+ // .append("Accept: *\/\* \r\n")
+ // .append("Accept-Language: ja\r\n")
+ // .append("If-Modified-Since: Mon,04 Dec 2000 00:11:45 GMT; length=35\r\n")
+ // .append("User-Agent: Mozilla/4.0(compatible; MSIE 5.5; Windows NT 5.0)\r\n");
+ // array.append("Host: ").append("api.twitter.com").append("\r\n");
+ // array.append("Host: ").append("userstream.twitter.com").append("\r\n");
+ // .append("Connection: Keep-Alive");
+ qDebug() << array;
+ sock->write(array);
+
+// connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
+// this, SLOT(slotError(QNetworkReply::NetworkError)));
}
else if (_oauthRequest->httpMethod() == KQOAuthRequest::POST) {
if (_oauthRequest->contentType() == "application/x-www-form-urlencoded") {
//reply = d->networkManager->post(networkRequest, _oauthRequest->requestBody());
reply = _oauthManager->networkManager()->post(networkRequest, _oauthRequest->requestBody());
- qDebug() << "pp" << _oauthRequest->requestBody();
+ qDebug() << "pp" << _oauthRequest->requestBody() << reply->readAll();
} else {
//reply = d->networkManager->post(networkRequest, _oauthRequest->rawData());
reply = _oauthManager->networkManager()->post(networkRequest, _oauthRequest->rawData());
this, SLOT(slotError(QNetworkReply::NetworkError)));
}
- return;
-
+*/
// sock->disconnectFromHost();
// }
}
+bool Widget::setShortCutKeyAndContext(QShortcut *sc, QKeySequence s, Qt::ShortcutContext c)
+{
+ sc->setKey(s);
+ sc->setContext(c);
+}
+
+bool Widget::initializeOwnPostsWidgets()
+{
+ QUrl url("https://api.twitter.com/1/statuses/user_timeline.json");
+ _oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, url);
+ _oauthRequest->setHttpMethod(KQOAuthRequest::GET); // GET指定
+ _oauthRequest->setConsumerKey("nXrjGagSLIQxCC4AmJ1J3g");
+ _oauthRequest->setConsumerSecretKey("QkTRr36zT6wAMERWqKUefyshxXIeaGzPKxB5pwMN0tg");
+ _oauthRequest->setToken(_oauthSettings->value("oauth_token").toString());
+ _oauthRequest->setTokenSecret(
+ _oauthSettings->value("oauth_token_secret").toString());
+
+ KQOAuthParameters params;
+ params.insert("count", "131");
+ _oauthRequest->setAdditionalParameters(params);
+
+
+ qDebug() << _oauthSettings->value("oauth_token").toString();
+ qDebug() << _oauthSettings->value("oauth_token_secret").toString();
+
+ disconnect(_oauthManager, SIGNAL(requestReady(QByteArray)));
+ connect(_oauthManager, SIGNAL(requestReady(QByteArray)),
+ this, SLOT(onRequestReadyOwnPosts(QByteArray)));
+
+ connect(_oauthManager, SIGNAL(authorizedRequestDone()),
+ this, SLOT(onAuthorizedRequestDone()));
+
+ _oauthManager->executeRequest(_oauthRequest);
+
+ return true;
+}
+
void Widget::slotError(QNetworkReply::NetworkError e)
{
qDebug() << "1" << e;
void Widget::readyRead()
{
- qDebug() << "3" << sock->readAll();
+ qDebug() << "3";
+ qDebug() << sock->readAll();
}
void Widget::cError(QAbstractSocket::SocketError e)
qDebug() << ke->text() << _keyString << ke->count();
for(int i=0;i<ui->buttonsGridLayout->count();++i)
{
- if(dynamic_cast<ExtraPushButton*>(ui->buttonsGridLayout->itemAt(i)->widget())->text().contains(QRegExp("^" + _keyString))==false)
+ ExtraPushButton *p = dynamic_cast<ExtraPushButton*>(ui->buttonsGridLayout->itemAt(i)->widget());
+ if(p->getShortCutKey().indexOf(_keyString)==-1)
{
ui->buttonsGridLayout->itemAt(i)->widget()->setEnabled(false);
}
}
if( ( ke->key()==Qt::Key_Control) && (_keyString.size()>0) )
{
- for(int i=0;i<ui->buttonsGridLayout->count();++i)
- {
- if(!dynamic_cast<ExtraPushButton*>(ui->buttonsGridLayout->itemAt(i)->widget())->text().contains(QRegExp("^" + _keyString)));
- {
- ui->buttonsGridLayout->itemAt(i)->widget()->setEnabled(true);
- }
- }
qDebug() << "ctrl!" << _keyString;
QString tweet;
- QList<QString> list = _keysHash->keys();
int matchedKeysNumber = 0;
+ QList<QString> list = _keysHash->keys();
for(int i=0;i<list.size();++i)
{
- if(list.at(i).contains(QRegExp("^" + _keyString.toLower())))
+ if(list.at(i).indexOf(_keyString)==0)
{
+ // Match
+ if(list.at(i).length() == _keyString.length())
+ {
+ tweet = _keysHash->value(list.at(i));
+ matchedKeysNumber = -1;
+ break;
+ }
++matchedKeysNumber;
tweet = _keysHash->value(list.at(i));
}
- if(matchedKeysNumber>1)
- {
- break;
- }
}
- if(matchedKeysNumber!=1)
+
+ if(matchedKeysNumber>1)
{
tweet.clear();
}
_keyString.clear();
- if(tweet.size()==0)
- {
- qDebug() << "There is not such a short cut key.";
- return;
- }
if(tweet.contains(QRegExp("\\(\\d.*\\)")))
{
- qDebug("ho");
+ ui->plainTextEdit->setPlainText(tweet);
+ for(int i=0;i<ui->buttonsGridLayout->count();++i)
+ {
+ if(ui->buttonsGridLayout->itemAt(i)->widget()->isEnabled()==true)
+ {
+ ui->buttonsGridLayout->itemAt(i)->widget()->setEnabled(false);
+ }
+ }
ui->lineEdit_2->setFocus();
}
else
{
- //sendTweet(tweet);
+ for(int i=0;i<ui->buttonsGridLayout->count();++i)
+ {
+ if(ui->buttonsGridLayout->itemAt(i)->widget()->isEnabled()==false)
+ {
+ ui->buttonsGridLayout->itemAt(i)->widget()->setEnabled(true);
+ }
+ }
+ if(tweet.size()==0)
+ {
+ qDebug() << "There is not such a short cut key.";
+ return;
+ }
+ sendTweet(tweet);
}
- qDebug() << "send " << tweet;
tweet.clear();
}
}
qDebug() << "Access token received: " << token << tokenSecret;
_oauthSettings->setValue(tr("oauth_token"), token);
- _oauthSettings->setValue(tr("_oauth_token_secret"), tokenSecret);
+ _oauthSettings->setValue(tr("oauth_token_secret"), tokenSecret);
qDebug() << "Access tokens now stored. "
"You are ready to send Tweets from user's account!";
}
void Widget::on_pushButton_clicked() {
+ ui->lineEdit->setEnabled(true);
+ ui->pushButton_3->setEnabled(true);
+
//--------------------------
// kQOAuthのスロットの登録
connect(_oauthManager, SIGNAL(temporaryTokenReceived(QString,QString)),
}
void Widget::on_pushButton_2_clicked() {
- ui->pushButton_2->setEnabled(false);
+ //ui->pushButton_2->setEnabled(false);
+ ui->listWidget->clear();
- QUrl url("https://api.twitter.com/1/statuses/home_timeline.xml");
+ QUrl url("https://api.twitter.com/1/statuses/home_timeline.json");
_oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, url);
_oauthRequest->setHttpMethod(KQOAuthRequest::GET); // GET指定
_oauthRequest->setConsumerKey("nXrjGagSLIQxCC4AmJ1J3g");
qDebug() << _oauthSettings->value("oauth_token").toString();
qDebug() << _oauthSettings->value("oauth_token_secret").toString();
- disconnect(_oauthManager, SIGNAL(requestReady(QByteArray)));
+ disconnect(_oauthManager, SIGNAL(requestReady(QByteArray)),0,0);
connect(_oauthManager, SIGNAL(requestReady(QByteArray)),
this, SLOT(onRequestReadyTimeline(QByteArray)));
- connect(_oauthManager, SIGNAL(authorizedRequestDone()),
- this, SLOT(onAuthorizedRequestDone()));
+ // connect(_oauthManager, SIGNAL(authorizedRequestDone()),
+ // this, SLOT(onAuthorizedRequestDone()));
_oauthManager->executeRequest(_oauthRequest);
}
void Widget::onRequestReadyTimeline(QByteArray response) {
qDebug() << "requestReady-Timeline";
QDomDocument dom;
+ // For JSON
if(dom.setContent(response)==false)
{
QJson::Parser parser;
QVariant top = parser.parse(response, &ok);
if(!ok)
{
- qDebug() << "json error";
+ qDebug() << response.size() << response << "json error";
return;
}
- qDebug() << "top.list.size:" << top.toList().size();
- qDebug() << "top.map.size:" << top.toMap().size();
//QVariantMap result = top.toMap();
QVariantList contentList = top.toList();
foreach ( QVariant content, contentList ){
- //qDebug() << contentList.toMap();
+ /*
qDebug() <<
content.toMap()["contributors"] <<
- "\t" <<
+ "\n" <<
content.toMap()["coordinates"] <<
- "-" <<
+ "\n" <<
content.toMap()["created_at"].toString() <<
- "\t" <<
+ "\n" <<
content.toMap()["geo"]<<
- "\t" <<
+ "\n" <<
content.toMap()["id"].toLongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["id_str"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["in_reply_to_screen_name"] <<
- ":" <<
+ "\n" <<
content.toMap()["in_reply_to_status_id"]<<
- ":" <<
+ "\n" <<
content.toMap()["in_reply_to_status_id"] <<
- ":" <<
+ "\n" <<
content.toMap()["in_reply_to_user_id"] <<
- ":" <<
+ "\n" <<
content.toMap()["in_reply_to_user_id_str"] <<
- ":" <<
+ "\n" <<
content.toMap()["place"] <<
- ":" <<
+ "\n" <<
content.toMap()["possibly_sensitive"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["retweet_count"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["retweeted"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["text"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["truncated"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["contributors_enabled"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["created_at"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["default_profile"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["default_profile_image"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["description"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["favourites_count"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["followers_count"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["following"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["friends_count"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["geo_enabled"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["id"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["id_str"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["is_translator"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["lang"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["listed_count"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["location"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_background_color"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_background_image_url"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_background_image_url_https"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_background_tile"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_image_url_https"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_sidebar_border_color"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_sidebar_fill_color"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_text_color"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["profile_use_background_image"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["protected"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["screen_name"].toBool() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["show_all_inline_media"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["statuses_count"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["time_zone"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["url"].toString() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["utc_offset"].toULongLong() <<
- ":" <<
+ "\n" <<
content.toMap()["user"].toMap()["verified"].toBool() <<
"\n\n";
-
+*/
ui->listWidget->addItem(content.toMap()["text"].toString());
}
return;
}
-
- // DOM からヘッダ情報を取得する
- QDomElement root = dom.documentElement();
- QDomNode node;
- node = root.firstChild();
- while ( !node.isNull() )
+ // for XML
+ else
{
- if ( node.isElement() && (node.nodeName() == "status" ) )
+ QDomElement root = dom.documentElement();
+ QDomNode node;
+ node = root.firstChild();
+ while ( !node.isNull() )
{
- QDomElement header = node.toElement();
-
- QDomNode node = header.firstChild();
- while ( !node.isNull() )
+ if ( node.isElement() && (node.nodeName() == "status" ) )
{
- if ( node.isElement() )
+ QDomElement header = node.toElement();
+
+ QDomNode node = header.firstChild();
+ while ( !node.isNull() )
{
- // いろいろなヘッダエントリの場合
- if ( node.nodeName() == "text" )
+ if ( node.isElement() )
{
- QDomText textChild = node.firstChild().toText();
- if ( !textChild.isNull() )
+ // いろいろなヘッダエントリの場合
+ if ( node.nodeName() == "text" )
{
- qDebug() << textChild.nodeValue();
- ui->listWidget->addItem(textChild.nodeValue());
+ QDomText textChild = node.firstChild().toText();
+ if ( !textChild.isNull() )
+ {
+ ui->listWidget->addItem(textChild.nodeValue());
+ }
}
}
+ node = node.nextSibling();
}
- node = node.nextSibling();
}
+ node = node.nextSibling();
}
- node = node.nextSibling();
}
}
+void Widget::onRequestReadyOwnPosts(QByteArray response) {
+ qDebug() << "requestReady-OwnPosts";
+ // for JSON
+ QDomDocument dom;
+ if(dom.setContent(response)==false)
+ {
+ QJson::Parser parser;
+ bool ok =false;
+ QVariant top = parser.parse(response, &ok);
+ if(!ok)
+ {
+ qDebug() << response.size() << response << "json error";
+ return;
+ }
+ qDebug() << "top.list.size:" << top.toList().size();
+ qDebug() << "top.map.size:" << top.toMap().size();
+
+ //QVariantMap result = top.toMap();
+ QVariantList contentList = top.toList();
+
+ for(int i=0;i<contentList.size();++i)
+ {
+ QVariant content = contentList.at(i);
+ ui->tableWidget_2->setItem(ui->tableWidget_2->rowCount()-i-1, 0, new QTableWidgetItem(content.toMap()["created_at"].toString().mid(8,11)));
+ if(i<10)
+ {
+ ui->tableWidget->setItem(9-i,0, new QTableWidgetItem(content.toMap()["text"].toString()));
+ }
+ }
+ return;
+ }
+}
void Widget::sendTweet(QString tweet) {
_oauthRequest->setAdditionalParameters(params);
qDebug() << "Attempting send tweet such as " << tweet;
- _oauthManager->executeRequest(_oauthRequest);
+ //_oauthManager->executeRequest(_oauthRequest);
+
+ ui->tableWidget->removeRow(0);
+ ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1);
+ ui->tableWidget->setItem(9,0,new QTableWidgetItem(tweet));
+ ui->tableWidget_2->removeRow(0);
+ ui->tableWidget_2->setRowCount(ui->tableWidget_2->rowCount()+1);
+ ui->tableWidget_2->setItem(129,0, new QTableWidgetItem( (QDateTime::currentDateTime().toString("dd hh:mm:ss"))));
// connect(_oauthManager, SIGNAL(authorizedRequestReady()),
// this, SLOT(onAuthorizedRequestReady()));
+ // LineEdits must cleare content.
+ ui->lineEdit_2->clear();
+ ui->lineEdit_3->clear();
+ ui->lineEdit_4->clear();
+ ui->lineEdit_5->clear();
+ ui->lineEdit_6->clear();
}
void Widget::showOAuthError(const int nErrNum)
void Widget::on_pushButton_3_clicked()
{
+ ui->lineEdit->setEnabled(false);
+ ui->pushButton_3->setEnabled(false);
+ _oauthSettings->setValue("number", ui->lineEdit->text());
_oauthManager->onVerificationReceived1(ui->lineEdit->text());
}
{
//lineEditの継承クラスにCtrl+Enter押し下し時の処置:(\d)との置換:を記述する
}
+
+void Widget::on_pushButton_4_clicked()
+{
+ QString tweet = ui->plainTextEdit->toPlainText();
+ tweet.replace(QRegExp("\\(\\d+:([^()]+)\\)"), "\\1");
+ sendTweet(tweet);
+}
+
+void Widget::on_lineEdit_2_textChanged(const QString &arg1)
+{
+ replacePlainTextEditContent(1, arg1);
+}
+
+void Widget::on_lineEdit_3_textChanged(const QString &arg1)
+{
+ replacePlainTextEditContent(1, arg1);
+}
+
+void Widget::on_lineEdit_4_textChanged(const QString &arg1)
+{
+ replacePlainTextEditContent(1, arg1);
+}
+
+void Widget::on_lineEdit_5_textChanged(const QString &arg1)
+{
+ replacePlainTextEditContent(1, arg1);
+}
+
+void Widget::on_lineEdit_6_textChanged(const QString &arg1)
+{
+ replacePlainTextEditContent(1, arg1);
+}
+
+bool Widget::replacePlainTextEditContent(int i, QString str)
+{
+ if(str.length()>0)
+ {
+ QString text = ui->plainTextEdit->toPlainText();
+ text.replace(QRegExp("(\\(" + QString::number(i) + ":)[^()]+(\\))"), "\\1" + str + "\\2");
+ ui->plainTextEdit->setPlainText(text);
+ }
+ return true;
+}
<rect>
<x>0</x>
<y>0</y>
- <width>402</width>
- <height>358</height>
+ <width>361</width>
+ <height>484</height>
</rect>
</property>
<property name="focusPolicy">
- <enum>Qt::TabFocus</enum>
+ <enum>Qt::ClickFocus</enum>
</property>
- <layout class="QGridLayout" name="gridLayout">
+ <layout class="QGridLayout" name="gridLayout_3">
<property name="sizeConstraint">
- <enum>QLayout::SetMaximumSize</enum>
+ <enum>QLayout::SetNoConstraint</enum>
</property>
- <item row="0" column="0" rowspan="2">
- <layout class="QVBoxLayout" name="oauthVerticalLayout">
- <item>
- <widget class="QPushButton" name="pushButton">
- <property name="minimumSize">
- <size>
- <width>75</width>
- <height>23</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>75</width>
- <height>23</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::ClickFocus</enum>
- </property>
- <property name="text">
- <string>OAuth</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEdit">
- <property name="minimumSize">
- <size>
- <width>75</width>
- <height>20</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>75</width>
- <height>20</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::ClickFocus</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="pushButton_3">
- <property name="minimumSize">
- <size>
- <width>75</width>
- <height>23</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>75</width>
- <height>23</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::ClickFocus</enum>
- </property>
- <property name="text">
- <string>Verification</string>
+ <item row="0" column="0">
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QWidget" name="layoutWidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="oauthVerticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="minimumSize">
+ <size>
+ <width>75</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::ClickFocus</enum>
+ </property>
+ <property name="text">
+ <string>OAuth</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>75</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::ClickFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton_3">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>75</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::ClickFocus</enum>
+ </property>
+ <property name="text">
+ <string>Verification</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Latest 130</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="tableWidget_2">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="rowCount">
+ <number>130</number>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <column>
+ <property name="text">
+ <string>日 時刻</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>現時刻との差</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Latest 10</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="rowCount">
+ <number>10</number>
+ </property>
+ <property name="columnCount">
+ <number>1</number>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <column>
+ <property name="text">
+ <string>POST</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="timeLienVerticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushButton_2">
+ <property name="text">
+ <string>TL</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="listWidget"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMaximumSize</enum>
</property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="4" column="0">
+ <widget class="QLineEdit" name="lineEdit_2">
+ <property name="focusPolicy">
+ <enum>Qt::ClickFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLineEdit" name="lineEdit_3"/>
+ </item>
+ <item row="4" column="2">
+ <widget class="QLineEdit" name="lineEdit_4"/>
+ </item>
+ <item row="4" column="3">
+ <widget class="QLineEdit" name="lineEdit_5"/>
+ </item>
+ <item row="4" column="4">
+ <widget class="QLineEdit" name="lineEdit_6"/>
+ </item>
+ <item row="0" column="0" colspan="4">
+ <widget class="QPlainTextEdit" name="plainTextEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QPushButton" name="pushButton_4">
+ <property name="text">
+ <string>POST
+Ctrl+Enter</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>ctrl+</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <property name="margin">
+ <number>0</number>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>174</height>
- </size>
+ <property name="spacing">
+ <number>0</number>
</property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="0" column="1" colspan="5">
- <layout class="QVBoxLayout" name="timeLienVerticalLayout">
- <item>
- <widget class="QPushButton" name="pushButton_2">
- <property name="text">
- <string>TL</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QListWidget" name="listWidget"/>
- </item>
- </layout>
- </item>
- <item row="1" column="2">
- <widget class="QLineEdit" name="lineEdit_3">
- <property name="enabled">
- <bool>false</bool>
- </property>
+ <item row="0" column="0">
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>339</width>
+ <height>69</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="buttonsGridLayout"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
- <item row="1" column="3">
- <widget class="QLineEdit" name="lineEdit_4">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="6">
- <widget class="QPlainTextEdit" name="plainTextEdit"/>
- </item>
- <item row="3" column="0" colspan="6">
- <widget class="QGroupBox" name="groupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>ctrl+</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <layout class="QGridLayout" name="buttonsGridLayout">
- <property name="sizeConstraint">
- <enum>QLayout::SetDefaultConstraint</enum>
- </property>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="4">
- <widget class="QLineEdit" name="lineEdit_5">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="5">
- <widget class="QLineEdit" name="lineEdit_6">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="lineEdit_2"/>
- </item>
</layout>
</widget>
<tabstops>
- <tabstop>lineEdit_2</tabstop>
- <tabstop>lineEdit_3</tabstop>
- <tabstop>lineEdit_4</tabstop>
- <tabstop>lineEdit_5</tabstop>
- <tabstop>lineEdit_6</tabstop>
<tabstop>pushButton</tabstop>
<tabstop>lineEdit</tabstop>
- <tabstop>plainTextEdit</tabstop>
<tabstop>pushButton_3</tabstop>
<tabstop>pushButton_2</tabstop>
<tabstop>listWidget</tabstop>